-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 6cc9bf0
- Loading branch information
1 parent
8f0ce83
commit 1d5456b
Showing
20 changed files
with
440 additions
and
3 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
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
39 changes: 39 additions & 0 deletions
39
...r/src/main/java/com/mesosphere/sdk/scheduler/recovery/constrain/AllLaunchConstrainer.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,39 @@ | ||
package com.mesosphere.sdk.scheduler.recovery.constrain; | ||
|
||
import com.mesosphere.sdk.offer.LaunchOfferRecommendation; | ||
import com.mesosphere.sdk.scheduler.recovery.RecoveryType; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* A {@link LaunchConstrainer} combinator that ensures that all the given constrainers are satisfied before launching a | ||
* task. Useful to create policies that need to limit launches to a certain rate, and when it's an off-peak time. | ||
* <p> | ||
* N.B. When determining whether a launch can happen, this object will short-circuit if any of its {@link | ||
* LaunchConstrainer}s reject the task. | ||
*/ | ||
public class AllLaunchConstrainer implements LaunchConstrainer { | ||
private List<LaunchConstrainer> constrainers; | ||
|
||
public AllLaunchConstrainer(LaunchConstrainer... constrainers) { | ||
this.constrainers = Arrays.asList(constrainers); | ||
} | ||
|
||
@Override | ||
public void launchHappened(LaunchOfferRecommendation recommendation, RecoveryType recoveryType) { | ||
for (LaunchConstrainer constrainer : constrainers) { | ||
constrainer.launchHappened(recommendation, recoveryType); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canLaunch(RecoveryType recoveryType) { | ||
for (LaunchConstrainer constrainer : constrainers) { | ||
if (!constrainer.canLaunch(recoveryType)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...uler/src/main/java/com/mesosphere/sdk/scheduler/recovery/constrain/LaunchConstrainer.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,34 @@ | ||
package com.mesosphere.sdk.scheduler.recovery.constrain; | ||
|
||
import com.mesosphere.sdk.offer.LaunchOfferRecommendation; | ||
import com.mesosphere.sdk.scheduler.recovery.RecoveryType; | ||
|
||
import org.apache.mesos.Protos.Offer.Operation; | ||
|
||
/** | ||
* This interface provides methods which govern and react to Launch Operations. It is sometimes desirable to limit the | ||
* rate of Launch Operations. In particular may be desirable to limit the rate of Operations which may be destructive | ||
* in reaction to permanent failures. Notifications regarding launch Operations and desired RecoveryRequirements allow | ||
* LaunchConstrainers to throttle Launch Operations. | ||
*/ | ||
public interface LaunchConstrainer { | ||
/** | ||
* Invoked every time a task is launchHappened. | ||
* <p> | ||
* We take a {@link Operation} so that frameworks can specify additional metadata, in order to smooth the launch | ||
* rate. | ||
* | ||
* @param recommendation The OfferRecommendation containing the Launch Operation which occurred | ||
* @param recoveryType The type of the recovery which has been executed | ||
*/ | ||
void launchHappened(LaunchOfferRecommendation recommendation, RecoveryType recoveryType); | ||
|
||
/** | ||
* Determines whether the given {@link RecoveryType} | ||
* can be launchHappened right now. | ||
* | ||
* @param recoveryType The {@link RecoveryType} to be examined | ||
* @return {@code true} if the offer is safe to launch immediately, false if it should wait | ||
*/ | ||
boolean canLaunch(RecoveryType recoveryType); | ||
} |
31 changes: 31 additions & 0 deletions
31
...c/main/java/com/mesosphere/sdk/scheduler/recovery/constrain/TestingLaunchConstrainer.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,31 @@ | ||
package com.mesosphere.sdk.scheduler.recovery.constrain; | ||
|
||
import com.mesosphere.sdk.offer.LaunchOfferRecommendation; | ||
import com.mesosphere.sdk.scheduler.recovery.RecoveryType; | ||
|
||
/** | ||
* {@link LaunchConstrainer} that makes it easy to enable/disable launches for testing. | ||
* <p> | ||
* Defaults to allowing all launches. | ||
*/ | ||
public class TestingLaunchConstrainer implements LaunchConstrainer { | ||
private boolean canLaunch; | ||
|
||
public TestingLaunchConstrainer() { | ||
this.canLaunch = false; | ||
} | ||
|
||
public void setCanLaunch(boolean canLaunch) { | ||
this.canLaunch = canLaunch; | ||
} | ||
|
||
@Override | ||
public void launchHappened(LaunchOfferRecommendation recommendation, RecoveryType recoveryType) { | ||
// Does nothing when the launch happens | ||
} | ||
|
||
@Override | ||
public boolean canLaunch(RecoveryType recoveryType) { | ||
return this.canLaunch; | ||
} | ||
} |
Oops, something went wrong.