Search in sources :

Example 26 with AgentData

use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.

the class Provisioner method killJavaProcesses.

void killJavaProcesses(final boolean sudo) {
    onlineCheckAgents(properties, registry);
    ensureIsRemoteSetup(properties, "kill");
    long started = System.nanoTime();
    logWithRuler("Killing %s Java processes...", registry.agentCount());
    ThreadSpawner spawner = new ThreadSpawner("killJavaProcesses", true);
    for (final AgentData agent : registry.getAgents()) {
        spawner.spawn(new Runnable() {

            @Override
            public void run() {
                log("    Killing Java processes on %s", agent.getPublicAddress());
                bash.killAllJavaProcesses(agent.getPublicAddress(), sudo);
            }
        });
    }
    spawner.awaitCompletion();
    long elapsed = getElapsedSeconds(started);
    logWithRuler("Successfully killed %s Java processes (%s seconds)", registry.agentCount(), elapsed);
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) ThreadSpawner(com.hazelcast.simulator.utils.ThreadSpawner)

Example 27 with AgentData

use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.

the class Provisioner method scaleDown.

private void scaleDown(int count) {
    if (count > registry.agentCount()) {
        count = registry.agentCount();
    }
    logWithRuler("Terminating %s %s machines (can take some time)", count, properties.getCloudProvider());
    log("Current number of machines: " + registry.agentCount());
    log("Desired number of machines: " + (registry.agentCount() - count));
    long started = System.nanoTime();
    int destroyedCount = 0;
    List<String> privateIps = new LinkedList<String>();
    List<AgentData> agents = registry.getAgents();
    for (int k = 0; k < count; k++) {
        privateIps.add(agents.get(k).getPrivateAddress());
        destroyedCount++;
    }
    new BashCommand(getConfigurationFile("aws-ec2_terminate.sh").getAbsolutePath()).addEnvironment(properties.asMap()).addParams(join(privateIps, ",")).execute();
    for (int k = 0; k < count; k++) {
        registry.removeAgent(agents.get(k));
    }
    log("Updating " + agentsFile.getAbsolutePath());
    AgentsFile.save(agentsFile, registry);
    long elapsed = getElapsedSeconds(started);
    logWithRuler("Terminated %s of %s machines (%s remaining) (%s seconds)", destroyedCount, count, registry.agentCount(), elapsed);
    if (destroyedCount != count) {
        throw new IllegalStateException("Terminated " + destroyedCount + " of " + count + NEW_LINE + "1) You are trying to terminate physical hardware that you own (unsupported feature)" + NEW_LINE + "2) If and only if you are using AWS our Harakiri Monitor might have terminated them" + NEW_LINE + "3) You have not payed you bill and your instances have been terminated by your cloud provider" + NEW_LINE + "4) You have terminated your own instances (perhaps via some console interface)" + NEW_LINE + "5) Someone else has terminated your instances" + NEW_LINE + "Please try again!");
    }
}
Also used : BashCommand(com.hazelcast.simulator.utils.BashCommand) AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) UuidUtil.newUnsecureUuidString(com.hazelcast.simulator.utils.UuidUtil.newUnsecureUuidString) LinkedList(java.util.LinkedList)

Example 28 with AgentData

use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.

the class DeploymentPlanTest method testGetVersionSpecs.

@Test
public void testGetVersionSpecs() {
    AgentData agent = new AgentData(1, "127.0.0.1", "127.0.0.1");
    testGetVersionSpecs(singletonList(agent), 1, 0);
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Test(org.junit.Test)

Example 29 with AgentData

use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.

the class DeploymentPlanTest method testGetVersionSpecs.

private void testGetVersionSpecs(List<AgentData> agents, int memberCount, int clientCount) {
    Registry registry = new Registry();
    for (AgentData agent : agents) {
        registry.addAgent(agent.getPublicAddress(), agent.getPrivateAddress());
    }
    vendorDriver.set("VERSION_SPEC", "outofthebox");
    DeploymentPlan deploymentPlan = new DeploymentPlan(vendorDriver, registry).addToPlan(memberCount, "member").addToPlan(clientCount, "javaclient");
    assertEquals(singleton("outofthebox"), deploymentPlan.getVersionSpecs());
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Registry(com.hazelcast.simulator.coordinator.registry.Registry)

Example 30 with AgentData

use of com.hazelcast.simulator.coordinator.registry.AgentData in project hazelcast-simulator by hazelcast.

the class AgentsFileTest method testLoad_fileContainsEmptyLines.

@Test
public void testLoad_fileContainsEmptyLines() {
    writeText(NEW_LINE + "192.168.1.1" + NEW_LINE + NEW_LINE, agentsFile);
    registry = load(agentsFile);
    assertEquals(1, registry.agentCount());
    AgentData agentData = registry.getFirstAgent();
    assertEquals("192.168.1.1", agentData.getPublicAddress());
    assertEquals("192.168.1.1", agentData.getPrivateAddress());
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Test(org.junit.Test)

Aggregations

AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)32 Test (org.junit.Test)10 Registry (com.hazelcast.simulator.coordinator.registry.Registry)7 ThreadSpawner (com.hazelcast.simulator.utils.ThreadSpawner)5 CommandLineExitException (com.hazelcast.simulator.utils.CommandLineExitException)3 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)2 SimulatorProperties (com.hazelcast.simulator.common.SimulatorProperties)2 AgentData.publicAddressesString (com.hazelcast.simulator.coordinator.registry.AgentData.publicAddressesString)2 BashCommand (com.hazelcast.simulator.utils.BashCommand)2 VendorDriver (com.hazelcast.simulator.vendors.VendorDriver)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 Before (org.junit.Before)2 ConfigFileTemplate (com.hazelcast.simulator.coordinator.ConfigFileTemplate)1 WorkerData (com.hazelcast.simulator.coordinator.registry.WorkerData)1 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)1 FileUtils.ensureExistingFile (com.hazelcast.simulator.utils.FileUtils.ensureExistingFile)1