-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mesos primitives, Unavailability support
- Loading branch information
Showing
3 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/main/scala/org/apache/mesos/chronos/scheduler/mesos/AvailabilityChecker.scala
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,30 @@ | ||
package org.apache.mesos.chronos.scheduler.mesos | ||
|
||
import java.util.logging.Logger | ||
|
||
import org.apache.mesos.Protos | ||
|
||
/** | ||
* Helper for checking availability using mesos primitives | ||
*/ | ||
object AvailabilityChecker { | ||
|
||
private[this] val log = Logger.getLogger(getClass.getName) | ||
|
||
def checkAvailability(offer: Protos.Offer): Boolean = { | ||
val now = System.nanoTime() | ||
if (offer.hasUnavailability && offer.getUnavailability.hasStart) { | ||
val start = offer.getUnavailability.getStart.getNanoseconds | ||
if (now.>=(start)) { | ||
if (offer.getUnavailability.hasDuration) { | ||
return start.+(offer.getUnavailability.getDuration.getNanoseconds).<(now) | ||
} else { | ||
return false; | ||
} | ||
|
||
} | ||
} | ||
return true | ||
} | ||
|
||
} |
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