@Override public boolean put(File localFile, JobID jobId, BlobKey blobKey) throws IOException { return put(localFile, BlobUtils.getStorageLocationPath(basePath, jobId, blobKey)); }
@Override public boolean get(JobID jobId, BlobKey blobKey, File localFile) throws IOException { return get(BlobUtils.getStorageLocationPath(basePath, jobId, blobKey), localFile, blobKey); }
/** * Returns the (designated) physical storage location of the BLOB with the given key. * * @param storageDir * storage directory used be the BLOB service * @param key * the key identifying the BLOB * @param jobId * ID of the job for the incoming files (or <tt>null</tt> if job-unrelated) * * @return the (designated) physical storage location of the BLOB * * @throws IOException * if creating the directory fails */ static File getStorageLocation( File storageDir, @Nullable JobID jobId, BlobKey key) throws IOException { File file = new File(getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); Files.createDirectories(file.getParentFile().toPath()); return file; }
@Override public boolean get(JobID jobId, BlobKey blobKey, File localFile) throws IOException { return get(BlobUtils.getStorageLocationPath(basePath, jobId, blobKey), localFile, blobKey); }
@Override public boolean delete(JobID jobId, BlobKey blobKey) { return delete(BlobUtils.getStorageLocationPath(basePath, jobId, blobKey)); }
@Override public boolean deleteAll(JobID jobId) { return delete(BlobUtils.getStorageLocationPath(basePath, jobId)); }
@Override public boolean put(File localFile, JobID jobId, BlobKey blobKey) throws IOException { return put(localFile, BlobUtils.getStorageLocationPath(basePath, jobId, blobKey)); }
@Override public boolean delete(JobID jobId, BlobKey blobKey) { return delete(BlobUtils.getStorageLocationPath(basePath, jobId, blobKey)); }
@Override public boolean deleteAll(JobID jobId) { return delete(BlobUtils.getStorageLocationPath(basePath, jobId)); }
@Override public boolean delete(JobID jobId, BlobKey blobKey) { return delete(BlobUtils.getStorageLocationPath(basePath, jobId, blobKey)); }
@Override public boolean deleteAll(JobID jobId) { return delete(BlobUtils.getStorageLocationPath(basePath, jobId)); }
@Override public boolean put(File localFile, JobID jobId, BlobKey blobKey) throws IOException { return put(localFile, BlobUtils.getStorageLocationPath(basePath, jobId, blobKey)); }
@Override public boolean get(JobID jobId, BlobKey blobKey, File localFile) throws IOException { return get(BlobUtils.getStorageLocationPath(basePath, jobId, blobKey), localFile, blobKey); }
/** * Returns the (designated) physical storage location of the BLOB with the given key. * * @param storageDir * storage directory used be the BLOB service * @param key * the key identifying the BLOB * @param jobId * ID of the job for the incoming files (or <tt>null</tt> if job-unrelated) * * @return the (designated) physical storage location of the BLOB * * @throws IOException * if creating the directory fails */ static File getStorageLocation( File storageDir, @Nullable JobID jobId, BlobKey key) throws IOException { File file = new File(getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); Files.createDirectories(file.getParentFile().toPath()); return file; }
/** * Returns the (designated) physical storage location of the BLOB with the given key. * * @param storageDir * storage directory used be the BLOB service * @param key * the key identifying the BLOB * @param jobId * ID of the job for the incoming files (or <tt>null</tt> if job-unrelated) * * @return the (designated) physical storage location of the BLOB * * @throws IOException * if creating the directory fails */ static File getStorageLocation( File storageDir, @Nullable JobID jobId, BlobKey key) throws IOException { File file = new File(getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); mkdirTolerateExisting(file.getParentFile()); return file; }
/** * Deletes the file associated with the blob key in this BLOB cache. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param key * blob key associated with the file to be deleted * * @return <tt>true</tt> if the given blob is successfully deleted or non-existing; * <tt>false</tt> otherwise */ private boolean deleteInternal(@Nullable JobID jobId, TransientBlobKey key) { final File localFile = new File(BlobUtils.getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); readWriteLock.writeLock().lock(); try { if (!localFile.delete() && localFile.exists()) { log.warn("Failed to delete locally cached BLOB {} at {}", key, localFile.getAbsolutePath()); return false; } else { // this needs to happen inside the write lock in case of concurrent getFile() calls blobExpiryTimes.remove(Tuple2.of(jobId, key)); } } finally { readWriteLock.writeLock().unlock(); } return true; }
/** * Deletes the file associated with the blob key in the local storage of the blob server. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param key * blob key associated with the file to be deleted * * @return <tt>true</tt> if the given blob is successfully deleted or non-existing; * <tt>false</tt> otherwise */ boolean deleteInternal(@Nullable JobID jobId, TransientBlobKey key) { final File localFile = new File(BlobUtils.getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); readWriteLock.writeLock().lock(); try { if (!localFile.delete() && localFile.exists()) { LOG.warn("Failed to locally delete BLOB " + key + " at " + localFile.getAbsolutePath()); return false; } // this needs to happen inside the write lock in case of concurrent getFile() calls blobExpiryTimes.remove(Tuple2.of(jobId, key)); return true; } finally { readWriteLock.writeLock().unlock(); } }
/** * Deletes the file associated with the blob key in the local storage of the blob server. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param key * blob key associated with the file to be deleted * * @return <tt>true</tt> if the given blob is successfully deleted or non-existing; * <tt>false</tt> otherwise */ boolean deleteInternal(@Nullable JobID jobId, TransientBlobKey key) { final File localFile = new File(BlobUtils.getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); readWriteLock.writeLock().lock(); try { if (!localFile.delete() && localFile.exists()) { LOG.warn("Failed to locally delete BLOB " + key + " at " + localFile.getAbsolutePath()); return false; } // this needs to happen inside the write lock in case of concurrent getFile() calls blobExpiryTimes.remove(Tuple2.of(jobId, key)); return true; } finally { readWriteLock.writeLock().unlock(); } }
/** * Deletes the file associated with the blob key in the local storage of the blob server. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param key * blob key associated with the file to be deleted * * @return <tt>true</tt> if the given blob is successfully deleted or non-existing; * <tt>false</tt> otherwise */ boolean deleteInternal(@Nullable JobID jobId, TransientBlobKey key) { final File localFile = new File(BlobUtils.getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); readWriteLock.writeLock().lock(); try { if (!localFile.delete() && localFile.exists()) { LOG.warn("Failed to locally delete BLOB " + key + " at " + localFile.getAbsolutePath()); return false; } // this needs to happen inside the write lock in case of concurrent getFile() calls blobExpiryTimes.remove(Tuple2.of(jobId, key)); return true; } finally { readWriteLock.writeLock().unlock(); } }
/** * Deletes the file associated with the blob key in this BLOB cache. * * @param jobId * ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated) * @param key * blob key associated with the file to be deleted * * @return <tt>true</tt> if the given blob is successfully deleted or non-existing; * <tt>false</tt> otherwise */ private boolean deleteInternal(@Nullable JobID jobId, TransientBlobKey key) { final File localFile = new File(BlobUtils.getStorageLocationPath(storageDir.getAbsolutePath(), jobId, key)); readWriteLock.writeLock().lock(); try { if (!localFile.delete() && localFile.exists()) { log.warn("Failed to delete locally cached BLOB {} at {}", key, localFile.getAbsolutePath()); return false; } else { // this needs to happen inside the write lock in case of concurrent getFile() calls blobExpiryTimes.remove(Tuple2.of(jobId, key)); } } finally { readWriteLock.writeLock().unlock(); } return true; }