protected AbstractSharedBackend createBackend() { FSBackend backend = new FSBackend(); if(this.properties != null) { backend.setProperties(this.properties); } return backend; }
@Override public void deleteRecord(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); synchronized (this) { if (file.exists()) { if (file.delete()) { deleteEmptyParentDirs(file); } else { LOG.warn("Failed to delete file " + file.getAbsolutePath()); } } } }
@Override public void write(DataIdentifier identifier, File file) throws DataStoreException { File dest = getFile(identifier, fsPathDir); synchronized (this) { if (dest.exists()) { long now = System.currentTimeMillis(); if (getLastModified(dest) < now + ACCESS_TIME_RESOLUTION) { setLastModified(dest, now + ACCESS_TIME_RESOLUTION); } } else { try { FileUtils.copyFile(file, dest); } catch (IOException ie) { LOG.error("failed to copy [{}] to [{}]", file.getAbsolutePath(), dest.getAbsolutePath()); throw new DataStoreException("Not able to write file [" + identifier + "]", ie); } } } }
@Override public boolean exists(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); return file.exists() && file.isFile(); }
@Override public void write(DataIdentifier identifier, File file) throws DataStoreException { File dest = getFile(identifier, fsPathDir); synchronized (this) { if (dest.exists()) { long now = System.currentTimeMillis(); if (getLastModified(dest) < now + ACCESS_TIME_RESOLUTION) { setLastModified(dest, now + ACCESS_TIME_RESOLUTION); } } else { try { FileUtils.copyFile(file, dest); } catch (IOException ie) { LOG.error("failed to copy [{}] to [{}]", file.getAbsolutePath(), dest.getAbsolutePath()); throw new DataStoreException("Not able to write file [" + identifier + "]", ie); } } } }
@Override public boolean exists(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); return file.exists() && file.isFile(); }
@Override public void write(DataIdentifier identifier, File file) throws DataStoreException { File dest = getFile(identifier, fsPathDir); synchronized (this) { if (dest.exists()) { long now = System.currentTimeMillis(); if (getLastModified(dest) < now + ACCESS_TIME_RESOLUTION) { setLastModified(dest, now + ACCESS_TIME_RESOLUTION); } } else { try { FileUtils.copyFile(file, dest); } catch (IOException ie) { LOG.error("failed to copy [{}] to [{}]", file.getAbsolutePath(), dest.getAbsolutePath()); throw new DataStoreException("Not able to write file [" + identifier + "]", ie); } } } }
@Override public void deleteRecord(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); synchronized (this) { if (file.exists()) { if (file.delete()) { deleteEmptyParentDirs(file); } else { LOG.warn("Failed to delete file " + file.getAbsolutePath()); } } } }
protected AbstractSharedBackend createBackend() { FSBackend backend = new FSBackend(); if(this.properties != null) { backend.setProperties(this.properties); } return backend; }
@Override public boolean exists(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); return file.exists() && file.isFile(); }
@Override public void deleteRecord(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); synchronized (this) { if (file.exists()) { if (file.delete()) { deleteEmptyParentDirs(file); } else { LOG.warn("Failed to delete file " + file.getAbsolutePath()); } } } }
protected AbstractSharedBackend createBackend() { FSBackend backend = new FSBackend(); if(this.properties != null) { backend.setProperties(this.properties); } return backend; }
@Override public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException { long start = System.currentTimeMillis(); File file = getFile(identifier, fsPathDir); if (!file.exists() || !file.isFile()) { LOG.info("getRecord:Identifier [{}] not found. Took [{}] ms.", identifier, (System.currentTimeMillis() - start)); throw new DataStoreException("Identifier [" + identifier + "] not found."); } return new FSBackendDataRecord(this, identifier, file); }
@Override public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException { long start = System.currentTimeMillis(); File file = getFile(identifier, fsPathDir); if (!file.exists() || !file.isFile()) { LOG.info("getRecord:Identifier [{}] not found. Took [{}] ms.", identifier, (System.currentTimeMillis() - start)); throw new DataStoreException("Identifier [" + identifier + "] not found."); } return new FSBackendDataRecord(this, identifier, file); }
@Override public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException { long start = System.currentTimeMillis(); File file = getFile(identifier, fsPathDir); if (!file.exists() || !file.isFile()) { LOG.info("getRecord:Identifier [{}] not found. Took [{}] ms.", identifier, (System.currentTimeMillis() - start)); throw new DataStoreException("Identifier [" + identifier + "] not found."); } return new FSBackendDataRecord(this, identifier, file); }
@Override public InputStream read(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); try { return new LazyFileInputStream(file); } catch (IOException e) { throw new DataStoreException("Error opening input stream of " + file.getAbsolutePath(), e); } }
@Override public InputStream read(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); try { return new LazyFileInputStream(file); } catch (IOException e) { throw new DataStoreException("Error opening input stream of " + file.getAbsolutePath(), e); } }
@Override public InputStream read(DataIdentifier identifier) throws DataStoreException { File file = getFile(identifier, fsPathDir); try { return new LazyFileInputStream(file); } catch (IOException e) { throw new DataStoreException("Error opening input stream of " + file.getAbsolutePath(), e); } }