Search in sources :

Example 21 with AgentData

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

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

the class Coordinator method workerStart.

public String workerStart(RcWorkerStartOperation op) throws Exception {
    // todo: tags
    String workerType = op.getWorkerType();
    LOGGER.info("Starting " + op.getCount() + " [" + workerType + "] workers...");
    VendorDriver vendorDriver = loadVendorDriver(properties.get("VENDOR")).setAgents(registry.getAgents()).setAll(properties.asPublicMap()).set("CLIENT_ARGS", op.getVmOptions()).set("MEMBER_ARGS", op.getVmOptions()).set("SESSION_ID", parameters.getSessionId()).setIfNotNull("VERSION_SPEC", op.getVersionSpec()).setIfNotNull("CONFIG", op.getConfig());
    List<AgentData> agents = findAgents(op);
    if (agents.isEmpty()) {
        throw new IllegalStateException("No suitable agents found");
    }
    LOGGER.info("Suitable agents: " + agents);
    DeploymentPlan deploymentPlan = new DeploymentPlan(vendorDriver, agents).addToPlan(op.getCount(), workerType);
    List<WorkerData> workers = createStartWorkersTask(deploymentPlan.getWorkerDeployment(), op.getTags()).run();
    LOGGER.info("Workers started!");
    return WorkerData.toAddressString(workers);
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) WorkerData(com.hazelcast.simulator.coordinator.registry.WorkerData) VendorDriver.loadVendorDriver(com.hazelcast.simulator.vendors.VendorDriver.loadVendorDriver) VendorDriver(com.hazelcast.simulator.vendors.VendorDriver)

Example 23 with AgentData

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

the class ArtifactCleanTask method cleanRemote.

private void cleanRemote() {
    long started = System.nanoTime();
    LOGGER.info(format("Cleaning Worker homes of %s machines...", registry.agentCount()));
    final String cleanCommand = format("rm -fr hazelcast-simulator-%s/workers/*", getSimulatorVersion());
    ThreadSpawner spawner = new ThreadSpawner("clean", true);
    for (final AgentData agent : registry.getAgents()) {
        spawner.spawn(new Runnable() {

            @Override
            public void run() {
                LOGGER.info(format("Cleaning %s", agent.getPublicAddress()));
                bash.ssh(agent.getPublicAddress(), cleanCommand);
            }
        });
    }
    spawner.awaitCompletion();
    long elapsed = getElapsedSeconds(started);
    LOGGER.info(format("Finished cleaning Worker homes of %s machines (%s seconds)", registry.agentCount(), elapsed));
}
Also used : AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) ThreadSpawner(com.hazelcast.simulator.utils.ThreadSpawner)

Example 24 with AgentData

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

the class AgentsSshCli method findAgents.

private List<AgentData> findAgents() {
    List<AgentData> agents = registry.getAgents();
    String agentAddress = agentSpec.value(options);
    if (agentAddress == null) {
        return agents;
    }
    for (AgentData agent : agents) {
        if (agent.getPublicAddress().equals(agentAddress) || agent.getPrivateAddress().equals(agentAddress) || agent.getAddress().toString().equals(agentAddress)) {
            return singletonList(agent);
        }
    }
    throw new CommandLineExitException(format("Could not found agent [%s]", agentAddress));
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) AgentData.publicAddressesString(com.hazelcast.simulator.coordinator.registry.AgentData.publicAddressesString)

Example 25 with AgentData

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

AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)32 Test (org.junit.Test)10 Registry (com.hazelcast.simulator.coordinator.registry.Registry)7 ThreadSpawner (com.hazelcast.simulator.utils.ThreadSpawner)5 CommandLineExitException (com.hazelcast.simulator.utils.CommandLineExitException)3 WorkerParameters (com.hazelcast.simulator.agent.workerprocess.WorkerParameters)2 SimulatorProperties (com.hazelcast.simulator.common.SimulatorProperties)2 AgentData.publicAddressesString (com.hazelcast.simulator.coordinator.registry.AgentData.publicAddressesString)2 BashCommand (com.hazelcast.simulator.utils.BashCommand)2 VendorDriver (com.hazelcast.simulator.vendors.VendorDriver)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 Before (org.junit.Before)2 ConfigFileTemplate (com.hazelcast.simulator.coordinator.ConfigFileTemplate)1 WorkerData (com.hazelcast.simulator.coordinator.registry.WorkerData)1 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)1 FileUtils.ensureExistingFile (com.hazelcast.simulator.utils.FileUtils.ensureExistingFile)1