public static void deleteQuiet(String fileName) { deleteQuiet(new File(fileName)); }
public static void deleteQuiet(String fileName) { deleteQuiet(new File(fileName)); }
private String readAddress(WorkerProcess workerProcess) { File file = new File(workerProcess.getWorkerHome(), "worker.address"); if (!file.exists()) { return null; } String address = fileAsText(file); deleteQuiet(file); return address; }
private void createPidFile() { deleteQuiet(pidFile); writeText("" + getPID(), pidFile); }
@Override public void doRun() { LOGGER.info("Stopping workers..."); workerProcessManager.shutdown(); LOGGER.info("Stopping WorkerProcessFailureMonitor..."); workerProcessFailureMonitor.shutdown(); LOGGER.info("Stopping AgentConnector..."); agentConnector.close(); LOGGER.info("Removing PID file..."); deleteQuiet(pidFile); OperationTypeCounter.printStatistics(); } }
private void detectExceptions(WorkerProcess workerProcess) { File workerHome = workerProcess.getWorkerHome(); if (!workerHome.exists()) { return; } File[] exceptionFiles = ExceptionExtensionFilter.listFiles(workerHome); for (File exceptionFile : exceptionFiles) { String content = fileAsText(exceptionFile); int indexOf = content.indexOf(NEW_LINE); String testId = content.substring(0, indexOf); String cause = content.substring(indexOf + 1); if (testId.isEmpty() || "null".equals(testId)) { testId = null; } // we delete or rename the exception file so that we don't detect the same exception again boolean send = failureHandler.handle("Worked ran into an unhandled exception", WORKER_EXCEPTION, workerProcess, testId, cause); if (send) { deleteQuiet(exceptionFile); } else { rename(exceptionFile, new File(exceptionFile.getParentFile(), exceptionFile.getName() + ".sendFailure")); } } }
private void executeInitScript(String ip) { File initFile = newFile("init-" + newUnsecureUuidString() + ".sh"); writeText(loadInitScript(), initFile); bash.scpToRemote(ip, initFile, "init.sh"); bash.sshTTY(ip, "bash init.sh"); deleteQuiet(initFile); }
public static void main(String[] args) throws IOException { File outputFile = new File(args[0]); deleteQuiet(outputFile); ensureExistingFile(outputFile);