private JsonBatchCallback < Void > getDeletionCallback ( final StorageResourceId resourceId , final KeySetView < IOException , Boolean > innerExceptions , final BatchHelper batchHelper , final int attempt , final long generation ) { return new JsonBatchCallback < Void > ( ) { @ Override public void onSuccess ( Void obj , HttpHeaders responseHeaders ) { logger . atFine ( ) . log ( "Successfully deleted %s at generation %s" , resourceId , generation ) ; } @ Override public void onFailure ( GoogleJsonError e , HttpHeaders responseHeaders ) throws IOException { if ( errorExtractor . itemNotFound ( e ) ) { // Ignore item-not-found errors. We do not have to delete what we cannot find. This // error typically shows up when we make a request to delete something and the server // receives the request but we get a retry-able error before we get a response. // During a retry, we no longer find the item because the server had deleted // it already. logger . atFine ( ) . log ( "deleteObjects(%s): delete not found:%n%s" , resourceId , e ) ; } else if ( errorExtractor . preconditionNotMet ( e ) && attempt <= MAXIMUM_PRECONDITION_FAILURES_IN_DELETE ) { logger . atInfo ( ) . log ( "Precondition not met while deleting %s at generation %s. Attempt %s. Retrying:%n%s" , resourceId , generation , attempt , e ) ; queueSingleObjectDelete ( resourceId , innerExceptions , batchHelper , attempt + 1 ) ; } else { innerExceptions . add ( new IOException ( String . format ( "Error deleting %s, stage 2 with generation %s:%n%s" , resourceId , generation , e ) ) ) ; } } } ; }
Helper to create a callback for a particular deletion request .