Search in sources :

Example 1 with Registry

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

the class CoordinatorCliTest method testInit_withLocalSetup.

@Test
public void testInit_withLocalSetup() {
    File simulatorProperties = new File(getUserDir(), "simulator.properties").getAbsoluteFile();
    writeText(format("%s=%s", CLOUD_PROVIDER, CloudProviderUtils.PROVIDER_LOCAL), simulatorProperties);
    writeText("COORDINATOR_PORT=5000\n", simulatorProperties);
    try {
        CoordinatorCli cli = createCoordinatorCli();
        Registry registry = cli.registry;
        assertEquals(1, registry.agentCount());
        AgentData firstAgent = registry.getFirstAgent();
        assertEquals("localhost", firstAgent.getPublicAddress());
        assertEquals("localhost", firstAgent.getPrivateAddress());
    } finally {
        deleteQuiet(simulatorProperties);
    }
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Registry(com.hazelcast.simulator.coordinator.registry.Registry) File(java.io.File) FileUtils.ensureExistingFile(com.hazelcast.simulator.utils.FileUtils.ensureExistingFile) Test(org.junit.Test)

Example 2 with Registry

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

the class CoordinatorTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    setupFakeEnvironment();
    hzConfig = FileUtils.fileAsText(new File(localResourceDirectory(), "hazelcast.xml"));
    hzClientConfig = FileUtils.fileAsText(new File(localResourceDirectory(), "client-hazelcast.xml"));
    File simulatorPropertiesFile = new File(getUserDir(), "simulator.properties");
    appendText("CLOUD_PROVIDER=embedded\n", simulatorPropertiesFile);
    SimulatorProperties simulatorProperties = loadSimulatorProperties();
    CoordinatorParameters coordinatorParameters = new CoordinatorParameters().setSimulatorProperties(simulatorProperties).setSkipShutdownHook(true);
    agent = new Agent(1, "127.0.0.1", simulatorProperties.getAgentPort(), 60, null);
    agent.start();
    registry = new Registry();
    agentData = registry.addAgent(localIp(), localIp());
    coordinator = new Coordinator(registry, coordinatorParameters);
    coordinator.start();
}
Also used : Agent(com.hazelcast.simulator.agent.Agent) Registry(com.hazelcast.simulator.coordinator.registry.Registry) File(java.io.File) SimulatorUtils.loadSimulatorProperties(com.hazelcast.simulator.utils.SimulatorUtils.loadSimulatorProperties) SimulatorProperties(com.hazelcast.simulator.common.SimulatorProperties) BeforeClass(org.junit.BeforeClass)

Example 3 with Registry

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

the class AgentsFileTest method testSave.

@Test
public void testSave() {
    registry = load(agentsFile);
    registry.addAgent("192.168.1.1", "192.168.1.1");
    registry.addAgent("192.168.1.1", "10.10.10.10");
    assertEquals(2, registry.agentCount());
    save(agentsFile, registry);
    Registry actualRegistry = load(agentsFile);
    assertEquals(2, actualRegistry.agentCount());
    List<AgentData> agents = actualRegistry.getAgents();
    assertEquals("192.168.1.1", agents.get(0).getPublicAddress());
    assertEquals("192.168.1.1", agents.get(0).getPrivateAddress());
    assertEquals("192.168.1.1", agents.get(1).getPublicAddress());
    assertEquals("10.10.10.10", agents.get(1).getPrivateAddress());
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Registry(com.hazelcast.simulator.coordinator.registry.Registry) Test(org.junit.Test)

Example 4 with Registry

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

the class Runner method newCoordinator.

private Coordinator newCoordinator() {
    CoordinatorParameters parameters = new CoordinatorParameters().setSkipShutdownHook(true).setSimulatorProperties(options.simulatorProperties);
    if (options.sessionId != null) {
        parameters.setSessionId(options.sessionId);
    }
    Registry registry;
    if ("local".equals(options.simulatorProperties.getCloudProvider())) {
        registry = new Registry();
        registry.addAgent("localhost", "localhost");
    } else {
        registry = loadComponentRegister(new File("agents.txt"));
    }
    Coordinator coordinator = new Coordinator(registry, parameters);
    try {
        coordinator.start();
    } catch (Exception e) {
        // todo
        throw new RuntimeException(e);
    }
    return coordinator;
}
Also used : CoordinatorParameters(com.hazelcast.simulator.coordinator.CoordinatorParameters) Registry(com.hazelcast.simulator.coordinator.registry.Registry) Coordinator(com.hazelcast.simulator.coordinator.Coordinator) File(java.io.File)

Example 5 with Registry

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

the class Wizard method sshConnectionCheck.

void sshConnectionCheck(SimulatorProperties simulatorProperties, Bash bash) {
    if (isLocal(simulatorProperties)) {
        throw new CommandLineExitException("SSH is not supported for local setups.");
    }
    Registry registry = loadComponentRegister(agentFile, true);
    String userName = simulatorProperties.getUser();
    for (AgentData agent : registry.getAgents()) {
        String publicAddress = agent.getPublicAddress();
        echo("Connecting to %s@%s...", userName, publicAddress);
        bash.ssh(publicAddress, "echo ok 2>&1");
    }
    echo("Connected successfully to all remote machines!");
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Registry(com.hazelcast.simulator.coordinator.registry.Registry)

Aggregations

Registry (com.hazelcast.simulator.coordinator.registry.Registry)15 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)7 File (java.io.File)5 SimulatorProperties (com.hazelcast.simulator.common.SimulatorProperties)3 Before (org.junit.Before)3 Test (org.junit.Test)3 Agent (com.hazelcast.simulator.agent.Agent)2 CommandLineExitException (com.hazelcast.simulator.utils.CommandLineExitException)2 SimulatorUtils.loadSimulatorProperties (com.hazelcast.simulator.utils.SimulatorUtils.loadSimulatorProperties)2 HazelcastDriver (com.hazelcast.simulator.vendors.HazelcastDriver)2 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)1 Coordinator (com.hazelcast.simulator.coordinator.Coordinator)1 CoordinatorParameters (com.hazelcast.simulator.coordinator.CoordinatorParameters)1 FailureOperation (com.hazelcast.simulator.coordinator.operations.FailureOperation)1 FileUtils.ensureExistingFile (com.hazelcast.simulator.utils.FileUtils.ensureExistingFile)1 TagUtils.tagsToString (com.hazelcast.simulator.utils.TagUtils.tagsToString)1 VendorDriver (com.hazelcast.simulator.vendors.VendorDriver)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 BeforeClass (org.junit.BeforeClass)1