use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.
the class WorkerTest method before.
@Before
public void before() {
setupFakeEnvironment();
Registry registry = new Registry();
AgentData agent = registry.addAgent(PUBLIC_ADDRESS, PUBLIC_ADDRESS);
SimulatorProperties properties = new SimulatorProperties().set("MANAGEMENT_CENTER_URL", "none");
VendorDriver driver = new HazelcastDriver().setAgents(registry.getAgents()).setAll(properties.asPublicMap()).set("CONFIG", fileAsText(localResourceDirectory() + "/hazelcast.xml"));
workerAddress = workerAddress(AGENT_INDEX, WORKER_INDEX);
parameters = driver.loadWorkerParameters("member", agent.getAddressIndex()).set("WORKER_ADDRESS", workerAddress).set("PUBLIC_ADDRESS", PUBLIC_ADDRESS);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
String key = entry.getKey();
if (key.startsWith("file:")) {
FileUtils.writeText(entry.getValue(), new File(getUserDir(), key.substring(5, key.length())));
}
}
}
use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.
the class Coordinator method workerStart.
public String workerStart(RcWorkerStartOperation op) throws Exception {
// todo: tags
String workerType = op.getWorkerType();
LOGGER.info("Starting " + op.getCount() + " [" + workerType + "] workers...");
VendorDriver vendorDriver = loadVendorDriver(properties.get("VENDOR")).setAgents(registry.getAgents()).setAll(properties.asPublicMap()).set("CLIENT_ARGS", op.getVmOptions()).set("MEMBER_ARGS", op.getVmOptions()).set("SESSION_ID", parameters.getSessionId()).setIfNotNull("VERSION_SPEC", op.getVersionSpec()).setIfNotNull("CONFIG", op.getConfig());
List<AgentData> agents = findAgents(op);
if (agents.isEmpty()) {
throw new IllegalStateException("No suitable agents found");
}
LOGGER.info("Suitable agents: " + agents);
DeploymentPlan deploymentPlan = new DeploymentPlan(vendorDriver, agents).addToPlan(op.getCount(), workerType);
List<WorkerData> workers = createStartWorkersTask(deploymentPlan.getWorkerDeployment(), op.getTags()).run();
LOGGER.info("Workers started!");
return WorkerData.toAddressString(workers);
}
use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.
the class ArtifactCleanTask method cleanRemote.
private void cleanRemote() {
long started = System.nanoTime();
LOGGER.info(format("Cleaning Worker homes of %s machines...", registry.agentCount()));
final String cleanCommand = format("rm -fr hazelcast-simulator-%s/workers/*", getSimulatorVersion());
ThreadSpawner spawner = new ThreadSpawner("clean", true);
for (final AgentData agent : registry.getAgents()) {
spawner.spawn(new Runnable() {
@Override
public void run() {
LOGGER.info(format("Cleaning %s", agent.getPublicAddress()));
bash.ssh(agent.getPublicAddress(), cleanCommand);
}
});
}
spawner.awaitCompletion();
long elapsed = getElapsedSeconds(started);
LOGGER.info(format("Finished cleaning Worker homes of %s machines (%s seconds)", registry.agentCount(), elapsed));
}
use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.
the class AgentsSshCli method findAgents.
private List<AgentData> findAgents() {
List<AgentData> agents = registry.getAgents();
String agentAddress = agentSpec.value(options);
if (agentAddress == null) {
return agents;
}
for (AgentData agent : agents) {
if (agent.getPublicAddress().equals(agentAddress) || agent.getPrivateAddress().equals(agentAddress) || agent.getAddress().toString().equals(agentAddress)) {
return singletonList(agent);
}
}
throw new CommandLineExitException(format("Could not found agent [%s]", agentAddress));
}
use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.
the class StartWorkersTask method startWorkers.
private void startWorkers(Map<SimulatorAddress, List<WorkerParameters>> deploymentPlan) {
ThreadSpawner spawner = new ThreadSpawner("createWorkers", true);
for (Map.Entry<SimulatorAddress, List<WorkerParameters>> entry : deploymentPlan.entrySet()) {
SimulatorAddress agentAddress = entry.getKey();
AgentData agent = registry.getAgent(agentAddress);
for (WorkerParameters workerParameters : entry.getValue()) {
spawner.spawn(new CreateWorkerOnAgentTask(workerParameters, startupDelayMs * workerStartupIndex, agent));
workerStartupIndex++;
}
}
spawner.awaitCompletion();
}
Aggregations