Java Code Examples for org.apache.flink.util.FileUtils#deleteFileOrDirectory()
The following examples show how to use
org.apache.flink.util.FileUtils#deleteFileOrDirectory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileArchivedExecutionGraphStore.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void close() throws IOException { cleanupFuture.cancel(false); jobDetailsCache.invalidateAll(); // clean up the storage directory FileUtils.deleteFileOrDirectory(storageDir); // Remove shutdown hook to prevent resource leaks ShutdownHookUtil.removeShutdownHook(shutdownHook, getClass().getSimpleName(), LOG); }
Example 2
Source File: FileArchivedExecutionGraphStore.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void deleteExecutionGraphFile(JobID jobId) { Preconditions.checkNotNull(jobId); final File archivedExecutionGraphFile = getExecutionGraphFile(jobId); try { FileUtils.deleteFileOrDirectory(archivedExecutionGraphFile); } catch (IOException e) { LOG.debug("Could not delete file {}.", archivedExecutionGraphFile, e); } archivedExecutionGraphCache.invalidate(jobId); jobDetailsCache.invalidate(jobId); }
Example 3
Source File: TaskExecutorLocalStateStoresManager.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Deletes the base dirs for this allocation id (recursively). */ private void cleanupAllocationBaseDirs(AllocationID allocationID) { // clear the base dirs for this allocation id. File[] allocationDirectories = allocationBaseDirectories(allocationID); for (File directory : allocationDirectories) { try { FileUtils.deleteFileOrDirectory(directory); } catch (IOException e) { LOG.warn("Exception while deleting local state directory for allocation id {}.", allocationID, e); } } }
Example 4
Source File: FileArchivedExecutionGraphStore.java From flink with Apache License 2.0 | 5 votes |
@Override public void close() throws IOException { cleanupFuture.cancel(false); jobDetailsCache.invalidateAll(); // clean up the storage directory FileUtils.deleteFileOrDirectory(storageDir); // Remove shutdown hook to prevent resource leaks ShutdownHookUtil.removeShutdownHook(shutdownHook, getClass().getSimpleName(), LOG); }
Example 5
Source File: FileArchivedExecutionGraphStore.java From flink with Apache License 2.0 | 5 votes |
private void deleteExecutionGraphFile(JobID jobId) { Preconditions.checkNotNull(jobId); final File archivedExecutionGraphFile = getExecutionGraphFile(jobId); try { FileUtils.deleteFileOrDirectory(archivedExecutionGraphFile); } catch (IOException e) { LOG.debug("Could not delete file {}.", archivedExecutionGraphFile, e); } archivedExecutionGraphCache.invalidate(jobId); jobDetailsCache.invalidate(jobId); }
Example 6
Source File: TaskExecutorLocalStateStoresManager.java From flink with Apache License 2.0 | 5 votes |
/** * Deletes the base dirs for this allocation id (recursively). */ private void cleanupAllocationBaseDirs(AllocationID allocationID) { // clear the base dirs for this allocation id. File[] allocationDirectories = allocationBaseDirectories(allocationID); for (File directory : allocationDirectories) { try { FileUtils.deleteFileOrDirectory(directory); } catch (IOException e) { LOG.warn("Exception while deleting local state directory for allocation id {}.", allocationID, e); } } }
Example 7
Source File: TaskExecutorLocalStateStoresManagerTest.java From flink with Apache License 2.0 | 5 votes |
/** * This tests that the creation of {@link TaskManagerServices} correctly creates the local state root directory * for the {@link TaskExecutorLocalStateStoresManager} with the configured root directory. */ @Test public void testCreationFromConfig() throws Exception { final Configuration config = new Configuration(); File newFolder = temporaryFolder.newFolder(); String tmpDir = newFolder.getAbsolutePath() + File.separator; final String rootDirString = "__localStateRoot1,__localStateRoot2,__localStateRoot3".replaceAll("__", tmpDir); // test configuration of the local state directories config.setString(CheckpointingOptions.LOCAL_RECOVERY_TASK_MANAGER_STATE_ROOT_DIRS, rootDirString); // test configuration of the local state mode config.setBoolean(CheckpointingOptions.LOCAL_RECOVERY, true); TaskManagerServices taskManagerServices = createTaskManagerServices(createTaskManagerServiceConfiguration(config)); TaskExecutorLocalStateStoresManager taskStateManager = taskManagerServices.getTaskManagerStateStore(); // verify configured directories for local state String[] split = rootDirString.split(","); File[] rootDirectories = taskStateManager.getLocalStateRootDirectories(); for (int i = 0; i < split.length; ++i) { Assert.assertEquals( new File(split[i], TaskManagerServices.LOCAL_STATE_SUB_DIRECTORY_ROOT), rootDirectories[i]); } // verify local recovery mode Assert.assertTrue(taskStateManager.isLocalRecoveryEnabled()); Assert.assertEquals("localState", TaskManagerServices.LOCAL_STATE_SUB_DIRECTORY_ROOT); for (File rootDirectory : rootDirectories) { FileUtils.deleteFileOrDirectory(rootDirectory); } }
Example 8
Source File: FileArchivedExecutionGraphStore.java From flink with Apache License 2.0 | 5 votes |
@Override public void close() throws IOException { cleanupFuture.cancel(false); jobDetailsCache.invalidateAll(); // clean up the storage directory FileUtils.deleteFileOrDirectory(storageDir); // Remove shutdown hook to prevent resource leaks ShutdownHookUtil.removeShutdownHook(shutdownHook, getClass().getSimpleName(), LOG); }
Example 9
Source File: FileArchivedExecutionGraphStore.java From flink with Apache License 2.0 | 5 votes |
private void deleteExecutionGraphFile(JobID jobId) { Preconditions.checkNotNull(jobId); final File archivedExecutionGraphFile = getExecutionGraphFile(jobId); try { FileUtils.deleteFileOrDirectory(archivedExecutionGraphFile); } catch (IOException e) { LOG.debug("Could not delete file {}.", archivedExecutionGraphFile, e); } archivedExecutionGraphCache.invalidate(jobId); jobDetailsCache.invalidate(jobId); }
Example 10
Source File: TaskExecutorLocalStateStoresManager.java From flink with Apache License 2.0 | 5 votes |
/** * Deletes the base dirs for this allocation id (recursively). */ private void cleanupAllocationBaseDirs(AllocationID allocationID) { // clear the base dirs for this allocation id. File[] allocationDirectories = allocationBaseDirectories(allocationID); for (File directory : allocationDirectories) { try { FileUtils.deleteFileOrDirectory(directory); } catch (IOException e) { LOG.warn("Exception while deleting local state directory for allocation id {}.", allocationID, e); } } }
Example 11
Source File: TaskExecutorLocalStateStoresManagerTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * This tests that the creation of {@link TaskManagerServices} correctly creates the local state root directory * for the {@link TaskExecutorLocalStateStoresManager} with the configured root directory. */ @Test public void testCreationFromConfig() throws Exception { final Configuration config = new Configuration(); File newFolder = temporaryFolder.newFolder(); String tmpDir = newFolder.getAbsolutePath() + File.separator; final String rootDirString = "__localStateRoot1,__localStateRoot2,__localStateRoot3".replaceAll("__", tmpDir); // test configuration of the local state directories config.setString(CheckpointingOptions.LOCAL_RECOVERY_TASK_MANAGER_STATE_ROOT_DIRS, rootDirString); // test configuration of the local state mode config.setBoolean(CheckpointingOptions.LOCAL_RECOVERY, true); final ResourceID tmResourceID = ResourceID.generate(); TaskManagerServicesConfiguration taskManagerServicesConfiguration = TaskManagerServicesConfiguration.fromConfiguration(config, InetAddress.getLocalHost(), true); TaskManagerServices taskManagerServices = TaskManagerServices.fromConfiguration( taskManagerServicesConfiguration, tmResourceID, Executors.directExecutor(), MEM_SIZE_PARAM, MEM_SIZE_PARAM); TaskExecutorLocalStateStoresManager taskStateManager = taskManagerServices.getTaskManagerStateStore(); // verify configured directories for local state String[] split = rootDirString.split(","); File[] rootDirectories = taskStateManager.getLocalStateRootDirectories(); for (int i = 0; i < split.length; ++i) { Assert.assertEquals( new File(split[i], TaskManagerServices.LOCAL_STATE_SUB_DIRECTORY_ROOT), rootDirectories[i]); } // verify local recovery mode Assert.assertTrue(taskStateManager.isLocalRecoveryEnabled()); Assert.assertEquals("localState", TaskManagerServices.LOCAL_STATE_SUB_DIRECTORY_ROOT); for (File rootDirectory : rootDirectories) { FileUtils.deleteFileOrDirectory(rootDirectory); } }
Example 12
Source File: AutoClosablePath.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void close() throws IOException { FileUtils.deleteFileOrDirectory(path.toFile()); }
Example 13
Source File: AutoClosablePath.java From flink with Apache License 2.0 | 4 votes |
@Override public void close() throws IOException { FileUtils.deleteFileOrDirectory(path.toFile()); }
Example 14
Source File: CsvSourceSinkTest.java From Alink with Apache License 2.0 | 4 votes |
@After public void clear() throws Exception { FileUtils.deleteFileOrDirectory(new File(path)); }
Example 15
Source File: TaskExecutorLocalStateStoresManagerTest.java From flink with Apache License 2.0 | 4 votes |
/** * This tests that the creation of {@link TaskManagerServices} correctly creates the local state root directory * for the {@link TaskExecutorLocalStateStoresManager} with the configured root directory. */ @Test public void testCreationFromConfig() throws Exception { final Configuration config = new Configuration(); File newFolder = temporaryFolder.newFolder(); String tmpDir = newFolder.getAbsolutePath() + File.separator; final String rootDirString = "__localStateRoot1,__localStateRoot2,__localStateRoot3".replaceAll("__", tmpDir); // test configuration of the local state directories config.setString(CheckpointingOptions.LOCAL_RECOVERY_TASK_MANAGER_STATE_ROOT_DIRS, rootDirString); // test configuration of the local state mode config.setBoolean(CheckpointingOptions.LOCAL_RECOVERY, true); TaskManagerServices taskManagerServices = createTaskManagerServices(createTaskManagerServiceConfiguration(config)); try { TaskExecutorLocalStateStoresManager taskStateManager = taskManagerServices.getTaskManagerStateStore(); // verify configured directories for local state String[] split = rootDirString.split(","); File[] rootDirectories = taskStateManager.getLocalStateRootDirectories(); for (int i = 0; i < split.length; ++i) { Assert.assertEquals( new File(split[i], TaskManagerServices.LOCAL_STATE_SUB_DIRECTORY_ROOT), rootDirectories[i]); } // verify local recovery mode Assert.assertTrue(taskStateManager.isLocalRecoveryEnabled()); Assert.assertEquals("localState", TaskManagerServices.LOCAL_STATE_SUB_DIRECTORY_ROOT); for (File rootDirectory : rootDirectories) { FileUtils.deleteFileOrDirectory(rootDirectory); } } finally { taskManagerServices.shutDown(); } }
Example 16
Source File: AutoClosablePath.java From flink with Apache License 2.0 | 4 votes |
@Override public void close() throws IOException { FileUtils.deleteFileOrDirectory(path.toFile()); }