use of com.hazelcast.simulator.coordinator.registry.Registry in project hazelcast-simulator by hazelcast.
the class HazelcastUtilsTest method getComponentRegistryMock.
private Registry getComponentRegistryMock() {
List<AgentData> agents = new ArrayList<AgentData>();
for (int i = 1; i <= 5; i++) {
AgentData agent = mock(AgentData.class);
when(agent.getPrivateAddress()).thenReturn("192.168.0." + i);
agents.add(agent);
}
Registry registry = mock(Registry.class);
when(registry.getAgents()).thenReturn(agents);
return registry;
}
use of com.hazelcast.simulator.coordinator.registry.Registry in project hazelcast-simulator by hazelcast.
the class FailureCollectorTest method before.
@Before
public void before() {
outputDirectory = TestUtils.createTmpDirectory();
registry = new Registry();
failureCollector = new FailureCollector(outputDirectory, registry);
agentAddress = registry.addAgent("192.168.0.1", "192.168.0.1").getAddress();
workerAddress = workerAddress(agentAddress.getAgentIndex(), 1);
WorkerParameters workerParameters = new WorkerParameters().set("WORKER_ADDRESS", workerAddress);
registry.addWorkers(singletonList(workerParameters));
exceptionFailure = new FailureOperation("exception", WORKER_EXCEPTION, workerAddress, agentAddress.toString(), "workerId", "testId", null);
abnormalExitFailure = new FailureOperation("exception", WORKER_ABNORMAL_EXIT, workerAddress, agentAddress.toString(), "workerId", "testId", null);
oomeFailure = new FailureOperation("oom", WORKER_OOME, workerAddress, agentAddress.toString(), "workerId", "testId", null);
normalExitFailure = new FailureOperation("finished", WORKER_NORMAL_EXIT, workerAddress, agentAddress.toString(), "workerId", "testId", null);
}
use of com.hazelcast.simulator.coordinator.registry.Registry in project hazelcast-simulator by hazelcast.
the class WorkerTest method before.
@Before
public void before() {
setupFakeEnvironment();
Registry registry = new Registry();
AgentData agent = registry.addAgent(PUBLIC_ADDRESS, PUBLIC_ADDRESS);
SimulatorProperties properties = new SimulatorProperties().set("MANAGEMENT_CENTER_URL", "none");
VendorDriver driver = new HazelcastDriver().setAgents(registry.getAgents()).setAll(properties.asPublicMap()).set("CONFIG", fileAsText(localResourceDirectory() + "/hazelcast.xml"));
workerAddress = workerAddress(AGENT_INDEX, WORKER_INDEX);
parameters = driver.loadWorkerParameters("member", agent.getAddressIndex()).set("WORKER_ADDRESS", workerAddress).set("PUBLIC_ADDRESS", PUBLIC_ADDRESS);
for (Map.Entry<String, String> entry : parameters.entrySet()) {
String key = entry.getKey();
if (key.startsWith("file:")) {
FileUtils.writeText(entry.getValue(), new File(getUserDir(), key.substring(5, key.length())));
}
}
}
use of com.hazelcast.simulator.coordinator.registry.Registry in project hazelcast-simulator by hazelcast.
the class CoordinatorCli method newRegistry.
private Registry newRegistry(SimulatorProperties simulatorProperties) {
Registry registry;
if (isLocal(simulatorProperties)) {
registry = new Registry();
registry.addAgent("localhost", "localhost");
} else {
registry = loadComponentRegister(getAgentsFile());
}
if (options.has(dedicatedMemberMachinesSpec)) {
registry.assignDedicatedMemberMachines(options.valueOf(dedicatedMemberMachinesSpec));
}
return registry;
}
use of com.hazelcast.simulator.coordinator.registry.Registry in project hazelcast-simulator by hazelcast.
the class AgentsFile method load.
public static Registry load(File agentFile) {
Registry registry = new Registry();
String content = fileAsText(agentFile);
String[] lines = content.split(NEW_LINE);
int lineNumber = 0;
for (String line : lines) {
lineNumber++;
line = cleanLine(line);
if (line.isEmpty()) {
continue;
}
int tagsIndex = line.indexOf('|');
String addressesString = tagsIndex == -1 ? line : line.substring(0, tagsIndex);
String tagsString = tagsIndex == -1 ? "" : line.substring(tagsIndex + 1);
String publicIpAddress;
String privateIpAddress;
String[] addresses = addressesString.split(",");
switch(addresses.length) {
case 1:
publicIpAddress = addresses[0];
privateIpAddress = addresses[0];
break;
case 2:
publicIpAddress = addresses[0];
privateIpAddress = addresses[1];
break;
default:
throw new CommandLineExitException(format("Line %s of file %s is invalid!" + " It should contain one or two IP addresses separated by a comma," + " but it contains %s", lineNumber, agentFile, addresses.length));
}
Map<String, String> tags = TagUtils.parseTags(tagsString);
registry.addAgent(publicIpAddress, privateIpAddress, tags);
}
return registry;
}
Aggregations