Search in sources :

Example 11 with WorkerParameters

use of com.hazelcast.simulator.agent.workerprocess.WorkerParameters 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 12 with WorkerParameters

use of com.hazelcast.simulator.agent.workerprocess.WorkerParameters in project hazelcast-simulator by hazelcast.

the class FailureCollectorTest method before.

@Before
public void before() {
    outputDirectory = TestUtils.createTmpDirectory();
    registry = new Registry();
    failureCollector = new FailureCollector(outputDirectory, registry);
    agentAddress = registry.addAgent("192.168.0.1", "192.168.0.1").getAddress();
    workerAddress = workerAddress(agentAddress.getAgentIndex(), 1);
    WorkerParameters workerParameters = new WorkerParameters().set("WORKER_ADDRESS", workerAddress);
    registry.addWorkers(singletonList(workerParameters));
    exceptionFailure = new FailureOperation("exception", WORKER_EXCEPTION, workerAddress, agentAddress.toString(), "workerId", "testId", null);
    abnormalExitFailure = new FailureOperation("exception", WORKER_ABNORMAL_EXIT, workerAddress, agentAddress.toString(), "workerId", "testId", null);
    oomeFailure = new FailureOperation("oom", WORKER_OOME, workerAddress, agentAddress.toString(), "workerId", "testId", null);
    normalExitFailure = new FailureOperation("finished", WORKER_NORMAL_EXIT, workerAddress, agentAddress.toString(), "workerId", "testId", null);
}
Also used : Registry(com.hazelcast.simulator.coordinator.registry.Registry) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) FailureOperation(com.hazelcast.simulator.coordinator.operations.FailureOperation) Before(org.junit.Before)

Example 13 with WorkerParameters

use of com.hazelcast.simulator.agent.workerprocess.WorkerParameters in project hazelcast-simulator by hazelcast.

the class HazelcastDriverTest method test.

@Test
public void test() throws Exception {
    VendorDriver<HazelcastInstance> driverAtCoordinator = new HazelcastDriver().setAll(simulatorProperties.asPublicMap()).setAgents(singletonList(agent)).set("CONFIG", fileAsText(localResourceDirectory() + "/hazelcast.xml"));
    WorkerParameters workerParameters = driverAtCoordinator.loadWorkerParameters("member", agent.getAddressIndex());
    for (Map.Entry<String, String> entry : workerParameters.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith("file:")) {
            writeText(entry.getValue(), new File(getUserDir(), key.substring(5, key.length())));
        }
    }
    VendorDriver<HazelcastInstance> driverAtWorker = new HazelcastDriver().setAll(workerParameters.asMap());
    driverAtWorker.startVendorInstance();
    HazelcastInstance hz = driverAtWorker.getVendorInstance();
    assertNotNull(hz);
    driverAtWorker.close();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) Map(java.util.Map) File(java.io.File) Test(org.junit.Test)

Example 14 with WorkerParameters

use of com.hazelcast.simulator.agent.workerprocess.WorkerParameters in project hazelcast-simulator by hazelcast.

the class Registry method addWorkers.

public synchronized List<WorkerData> addWorkers(List<WorkerParameters> workerParametersList, Map<String, String> tags) {
    List<WorkerData> result = new ArrayList<WorkerData>(workerParametersList.size());
    for (WorkerParameters workerParameters : workerParametersList) {
        WorkerData worker = new WorkerData(workerParameters, tags);
        AgentData agent = agents.get(worker.getAddress().getAgentIndex() - 1);
        agent.addWorker(worker);
        agent.updateWorkerIndex(worker.getAddress().getAddressIndex());
        workers.add(worker);
        result.add(worker);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters)

Example 15 with WorkerParameters

use of com.hazelcast.simulator.agent.workerprocess.WorkerParameters 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)

Aggregations

WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)18 Test (org.junit.Test)9 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)8 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)2 File (java.io.File)2 List (java.util.List)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 CreateWorkerOperation (com.hazelcast.simulator.agent.operations.CreateWorkerOperation)1 FailureOperation (com.hazelcast.simulator.coordinator.operations.FailureOperation)1 Registry (com.hazelcast.simulator.coordinator.registry.Registry)1 ThreadSpawner (com.hazelcast.simulator.utils.ThreadSpawner)1 Arrays.asList (java.util.Arrays.asList)1 LinkedList (java.util.LinkedList)1 Ignite (org.apache.ignite.Ignite)1 Before (org.junit.Before)1