/** like {@link #deleteOnExitRecursively(File)} followed by {@link #deleteOnExitEmptyParentsUpTo(File, File)} */ public static void deleteOnExitRecursivelyAndEmptyParentsUpTo(File directoryToCleanOrFile, File highestAncestorToDelete) { deleteOnExitRecursively(directoryToCleanOrFile); deleteOnExitEmptyParentsUpTo(directoryToCleanOrFile, highestAncestorToDelete); }
@Inject public Uploader(ArchiveUploadService archiveUploadService){ this.archiveUploadService = archiveUploadService; tmpRoot = Os.newTempDir("brooklyn-a4c"); Os.deleteOnExitRecursively(tmpRoot); }
@Inject public Alien4CloudFacade(ICSARRepositorySearchService repositorySearchService, TopologyTreeBuilderService treeBuilder, ICsarRepositry csarFileRepository, TopologyServiceCore topologyService, TopologyTemplateVersionService topologyTemplateVersionService, DeploymentTopologyService deploymentTopologyService, ApplicationService applicationService) { this.repositorySearchService = repositorySearchService; this.treeBuilder = treeBuilder; this.csarFileRepository = csarFileRepository; this.topologyService = topologyService; this.topologyTemplateVersionService = topologyTemplateVersionService; this.deploymentTopologyService = deploymentTopologyService; this.applicationService = applicationService; tmpRoot = Os.newTempDir("brooklyn-a4c"); Os.deleteOnExitRecursively(tmpRoot); }
@Inject public Alien4CloudToscaPlatform(BeanFactory beanFactory, ToscaFacade alien4CloudFacade, Uploader uploader) { this.beanFactory = beanFactory; this.alien4CloudFacade = alien4CloudFacade; this.uploader = uploader; tmpRoot = Os.newTempDir("brooklyn-a4c"); Os.deleteOnExitRecursively(tmpRoot); loadDefaultTypes(); }
public static File getOsgiCacheDirCleanedIfNeeded(ManagementContext mgmt) { File cacheDirF = getOsgiCacheDir(mgmt); boolean clean = isOsgiCacheForCleaning(mgmt, cacheDirF); log.debug("OSGi cache dir computed as "+cacheDirF.getAbsolutePath()+" ("+ (cacheDirF.exists() ? "already exists" : "does not exist")+", "+ (clean ? "cleaning now (and on exit)" : "cleaning not requested")); if (clean) { Os.deleteRecursively(cacheDirF); Os.deleteOnExitRecursively(cacheDirF); } return cacheDirF; }
@Override protected String newTempPersistenceContainerName() { File persistenceDirF = Files.createTempDir(); Os.deleteOnExitRecursively(persistenceDirF); return persistenceDirF.getAbsolutePath(); }
protected String newTempPersistenceContainerName() { File persistenceDirF = Files.createTempDir(); Os.deleteOnExitRecursively(persistenceDirF); return persistenceDirF.getAbsolutePath(); }
@BeforeMethod(alwaysRun=true) public void setUp() throws Exception { persistenceDir = Files.createTempDir(); Os.deleteOnExitRecursively(persistenceDir); }
@Override protected String newTempPersistenceContainerName() { File persistenceDirF = Files.createTempDir(); Os.deleteOnExitRecursively(persistenceDirF); return persistenceDirF.getAbsolutePath(); }
/** creates a temp dir which will be deleted on exit */ public static File newTempDir(String prefix) { String sanitizedPrefix = (prefix==null ? "" : Strings.makeValidFilename(prefix) + "-"); String tmpParent = tmp(); //With lots of stale temp dirs it is possible to have //name collisions so we need to retry until a unique //name is found for (int i = 0; i < TEMP_DIR_ATTEMPTS; i++) { String baseName = sanitizedPrefix + Identifiers.makeRandomId(4); File tempDir = new File(tmpParent, baseName); if (!tempDir.exists()) { if (tempDir.mkdir()) { Os.deleteOnExitRecursively(tempDir); return tempDir; } else { log.warn("Attempt to create temp dir failed " + tempDir + ". Either an IO error (disk full, no rights) or someone else created the folder after the !exists() check."); } } else { log.debug("Attempt to create temp dir failed, already exists " + tempDir + ". With ID of length 4 it is not unusual (15% chance) to have duplicate names at the 2000 samples mark."); } } throw new IllegalStateException("cannot create temporary folders in parent " + tmpParent + " after " + TEMP_DIR_ATTEMPTS + " attempts."); }
Os.deleteOnExitRecursively(brooklynBundlesCacheDir); Os.deleteOnExitRecursively(osgiFrameworkCacheDir); if (numberOfReusableFrameworksCreated.incrementAndGet()%10==0) { log.warn("Possible leak of reusable OSGi containers ("+numberOfReusableFrameworksCreated+" total)");
@BeforeClass public void createTmpDirAndFiles() throws IOException { parentDir = Os.newTempDir(getClass().getSimpleName()); Os.deleteOnExitRecursively(parentDir); tmpDir = new File(parentDir, Identifiers.makeRandomId(4)); Os.mkdirs(tmpDir); Files.write("abcdef", new File(tmpDir, "data01.txt"), Charsets.US_ASCII); Files.write("123456", new File(tmpDir, "data02.txt"), Charsets.US_ASCII); Files.write("qqqqqq", new File(tmpDir, "data03.txt"), Charsets.US_ASCII); tmpDir2 = new File(parentDir, Identifiers.makeRandomId(4)); Os.mkdirs(tmpDir2); Files.write("zzzzzz", new File(tmpDir2, "data04.txt"), Charsets.US_ASCII); }
@Override protected ManagementContext newPersistingManagementContext() { mementoDir = Os.newTempDir(JavaClassNames.cleanSimpleClassName(this)); Os.deleteOnExitRecursively(mementoDir); return RebindTestUtils.managementContextBuilder(classLoader, new FileBasedObjectStore(mementoDir)) .persistPeriod(Duration.millis(10)).buildStarted(); }