-
Notifications
You must be signed in to change notification settings - Fork 749
[GOBBLIN-1837] Implement multi-active, non blocking for leader host #3700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b6b135b
basic outline of changes to make, started SchedulerLeaseDetermination…
ffed36c
multiple query options for store
0b4ebd8
add launch type as column
57962e3
wip for scheduler abstractions
1ecab1d
non blocking algo impl, dag action store updates
75b446f
DagActionMonitor changes to handle LAUNCH events
888b8d1
clean up comments, add docstrings
9fb1d55
redefined lease arbiter & algo handler to separate scheduler specific…
57a3326
Address second round of review comments
8e434cb
Cleanup in response to review, fix failing test
b6b78a5
small clean ups
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/MultiActiveLeaseArbiter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /* | ||
| * 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.runtime.api; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
|
|
||
| /** | ||
|
umustafi marked this conversation as resolved.
|
||
| * This interface defines a generic approach to a non-blocking, multiple active thread or host system, in which one or | ||
| * more active participants compete to take responsiblity for a particular flow's event. The type of flow event in | ||
| * question does not impact the algorithm other than to uniquely identify the flow event. Each participant uses the | ||
| * interface to initiate an attempt at ownership over the flow event and receives a response indicating the status of | ||
| * the attempt. | ||
| * | ||
| * At a high level the lease arbiter works as follows: | ||
| * 1. Multiple participants independently learn of a flow action event to act upon | ||
| * 2. Each participant attempts to acquire rights or `a lease` to be the sole participant acting on the event by | ||
| * calling the tryAcquireLease method below and receives the resulting status. The status indicates whether this | ||
| * participant has | ||
| * a) LeaseObtainedStatus -> this participant will attempt to carry out the required action before the lease expires | ||
| * b) LeasedToAnotherStatus -> another will attempt to carry out the required action before the lease expires | ||
| * c) NoLongerLeasingStatus -> flow event no longer needs to be acted upon (terminal state) | ||
| * 3. If another participant has acquired the lease before this one could, then the present participant must check back | ||
| * in at the time of lease expiry to see if it needs to attempt the lease again [status (b) above]. | ||
| * 4. Once the participant which acquired the lease completes its work on the flow event, it calls recordLeaseSuccess | ||
| * to indicate to all other participants that the flow event no longer needs to be acted upon [status (c) above] | ||
| */ | ||
| public interface MultiActiveLeaseArbiter { | ||
| /** | ||
| * This method attempts to insert an entry into store for a particular flow action event if one does not already | ||
| * exist in the store for the flow action or has expired. Regardless of the outcome it also reads the lease | ||
| * acquisition timestamp of the entry for that flow action event (it could have pre-existed in the table or been newly | ||
| * added by the previous write). Based on the transaction results, it will return {@link LeaseAttemptStatus} to | ||
| * determine the next action. | ||
| * @param flowAction uniquely identifies the flow and the present action upon it | ||
| * @param eventTimeMillis is the time this flow action was triggered | ||
| * @return LeaseAttemptStatus | ||
| * @throws IOException | ||
| */ | ||
| LeaseAttemptStatus tryAcquireLease(DagActionStore.DagAction flowAction, long eventTimeMillis) throws IOException; | ||
|
|
||
| /** | ||
| * This method is used to indicate the owner of the lease has successfully completed required actions while holding | ||
| * the lease of the flow action event. It marks the lease as "no longer leasing", if the eventTimeMillis and | ||
| * leaseAcquisitionTimeMillis values have not changed since this owner acquired the lease (indicating the lease did | ||
| * not expire). | ||
| * @return true if successfully updated, indicating no further actions need to be taken regarding this event. | ||
|
umustafi marked this conversation as resolved.
|
||
| * false if failed to update the lease properly, the caller should continue seeking to acquire the lease as | ||
| * if any actions it did successfully accomplish, do not count | ||
| */ | ||
| boolean recordLeaseSuccess(LeaseObtainedStatus status) throws IOException; | ||
|
|
||
| /* | ||
| Class used to encapsulate status of lease acquisition attempt and derivations should contain information specific to | ||
| the status that results. | ||
| */ | ||
| abstract class LeaseAttemptStatus {} | ||
|
|
||
| class NoLongerLeasingStatus extends LeaseAttemptStatus {} | ||
|
|
||
| /* | ||
| The participant calling this method acquired the lease for the event in question. The class contains the | ||
| `eventTimestamp` associated with the lease as well as the time the caller obtained the lease or | ||
| `leaseAcquisitionTimestamp`. | ||
| */ | ||
| @Data | ||
| class LeaseObtainedStatus extends LeaseAttemptStatus { | ||
| private final DagActionStore.DagAction flowAction; | ||
| private final long eventTimestamp; | ||
| private final long leaseAcquisitionTimestamp; | ||
| } | ||
|
|
||
| /* | ||
| This flow action event already has a valid lease owned by another participant. | ||
| `eventTimeMillis` is the timestamp the lease is associated with, which may be a different timestamp for the same flow | ||
| action corresponding to the same instance of the event or a distinct one. | ||
| `minimumLingerDurationMillis` is the minimum amount of time to wait before this participant should return to check if | ||
| the lease has completed or expired | ||
| */ | ||
| @Data | ||
| class LeasedToAnotherStatus extends LeaseAttemptStatus { | ||
| private final DagActionStore.DagAction flowAction; | ||
| private final long eventTimeMillis; | ||
| private final long minimumLingerDurationMillis; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.