Search in sources :

Example 11 with WorkerData

use of com.hazelcast.simulator.coordinator.registry.WorkerData in project hazelcast-simulator by hazelcast.

the class KillWorkersTask method awaitTermination.

private void awaitTermination(List<WorkerData> victims) {
    Set<WorkerData> aliveVictims = new HashSet<WorkerData>(victims);
    long deadlineSeconds = currentTimeSeconds() + workerShutdownTimeoutSeconds;
    for (; ; ) {
        Iterator<WorkerData> it = aliveVictims.iterator();
        while (it.hasNext()) {
            WorkerData victim = it.next();
            if (registry.findWorker(victim.getAddress()) == null) {
                result.add(victim);
                it.remove();
            }
        }
        if (aliveVictims.isEmpty()) {
            LOGGER.info(format("Killing of workers [%s] success", toAddressString(victims)));
            break;
        }
        long remainingSeconds = deadlineSeconds - currentTimeSeconds();
        if (remainingSeconds <= 0) {
            LOGGER.info(format("Killing of %s workers failed, following failed to terminate [%s]", aliveVictims.size(), toAddressString(aliveVictims)));
            break;
        }
        LOGGER.info(format("Waiting for [%s] to die", toAddressString(aliveVictims)));
        sleepSeconds(min(remainingSeconds, CHECK_INTERVAL_SECONDS));
    }
}
Also used : WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData) HashSet(java.util.HashSet)

Example 12 with WorkerData

use of com.hazelcast.simulator.coordinator.registry.WorkerData 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)

Example 13 with WorkerData

use of com.hazelcast.simulator.coordinator.registry.WorkerData in project hazelcast-simulator by hazelcast.

the class StartWorkersTaskTest method assertComponentRegistry.

private static void assertComponentRegistry(Registry registry, int expectedMemberCount, int expectedClientCount) {
    int actualMemberCount = 0;
    int actualClientCount = 0;
    for (WorkerData workerData : registry.getWorkers()) {
        if (workerData.isMemberWorker()) {
            actualMemberCount++;
        } else {
            actualClientCount++;
        }
    }
    assertEquals(expectedMemberCount, actualMemberCount);
    assertEquals(expectedClientCount, actualClientCount);
}
Also used : WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData)

Aggregations

WorkerData (com.hazelcast.simulator.coordinator.registry.WorkerData)13 Future (java.util.concurrent.Future)4 WorkerQuery (com.hazelcast.simulator.coordinator.registry.WorkerQuery)2 ExecuteScriptOperation (com.hazelcast.simulator.worker.operations.ExecuteScriptOperation)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 StopTimeoutDetectionOperation (com.hazelcast.simulator.agent.operations.StopTimeoutDetectionOperation)1 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)1 KillWorkersTask (com.hazelcast.simulator.coordinator.tasks.KillWorkersTask)1 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)1 VendorDriver (com.hazelcast.simulator.vendors.VendorDriver)1 VendorDriver.loadVendorDriver (com.hazelcast.simulator.vendors.VendorDriver.loadVendorDriver)1 StartPhaseOperation (com.hazelcast.simulator.worker.operations.StartPhaseOperation)1 StopRunOperation (com.hazelcast.simulator.worker.operations.StopRunOperation)1 TerminateWorkerOperation (com.hazelcast.simulator.worker.operations.TerminateWorkerOperation)1 Map (java.util.Map)1