Search in sources :

Example 1 with TerminateWorkerOperation

use of com.hazelcast.simulator.worker.operations.TerminateWorkerOperation in project hazelcast-simulator by hazelcast.

the class WorkerTest method after.

@After
public void after() throws Exception {
    if (worker != null) {
        worker.shutdown(new TerminateWorkerOperation(false));
        worker.awaitShutdown();
    }
    Hazelcast.shutdownAll();
    tearDownFakeEnvironment();
}
Also used : TerminateWorkerOperation(com.hazelcast.simulator.worker.operations.TerminateWorkerOperation) After(org.junit.After)

Example 2 with TerminateWorkerOperation

use of com.hazelcast.simulator.worker.operations.TerminateWorkerOperation in project hazelcast-simulator by hazelcast.

the class WorkerOperationProcessorTest method test_TerminateWorkerOperation.

@Test
public void test_TerminateWorkerOperation() throws Exception {
    TerminateWorkerOperation op = new TerminateWorkerOperation(true);
    processor.process(op, sourceAddress, promise);
    verify(worker).shutdown(op);
    assertTrue(promise.hasAnswer());
}
Also used : TerminateWorkerOperation(com.hazelcast.simulator.worker.operations.TerminateWorkerOperation) Test(org.junit.Test)

Example 3 with TerminateWorkerOperation

use of com.hazelcast.simulator.worker.operations.TerminateWorkerOperation in project hazelcast-simulator by hazelcast.

the class TerminateWorkersTask method run0.

private void run0() throws TimeoutException, InterruptedException, ExecutionException {
    int currentWorkerCount = registry.workerCount();
    if (currentWorkerCount == 0) {
        return;
    }
    LOGGER.info(format("Terminating %d Workers...", currentWorkerCount));
    client.invokeOnAllAgents(new StopTimeoutDetectionOperation(), MINUTES.toMillis(1));
    // prevent any failures from being printed due to killing the members.
    Set<WorkerData> clients = new HashSet<WorkerData>();
    Set<WorkerData> members = new HashSet<WorkerData>();
    for (WorkerData worker : registry.getWorkers()) {
        worker.setIgnoreFailures(true);
        if (worker.getParameters().getWorkerType().equals("member")) {
            members.add(worker);
        } else {
            clients.add(worker);
        }
    }
    // first shut down all clients
    for (WorkerData worker : clients) {
        client.send(worker.getAddress(), new TerminateWorkerOperation(true));
    }
    // wait some if there were any clients
    if (!clients.isEmpty()) {
        sleepSeconds(simulatorProperties.getMemberWorkerShutdownDelaySeconds());
    }
    // and then terminate all members
    for (WorkerData worker : members) {
        client.send(worker.getAddress(), new TerminateWorkerOperation(true));
    }
    // now we wait for the workers to die
    waitForWorkerShutdown(currentWorkerCount);
}
Also used : StopTimeoutDetectionOperation(com.hazelcast.simulator.agent.operations.StopTimeoutDetectionOperation) WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData) TerminateWorkerOperation(com.hazelcast.simulator.worker.operations.TerminateWorkerOperation) HashSet(java.util.HashSet)

Aggregations

TerminateWorkerOperation (com.hazelcast.simulator.worker.operations.TerminateWorkerOperation)3 StopTimeoutDetectionOperation (com.hazelcast.simulator.agent.operations.StopTimeoutDetectionOperation)1 WorkerData (com.hazelcast.simulator.coordinator.registry.WorkerData)1 HashSet (java.util.HashSet)1 After (org.junit.After)1 Test (org.junit.Test)1