use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class StartWorkersTask method startWorkers.
private void startWorkers(Map<SimulatorAddress, List<WorkerParameters>> deploymentPlan) {
ThreadSpawner spawner = new ThreadSpawner("createWorkers", true);
for (Map.Entry<SimulatorAddress, List<WorkerParameters>> entry : deploymentPlan.entrySet()) {
SimulatorAddress agentAddress = entry.getKey();
AgentData agent = registry.getAgent(agentAddress);
for (WorkerParameters workerParameters : entry.getValue()) {
spawner.spawn(new CreateWorkerOnAgentTask(workerParameters, startupDelayMs * workerStartupIndex, agent));
workerStartupIndex++;
}
}
spawner.awaitCompletion();
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class WorkerProcessFailureMonitorTest method addWorkerProcess.
private WorkerProcess addWorkerProcess(Integer exitCode) {
SimulatorAddress address = createWorkerAddress();
File sessionHome = new File(workersHome, "sessions");
File workerHome = new File(sessionHome, "worker" + address.getAddressIndex());
ensureExistingDirectory(workerHome);
WorkerProcess workerProcess = new WorkerProcess(address, "WorkerProcessFailureMonitorTest" + address.getAddressIndex(), workerHome);
Process process = mock(Process.class);
if (exitCode == null) {
// this is needed for the failure monitor to believe the process is still running.
when(process.exitValue()).thenThrow(new IllegalThreadStateException());
} else {
when(process.exitValue()).thenReturn(exitCode);
}
workerProcess.setProcess(process);
workerProcessManager.add(address, workerProcess);
return workerProcess;
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class PerformanceStatsCollectorTest method testFormatPerformanceNumbers_avgLatencyOverMicrosThreshold.
@Test
public void testFormatPerformanceNumbers_avgLatencyOverMicrosThreshold() throws Exception {
SimulatorAddress worker = workerAddress(3, 1);
Map<String, PerformanceStats> performanceStats = new HashMap<String, PerformanceStats>();
performanceStats.put(TEST_CASE_ID_1, new PerformanceStats(800, 100, 300, SECONDS.toNanos(3), MICROSECONDS.toNanos(2400), MICROSECONDS.toNanos(2500)));
performanceStatsCollector.update(worker, performanceStats);
String performance = performanceStatsCollector.formatIntervalPerformanceNumbers(TEST_CASE_ID_1);
assertTrue(performance.contains("ms"));
assertFalse(performance.contains("µs"));
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class RegistryTest method testRemoveWorker_viaSimulatorAddress.
@Test
public void testRemoveWorker_viaSimulatorAddress() {
SimulatorAddress agentAddress = addAgent();
List<WorkerParameters> parametersList = newWorkerParametersList(agentAddress, 5);
registry.addWorkers(parametersList);
assertEquals(5, registry.workerCount());
registry.removeWorker(workerAddress(1, 3));
assertEquals(4, registry.workerCount());
}
use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.
the class RegistryTest method testGetWorkers_getClientWorkers_notEnoughWorkersFound.
@Test(expected = IllegalStateException.class)
public void testGetWorkers_getClientWorkers_notEnoughWorkersFound() {
SimulatorAddress agentAddress = addAgent();
registry.addWorkers(newWorkerParametersList(agentAddress, 2, "member"));
registry.addWorkers(newWorkerParametersList(agentAddress, 2, "javaclient"));
assertEquals(4, registry.workerCount());
registry.getWorkerAddresses(TargetType.CLIENT, 3);
}
Aggregations