Search in sources :

Example 6 with AgentData

use of com.hazelcast.simulator.coordinator.registry.AgentData 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 7 with AgentData

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

the class AgentsFileTest method testLoad_publicAndPrivateAddressAndTags.

@Test
public void testLoad_publicAndPrivateAddressAndTags() {
    writeText("192.168.1.1,10.10.10.10|a=10,b=20", agentsFile);
    registry = load(agentsFile);
    assertEquals(1, registry.agentCount());
    AgentData agentData = registry.getFirstAgent();
    assertEquals("192.168.1.1", agentData.getPublicAddress());
    assertEquals("10.10.10.10", agentData.getPrivateAddress());
    assertEquals(toMap("a", "10", "b", "20"), agentData.getTags());
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Test(org.junit.Test)

Example 8 with AgentData

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

the class AgentsFileTest method testLoad_emptyTag.

@Test
public void testLoad_emptyTag() {
    writeText("192.168.1.1|", 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());
    assertEquals(toMap(), agentData.getTags());
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Test(org.junit.Test)

Example 9 with AgentData

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

the class Coordinator method findAgents.

private List<AgentData> findAgents(RcWorkerStartOperation op) {
    List<AgentData> agents = new ArrayList<AgentData>(registry.getAgents());
    List<AgentData> result = new ArrayList<AgentData>();
    for (AgentData agent : agents) {
        List<String> expectedAgentAddresses = op.getAgentAddresses();
        if (expectedAgentAddresses != null) {
            if (!expectedAgentAddresses.contains(agent.getAddress().toString())) {
                continue;
            }
        }
        Map<String, String> expectedAgentTags = op.getAgentTags();
        if (expectedAgentTags != null) {
            if (!matches(op.getAgentTags(), agent.getTags())) {
                continue;
            }
        }
        result.add(agent);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) AgentData(com.hazelcast.simulator.coordinator.registry.AgentData)

Example 10 with AgentData

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

the class AgentsSshCli method executeCommand.

private void executeCommand() {
    List commands = options.nonOptionArguments();
    if (commands.size() != 1) {
        throw new CommandLineExitException("1 argument expected");
    }
    String command = (String) commands.get(0);
    String sshOptions = properties.get("SSH_OPTIONS");
    String simulatorUser = properties.get("SIMULATOR_USER");
    for (AgentData agent : findAgents()) {
        System.out.println("[" + agent.getPublicAddress() + "]");
        new BashCommand("ssh -n -o LogLevel=quiet " + sshOptions + " " + simulatorUser + "@" + agent.getPublicAddress() + " '" + command + "'").setSystemOut(true).addEnvironment(properties.asMap()).execute();
    }
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) BashCommand(com.hazelcast.simulator.utils.BashCommand) AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) AgentData.publicAddressesString(com.hazelcast.simulator.coordinator.registry.AgentData.publicAddressesString)

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