@Override public Void repeat(final PasswordCallback callback) { scheduler.execute(new Callable<R>() { @Override public R call() throws Exception { return operate(callback, file); } }); return null; }
private Future<MultipartPart> submit(final Path source, final MultipartUpload multipart, final int partNumber, final long offset, final long length) { if(log.isInfoEnabled()) { log.info(String.format("Submit part %d of %s to queue with offset %d and length %d", partNumber, source, offset, length)); } return pool.execute(new Callable<MultipartPart>() { @Override public MultipartPart call() throws BackgroundException { try { final HttpRange range = HttpRange.byLength(offset, length); final MultipartPart part = session.getClient().multipartUploadPartCopy(multipart, partNumber, containerService.getContainer(source).getName(), containerService.getKey(source), null, null, null, null, range.getStart(), range.getEnd(), source.attributes().getVersionId()); if(log.isInfoEnabled()) { log.info(String.format("Received response %s for part number %d", part, partNumber)); } // Populate part with response data that is accessible via the object's metadata return new MultipartPart(partNumber, null == part.getLastModified() ? new Date(System.currentTimeMillis()) : part.getLastModified(), null == part.getEtag() ? StringUtils.EMPTY : part.getEtag(), part.getSize()); } catch(S3ServiceException e) { throw new S3ExceptionMappingService().map("Cannot copy {0}", e, source); } } }); } }
@Override public boolean open(final Local file, final Application application, final ApplicationQuitCallback callback) { try { final Process process = runtime.exec(String.format("%s %s", application.getIdentifier(), file.getAbsolute())); pool.execute(new Callable<Boolean>() { @Override public Boolean call() { try { process.waitFor(); callback.callback(); return true; } catch(InterruptedException e) { log.warn(String.format("Failure waiting for application %s to exit", process)); return false; } } }); return true; } catch(IOException e) { log.warn(String.format("Failure launching application %s", e.getMessage())); return false; } }
log.info(String.format("Submit part %d of %s to queue with offset %d and length %d", partNumber, file, offset, length)); return pool.execute(new DefaultRetryCallable<B2UploadPartResponse>(new BackgroundExceptionCallable<B2UploadPartResponse>() { @Override public B2UploadPartResponse call() throws BackgroundException {
@Override public <T> Future<T> execute(final Controller controller, final BackgroundActionRegistry registry, final BackgroundAction<T> action) { if(log.isDebugEnabled()) { log.debug(String.format("Run action %s in background", action)); } // Add action to registry of controller. Will be removed automatically when stopped registry.add(action); action.init(); // Start background task final Callable<T> command = new BackgroundCallable<T>(action, controller); try { final Future<T> task = concurrentExecutor.execute(command); if(log.isInfoEnabled()) { log.info(String.format("Scheduled background runnable %s for execution", action)); } return task; } catch(RejectedExecutionException e) { log.error(String.format("Error scheduling background task %s for execution. %s", action, e.getMessage())); action.cancel(); action.cleanup(); return ConcurrentUtils.constantFuture(null); } }
pool.execute(new Callable<Boolean>() { @Override public Boolean call() {
private Future<Path> submit(final ThreadPool pool, final Path bucket, final String common) { return pool.execute(new BackgroundExceptionCallable<Path>() { @Override public Path call() throws BackgroundException {
private Future<StorageObject> submit(final ThreadPool pool, final Path segment, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus overall, final Long offset, final Long length, final ConnectionCallback callback) { return pool.execute(new DefaultRetryCallable<StorageObject>(new BackgroundExceptionCallable<StorageObject>() { @Override public StorageObject call() throws BackgroundException {
log.info(String.format("Submit part %d of %s to queue with offset %d and length %d", partNumber, file, offset, length)); return pool.execute(new DefaultRetryCallable<MultipartPart>(new BackgroundExceptionCallable<MultipartPart>() { @Override public MultipartPart call() throws BackgroundException {
final ThreadPool pool = ThreadPoolFactory.get("checksum", 1); try { final Future execute = pool.execute(new Callable<TransferStatus>() { @Override public TransferStatus call() throws Exception {