use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.
the class HarakiriMonitor method start.
void start() {
if (!isEC2(cloudProvider)) {
LOGGER.info("No Harakiri monitor is active: only on AWS-EC2 unused machines will be terminated.");
return;
}
LOGGER.info(format("Harakiri monitor is active and will wait %d seconds to kill this instance", waitSeconds));
sleepSeconds(waitSeconds);
LOGGER.info("Trying to commit Harakiri once!");
try {
LOGGER.info("Harakiri command: " + command);
execute(command);
} catch (Exception e) {
throw new CommandLineExitException("Failed to execute Harakiri", e);
}
}
use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.
the class CoordinatorCli method loadRawTestSuite.
private TestSuite loadRawTestSuite() {
String content;
List testsuiteFiles = options.nonOptionArguments();
File defaultTestProperties = new File("test.properties");
if (testsuiteFiles.size() > 1) {
throw new CommandLineExitException(format("Too many TestSuite files specified: %s", testsuiteFiles));
} else if (testsuiteFiles.size() == 1) {
content = (String) testsuiteFiles.get(0);
} else if (defaultTestProperties.exists()) {
content = defaultTestProperties.getPath();
} else {
return null;
}
TestSuite testSuite;
File testSuiteFile = new File(content);
if (testSuiteFile.exists()) {
LOGGER.info("Loading TestSuite file: " + testSuiteFile.getAbsolutePath());
testSuite = new TestSuite(testSuiteFile);
} else if (!content.endsWith(".properties")) {
testSuite = new TestSuite(content);
} else {
throw new CommandLineExitException(format("TestSuite file '%s' not found", testSuiteFile));
}
return testSuite;
}
use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.
the class CoordinatorCli method getDurationSeconds.
public static int getDurationSeconds(OptionSet options, OptionSpec<String> optionSpec) {
int duration;
String value = options.valueOf(optionSpec);
try {
if (value.endsWith("s")) {
duration = parseDurationWithoutLastChar(SECONDS, value);
} else if (value.endsWith("m")) {
duration = parseDurationWithoutLastChar(MINUTES, value);
} else if (value.endsWith("h")) {
duration = parseDurationWithoutLastChar(HOURS, value);
} else if (value.endsWith("d")) {
duration = parseDurationWithoutLastChar(DAYS, value);
} else {
duration = Integer.parseInt(value);
}
} catch (NumberFormatException e) {
throw new CommandLineExitException(format("Failed to parse duration '%s'", value), e);
}
if (duration < 0) {
throw new CommandLineExitException("duration must be a positive number, but was: " + duration);
}
return duration;
}
use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.
the class CoordinatorRemoteCli method loadAddresses.
private static List<String> loadAddresses(OptionSet options, OptionSpec<String> spec, AddressLevel addressLevel) {
String addresses = options.valueOf(spec);
if (addresses == null) {
return null;
}
List<String> result = new LinkedList<String>();
for (String addressString : addresses.split(",")) {
if (addressString != null) {
SimulatorAddress address;
try {
address = SimulatorAddress.fromString(addressString);
} catch (Exception e) {
throw new CommandLineExitException("Worker address [" + addressString + "] is not a valid simulator address", e);
}
if (!address.getAddressLevel().equals(addressLevel)) {
throw new CommandLineExitException("address [" + addressString + "] is not a valid " + addressLevel + " address, it's a " + address.getAddressLevel() + " address");
}
}
result.add(addressString);
}
return result;
}
use of com.hazelcast.simulator.utils.CommandLineExitException in project hazelcast-simulator by hazelcast.
the class AgentsSshCli method executeCommand.
private void executeCommand() {
List commands = options.nonOptionArguments();
if (commands.size() != 1) {
throw new CommandLineExitException("1 argument expected");
}
String command = (String) commands.get(0);
String sshOptions = properties.get("SSH_OPTIONS");
String simulatorUser = properties.get("SIMULATOR_USER");
for (AgentData agent : findAgents()) {
System.out.println("[" + agent.getPublicAddress() + "]");
new BashCommand("ssh -n -o LogLevel=quiet " + sshOptions + " " + simulatorUser + "@" + agent.getPublicAddress() + " '" + command + "'").setSystemOut(true).addEnvironment(properties.asMap()).execute();
}
}
Aggregations