diff --git a/opencga-core/src/main/java/org/opencb/opencga/core/config/OperationExecutionConfig.java b/opencga-core/src/main/java/org/opencb/opencga/core/config/OperationExecutionConfig.java index 91274f8980..f5d72d8127 100644 --- a/opencga-core/src/main/java/org/opencb/opencga/core/config/OperationExecutionConfig.java +++ b/opencga-core/src/main/java/org/opencb/opencga/core/config/OperationExecutionConfig.java @@ -20,6 +20,7 @@ public class OperationExecutionConfig { public enum Policy { IMMEDIATE, NIGHTLY, + WEEKLY, NEVER } diff --git a/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/VariantOperationJanitor.java b/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/VariantOperationJanitor.java index 7cdb7981ad..19d50ff6b5 100644 --- a/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/VariantOperationJanitor.java +++ b/opencga-master/src/main/java/org/opencb/opencga/master/monitor/daemons/VariantOperationJanitor.java @@ -29,6 +29,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.time.DayOfWeek; +import java.time.LocalDate; import java.time.LocalTime; import java.util.*; import java.util.stream.Collectors; @@ -101,6 +103,11 @@ private void checkPendingVariantOperations(OperationChore operationChore) return; } + if (!isWeekend() && config.getPolicy() == OperationExecutionConfig.Policy.WEEKLY) { + logger.info("Waiting until weekend to check for pending operation '{}'", toolId); + return; + } + List organizationIds = catalogManager.getOrganizationManager().getOrganizationIds(token); QueryOptions options = new QueryOptions(QueryOptions.INCLUDE, OrganizationDBAdaptor.QueryParams.PROJECTS.key()); for (String organizationId : organizationIds) { @@ -360,6 +367,12 @@ private static boolean isNightTime() { return isNightTime; } + private static boolean isWeekend() { + LocalDate today = LocalDate.now(); + DayOfWeek dayOfWeek = today.getDayOfWeek(); + return dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY; + } + private boolean pendingJobs(String studyIds, String toolId) throws CatalogException { return !noPendingJobs(Collections.singletonList(studyIds), Collections.singletonList(toolId)); }