Search in sources :

Example 6 with CommandLineExitException

use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.

the class Wizard method sshConnectionCheck.

void sshConnectionCheck(SimulatorProperties simulatorProperties, Bash bash) {
    if (isLocal(simulatorProperties)) {
        throw new CommandLineExitException("SSH is not supported for local setups.");
    }
    Registry registry = loadComponentRegister(agentFile, true);
    String userName = simulatorProperties.getUser();
    for (AgentData agent : registry.getAgents()) {
        String publicAddress = agent.getPublicAddress();
        echo("Connecting to %s@%s...", userName, publicAddress);
        bash.ssh(publicAddress, "echo ok 2>&1");
    }
    echo("Connected successfully to all remote machines!");
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) AgentData(com.hazelcast.simulator.coordinator.registry.AgentData) Registry(com.hazelcast.simulator.coordinator.registry.Registry)

Example 7 with CommandLineExitException

use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.

the class Wizard method createWorkDir.

void createWorkDir(SimulatorProperties simulatorProperties, String pathName, String cloudProvider) {
    File workDir = new File(pathName).getAbsoluteFile();
    if (workDir.exists()) {
        throw new CommandLineExitException(format("Working directory '%s' already exists!", workDir));
    }
    echo("Will create working directory '%s' for cloud provider '%s'", workDir, cloudProvider);
    ensureExistingDirectory(workDir);
    copyResourceFile(workDir, "runScript", "run");
    copyResourceFile(workDir, "testSuite", "test.properties");
    if (isLocal(cloudProvider)) {
        return;
    }
    ensureExistingFile(workDir, AgentsFile.NAME);
    File simulatorPropertiesFile = ensureExistingFile(workDir, SimulatorProperties.PROPERTIES_FILE_NAME);
    writeText(format("%s=%s%n", CLOUD_PROVIDER, cloudProvider), simulatorPropertiesFile);
    if (isEC2(cloudProvider)) {
        appendText(format("%n# These files contain your AWS access key ID and secret access key (change if needed)%n#%s=%s%n#%s=%s%n", CLOUD_IDENTITY, simulatorProperties.get(CLOUD_IDENTITY), CLOUD_CREDENTIAL, simulatorProperties.get(CLOUD_CREDENTIAL)), simulatorPropertiesFile);
        appendText(format("%n# Machine specification used for AWS (change if needed)%n#MACHINE_SPEC=%s%n", simulatorProperties.get("MACHINE_SPEC")), simulatorPropertiesFile);
    }
    if (isStatic(cloudProvider)) {
        copyResourceFile(workDir, "prepareScriptStatic", "prepare");
    } else {
        copyResourceFile(workDir, "prepareScriptCloud", "prepare");
    }
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) AgentsFile(com.hazelcast.simulator.common.AgentsFile) File(java.io.File) FileUtils.ensureExistingFile(com.hazelcast.simulator.utils.FileUtils.ensureExistingFile) WizardUtils.copyResourceFile(com.hazelcast.simulator.wizard.WizardUtils.copyResourceFile)

Example 8 with CommandLineExitException

use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.

the class SimulatorProperties method loadDirectOrFile.

private String loadDirectOrFile(String property) {
    String value = get(property);
    if (value == null) {
        throw new IllegalArgumentException(format("Simulator property '%s' is not found", property));
    }
    File file = newFile(value);
    if (file.exists()) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(format("Loading simulator property value for %s from file: %s", property, file.getAbsolutePath()));
        }
        return fileAsText(file).trim();
    } else if (value.endsWith(".identity") || value.endsWith(".credential") || value.endsWith(".txt")) {
        throw new CommandLineExitException("file [" + value + "] is not found");
    } else {
        return value.trim();
    }
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) FileUtils.newFile(com.hazelcast.simulator.utils.FileUtils.newFile) File(java.io.File)

Example 9 with CommandLineExitException

use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.

the class CoordinatorCli method getAgentsFile.

private static File getAgentsFile() {
    File file = new File("agents.txt");
    if (!file.exists()) {
        throw new CommandLineExitException(format("Agents file [%s] does not exist", file));
    }
    LOGGER.info("Loading Agents file: " + file.getAbsolutePath());
    return file;
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException) File(java.io.File)

Example 10 with CommandLineExitException

use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.

the class CoordinatorCli method newDeploymentPlan.

private DeploymentPlan newDeploymentPlan() {
    String workerType = options.valueOf(clientTypeSpec);
    if ("member".equals(workerType)) {
        throw new CommandLineExitException("client workerType can't be [member]");
    }
    int members = options.valueOf(membersSpec);
    if (members == -1) {
        members = registry.agentCount();
    } else if (members < -1) {
        throw new CommandLineExitException("--member must be a equal or larger than -1");
    }
    int clients = options.valueOf(clientsSpec);
    if (clients < 0) {
        throw new CommandLineExitException("--client must be a equal or larger than 0");
    }
    if (members == 0 && clients == 0) {
        throw new CommandLineExitException("No workers have been defined!");
    }
    DeploymentPlan plan = new DeploymentPlan(vendorDriver, registry.getAgents()).addToPlan(members, "member").addToPlan(clients, options.valueOf(clientTypeSpec));
    plan.printLayout();
    return plan;
}
Also used : CommandLineExitException(com.hazelcast.simulator.utils.CommandLineExitException)

Aggregations

CommandLineExitException (com.hazelcast.simulator.utils.CommandLineExitException)16 File (java.io.File)6 AgentData (com.hazelcast.simulator.coordinator.registry.AgentData)3 AgentData.publicAddressesString (com.hazelcast.simulator.coordinator.registry.AgentData.publicAddressesString)2 Registry (com.hazelcast.simulator.coordinator.registry.Registry)2 BashCommand (com.hazelcast.simulator.utils.BashCommand)2 FileUtils.ensureExistingFile (com.hazelcast.simulator.utils.FileUtils.ensureExistingFile)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 AgentsFile (com.hazelcast.simulator.common.AgentsFile)1 SimulatorAddress (com.hazelcast.simulator.protocol.core.SimulatorAddress)1 FileUtils.getConfigurationFile (com.hazelcast.simulator.utils.FileUtils.getConfigurationFile)1 FileUtils.newFile (com.hazelcast.simulator.utils.FileUtils.newFile)1 FileUtils.toTextFromResourceFile (com.hazelcast.simulator.utils.FileUtils.toTextFromResourceFile)1 TagUtils.tagsToString (com.hazelcast.simulator.utils.TagUtils.tagsToString)1 UuidUtil.newUnsecureUuidString (com.hazelcast.simulator.utils.UuidUtil.newUnsecureUuidString)1 WizardUtils.copyResourceFile (com.hazelcast.simulator.wizard.WizardUtils.copyResourceFile)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 NotBoundException (java.rmi.NotBoundException)1