/** * Delete the topo dir if it contains zero port dirs. */ @VisibleForTesting void cleanupEmptyTopoDirectory(File dir) throws IOException { File topoDir = dir.getParentFile(); if (topoDir.listFiles().length == 0) { Utils.forceDelete(topoDir.getCanonicalPath()); } }
@VisibleForTesting public void forceDeleteTopoDistDir(String topoId) throws IOException { Utils.forceDelete(ServerConfigUtils.masterStormDistRoot(conf, topoId)); }
public static void main(String[] args) throws Exception { SysOutOverSLF4J.sendSystemOutAndErrToSLF4J(); Map<String, Object> conf = ConfigUtils.readStormConfig(); Object port = conf.get(Config.STORM_ZOOKEEPER_PORT); String localPath = (String) conf.get(DaemonConfig.DEV_ZOOKEEPER_PATH); Utils.forceDelete(localPath); Zookeeper.mkInprocessZookeeper(localPath, ObjectReader.getInt(port)); } }
Utils.forceDelete(path); cleanupEmptyTopoDirectory(dir); numFilesCleaned++;
@Override public void deleteIfExists(File path, String user, String logPrefix) throws IOException { String absolutePath = path.getAbsolutePath(); if (Utils.checkFileExists(absolutePath)) { LOG.info("Deleting path (runAsUser) {}", absolutePath); if (user == null) { user = Files.getOwner(path.toPath()).getName(); } List<String> commands = new ArrayList<>(); commands.add("rmr"); commands.add(absolutePath); ClientSupervisorUtils.processLauncherAndWait(_conf, user, commands, null, logPrefix); if (Utils.checkFileExists(absolutePath)) { // It's possible that permissions were not set properly on the directory, and // the user who is *supposed* to own the dir does not. In this case, try the // delete as the supervisor user. Utils.forceDelete(absolutePath); if (Utils.checkFileExists(absolutePath)) { throw new RuntimeException(path + " was not deleted."); } } } }
/** * Clean up test environment. */ @After public void tearDown() { if (StringUtils.isNotEmpty(topoPath)) { try { Utils.forceDelete(topoPath); } catch (IOException e) { // ignore... } } }
Utils.forceDelete(file.getPath()); LOG.info("Delete file: {}, size: {}, lastModified: {}", canonicalPath, fileSize, lastModified); toDeleteSize -= fileSize;
final Response returnedFilterTopoId = handler.listLogFiles("user", null, "topoB", null, origin); Utils.forceDelete(rootPath);
forceDeleteArgs.add(path); return null; }).when(mockUtils).forceDelete(anyString());
@Override public void deleteIfExists(File path, String user, String logPrefix) throws IOException { String absolutePath = path.getAbsolutePath(); LOG.info("Deleting path {}", absolutePath); if (user == null) { user = Files.getOwner(path.toPath()).getName(); } List<String> commands = new ArrayList<>(); commands.add("rmr"); commands.add(absolutePath); SupervisorUtils.processLauncherAndWait(_conf, user, commands, null, logPrefix); if (Utils.checkFileExists(absolutePath)) { // It's possible that permissions were not set properly on the directory, and // the user who is *supposed* to own the dir does not. In this case, try the // delete as the supervisor user. Utils.forceDelete(absolutePath); if (Utils.checkFileExists(absolutePath)) { throw new RuntimeException(path + " was not deleted."); } } }