File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
src/main/scala/org/apache/mesos/chronos/scheduler/mesos Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 1+ package org .apache .mesos .chronos .scheduler .mesos
2+
3+ import java .util .logging .Logger
4+
5+ import org .apache .mesos .Protos
6+
7+ /**
8+ * Helper for checking availability using mesos primitives
9+ */
10+ object AvailabilityChecker {
11+
12+ private [this ] val log = Logger .getLogger(getClass.getName)
13+
14+ def checkAvailability (offer : Protos .Offer ): Boolean = {
15+ var unavailability = offer.hasUnavailability
16+ var now = System .nanoTime()
17+ if (offer.hasUnavailability && offer.getUnavailability.hasStart) {
18+ val start = offer.getUnavailability.getStart.getNanoseconds
19+ if (now.>= (start)) {
20+ if (offer.getUnavailability.hasDuration) {
21+ return start.+ (offer.getUnavailability.getDuration.getNanoseconds).> (now)
22+ } else {
23+ return false ;
24+ }
25+
26+ }
27+ }
28+ return true
29+ }
30+
31+ }
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ class MesosJobFramework @Inject()(
131131 case None =>
132132 val neededResources = new Resources (job)
133133 offerResources.toIterator.find { ors =>
134- ors._2.canSatisfy(neededResources) && ConstraintChecker .checkConstraints(ors._1, job.constraints)
134+ ors._2.canSatisfy(neededResources) && ConstraintChecker .checkConstraints(ors._1, job.constraints) && AvailabilityChecker .checkAvailability(ors._1)
135135 } match {
136136 case Some ((offer, resources)) =>
137137 // Subtract this job's resource requirements from the remaining available resources in this offer.
You can’t perform that action at this time.
0 commit comments