use of org.apache.mesos.Protos.FrameworkID in project incubator-myriad by apache.
the class ByteBufferSupportTest method testFrameworkIDToFromByteBuffer.
@Test
public void testFrameworkIDToFromByteBuffer() throws Exception {
ByteBuffer bb = ByteBufferSupport.toByteBuffer(getExecutorInfo().getFrameworkId());
FrameworkID id = ByteBufferSupport.toFrameworkID(bb);
assertEquals(getExecutorInfo().getFrameworkId(), id);
}
use of org.apache.mesos.Protos.FrameworkID in project incubator-myriad by apache.
the class OfferUtilsTest method generateOffers.
private List<Offer> generateOffers(List<Resource> resources) {
FrameworkID fidOne = Protos.FrameworkID.newBuilder().setValue("framework-1").build();
FrameworkID fidTwo = Protos.FrameworkID.newBuilder().setValue("framework-2").build();
FrameworkID fidThree = Protos.FrameworkID.newBuilder().setValue("framework-3").build();
FrameworkID fidFour = Protos.FrameworkID.newBuilder().setValue("framework-4").build();
OfferID oidOne = Protos.OfferID.newBuilder().setValue("offer-1").build();
OfferID oidTwo = Protos.OfferID.newBuilder().setValue("offer-2").build();
OfferID oidThree = Protos.OfferID.newBuilder().setValue("offer-3").build();
OfferID oidFour = Protos.OfferID.newBuilder().setValue("offer-4").build();
SlaveID sidOne = Protos.SlaveID.newBuilder().setValue("slave-1").build();
SlaveID sidTwo = Protos.SlaveID.newBuilder().setValue("slave-2").build();
SlaveID sidThree = Protos.SlaveID.newBuilder().setValue("slave-3").build();
SlaveID sidFour = Protos.SlaveID.newBuilder().setValue("slave-4").build();
Offer offerOne = Protos.Offer.newBuilder().setFrameworkId(fidOne).setHostname("10.0.0.1").setId(oidOne).setSlaveId(sidOne).addResources(resources.get(0)).addResources(resources.get(1)).build();
Offer offerTwo = Protos.Offer.newBuilder().setFrameworkId(fidTwo).setHostname("10.0.0.2").setId(oidTwo).setSlaveId(sidTwo).addResources(resources.get(2)).addResources(resources.get(3)).build();
Offer offerThree = Protos.Offer.newBuilder().setFrameworkId(fidThree).setHostname("10.0.0.3").setId(oidThree).setSlaveId(sidThree).addResources(resources.get(0)).addResources(resources.get(3)).build();
Offer offerFour = Protos.Offer.newBuilder().setFrameworkId(fidFour).setHostname("10.0.0.4").setId(oidFour).setSlaveId(sidFour).addResources(resources.get(2)).addResources(resources.get(1)).build();
return Lists.newArrayList(offerOne, offerTwo, offerThree, offerFour);
}
use of org.apache.mesos.Protos.FrameworkID in project jesos by groupon.
the class LocalSchedulerMessageProcessor method frameworkStatusUpdate.
@Subscribe
public void frameworkStatusUpdate(final StatusUpdateMessageEnvelope envelope) throws IOException {
checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
final UPID sender = envelope.getSender();
if (!driverIsConnected(sender)) {
return;
}
final StatusUpdateMessage statusUpdateMessage = envelope.getMessage();
final FrameworkID frameworkId = context.getFrameworkId();
final FrameworkID messageFrameworkId = statusUpdateMessage.getUpdate().getFrameworkId();
checkState(frameworkId.equals(messageFrameworkId), "Received Message for framework %s, but local id is %s", messageFrameworkId, frameworkId);
final TaskStatus.Builder taskStatusBuilder = TaskStatus.newBuilder(statusUpdateMessage.getUpdate().getStatus());
final TaskStatus taskStatus;
// If the update is driver-generated or master-generated, it does not require acknowledgement (from Mesos source code, sched.cpp).
final Optional<UPID> pid = statusUpdateMessage.hasPid() ? Optional.of(UPID.create(statusUpdateMessage.getPid())) : Optional.<UPID>absent();
final boolean noAckRequired = envelope.getSender().equals(context.getDriverUPID()) || pid.isPresent() && pid.get().equals(context.getDriverUPID());
if (noAckRequired) {
taskStatus = taskStatusBuilder.clearUuid().build();
} else {
taskStatus = taskStatusBuilder.setUuid(statusUpdateMessage.getUpdate().getUuid()).build();
}
eventBus.post(new SchedulerCallback() {
@Override
public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
return new Runnable() {
@Override
public void run() {
scheduler.statusUpdate(schedulerDriver, taskStatus);
}
};
}
});
if (implicitAcknowledgements && !noAckRequired) {
final StatusUpdateAcknowledgementMessage statusUpdateAcknowledgementMessage = StatusUpdateAcknowledgementMessage.newBuilder().setFrameworkId(frameworkId).setSlaveId(statusUpdateMessage.getUpdate().getSlaveId()).setTaskId(taskStatus.getTaskId()).setUuid(statusUpdateMessage.getUpdate().getUuid()).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), statusUpdateAcknowledgementMessage));
}
}
use of org.apache.mesos.Protos.FrameworkID in project jesos by groupon.
the class LocalSchedulerMessageProcessor method frameworkRegistered.
@Subscribe
public void frameworkRegistered(final FrameworkRegisteredMessageEnvelope envelope) {
checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
final FrameworkRegisteredMessage frameworkRegisteredMessage = envelope.getMessage();
if (!masterIsValid(frameworkRegisteredMessage.getMasterInfo())) {
return;
}
final FrameworkID frameworkId = frameworkRegisteredMessage.getFrameworkId();
context.connected();
context.setFailover(false);
context.setFrameworkId(frameworkId);
eventBus.post(new SchedulerCallback() {
@Override
public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
return new Runnable() {
@Override
public void run() {
scheduler.registered(schedulerDriver, frameworkId, context.getMaster());
}
};
}
});
}
Aggregations