DeferredTask deleteRecordsTask = new DeferredTask() {
private static final long serialVersionUID = -7510918963650055768L;
@Override
public void run() {
PipelineService service = PipelineServiceFactory.newPipelineService();
try {
service.deletePipelineRecords(key);
log.info("Deleted pipeline: " + key);
} catch (IllegalStateException e) {
log.info("Failed to delete pipeline: " + key);
HttpServletRequest request = DeferredTaskContext.getCurrentRequest();
if (request != null) {
int attempts = request.getIntHeader("X-AppEngine-TaskExecutionCount");
if (attempts <= 5) {
log.info("Request to retry deferred task #" + attempts);
DeferredTaskContext.markForRetry();
return;
}
}
try {
service.deletePipelineRecords(key, true, false);
log.info("Force deleted pipeline: " + key);
} catch (Exception ex) {
log.log(Level.WARNING, "Failed to force delete pipeline: " + key, ex);
}
} catch (NoSuchObjectException e) {