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!");
}
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");
}
}
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();
}
}
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;
}
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;
}
Aggregations