private void writeHeader() { String columns = "epoch,timestamp,operations,operations-delta,operations/second,number-of-tests,total-tests\n"; appendText(columns, file); }
public static File appendText(String text, String fileName) { File file = new File(fileName); appendText(text, file); return file; }
public static File appendText(String text, String fileName) { File file = new File(fileName); appendText(text, file); return file; }
void write(long timeMillis, String timestamp, long operationsTotal, long operationsDelta, double operationsPerSecond, long numberOfTests, long totalTests) { sb.setLength(0); // ms are expressed in epoch time after the decimal point sb.append(format.format(timeMillis * 1d / SECONDS.toMillis(1))); sb.append(',').append(timestamp); sb.append(',').append(operationsTotal); sb.append(',').append(operationsDelta); sb.append(',').append(format.format(operationsPerSecond)); sb.append(',').append(numberOfTests); sb.append(',').append(totalTests); sb.append('\n'); appendText(sb.toString(), file); } }
void createSshCopyIdScript(SimulatorProperties simulatorProperties) { ComponentRegistry componentRegistry = loadComponentRegister(agentFile, true); String userName = simulatorProperties.getUser(); ensureExistingFile(SSH_COPY_ID_FILE); writeText("#!/bin/bash" + NEW_LINE + NEW_LINE, SSH_COPY_ID_FILE); for (AgentData agentData : componentRegistry.getAgents()) { String publicAddress = agentData.getPublicAddress(); appendText(format("ssh-copy-id -i ~/.ssh/id_rsa.pub %s@%s%n", userName, publicAddress), SSH_COPY_ID_FILE); } execute(format("chmod u+x %s", SSH_COPY_ID_FILE.getAbsoluteFile())); echo("Please execute './%s' to copy your public RSA key to all remote machines.", SSH_COPY_ID_FILE.getName()); }
String createLoadBalancer(String name) { CreateLoadBalancerRequest request = new CreateLoadBalancerRequest(); request.setLoadBalancerName(name); request.withAvailabilityZones(elbAvailabilityZones.split(",")); List<Listener> listeners = new ArrayList<Listener>(); listeners.add(new Listener(elbProtocol, elbPortIn, elbPortOut)); request.setListeners(listeners); CreateLoadBalancerResult lbResult = elb.createLoadBalancer(request); appendText(lbResult.getDNSName() + NEW_LINE, elbFile); return request.getLoadBalancerName(); }
writeText(format("%s=%s%n", PROPERTY_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", PROPERTY_CLOUD_IDENTITY, simulatorProperties.get(PROPERTY_CLOUD_IDENTITY), PROPERTY_CLOUD_CREDENTIAL, simulatorProperties.get(PROPERTY_CLOUD_CREDENTIAL)), simulatorPropertiesFile); appendText(format( "%n# Machine specification used for AWS (change if needed)%n#MACHINE_SPEC=%s%n", simulatorProperties.get("MACHINE_SPEC")), simulatorPropertiesFile); String currentUser = execute("whoami").trim(); appendText(format( "%n# These files contain your GCE credentials (change if needed)%n%s=%s%n%s=%s%n", PROPERTY_CLOUD_IDENTITY, "~/gce.id", PROPERTY_CLOUD_CREDENTIAL, "~/gce.pem"), simulatorPropertiesFile); appendText(format( "%nGROUP_NAME=simulator-agent%nUSER=%s%n", currentUser), simulatorPropertiesFile); appendText(format( "%n# Machine specification used for GCE (change if needed)%nMACHINE_SPEC=%s%n", GCE_DEFAULT_MACHINE_SPEC), simulatorPropertiesFile); appendText(format( "%n# SSH options used for GCE (change if needed)%nSSH_OPTIONS=%s %s%n", simulatorProperties.getSshOptions(), GCE_DEFAULT_SSH_OPTIONS), simulatorPropertiesFile);
void install(String simulatorPath, File profileFile) { echoImportant("Hazelcast Simulator Installation"); echo("Found Simulator in the following directory: %s", simulatorPath); echo("Found the following profile file: %s", profileFile.getAbsolutePath()); String profile = fileAsText(profileFile); if (profile.contains("SIMULATOR_HOME")) { throw new CommandLineExitException("Hazelcast Simulator seems to be already installed on this system!"); } String config = NEW_LINE + "# Hazelcast Simulator configuration" + NEW_LINE + "export SIMULATOR_HOME=" + simulatorPath + NEW_LINE + "PATH=$SIMULATOR_HOME/bin:$PATH" + NEW_LINE; echo("Will append the following configuration to your profile file:%n%s", config); appendText(config, profileFile); echo("Done!%n%nNOTE: Don't forget to start a new terminal to make changes effective!"); }
public void notify(FailureOperation failure) { failure = enrich(failure); WorkerData worker = componentRegistry.findWorker(failure.getWorkerAddress()); if (worker == null) { // we are not interested in failures of workers that aren't registered any longer. return; } // it the failure is the terminal for that workers, we need to remove it from the component registry if (failure.getType().isTerminal()) { LOGGER.info("Removing worker " + worker.getAddress() + " from componentRegistry due to [" + failure.getType() + "]"); componentRegistry.removeWorker(worker.getAddress()); } // if we don't care for the failure, we are done; no need to log anything. if (worker.isIgnoreFailures() || failure.getType() == WORKER_NORMAL_EXIT) { return; } int failureCount = criticalFailureCounter.incrementAndGet(); String testId = failure.getTestId(); if (testId != null) { hasCriticalFailuresMap.put(testId, true); } logFailure(failure, failureCount, true); appendText(failure.getFileMessage(), file); for (FailureListener failureListener : listenerMap.keySet()) { failureListener.onFailure(failure, failure.getType().isTerminal(), true); } }
private void addInstanceToAgentsFile(Instance instance) { String instanceId = instance.getInstanceId(); DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest().withInstanceIds(instanceId); DescribeInstancesResult result = ec2.describeInstances(describeInstancesRequest); for (Reservation reservation : result.getReservations()) { for (Instance reserved : reservation.getInstances()) { appendText(reserved.getPublicIpAddress() + ',' + reserved.getPrivateIpAddress() + NEW_LINE, agentsFile); componentRegistry.addAgent(reserved.getPublicIpAddress(), reserved.getPrivateIpAddress()); } } }