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());
}
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());
}
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());
}
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;
}
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();
}
}
Aggregations