private boolean offerAccepted(Protos.Offer offer, List<Protos.OfferID> acceptedOfferIds) { return acceptedOfferIds.stream().anyMatch( acceptedOfferId -> acceptedOfferId.equals(offer.getId())); }
/** * This method removes an offer from the queue based on its OfferID. */ public void remove(Protos.OfferID offerID) { Collection<Protos.Offer> offers = queue.parallelStream() .filter(offer -> offer.getId().equals(offerID)) .collect(Collectors.toList()); boolean removed = queue.removeAll(offers); if (!removed) { logger.warning( String.format( "Attempted to remove offer: '%s' but it was not present in the queue.", offerID.getValue())); } else { logger.info(String.format("Removed offer: %s", offerID.getValue())); Metrics.metricRegistry().meter("mesos.offer.queue.removed").mark(); } }
/** * This method removes an offer from the queue based on its OfferID. */ public void remove(Protos.OfferID offerID) { Collection<Protos.Offer> offers = queue.parallelStream() .filter(offer -> offer.getId().equals(offerID)) .collect(Collectors.toList()); boolean removed = queue.removeAll(offers); if (!removed) { logger.warn( "Attempted to remove offer: '{}' but it was not present in the queue.", offerID.getValue()); } else { logger.info("Removed offer: {}", offerID.getValue()); } }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.mesos.scheduler.Protos.Event.Rescind)) { return super.equals(obj); } org.apache.mesos.scheduler.Protos.Event.Rescind other = (org.apache.mesos.scheduler.Protos.Event.Rescind) obj; boolean result = true; result = result && (hasOfferId() == other.hasOfferId()); if (hasOfferId()) { result = result && getOfferId() .equals(other.getOfferId()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.mesos.scheduler.Protos.Event.RescindInverseOffer)) { return super.equals(obj); } org.apache.mesos.scheduler.Protos.Event.RescindInverseOffer other = (org.apache.mesos.scheduler.Protos.Event.RescindInverseOffer) obj; boolean result = true; result = result && (hasInverseOfferId() == other.hasInverseOfferId()); if (hasInverseOfferId()) { result = result && getInverseOfferId() .equals(other.getInverseOfferId()); } result = result && unknownFields.equals(other.unknownFields); return result; }
@Override public UnexpectedResourcesResponse answer(InvocationOnMock invocation) throws Throwable { Optional<Protos.Offer> match = getOffersArgument(invocation).stream() .filter(o -> o.getId().equals(unexpectedOffer)) .findAny(); Collection<OfferResources> recs = match.isPresent() ? Collections.singletonList(new OfferResources(match.get()).addAll(match.get().getResourcesList())) : Collections.emptyList(); return UnexpectedResourcesResponse.processed(recs); } };
@Override public OfferResponse answer(InvocationOnMock invocation) throws Throwable { Optional<Protos.Offer> match = getOffersArgument(invocation).stream() .filter(o -> o.getId().equals(offerToConsume)) .findAny(); Collection<OfferRecommendation> recs = match.isPresent() ? Collections.singletonList(new ReserveOfferRecommendation(match.get(), getUnreservedCpus(3))) : Collections.emptyList(); return OfferResponse.processed(recs); } };