public FileBasedCloudKeeperEnvironment() throws IOException { temporaryDirectory = Files.createTempDirectory(getClass().getSimpleName()); cloudKeeper = new SingleVMCloudKeeper.Builder().setWorkspaceBasePath(temporaryDirectory).build(); delegate = cloudKeeper .newCloudKeeperEnvironmentBuilder() .setCleaningRequested(false) .setStagingAreaProvider( (runtimeContext, executionTrace, instanceProvider) -> { Path basePath; try { basePath = Files.createTempDirectory(temporaryDirectory, "StagingArea"); return new FileStagingArea.Builder( runtimeContext, executionTrace, basePath, executorService) .build(); } catch (IOException exception) { throw new InstanceProvisionException( "Failed to provide file-based staging area because temporary directory could not be created.", exception); } }) .build(); }
@Override public void close() throws IOException { cloudKeeper.shutdown(); executorService.shutdown(); Files.walkFileTree(temporaryDirectory, RecursiveDeleteVisitor.getInstance()); }