Search in sources :

Example 6 with Registry

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

the class HazelcastUtilsTest method getComponentRegistryMock.

private Registry getComponentRegistryMock() {
    List<AgentData> agents = new ArrayList<AgentData>();
    for (int i = 1; i <= 5; i++) {
        AgentData agent = mock(AgentData.class);
        when(agent.getPrivateAddress()).thenReturn("192.168.0." + i);
        agents.add(agent);
    }
    Registry registry = mock(Registry.class);
    when(registry.getAgents()).thenReturn(agents);
    return registry;
}
Also used : ArrayList(java.util.ArrayList) AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Registry(com.hazelcast.simulator.coordinator.registry.Registry)

Example 7 with Registry

use of com.hazelcast.simulator.coordinator.registry.Registry 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 8 with Registry

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

the class WorkerTest method before.

@Before
public void before() {
    setupFakeEnvironment();
    Registry registry = new Registry();
    AgentData agent = registry.addAgent(PUBLIC_ADDRESS, PUBLIC_ADDRESS);
    SimulatorProperties properties = new SimulatorProperties().set("MANAGEMENT_CENTER_URL", "none");
    VendorDriver driver = new HazelcastDriver().setAgents(registry.getAgents()).setAll(properties.asPublicMap()).set("CONFIG", fileAsText(localResourceDirectory() + "/hazelcast.xml"));
    workerAddress = workerAddress(AGENT_INDEX, WORKER_INDEX);
    parameters = driver.loadWorkerParameters("member", agent.getAddressIndex()).set("WORKER_ADDRESS", workerAddress).set("PUBLIC_ADDRESS", PUBLIC_ADDRESS);
    for (Map.Entry<String, String> entry : parameters.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith("file:")) {
            FileUtils.writeText(entry.getValue(), new File(getUserDir(), key.substring(5, key.length())));
        }
    }
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Registry(com.hazelcast.simulator.coordinator.registry.Registry) VendorDriver(com.hazelcast.simulator.vendors.VendorDriver) HazelcastDriver(com.hazelcast.simulator.vendors.HazelcastDriver) Map(java.util.Map) File(java.io.File) SimulatorProperties(com.hazelcast.simulator.common.SimulatorProperties) Before(org.junit.Before)

Example 9 with Registry

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

the class CoordinatorCli method newRegistry.

private Registry newRegistry(SimulatorProperties simulatorProperties) {
    Registry registry;
    if (isLocal(simulatorProperties)) {
        registry = new Registry();
        registry.addAgent("localhost", "localhost");
    } else {
        registry = loadComponentRegister(getAgentsFile());
    }
    if (options.has(dedicatedMemberMachinesSpec)) {
        registry.assignDedicatedMemberMachines(options.valueOf(dedicatedMemberMachinesSpec));
    }
    return registry;
}
Also used : Registry(com.hazelcast.simulator.coordinator.registry.Registry)

Example 10 with Registry

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

the class AgentsFile method load.

public static Registry load(File agentFile) {
    Registry registry = new Registry();
    String content = fileAsText(agentFile);
    String[] lines = content.split(NEW_LINE);
    int lineNumber = 0;
    for (String line : lines) {
        lineNumber++;
        line = cleanLine(line);
        if (line.isEmpty()) {
            continue;
        }
        int tagsIndex = line.indexOf('|');
        String addressesString = tagsIndex == -1 ? line : line.substring(0, tagsIndex);
        String tagsString = tagsIndex == -1 ? "" : line.substring(tagsIndex + 1);
        String publicIpAddress;
        String privateIpAddress;
        String[] addresses = addressesString.split(",");
        switch(addresses.length) {
            case 1:
                publicIpAddress = addresses[0];
                privateIpAddress = addresses[0];
                break;
            case 2:
                publicIpAddress = addresses[0];
                privateIpAddress = addresses[1];
                break;
            default:
                throw new CommandLineExitException(format("Line %s of file %s is invalid!" + " It should contain one or two IP addresses separated by a comma," + " but it contains %s", lineNumber, agentFile, addresses.length));
        }
        Map<String, String> tags = TagUtils.parseTags(tagsString);
        registry.addAgent(publicIpAddress, privateIpAddress, tags);
    }
    return registry;
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) Registry(com.hazelcast.simulator.coordinator.registry.Registry) TagUtils.tagsToString(com.hazelcast.simulator.utils.TagUtils.tagsToString)

Aggregations

Registry (com.hazelcast.simulator.coordinator.registry.Registry)15 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)7 File (java.io.File)5 SimulatorProperties (com.hazelcast.simulator.common.SimulatorProperties)3 Before (org.junit.Before)3 Test (org.junit.Test)3 Agent (com.hazelcast.simulator.agent.Agent)2 CommandLineExitException (com.hazelcast.simulator.utils.CommandLineExitException)2 SimulatorUtils.loadSimulatorProperties (com.hazelcast.simulator.utils.SimulatorUtils.loadSimulatorProperties)2 HazelcastDriver (com.hazelcast.simulator.vendors.HazelcastDriver)2 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)1 Coordinator (com.hazelcast.simulator.coordinator.Coordinator)1 CoordinatorParameters (com.hazelcast.simulator.coordinator.CoordinatorParameters)1 FailureOperation (com.hazelcast.simulator.coordinator.operations.FailureOperation)1 FileUtils.ensureExistingFile (com.hazelcast.simulator.utils.FileUtils.ensureExistingFile)1 TagUtils.tagsToString (com.hazelcast.simulator.utils.TagUtils.tagsToString)1 VendorDriver (com.hazelcast.simulator.vendors.VendorDriver)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 BeforeClass (org.junit.BeforeClass)1