List of usage examples for org.apache.commons.io FileDeleteStrategy FORCE
FileDeleteStrategy FORCE
To view the source code for org.apache.commons.io FileDeleteStrategy FORCE.
Click Source Link
From source file:voldemort.store.configuration.ConfigurationStorageEngineTest.java
@Override public void tearDown() throws Exception { super.tearDown(); if (null != tempDir && tempDir.exists()) FileDeleteStrategy.FORCE.delete(tempDir); }
From source file:voldemort.store.filesystem.FilesystemStorageEngine.java
public synchronized void put(String key, Versioned<String> value) throws VoldemortException { ArrayList<String> deleteList = new ArrayList<String>(); StoreUtils.assertValidKey(key);/*from w w w . j av a 2 s . com*/ // Check for obsolete version File[] files = this.directory.listFiles(); for (File file : files) { if (file.getName().startsWith(key)) { VectorClock clock = getVersion(file, key); if (null != clock) { if (clock.compare(value.getVersion()) == Occured.AFTER) throw new ObsoleteVersionException("A successor version to this exists."); else if (clock.compare(value.getVersion()) == Occured.BEFORE) { // Add the file to deleteList deleteList.add(file.getAbsolutePath()); } } } } VectorClock clock = (VectorClock) value.getVersion(); String path = this.directory.getAbsolutePath() + File.separator + key + "-" + new String(Hex.encodeHex(clock.toBytes())) + ".version"; File newFile = new File(path); try { if (!newFile.createNewFile()) throw new ObsoleteVersionException("File " + path + " already exists."); FileUtils.writeStringToFile(newFile, value.getValue(), "UTF-8"); } catch (IOException e) { throw new VoldemortException(e); } // if succceded remove the old value Object. for (String file : deleteList) { try { FileDeleteStrategy.FORCE.delete(new File(file)); } catch (IOException e) { logger.warn("Failed to Delete File:" + file); } } }
From source file:voldemort.store.filesystem.FilesystemStorageEngineTest.java
@Override public void tearDown() throws Exception { super.tearDown(); for (File file : tempDirs) FileDeleteStrategy.FORCE.delete(file); }