phet commented on code in PR #3890:
URL: https://github.com/apache/gobblin/pull/3890#discussion_r1522530236
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagProcArbiterDecorator.java:
##########
@@ -0,0 +1,140 @@
+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.JobExecutionException;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
+
+import com.google.common.base.Optional;
+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;
+import org.apache.gobblin.runtime.api.MysqlMultiActiveLeaseArbiter;
+
+
+/**
+ * Decorator used to coordinate multiple hosts with execution components
enabled to respond to 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
MysqlMultiActiveLeaseArbiter#recordLeaseSuccess(MultiActiveLeaseArbiter.LeaseObtainedStatus)}
method. Hosts
+ * that fail to acquire a lease will use the {@link DagProcReminderScheduler}
to set a reminder for the flow action
+ * event to check back in on the previous lease owner's completion status.
+ */
+public class DagProcArbiterDecorator extends InstrumentedLeaseArbiterDecorator
{
+ private final DagProcReminderScheduler dagProcReminderScheduler;
+
+ @Inject
+ public DagProcArbiterDecorator(Config config,
Optional<MultiActiveLeaseArbiter> leaseDeterminationStore,
+ DagProcReminderScheduler dagProcReminderScheduler) throws IOException {
+ super(config, leaseDeterminationStore.get(),
String.valueOf(DagProcArbiterDecorator.class));
+ this.dagProcReminderScheduler = dagProcReminderScheduler;
+ }
+
+ /**
+ * 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);
+ if (leaseAttemptStatus instanceof
MultiActiveLeaseArbiter.LeasedToAnotherStatus) {
+
scheduleReminderForEvent((MultiActiveLeaseArbiter.LeasedToAnotherStatus)
leaseAttemptStatus, eventTimeMillis);
+ return leaseAttemptStatus;
+ }
+ /* Otherwise leaseAttemptStatus instanceof {@link
MultiActiveLeaseArbiter.LeaseObtainedStatus/NoLongerLeasingStatus}
+ and no need to do anything
+ */
+ return leaseAttemptStatus;
Review Comment:
as discussed elsewhere, I believe we ought to set the reminder EXCEPT when
`NoLongerLeasing`.
such would defensively guards against "leaking" the action when this host
obtains the lease, but fails in executing the action
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagProcArbiterDecorator.java:
##########
@@ -0,0 +1,140 @@
+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.JobExecutionException;
+import org.quartz.SchedulerException;
+import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
+
+import com.google.common.base.Optional;
+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;
+import org.apache.gobblin.runtime.api.MysqlMultiActiveLeaseArbiter;
+
+
+/**
+ * Decorator used to coordinate multiple hosts with execution components
enabled to respond to 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
MysqlMultiActiveLeaseArbiter#recordLeaseSuccess(MultiActiveLeaseArbiter.LeaseObtainedStatus)}
method. Hosts
+ * that fail to acquire a lease will use the {@link DagProcReminderScheduler}
to set a reminder for the flow action
+ * event to check back in on the previous lease owner's completion status.
+ */
+public class DagProcArbiterDecorator extends InstrumentedLeaseArbiterDecorator
{
+ private final DagProcReminderScheduler dagProcReminderScheduler;
+
+ @Inject
+ public DagProcArbiterDecorator(Config config,
Optional<MultiActiveLeaseArbiter> leaseDeterminationStore,
+ DagProcReminderScheduler dagProcReminderScheduler) throws IOException {
+ super(config, leaseDeterminationStore.get(),
String.valueOf(DagProcArbiterDecorator.class));
+ this.dagProcReminderScheduler = dagProcReminderScheduler;
+ }
+
+ /**
+ * 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);
+ if (leaseAttemptStatus instanceof
MultiActiveLeaseArbiter.LeasedToAnotherStatus) {
+
scheduleReminderForEvent((MultiActiveLeaseArbiter.LeasedToAnotherStatus)
leaseAttemptStatus, eventTimeMillis);
+ return leaseAttemptStatus;
+ }
+ /* Otherwise leaseAttemptStatus instanceof {@link
MultiActiveLeaseArbiter.LeaseObtainedStatus/NoLongerLeasingStatus}
+ and no need to do anything
+ */
+ return leaseAttemptStatus;
Review Comment:
as discussed elsewhere, I believe we ought to set the reminder EXCEPT when
`NoLongerLeasing`.
such would defensively guard against "leaking" the action when this host
obtains the lease, but fails in executing the action
--
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]