@Test public void testPopulateJobs() throws Exception { ObjectStorageSchedulerManager.start(); boolean foundObjReaper = false; boolean foundBktReaper = false; boolean foundLifecycleProcessor = false; List<ScheduledJob> results = null; ScheduledJob example = new ScheduledJob(); try (TransactionResource tran = Entities.transactionFor(ScheduledJob.class)) { results = Entities.query(example); tran.commit(); } for (ScheduledJob job : results) { if (!foundBktReaper) { if (job.getJobClassName().equals(ObjectStorageSchedulerManager.BUCKET_REAPER_CLASSNAME)) { foundBktReaper = true; } } if (!foundObjReaper) { if (job.getJobClassName().equals(ObjectStorageSchedulerManager.OBJECT_REAPER_CLASSNAME)) { foundObjReaper = true; } } if (!foundLifecycleProcessor) { if (job.getJobClassName().equals(ObjectStorageSchedulerManager.LIFECYCLE_CLEANUP_CLASSNAME)) { foundLifecycleProcessor = true; } } } assertTrue("expected to find bucket reaper", foundBktReaper); assertTrue("expected to find object reaper", foundObjReaper); assertTrue("expected to find lifecycle processor", foundLifecycleProcessor); ObjectStorageSchedulerManager.dumpInfo(); ObjectStorageSchedulerManager.stop(); }
private static void populateJobs() { boolean foundLifecycleCleanup = false; boolean foundDeletedObjectReaper = false; boolean foundDeletedBucketReaper = false; List<ScheduledJob> jobs = null; try (TransactionResource tran = Entities.transactionFor(ScheduledJob.class)) { jobs = Entities.query(new ScheduledJob()); tran.commit(); } catch (Exception ex) { LOG.error("exception encountered while populating ObjectStorageGateway scheduled jobs from database - " + ex.getMessage()); } int jobIdx = 1; if (jobs != null && jobs.size() > 0) { for (ScheduledJob job : jobs) { scheduleJobInQuartz(job.getJobClassName(), job.getJobSchedule(), jobIdx); jobIdx++; if (!foundLifecycleCleanup) { foundLifecycleCleanup = checkForLifecycleCleanupJob(job.getJobClassName()); } if (!foundDeletedObjectReaper) { foundDeletedObjectReaper = checkForDeletedObjectReaperJob(job.getJobClassName()); } if (!foundDeletedBucketReaper) { foundDeletedBucketReaper = checkForDeletedBucketReaperJob(job.getJobClassName()); } } } else { LOG.debug("jobs were either not found in the database, or an exception occurred while querying " + "for scheduled jobs"); } if (!foundDeletedObjectReaper) { saveJobToDb(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of objects that have been deleted in the object storage gateway"); scheduleJobInQuartz(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundDeletedBucketReaper) { saveJobToDb(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of buckets that have been deleted in the object storage gateway"); scheduleJobInQuartz(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundLifecycleCleanup) { saveJobToDb(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, "processes bucket lifecycle rules"); scheduleJobInQuartz(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } }
ObjectStorageSchedulerManager { private static void populateJobs() { boolean foundLifecycleCleanup = false; boolean foundDeletedObjectReaper = false; boolean foundDeletedBucketReaper = false; List<ScheduledJob> jobs = null; try (TransactionResource tran = Entities.transactionFor(ScheduledJob.class)) { jobs = Entities.query(new ScheduledJob()); tran.commit(); } catch (Exception ex) { LOG.error("exception encountered while populating ObjectStorageGateway scheduled jobs from database - " + ex.getMessage()); } int jobIdx = 1; if (jobs != null && jobs.size() > 0) { for (ScheduledJob job : jobs) { scheduleJobInQuartz(job.getJobClassName(), job.getJobSchedule(), jobIdx); jobIdx++; if (!foundLifecycleCleanup) { foundLifecycleCleanup = checkForLifecycleCleanupJob(job.getJobClassName()); } if (!foundDeletedObjectReaper) { foundDeletedObjectReaper = checkForDeletedObjectReaperJob(job.getJobClassName()); } if (!foundDeletedBucketReaper) { foundDeletedBucketReaper = checkForDeletedBucketReaperJob(job.getJobClassName()); } } } else { LOG.debug("jobs were either not found in the database, or an exception occurred while querying " + "for scheduled jobs"); } if (!foundDeletedObjectReaper) { saveJobToDb(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of objects that have been deleted in the object storage gateway"); scheduleJobInQuartz(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundDeletedBucketReaper) { saveJobToDb(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of buckets that have been deleted in the object storage gateway"); scheduleJobInQuartz(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundLifecycleCleanup) { saveJobToDb(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, "processes bucket lifecycle rules"); scheduleJobInQuartz(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } } }
ObjectStorageSchedulerManager { private static void populateJobs() { boolean foundLifecycleCleanup = false; boolean foundDeletedObjectReaper = false; boolean foundDeletedBucketReaper = false; List<ScheduledJob> jobs = null; try (TransactionResource tran = Entities.transactionFor(ScheduledJob.class)) { jobs = Entities.query(new ScheduledJob()); tran.commit(); } catch (Exception ex) { LOG.error("exception encountered while populating ObjectStorageGateway scheduled jobs from database - " + ex.getMessage()); } int jobIdx = 1; if (jobs != null && jobs.size() > 0) { for (ScheduledJob job : jobs) { scheduleJobInQuartz(job.getJobClassName(), job.getJobSchedule(), jobIdx); jobIdx++; if (!foundLifecycleCleanup) { foundLifecycleCleanup = checkForLifecycleCleanupJob(job.getJobClassName()); } if (!foundDeletedObjectReaper) { foundDeletedObjectReaper = checkForDeletedObjectReaperJob(job.getJobClassName()); } if (!foundDeletedBucketReaper) { foundDeletedBucketReaper = checkForDeletedBucketReaperJob(job.getJobClassName()); } } } else { LOG.debug("jobs were either not found in the database, or an exception occurred while querying " + "for scheduled jobs"); } if (!foundDeletedObjectReaper) { saveJobToDb(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of objects that have been deleted in the object storage gateway"); scheduleJobInQuartz(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundDeletedBucketReaper) { saveJobToDb(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of buckets that have been deleted in the object storage gateway"); scheduleJobInQuartz(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundLifecycleCleanup) { saveJobToDb(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, "processes bucket lifecycle rules"); scheduleJobInQuartz(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } }  }
ObjectStorageSchedulerManager { private static void populateJobs() { boolean foundLifecycleCleanup = false; boolean foundDeletedObjectReaper = false; boolean foundDeletedBucketReaper = false; List<ScheduledJob> jobs = null; try (TransactionResource tran = Entities.transactionFor(ScheduledJob.class)) { jobs = Entities.query(new ScheduledJob()); tran.commit(); } catch (Exception ex) { LOG.error("exception encountered while populating ObjectStorageGateway scheduled jobs from database - " + ex.getMessage()); } int jobIdx = 1; if (jobs != null && jobs.size() > 0) { for (ScheduledJob job : jobs) { scheduleJobInQuartz(job.getJobClassName(), job.getJobSchedule(), jobIdx); jobIdx++; if (!foundLifecycleCleanup) { foundLifecycleCleanup = checkForLifecycleCleanupJob(job.getJobClassName()); } if (!foundDeletedObjectReaper) { foundDeletedObjectReaper = checkForDeletedObjectReaperJob(job.getJobClassName()); } if (!foundDeletedBucketReaper) { foundDeletedBucketReaper = checkForDeletedBucketReaperJob(job.getJobClassName()); } } } else { LOG.debug("jobs were either not found in the database, or an exception occurred while querying " + "for scheduled jobs"); } if (!foundDeletedObjectReaper) { saveJobToDb(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of objects that have been deleted in the object storage gateway"); scheduleJobInQuartz(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundDeletedBucketReaper) { saveJobToDb(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of buckets that have been deleted in the object storage gateway"); scheduleJobInQuartz(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundLifecycleCleanup) { saveJobToDb(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, "processes bucket lifecycle rules"); scheduleJobInQuartz(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } }  static void start(); static void stop(); static String dumpInfo(); }
ObjectStorageSchedulerManager { private static void populateJobs() { boolean foundLifecycleCleanup = false; boolean foundDeletedObjectReaper = false; boolean foundDeletedBucketReaper = false; List<ScheduledJob> jobs = null; try (TransactionResource tran = Entities.transactionFor(ScheduledJob.class)) { jobs = Entities.query(new ScheduledJob()); tran.commit(); } catch (Exception ex) { LOG.error("exception encountered while populating ObjectStorageGateway scheduled jobs from database - " + ex.getMessage()); } int jobIdx = 1; if (jobs != null && jobs.size() > 0) { for (ScheduledJob job : jobs) { scheduleJobInQuartz(job.getJobClassName(), job.getJobSchedule(), jobIdx); jobIdx++; if (!foundLifecycleCleanup) { foundLifecycleCleanup = checkForLifecycleCleanupJob(job.getJobClassName()); } if (!foundDeletedObjectReaper) { foundDeletedObjectReaper = checkForDeletedObjectReaperJob(job.getJobClassName()); } if (!foundDeletedBucketReaper) { foundDeletedBucketReaper = checkForDeletedBucketReaperJob(job.getJobClassName()); } } } else { LOG.debug("jobs were either not found in the database, or an exception occurred while querying " + "for scheduled jobs"); } if (!foundDeletedObjectReaper) { saveJobToDb(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of objects that have been deleted in the object storage gateway"); scheduleJobInQuartz(OBJECT_REAPER_CLASSNAME, OBJECT_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundDeletedBucketReaper) { saveJobToDb(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, "performs upstream deletes of buckets that have been deleted in the object storage gateway"); scheduleJobInQuartz(BUCKET_REAPER_CLASSNAME, BUCKET_REAPER_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } if (!foundLifecycleCleanup) { saveJobToDb(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, "processes bucket lifecycle rules"); scheduleJobInQuartz(LIFECYCLE_CLEANUP_CLASSNAME, LIFECYCLE_CLEANUP_DEFAULT_SCHEDULE, jobIdx); jobIdx++; } }  static void start(); static void stop(); static String dumpInfo();  }