Skip to content

Commit

Permalink
Merge pull request #3929 from gchq/3866-missing-descriptions
Browse files Browse the repository at this point in the history
Issue 3866 - Add missing descriptions
  • Loading branch information
patchwork01 authored Dec 13, 2024
2 parents b46ccf1 + d173e3e commit 67aae9e
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public GarbageCollectorStack(
Rule rule = Rule.Builder
.create(this, "GarbageCollectorPeriodicTrigger")
.ruleName(SleeperScheduleRule.GARBAGE_COLLECTOR.buildRuleName(instanceProperties))
.description("A rule to periodically trigger the garbage collector")
.description(SleeperScheduleRule.GARBAGE_COLLECTOR.getDescription())
.enabled(!shouldDeployPaused(this))
.schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(GARBAGE_COLLECTOR_PERIOD_IN_MINUTES))))
.targets(List.of(new LambdaFunction(triggerFunction)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void createTriggerFunction(InstanceProperties instanceProperties, Lambda
Rule rule = Rule.Builder
.create(this, "FindPartitionsToSplitPeriodicTrigger")
.ruleName(SleeperScheduleRule.PARTITION_SPLITTING.buildRuleName(instanceProperties))
.description("A rule to periodically trigger the lambda to look for partitions to split")
.description(SleeperScheduleRule.PARTITION_SPLITTING.getDescription())
.enabled(!shouldDeployPaused(this))
.schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(PARTITION_SPLITTING_TRIGGER_PERIOD_IN_MINUTES))))
.targets(List.of(new LambdaFunction(triggerFunction)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public TableMetricsStack(

Rule rule = Rule.Builder.create(this, "MetricsPublishSchedule")
.ruleName(SleeperScheduleRule.TABLE_METRICS.buildRuleName(instanceProperties))
.description(SleeperScheduleRule.TABLE_METRICS.getDescription())
.schedule(Schedule.rate(Duration.minutes(1)))
.targets(Collections.singletonList(new LambdaFunction(tableMetricsTrigger)))
.enabled(!shouldDeployPaused(this))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private IFunction lambdaToCreateCompactionJobBatches(
Rule rule = Rule.Builder
.create(stack, "CompactionJobCreationPeriodicTrigger")
.ruleName(SleeperScheduleRule.COMPACTION_JOB_CREATION.buildRuleName(instanceProperties))
.description("A rule to periodically trigger the compaction job creation lambda")
.description(SleeperScheduleRule.COMPACTION_JOB_CREATION.getDescription())
.enabled(!shouldDeployPaused(stack))
.schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(COMPACTION_JOB_CREATION_LAMBDA_PERIOD_IN_MINUTES))))
.targets(List.of(new LambdaFunction(triggerFunction)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void lambdaToCreateCompactionTasks(
Rule rule = Rule.Builder
.create(stack, "CompactionTasksCreationPeriodicTrigger")
.ruleName(SleeperScheduleRule.COMPACTION_TASK_CREATION.buildRuleName(instanceProperties))
.description("A rule to periodically trigger the compaction task creation lambda")
.description(SleeperScheduleRule.COMPACTION_TASK_CREATION.getDescription())
.enabled(!shouldDeployPaused(stack))
.schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(COMPACTION_TASK_CREATION_PERIOD_IN_MINUTES))))
.targets(Collections.singletonList(new LambdaFunction(handler)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private void createSnapshotCreationLambda(InstanceProperties instanceProperties,

Rule rule = Rule.Builder.create(this, "TransactionLogSnapshotCreationSchedule")
.ruleName(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_CREATION.buildRuleName(instanceProperties))
.description(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_CREATION.getDescription())
.schedule(Schedule.rate(Duration.seconds(
instanceProperties.getInt(SNAPSHOT_CREATION_LAMBDA_PERIOD_IN_SECONDS))))
.targets(List.of(new LambdaFunction(snapshotCreationTrigger)))
Expand Down Expand Up @@ -171,6 +172,7 @@ private void createSnapshotDeletionLambda(InstanceProperties instanceProperties,

Rule rule = Rule.Builder.create(this, "TransactionLogSnapshotDeletionSchedule")
.ruleName(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_DELETION.buildRuleName(instanceProperties))
.description(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_DELETION.getDescription())
.schedule(Schedule.rate(Duration.minutes(
instanceProperties.getLong(SNAPSHOT_DELETION_LAMBDA_PERIOD_IN_MINUTES))))
.targets(List.of(new LambdaFunction(snapshotDeletionTrigger)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private void createTransactionDeletionLambda(InstanceProperties instanceProperti

Rule rule = Rule.Builder.create(this, "TransactionLogTransactionDeletionSchedule")
.ruleName(SleeperScheduleRule.TRANSACTION_LOG_TRANSACTION_DELETION.buildRuleName(instanceProperties))
.description(SleeperScheduleRule.TRANSACTION_LOG_TRANSACTION_DELETION.getDescription())
.schedule(Schedule.rate(Duration.minutes(
instanceProperties.getLong(TRANSACTION_DELETION_LAMBDA_PERIOD_IN_MINUTES))))
.targets(List.of(new LambdaFunction(transactionDeletionTrigger)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public IngestBatcherStack(
Rule rule = Rule.Builder
.create(this, "IngestBatcherJobCreationPeriodicTrigger")
.ruleName(SleeperScheduleRule.INGEST_BATCHER_JOB_CREATION.buildRuleName(instanceProperties))
.description("A rule to periodically trigger the ingest batcher job creation lambda")
.description(SleeperScheduleRule.INGEST_BATCHER_JOB_CREATION.getDescription())
.enabled(!shouldDeployPaused(this))
.schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(INGEST_BATCHER_JOB_CREATION_LAMBDA_PERIOD_IN_MINUTES))))
.targets(Collections.singletonList(new LambdaFunction(jobCreatorLambda)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private void lambdaToCreateIngestTasks(CoreStacks coreStacks, Queue ingestJobQue
Rule rule = Rule.Builder
.create(this, "IngestTasksCreationPeriodicTrigger")
.ruleName(SleeperScheduleRule.INGEST.buildRuleName(instanceProperties))
.description("A rule to periodically trigger the ingest tasks lambda")
.description(SleeperScheduleRule.INGEST.getDescription())
.enabled(!shouldDeployPaused(this))
.schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(INGEST_TASK_CREATION_PERIOD_IN_MINUTES))))
.targets(Collections.singletonList(new LambdaFunction(handler)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public KeepLambdaWarmStack(Construct scope,
Rule rule = Rule.Builder
.create(this, "QueryExecutionPeriodicTrigger")
.ruleName(SleeperScheduleRule.QUERY_WARM_LAMBDA.buildRuleName(instanceProperties))
.description("A rule to periodically trigger the query execution lambda")
.description(SleeperScheduleRule.QUERY_WARM_LAMBDA.getDescription())
.enabled(!shouldDeployPaused(this))
.schedule(Schedule.rate(Duration.minutes(instanceProperties
.getInt(QUERY_WARM_LAMBDA_EXECUTION_PERIOD_IN_MINUTES))))
Expand Down
1 change: 1 addition & 0 deletions java/cdk/src/main/java/sleeper/cdk/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public static String normaliseSize(String size) {
public static void createAlarmForDlq(Construct scope, String id, String description, Queue dlq, Topic topic) {
Alarm alarm = Alarm.Builder
.create(scope, id)
.alarmName(dlq.getQueueName())
.alarmDescription(description)
.metric(dlq.metricApproximateNumberOfMessagesVisible()
.with(MetricOptions.builder().statistic("Sum").period(Duration.seconds(60)).build()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,50 +44,53 @@
public class SleeperScheduleRule {

private static final List<SleeperScheduleRule> RULES = new ArrayList<>();
// Rule that creates compaction jobs
public static final SleeperScheduleRule COMPACTION_JOB_CREATION = add(
COMPACTION_JOB_CREATION_CLOUDWATCH_RULE, "%s-CompactionJobCreationRule");
// Rule that creates compaction tasks
COMPACTION_JOB_CREATION_CLOUDWATCH_RULE, "%s-CompactionJobCreationRule",
"Triggers creation of compaction jobs for online Sleeper tables");
public static final SleeperScheduleRule COMPACTION_TASK_CREATION = add(
COMPACTION_TASK_CREATION_CLOUDWATCH_RULE, "%s-CompactionTasksCreationRule");
// Rule that looks for partitions that need splitting
COMPACTION_TASK_CREATION_CLOUDWATCH_RULE, "%s-CompactionTasksCreationRule",
"Triggers scaling compaction tasks to run created jobs");
public static final SleeperScheduleRule PARTITION_SPLITTING = add(
PARTITION_SPLITTING_CLOUDWATCH_RULE, "%s-FindPartitionsToSplitPeriodicTrigger");
// Rule that triggers garbage collector lambda
PARTITION_SPLITTING_CLOUDWATCH_RULE, "%s-FindPartitionsToSplitPeriodicTrigger",
"Triggers looking for partitions to split in online Sleeper tables");
public static final SleeperScheduleRule GARBAGE_COLLECTOR = add(
GARBAGE_COLLECTOR_CLOUDWATCH_RULE, "%s-GarbageCollectorPeriodicTrigger");
// Rule that triggers creation of ingest tasks
GARBAGE_COLLECTOR_CLOUDWATCH_RULE, "%s-GarbageCollectorPeriodicTrigger",
"Triggers garbage collection to delete unused files");
public static final SleeperScheduleRule INGEST = add(
INGEST_CLOUDWATCH_RULE, "%s-IngestTasksCreationRule");
// Rule that batches up ingest jobs from file ingest requests
INGEST_CLOUDWATCH_RULE, "%s-IngestTasksCreationRule",
"Triggers scaling ingest tasks to run queued jobs");
public static final SleeperScheduleRule INGEST_BATCHER_JOB_CREATION = add(
INGEST_BATCHER_JOB_CREATION_CLOUDWATCH_RULE, "%s-IngestBatcherJobCreationRule");
public static final SleeperScheduleRule TABLE_METRICS = add(TABLE_METRICS_RULE, "%s-MetricsPublishRule");
// Rule that triggers the query lambdas to keep warm
INGEST_BATCHER_JOB_CREATION_CLOUDWATCH_RULE, "%s-IngestBatcherJobCreationRule",
"Triggers creation of jobs from files submitted to the ingest batcher");
public static final SleeperScheduleRule TABLE_METRICS = add(TABLE_METRICS_RULE, "%s-MetricsPublishRule",
"Triggers publishing metrics based on the current state of Sleeper tables");
public static final SleeperScheduleRule QUERY_WARM_LAMBDA = add(
QUERY_WARM_LAMBDA_CLOUDWATCH_RULE, "%s-QueryWarmLambdaRule");
// Rule that triggers transaction log snapshot creation
QUERY_WARM_LAMBDA_CLOUDWATCH_RULE, "%s-QueryWarmLambdaRule",
"Triggers query requests to prevent the system scaling to zero");
public static final SleeperScheduleRule TRANSACTION_LOG_SNAPSHOT_CREATION = add(
TRANSACTION_LOG_SNAPSHOT_CREATION_RULE, "%s-TransactionLogSnapshotCreationRule");
// Rule that triggers deletion of old transaction log snapshots
TRANSACTION_LOG_SNAPSHOT_CREATION_RULE, "%s-TransactionLogSnapshotCreationRule",
"Triggers creation of snapshots of the current state of online Sleeper tables based on a transaction log");
public static final SleeperScheduleRule TRANSACTION_LOG_SNAPSHOT_DELETION = add(
TRANSACTION_LOG_SNAPSHOT_DELETION_RULE, "%s-TransactionLogSnapshotDeletionRule");
// Rule that triggers deletion of old transaction log transactions
TRANSACTION_LOG_SNAPSHOT_DELETION_RULE, "%s-TransactionLogSnapshotDeletionRule",
"Triggers deletion of old snapshots of online Sleeper tables based on a transaction log");
public static final SleeperScheduleRule TRANSACTION_LOG_TRANSACTION_DELETION = add(
TRANSACTION_LOG_TRANSACTION_DELETION_RULE, "%s-TransactionLogTransactionDeletionRule");
TRANSACTION_LOG_TRANSACTION_DELETION_RULE, "%s-TransactionLogTransactionDeletionRule",
"Triggers deletion of old transactions from the active transaction logs of online Sleeper tables");

private final InstanceProperty property;
private final String nameFormat;
private final String description;

private static SleeperScheduleRule add(InstanceProperty property, String nameFormat) {
SleeperScheduleRule rule = new SleeperScheduleRule(property, nameFormat);
private static SleeperScheduleRule add(InstanceProperty property, String nameFormat, String description) {
SleeperScheduleRule rule = new SleeperScheduleRule(property, nameFormat, description);
RULES.add(rule);
return rule;
}

private SleeperScheduleRule(InstanceProperty property, String nameFormat) {
private SleeperScheduleRule(InstanceProperty property, String nameFormat, String description) {
this.property = requireNonNull(property, "property must not be null");
this.nameFormat = requireNonNull(nameFormat, "nameFormat must not be null");
this.description = requireNonNull(description, "description must not be null");
}

/**
Expand Down Expand Up @@ -171,6 +174,10 @@ public InstanceProperty getProperty() {
return property;
}

public String getDescription() {
return description;
}

/**
* A wrapper for the instance property value for this CloudWatch rule.
*/
Expand Down

0 comments on commit 67aae9e

Please sign in to comment.