Search in sources :

Example 16 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class StartWorkersTaskTest method testCreateWorkers_noClients.

@Test
public void testCreateWorkers_noClients() throws Exception {
    Map<SimulatorAddress, List<WorkerParameters>> deploymentPlan = getDeployment(0, 6, 0);
    Future f = mock(Future.class);
    when(f.get()).thenReturn("SUCCESS");
    when(client.submit(eq(agent1.getAddress()), any(CreateWorkerOperation.class))).thenReturn(f);
    when(client.submit(eq(agent2.getAddress()), any(CreateWorkerOperation.class))).thenReturn(f);
    when(client.submit(eq(agent3.getAddress()), any(CreateWorkerOperation.class))).thenReturn(f);
    new StartWorkersTask(deploymentPlan, Collections.<String, String>emptyMap(), client, registry, 0).run();
    assertComponentRegistry(registry, 6, 0);
}
Also used : CreateWorkerOperation(com.hazelcast.simulator.agent.operations.CreateWorkerOperation) Future(java.util.concurrent.Future) List(java.util.List) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 17 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class MessagingTest method test.

@Test
public void test() throws Exception {
    agentServer = new Server("agents").setBrokerURL(broker.getBrokerURL()).setSelfAddress(agentAddress).setProcessor(new OperationProcessor() {

        @Override
        public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
            System.out.println(op);
            promise.answer("OK");
        }
    }).start();
    client = new CoordinatorClient().setProcessor(mock(OperationProcessor.class)).start().connectToAgentBroker(agentAddress, localIp());
    final Future f = client.submit(agentAddress, new LogOperation("", Level.DEBUG));
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertTrue(f.isDone());
            assertEquals("OK", f.get());
        }
    });
}
Also used : LogOperation(com.hazelcast.simulator.protocol.operation.LogOperation) SimulatorOperation(com.hazelcast.simulator.protocol.operation.SimulatorOperation) Future(java.util.concurrent.Future) AssertTask(com.hazelcast.simulator.utils.AssertTask) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) JMSException(javax.jms.JMSException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 18 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class MessagingTest method testWhenAgentConnectionFails.

@Test
public void testWhenAgentConnectionFails() throws Exception {
    final CountDownLatch received = new CountDownLatch(1);
    agentServer = new Server("agents").setBrokerURL(broker.getBrokerURL()).setSelfAddress(agentAddress).setProcessor(new OperationProcessor() {

        @Override
        public void process(SimulatorOperation op, SimulatorAddress source, Promise promise) throws Exception {
            // we don't do anything to let the future wait
            received.countDown();
        }
    }).start();
    client = new CoordinatorClient().setProcessor(mock(OperationProcessor.class));
    client.getConnectionFactory().setMaxReconnectAttempts(1);
    client.start().connectToAgentBroker(agentAddress, localIp());
    final Future f = client.submit(agentAddress, new LogOperation("", Level.DEBUG));
    received.await();
    broker.close();
    assertCompletesEventually(f);
    try {
        f.get();
        fail();
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof JMSException);
    }
}
Also used : LogOperation(com.hazelcast.simulator.protocol.operation.LogOperation) JMSException(javax.jms.JMSException) CountDownLatch(java.util.concurrent.CountDownLatch) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) JMSException(javax.jms.JMSException) ExecutionException(java.util.concurrent.ExecutionException) SimulatorOperation(com.hazelcast.simulator.protocol.operation.SimulatorOperation) Future(java.util.concurrent.Future) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 19 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class CoordinatorCliTest method count.

private int count(DeploymentPlan deploymentPlan, String workerType) {
    Map<SimulatorAddress, List<WorkerParameters>> deployment = deploymentPlan.getWorkerDeployment();
    int result = 0;
    for (List<WorkerParameters> list : deployment.values()) {
        for (WorkerParameters settings : list) {
            if (settings.getWorkerType().equals(workerType)) {
                result++;
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress)

Example 20 with SimulatorAddress

use of com.hazelcast.simulator.protocol.core.SimulatorAddress in project hazelcast-simulator by hazelcast.

the class FailureCollector method notify.

public void notify(FailureOperation failure) {
    failure = enrich(failure);
    SimulatorAddress workerAddress = failure.getWorkerAddress();
    if (workerAddress != null && failure.getType() != WORKER_CREATE_ERROR) {
        WorkerData worker = registry.findWorker(workerAddress);
        if (worker == null) {
            // we are not interested in failures of workers that aren't registered any longer.
            return;
        }
        // if the failure is the terminal for that workers, we need to remove it from the component registry
        if (failure.getType().isTerminal()) {
            LOGGER.info("Removing worker " + worker.getAddress() + " from registry due to [" + failure.getType() + "]");
            registry.removeWorker(worker.getAddress());
        }
        // if we don't care for the failure, we are done; no need to log anything.
        if (worker.isIgnoreFailures() || failure.getType() == WORKER_NORMAL_EXIT) {
            return;
        }
    }
    int failureCount = criticalFailureCounter.incrementAndGet();
    String testId = failure.getTestId();
    if (testId != null) {
        hasCriticalFailuresMap.put(testId, true);
    }
    logFailure(failure, failureCount);
    appendText(failure.getFileMessage(), file);
    for (FailureListener failureListener : listenerMap.keySet()) {
        failureListener.onFailure(failure, failure.getType().isTerminal(), true);
    }
}
Also used : WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress)

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