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