Search in sources :

Example 21 with SimulatorAddress

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();
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) List(java.util.List) Arrays.asList(java.util.Arrays.asList) LinkedList(java.util.LinkedList) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) HashMap(java.util.HashMap) Map(java.util.Map) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) ThreadSpawner(com.hazelcast.simulator.utils.ThreadSpawner)

Example 22 with SimulatorAddress

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;
}
Also used : SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) File(java.io.File) FileUtils.ensureExistingFile(com.hazelcast.simulator.utils.FileUtils.ensureExistingFile)

Example 23 with SimulatorAddress

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"));
}
Also used : PerformanceStats(com.hazelcast.simulator.worker.performance.PerformanceStats) HashMap(java.util.HashMap) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 24 with SimulatorAddress

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());
}
Also used : WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 25 with SimulatorAddress

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);
}
Also used : SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Aggregations

SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)30 Test (org.junit.Test)20 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)8 HashMap (java.util.HashMap)8 Future (java.util.concurrent.Future)7 PerformanceStats (com.hazelcast.simulator.worker.performance.PerformanceStats)6 List (java.util.List)5 LogOperation (com.hazelcast.simulator.protocol.operation.LogOperation)4 SimulatorOperation (com.hazelcast.simulator.protocol.operation.SimulatorOperation)4 ExecutionException (java.util.concurrent.ExecutionException)4 CreateWorkerOperation (com.hazelcast.simulator.agent.operations.CreateWorkerOperation)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 JMSException (javax.jms.JMSException)3 FailureOperation (com.hazelcast.simulator.coordinator.operations.FailureOperation)2 AssertTask (com.hazelcast.simulator.utils.AssertTask)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)1