phet commented on code in PR #3890:
URL: https://github.com/apache/gobblin/pull/3890#discussion_r1525755324


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/ReminderSettingDagProcLeaseArbiter.java:
##########
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.service.modules.orchestration;
+
+import java.io.IOException;
+import java.util.Date;
+
+import org.quartz.Job;
+import org.quartz.JobBuilder;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
+
+import com.typesafe.config.Config;
+
+import javax.inject.Inject;
+import lombok.extern.slf4j.Slf4j;
+
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.runtime.api.DagActionStore;
+import org.apache.gobblin.runtime.api.MultiActiveLeaseArbiter;
+
+
+/**
+ * Decorator used to coordinate multiple hosts with execution components 
enabled to respond to flow action events with
+ * added capabilities to properly handle the result of attempted ownership 
over these flow action events. It uses the
+ * {@link MultiActiveLeaseArbiter} to determine a single lease owner at a 
given event time for a flow action event.
+ * After acquiring the lease, the host can pursue executing the action. Once 
it has completed this action, it
+ * marks the lease as completed by calling the
+ * {@link 
MultiActiveLeaseArbiter#recordLeaseSuccess(MultiActiveLeaseArbiter.LeaseObtainedStatus)}
 method. Hosts
+ * that fail to acquire a lease will use the {@link 
DagActionReminderScheduler} to set a reminder for the flow action
+ * event to check back in on the previous lease owner's completion status.
+ */
+@Slf4j
+public class ReminderSettingDagProcLeaseArbiter implements 
MultiActiveLeaseArbiter {
+  private final MultiActiveLeaseArbiter decoratedLeaseArbiter;
+  private final DagActionReminderScheduler _dagActionReminderScheduler;
+  private final Config config;
+
+  @Inject
+  public ReminderSettingDagProcLeaseArbiter(Config config, 
MultiActiveLeaseArbiter leaseArbiter, DagActionReminderScheduler 
dagActionReminderScheduler) throws IOException {
+    this.decoratedLeaseArbiter = leaseArbiter;
+    this._dagActionReminderScheduler = dagActionReminderScheduler;
+    this.config = config;
+  }
+
+  /**
+   * This method is used by the multi-active scheduler and multi-active 
execution classes (DagTaskStream) to attempt a
+   * lease for a particular job event and return the status of the attempt.
+   * @param flowAction
+   * @param eventTimeMillis
+   * @param isReminderEvent
+   * @param skipFlowExecutionIdReplacement
+   * @return
+   */
+  @Override
+  public MultiActiveLeaseArbiter.LeaseAttemptStatus 
tryAcquireLease(DagActionStore.DagAction flowAction, long eventTimeMillis,
+      boolean isReminderEvent, boolean skipFlowExecutionIdReplacement) {
+    try {
+      MultiActiveLeaseArbiter.LeaseAttemptStatus leaseAttemptStatus = 
this.tryAcquireLease(flowAction, eventTimeMillis, isReminderEvent, 
skipFlowExecutionIdReplacement);
+      /* Schedule a reminder for the event unless the lease has been completed 
to safeguard against case lease owner

Review Comment:
   to be more specific, I believe you mean:
   "to safeguard against the case where even we, when we might become the lease 
owner still fail to complete processing"



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to