private static File getLatencyFile(String testId, String probeName) { return new File(getUserDir(), testId + '-' + probeName + ".hdr"); } }
public static File getSimulatorHome() { String home = System.getProperty("SIMULATOR_HOME"); if (home != null) { return new File(home); } home = System.getenv("SIMULATOR_HOME"); return home != null ? new File(home) : getUserDir(); }
public static void assertNoExceptions() { File userDir = getUserDir(); if (userDir.exists()) { for (File file : userDir.listFiles()) { if (file.isDirectory()) { continue; } assertFalse("exception found: " + file + " content: " + fileAsText(file), file.getName().endsWith(".exception")); } } }
private PerformanceMonitorThread(ServerConnector serverConnector, Collection<TestContainer> testContainers, long intervalNanos) { super("WorkerPerformanceMonitor"); setDaemon(true); this.serverConnector = serverConnector; this.testContainers = testContainers; this.intervalNanos = intervalNanos; this.globalPerformanceLogWriter = new PerformanceLogWriter(new File(getUserDir(), "performance.csv")); }
public static SimulatorProperties loadSimulatorProperties() { SimulatorProperties simulatorProperties = new SimulatorProperties(); File file = new File(FileUtils.getUserDir(), "simulator.properties"); if (file.exists()) { simulatorProperties.init(file); } return simulatorProperties; }
private void signalStartToAgent() { String address = getHazelcastAddress(type, publicAddress, hazelcastInstance); File file = new File(getUserDir(), "worker.address"); writeText(address, file); }
public static void assertException(String content, int id) { File userDir = getUserDir(); if (!userDir.exists()) { fail("userDir " + userDir.getAbsolutePath() + " does not exist"); } File exceptionFile = new File(userDir, id + ".exception"); assertTrue(exceptionFile.getAbsolutePath() + " does not exist", exceptionFile.exists()); String text = fileAsText(exceptionFile); assertTrue(format("'%s' does not contains '%s'", text, content), text.contains(content)); } }
/** * Initializes the SimulatorProperties. * * @param file the file to load the properties from. If {@code null}, the {@value #PROPERTIES_FILE_NAME} file in the working * directory is tried. * @throws CommandLineExitException if the given file does not exist. If file is {@code null} no exception will be thrown, * even if the {@value #PROPERTIES_FILE_NAME} file in the working directory cannot be found. */ public void init(File file) { if (file == null) { // if no file is explicitly given, we look in the working directory file = new File(getUserDir(), PROPERTIES_FILE_NAME); if (!file.exists()) { LOGGER.info(format("Found no %s in working directory, relying on default properties", PROPERTIES_FILE_NAME)); return; } } LOGGER.info(format("Loading additional %s: %s", PROPERTIES_FILE_NAME, file.getAbsolutePath())); check(file); load(file); }
@Override public String call() throws Exception { Map<String, Object> environment = new HashMap<String, Object>(); File pidFile = new File(getUserDir(), "worker.pid"); if (pidFile.exists()) { environment.put("PID", fileAsText(pidFile)); } return new BashCommand(command) .setDirectory(getUserDir()) .addEnvironment(environment) .setThrowsException(true) .execute(); } };
void download() throws Exception { new ArtifactDownloadTask("*", simulatorProperties, getUserDir(), componentRegistry).run(); }
public TestPerformanceTracker(TestContainer container) { this.testContainer = container; this.testStartedTimestamp = container.getTestStartedTimestamp(); this.lastTimestamp = testStartedTimestamp; this.performanceLogWriter = new PerformanceLogWriter( new File(getUserDir(), "performance-" + container.getTestCase().getId() + ".csv")); }
File dir = getUserDir(); File tmpFile = new File(dir, targetFileName + ".tmp"); try {
private CoordinatorRemoteCli(String[] args) { SimulatorProperties simulatorProperties = new SimulatorProperties(); File file = new File(FileUtils.getUserDir(), "simulator.properties"); if (file.exists()) { simulatorProperties.init(file); } this.args = args; this.coordinatorPort = simulatorProperties.getCoordinatorPort(); if (coordinatorPort == 0) { throw new CommandLineExitException("Coordinator port is disabled!"); } }
public static void main(String[] args) { int pid = NativeUtils.getPID(); LOGGER.info("PID: " + pid); writeText("" + pid, new File(getUserDir(), "worker.pid")); try { startWorker(); } catch (Exception e) { ExceptionReporter.report(null, e); exitWithError(LOGGER, "Could not start Hazelcast Simulator Worker!", e); } }
Coordinator(ComponentRegistry componentRegistry, CoordinatorParameters parameters) { this.componentRegistry = componentRegistry; this.parameters = parameters; this.outputDirectory = ensureNewDirectory(new File(getUserDir(), parameters.getSessionId())); this.failureCollector = new FailureCollector(outputDirectory, componentRegistry); this.simulatorProperties = parameters.getSimulatorProperties(); this.bash = new Bash(simulatorProperties); this.testCompletionTimeoutSeconds = simulatorProperties.getTestCompletionTimeoutSeconds(); }
class TimeStepRunnerCodeGenerator { private final File targetDirectory = new File(getUserDir(), "timestep-worker-classes");
static AwsProvisioner init(String[] args) { AwsProvisioner.logHeader(); AwsProvisionerCli cli = new AwsProvisionerCli(); initOptionsWithHelp(cli.parser, args); SimulatorProperties properties = loadSimulatorProperties(); ComponentRegistry componentRegistry = loadComponentRegister(new File(getUserDir(), AgentsFile.NAME), false); try { String awsCredentialsPath = properties.get("AWS_CREDENTIALS", "awscredentials.properties"); File credentialsFile = new File(awsCredentialsPath); AWSCredentials credentials = new PropertiesCredentials(credentialsFile); AmazonEC2 ec2 = new AmazonEC2Client(credentials); AmazonElasticLoadBalancingClient elb = new AmazonElasticLoadBalancingClient(credentials); return new AwsProvisioner(ec2, elb, componentRegistry, properties); } catch (Exception e) { throw new CommandLineExitException("Credentials file could not be loaded", e); } }