public ReadAfterWriteConsistentFeatureTransferManager(TransferManager originalTransferManager, TransferManager underlyingTransferManager, Config config, ReadAfterWriteConsistent readAfterWriteConsistentAnnotation) { this.underlyingTransferManager = underlyingTransferManager; this.throttler = new Throttler(readAfterWriteConsistentAnnotation.maxRetries(), readAfterWriteConsistentAnnotation.maxWaitTime()); this.readAfterWriteConsistentFeatureExtension = getReadAfterWriteConsistentFeatureExtension(originalTransferManager, readAfterWriteConsistentAnnotation); }
public RetriableFeatureTransferManager(TransferManager originalTransferManager, TransferManager underlyingTransferManager, Config config, Retriable retriableAnnotation) { this.underlyingTransferManager = underlyingTransferManager; this.retryMaxCount = retriableAnnotation.numberRetries(); this.retrySleepMillis = retriableAnnotation.sleepInterval(); this.tryCount = 0; }
@Override public void disconnect() throws StorageException { retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { underlyingTransferManager.disconnect(); return null; } }); }
public PathAwareFeatureTransferManager(TransferManager originalTransferManager, TransferManager underlyingTransferManager, Config config, PathAware pathAwareAnnotation) { this.underlyingTransferManager = underlyingTransferManager; this.subfolderDepth = pathAwareAnnotation.subfolderDepth(); this.bytesPerFolder = pathAwareAnnotation.bytesPerFolder(); this.folderSeparator = pathAwareAnnotation.folderSeparator(); this.affectedFiles = ImmutableList.copyOf(pathAwareAnnotation.affected()); this.pathAwareFeatureExtension = getPathAwareFeatureExtension(originalTransferManager, pathAwareAnnotation); }
private RemoteFile createPathAwareRemoteFile(RemoteFile remoteFile) throws StorageException { PathAwareRemoteFileAttributes pathAwareRemoteFileAttributes = new PathAwareRemoteFileAttributes(); remoteFile.setAttributes(pathAwareRemoteFileAttributes); if (isFolderizable(remoteFile.getClass())) { // If remote file is folderizable, i.e. an 'affected file', // get the sub-path for it String subPathId = getSubPathId(remoteFile); String subPath = getSubPath(subPathId); pathAwareRemoteFileAttributes.setPath(subPath); } return remoteFile; }
@Override public <T extends RemoteFile> Map<String, T> list(final Class<T> remoteFileClass) throws StorageException { Map<String, T> filesInFolder = Maps.newHashMap(); String remoteFilePath = getRemoteFilePath(remoteFileClass); list(remoteFilePath, filesInFolder, remoteFileClass); return filesInFolder; }
private Map<String, CleanupRemoteFile> getRemoteCleanupFiles() throws StorageException { return transferManager.list(CleanupRemoteFile.class); }
private void disconnectTransferManager() { try { transferManager.disconnect(); } catch (StorageException e) { logger.log(Level.FINE, "Could not disconnect the transfermanager", e); } }
@Override public void move(final RemoteFile sourceFile, final RemoteFile targetFile) throws StorageException { underlyingTransferManager.move(sourceFile, targetFile); waitForFile(targetFile); }
@Override public void upload(final File localFile, final RemoteFile remoteFile) throws StorageException { retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { underlyingTransferManager.upload(localFile, remoteFile); return null; } }); }
@Override public void download(final RemoteFile remoteFile, final File localFile) throws StorageException { retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { underlyingTransferManager.download(remoteFile, localFile); return null; } }); }
@Override public void move(final RemoteFile sourceFile, final RemoteFile targetFile) throws StorageException { retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { underlyingTransferManager.move(sourceFile, targetFile); return null; } }); }
@Override public boolean testTargetCanWrite() throws StorageException { return (Boolean) retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { return underlyingTransferManager.testTargetCanWrite(); } }); }
@Override public void connect() throws StorageException { retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { underlyingTransferManager.connect(); return null; } }); }
@Override public boolean delete(final RemoteFile remoteFile) throws StorageException { return (Boolean) retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { return underlyingTransferManager.delete(remoteFile); } }); }
@Override public boolean testTargetExists() throws StorageException { return (Boolean) retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { return underlyingTransferManager.testTargetExists(); } }); }
@Override public void init(final boolean createIfRequired) throws StorageException { retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { underlyingTransferManager.init(createIfRequired); return null; } }); }
@Override @SuppressWarnings("unchecked") public <T extends RemoteFile> Map<String, T> list(final Class<T> remoteFileClass) throws StorageException { return (Map<String, T>) retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { return underlyingTransferManager.list(remoteFileClass); } }); }
@Override public boolean testTargetCanCreate() throws StorageException { return (Boolean) retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { return underlyingTransferManager.testTargetCanCreate(); } }); }
@Override public boolean testRepoFileExists() throws StorageException { return (Boolean) retryMethod(new RetriableMethod() { @Override public Object execute() throws StorageException { return underlyingTransferManager.testRepoFileExists(); } }); }