src/main/java/edu/ucla/library/bucketeer/handlers/DeleteJobHandler.java
private void removeJob(final String aJobName, final AsyncMap<String, Job> aJobsMap,
            final Handler<AsyncResult<Job>> aHandler) {
        final Promise<Job> promise = Promise.<Job>promise();

        promise.future().onComplete(aHandler);

        aJobsMap.get(aJobName, getJob -> {
            if (getJob.succeeded()) {
                final Job job = getJob.result();
                final int remaining = job.remaining();

                // Wait and see if the number of remaining items has changed
                myVertx.setTimer(Constants.JOB_DELETE_TIMEOUT, timer -> {
                    if (remaining == job.remaining()) {
                        aJobsMap.remove(aJobName, deleteJob -> {
                            if (deleteJob.succeeded()) {
                                promise.complete(job);
                            } else {
                                promise.fail(LOGGER.getMessage(MessageCodes.BUCKETEER_097));
                            }
                        });
                    } else {
                        promise.fail(LOGGER.getMessage(MessageCodes.BUCKETEER_142, aJobName));
                    }
                });
            } else {
                final Throwable exception = getJob.cause();
                final String message = exception.getMessage();

                LOGGER.error(exception, message);
                promise.fail(message);
            }
        });
    }
/**
     * Remove job but only if it's not still actively processing images.
     *
     * @param aJobName The name of the job to remove
     * @param aJobsMap The map of jobs in which the job is found
     * @param aHandler A handler for the result of the removal
     */
Remove job but only if it's not still actively processing images.
@param aJobName The name of the job to remove
@param aJobsMap The map of jobs in which the job is found
@param aHandler A handler for the result of the removal
Remove job but only if it ' s not still actively processing images . @param aJobName The name of the job to remove @param aJobsMap The map of jobs in which the job is found @param aHandler A handler for the result of the removal
private void removeJob(final String aJobName, final AsyncMap<String, Job> aJobsMap,
            final Handler<AsyncResult<Job>> aHandler) {
        final Promise<Job> promise = Promise.<Job>promise();
        promise.future().onComplete(aHandler);
        aJobsMap.get(aJobName, getJob -> {
            if (getJob.succeeded()) {
                final Job job = getJob.result();
                final int remaining = job.remaining();
                myVertx.setTimer(Constants.JOB_DELETE_TIMEOUT, timer -> {
                    if (remaining == job.remaining()) {
                        aJobsMap.remove(aJobName, deleteJob -> {
                            if (deleteJob.succeeded()) {
                                promise.complete(job);
                            } else {
                                promise.fail(LOGGER.getMessage(MessageCodes.BUCKETEER_097));
                            }
                        });
                    } else {
                        promise.fail(LOGGER.getMessage(MessageCodes.BUCKETEER_142, aJobName));
                    }
                });
            } else {
                final Throwable exception = getJob.cause();
                final String message = exception.getMessage();
                LOGGER.error(exception, message);
                promise.fail(message);
            }
        });
    }
private void removeJob ( final String aJobName , final AsyncMap < String , Job > aJobsMap , final Handler < AsyncResult < Job > > aHandler ) { final Promise < Job > promise = Promise . < Job > promise ( ) ; promise . future ( ) . onComplete ( aHandler ) ; aJobsMap . get ( aJobName , getJob -> { if ( getJob . succeeded ( ) ) { final Job job = getJob . result ( ) ; final int remaining = job . remaining ( ) ; myVertx . setTimer ( Constants . JOB_DELETE_TIMEOUT , timer -> { if ( remaining == job . remaining ( ) ) { aJobsMap . remove ( aJobName , deleteJob -> { if ( deleteJob . succeeded ( ) ) { promise . complete ( job ) ; } else { promise . fail ( LOGGER . getMessage ( MessageCodes . BUCKETEER_097 ) ) ; } } ) ; } else { promise . fail ( LOGGER . getMessage ( MessageCodes . BUCKETEER_142 , aJobName ) ) ; } } ) ; } else { final Throwable exception = getJob . cause ( ) ; final String message = exception . getMessage ( ) ; LOGGER . error ( exception , message ) ; promise . fail ( message ) ; } } ) ; }
Remove job but only if it's not still actively processing images.
Remove job but only if it ' s not still actively processing images .
// Wait and see if the number of remaining items has changed