Search in sources :

Example 6 with WorkerParameters

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

the class RegistryTest method testRemoveWorker_viaWorkerData.

@Test
public void testRemoveWorker_viaWorkerData() {
    SimulatorAddress agentAddress = addAgent();
    List<WorkerParameters> parametersList = newWorkerParametersList(agentAddress, 5);
    registry.addWorkers(parametersList);
    assertEquals(5, registry.workerCount());
    registry.removeWorker(registry.getWorkers().get(0));
    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 7 with WorkerParameters

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

the class RegistryTest method testGetWorkers.

@Test
public void testGetWorkers() {
    SimulatorAddress agentAddress = addAgent();
    List<WorkerParameters> parametersList = newWorkerParametersList(agentAddress, 10);
    registry.addWorkers(parametersList);
    assertEquals(10, registry.workerCount());
    List<WorkerData> workers = registry.getWorkers();
    for (int i = 0; i < 10; i++) {
        WorkerData workerData = workers.get(i);
        assertEquals(i + 1, workerData.getAddress().getWorkerIndex());
        assertEquals(WORKER, workerData.getAddress().getAddressLevel());
        // assertEquals(i + 1, workerData.getParameters().getWorkerIndex());
        assertEquals("member", workerData.getParameters().getWorkerType());
    }
}
Also used : WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) SimulatorAddress(com.hazelcast.simulator.protocol.core.SimulatorAddress) Test(org.junit.Test)

Example 8 with WorkerParameters

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

the class HazelcastDriver method loadWorkerParameters.

@Override
public WorkerParameters loadWorkerParameters(String workerType, int agentIndex) {
    Map<String, String> s = new HashMap<String, String>(properties);
    s.remove("CONFIG");
    if ("hazelcast-enterprise".equals(get("VENDOR"))) {
        String licenceKey = get("LICENCE_KEY");
        if (licenceKey == null) {
            throw new IllegalStateException("licenceKey needs to be set with 'hazelcast-enterprise' as vendor");
        }
    }
    WorkerParameters params = new WorkerParameters().setAll(s).set("WORKER_TYPE", workerType).set("file:log4j.xml", loadLog4jConfig());
    if ("member".equals(workerType)) {
        loadMemberWorkerParameters(params);
    } else if ("javaclient".equals(workerType)) {
        loadJavaClientWorkerParameters(params);
    } else if ("litemember".equals(workerType)) {
        loadLiteMemberWorkerParameters(params);
    } else {
        throw new IllegalArgumentException(String.format("Unsupported workerType [%s]", workerType));
    }
    return params;
}
Also used : HashMap(java.util.HashMap) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters)

Example 9 with WorkerParameters

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

the class JetDriver method loadWorkerParameters.

@Override
public WorkerParameters loadWorkerParameters(String workerType, int agentIndex) {
    Map<String, String> s = new HashMap<String, String>(properties);
    s.remove("CONFIG");
    WorkerParameters params = new WorkerParameters().setAll(s).set("WORKER_TYPE", workerType).set("file:log4j.xml", loadLog4jConfig());
    if ("member".equals(workerType)) {
        loadMemberWorkerParameters(params);
    } else if ("javaclient".equals(workerType)) {
        loadJavaClientWorkerParameters(params);
    } else if ("litemember".equals(workerType)) {
        loadLiteMemberWorkerParameters(params);
    } else {
        throw new IllegalArgumentException(String.format("Unsupported workerType [%s]", workerType));
    }
    return params;
}
Also used : HashMap(java.util.HashMap) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters)

Example 10 with WorkerParameters

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

the class IgniteDriverTest method test.

@Test
public void test() throws Exception {
    VendorDriver<Ignite> driverAtCoordinator = new IgniteDriver().setAgents(singletonList(agent));
    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<Ignite> driverAtWorker = new IgniteDriver().setAll(workerParameters.asMap());
    driverAtWorker.startVendorInstance();
    Ignite ignite = driverAtWorker.getVendorInstance();
    assertNotNull(ignite);
    driverAtWorker.close();
}
Also used : Ignite(org.apache.ignite.Ignite) WorkerParameters(com.hazelcast.simulator.agent.workerprocess.WorkerParameters) Map(java.util.Map) File(java.io.File) Test(org.junit.Test)

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