-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DSIP-73] Add dolphinscheduler-task-executor module to unify the task…
… execution logic
- Loading branch information
1 parent
5e2abd7
commit d3942d4
Showing
240 changed files
with
6,092 additions
and
3,771 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
75 changes: 75 additions & 0 deletions
75
...er-eventbus/src/main/java/org/apache/dolphinscheduler/eventbus/LinearTimeRetryPolicy.java
This file contains 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,75 @@ | ||
/* | ||
* 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.dolphinscheduler.eventbus; | ||
|
||
import java.time.Duration; | ||
|
||
public class LinearTimeRetryPolicy implements IEvent.RetryPolicy { | ||
|
||
private int currentRetryTimes = 0; | ||
|
||
private final long firstRetryTimeStamp = System.currentTimeMillis(); | ||
|
||
private long nextRetryTimeStamp = firstRetryTimeStamp; | ||
|
||
private static final int maxRetryTimes = 180; | ||
|
||
private static final long maxRetryDuration = Duration.ofDays(1).toMillis(); | ||
|
||
private static final long baseRetryInterval = Duration.ofSeconds(10).toMillis(); | ||
|
||
@Override | ||
public boolean isRetryPolicyBroken() { | ||
if (currentRetryTimes > maxRetryTimes) { | ||
return true; | ||
} | ||
if (nextRetryTimeStamp > firstRetryTimeStamp + maxRetryDuration) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void increaseRetryTimes() { | ||
currentRetryTimes++; | ||
setNextRetryTimeStampWithExponentialStep(); | ||
} | ||
|
||
@Override | ||
public void setNextRetryTimeStampWithFixedStep() { | ||
nextRetryTimeStamp += baseRetryInterval; | ||
} | ||
|
||
@Override | ||
public void setNextRetryTimeStampWithExponentialStep() { | ||
nextRetryTimeStamp += baseRetryInterval * currentRetryTimes; | ||
} | ||
|
||
@Override | ||
public long getNextRetryTimeStamp() { | ||
return nextRetryTimeStamp; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "LinearTimeRetryPolicy{" + | ||
"firstRetryTimeStamp=" + firstRetryTimeStamp + | ||
", currentRetryTimes=" + currentRetryTimes + | ||
'}'; | ||
} | ||
} |
This file contains 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 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 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
Oops, something went wrong.