TemplateBuilder(ComputeService compute, SimulatorProperties simulatorProperties) { this.compute = compute; this.simulatorProperties = simulatorProperties; this.isEC2 = isEC2(simulatorProperties); populatePortRangeMap(); }
public static boolean isEC2(SimulatorProperties properties) { return isEC2(properties.getCloudProvider()); }
public static boolean isHarakiriMonitorEnabled(SimulatorProperties properties) { return (isEC2(properties) && "true".equalsIgnoreCase(properties.get("HARAKIRI_MONITOR_ENABLED"))); }
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); } }
public static String getStartHarakiriMonitorCommandOrNull(SimulatorProperties properties) { if (!isHarakiriMonitorEnabled(properties)) { if (isEC2(properties)) { LOGGER.info("HarakiriMonitor is not enabled"); } return null; } String waitSeconds = properties.get("HARAKIRI_MONITOR_WAIT_SECONDS"); LOGGER.info(format("HarakiriMonitor is enabled and will kill inactive EC2 instances after %s seconds", waitSeconds)); return format( "nohup hazelcast-simulator-%s/bin/harakiri-monitor --cloudProvider %s --cloudIdentity %s --cloudCredential %s" + " --waitSeconds %s > harakiri.out 2> harakiri.err < /dev/null &", getSimulatorVersion(), properties.getCloudProvider(), properties.getCloudIdentity(), properties.getCloudCredential(), waitSeconds); } }
private StartAgentTask(Logger logger, Bash bash, SimulatorProperties properties, AgentData agentData, int agentPort) { this.logger = logger; this.bash = bash; this.runMode = CloudProviderUtils.runMode(properties); this.ip = agentData.getPublicAddress(); this.mandatoryParameters = format("--addressIndex %d --publicAddress %s --port %s", agentData.getAddressIndex(), ip, agentPort); this.optionalParameters = format(" --threadPoolSize %d --workerLastSeenTimeoutSeconds %d", properties.getAgentThreadPoolSize(), properties.getWorkerLastSeenTimeoutSeconds()); if (isEC2(properties)) { this.ec2Parameters = format(" --cloudProvider %s --cloudIdentity %s --cloudCredential %s", properties.getCloudProvider(), properties.getCloudIdentity(), properties.getCloudCredential()); } else { this.ec2Parameters = ""; } }
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",