use of org.apache.mesos.Protos.FrameworkID in project incubator-myriad by apache.
the class TestObjectFactory method getOffer.
public static Offer getOffer(String host, String slaveId, String frameworkId, String offerId, double cpuCores, double memory) {
Protos.SlaveID sid = SlaveID.newBuilder().setValue(slaveId).build();
Protos.FrameworkID fid = FrameworkID.newBuilder().setValue(frameworkId).build();
Protos.Value.Scalar cores = Protos.Value.Scalar.newBuilder().setValue(cpuCores).build();
Protos.Value.Scalar mem = Protos.Value.Scalar.newBuilder().setValue(memory).build();
Protos.Resource cpuResource = Protos.Resource.newBuilder().setName("cpus").setScalar(cores).setType(Type.SCALAR).build();
Protos.Resource memResource = Protos.Resource.newBuilder().setName("mem").setScalar(mem).setType(Type.SCALAR).build();
return Protos.Offer.newBuilder().setHostname(host).setId(OfferID.newBuilder().setValue(offerId)).setSlaveId(sid).setFrameworkId(fid).addResources(cpuResource).addResources(memResource).build();
}
use of org.apache.mesos.Protos.FrameworkID in project incubator-myriad by apache.
the class ByteBufferSupportTest method getExecutorInfo.
private ExecutorInfo getExecutorInfo() {
FrameworkID id = Protos.FrameworkID.newBuilder().setValue("framework1").build();
ExecutorID eid = Protos.ExecutorID.newBuilder().setValue("executor1").build();
CommandInfo cm = Protos.CommandInfo.newBuilder().setValue("command").build();
return ExecutorInfo.newBuilder().setFrameworkId(id).setExecutorId(eid).setCommand(cm).build();
}
use of org.apache.mesos.Protos.FrameworkID in project jesos by groupon.
the class LocalSchedulerMessageProcessor method frameworkReregistered.
@Subscribe
public void frameworkReregistered(final FrameworkReregisteredMessageEnvelope envelope) {
checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
final FrameworkReregisteredMessage frameworkReregisteredMessage = envelope.getMessage();
if (!masterIsValid(frameworkReregisteredMessage.getMasterInfo())) {
return;
}
final FrameworkID frameworkId = frameworkReregisteredMessage.getFrameworkId();
checkState(frameworkId != null, "Received null framework reregistration message!");
checkState(frameworkId.equals(context.getFrameworkId()), "Received framework reregistration for %s but expected %s", frameworkId.getValue(), context.getFrameworkId().getValue());
context.connected();
context.setFailover(false);
eventBus.post(new SchedulerCallback() {
@Override
public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
return new Runnable() {
@Override
public void run() {
scheduler.reregistered(schedulerDriver, context.getMaster());
}
};
}
});
}
use of org.apache.mesos.Protos.FrameworkID in project jesos by groupon.
the class InternalSchedulerDriver method doLaunchTasks.
//
// Launch Tasks processing
//
private void doLaunchTasks(final LaunchTasksMessage message) {
final MasterInfo masterInfo = context.connectedMaster();
if (masterInfo == null) {
loseAllTasks(message.getTasksList(), "Master disconnected");
return;
}
final ImmutableList.Builder<TaskInfo> builder = ImmutableList.builder();
for (TaskInfo taskInfo : message.getTasksList()) {
if (taskInfo.hasExecutor() == taskInfo.hasCommand()) {
loseTask(taskInfo, "TaskInfo must have either an 'executor' or a 'command'");
// for(...
continue;
}
if (taskInfo.hasExecutor()) {
if (taskInfo.getExecutor().hasFrameworkId()) {
final FrameworkID executorFrameworkId = taskInfo.getExecutor().getFrameworkId();
if (!executorFrameworkId.equals(context.getFrameworkId())) {
loseTask(taskInfo, format("ExecutorInfo has an invalid FrameworkID (Actual: %s vs Expected: %s)", executorFrameworkId.getValue(), context.getFrameworkId().getValue()));
// for(...
continue;
}
} else {
// Executor present but not framework id. Set the framework id.
taskInfo = TaskInfo.newBuilder(taskInfo).setExecutor(ExecutorInfo.newBuilder(taskInfo.getExecutor()).setFrameworkId(context.getFrameworkId())).build();
}
}
builder.add(taskInfo);
}
final List<TaskInfo> launchTasks = builder.build();
for (final OfferID offer : message.getOfferIdsList()) {
if (!context.hasOffers(offer)) {
LOG.warn("Unknown offer %s ignored!", offer.getValue());
}
for (final TaskInfo launchTask : launchTasks) {
if (context.hasOffer(offer, launchTask.getSlaveId())) {
context.addSlave(launchTask.getSlaveId(), context.getOffer(offer, launchTask.getSlaveId()));
}
}
context.removeAllOffers(offer);
}
final LaunchTasksMessage launchMessage = LaunchTasksMessage.newBuilder(message).setFrameworkId(context.getFrameworkId()).clearTasks().addAllTasks(launchTasks).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), launchMessage));
}
use of org.apache.mesos.Protos.FrameworkID in project incubator-myriad by apache.
the class MesosModule method providesSchedulerDriver.
@Provides
@Singleton
SchedulerDriver providesSchedulerDriver(MyriadScheduler scheduler, MyriadConfiguration cfg, SchedulerState schedulerState) {
Builder frameworkInfoBuilder = FrameworkInfo.newBuilder().setUser("").setName(cfg.getFrameworkName()).setCheckpoint(cfg.isCheckpoint()).setFailoverTimeout(cfg.getFrameworkFailoverTimeout());
frameworkInfoBuilder.setRole(cfg.getFrameworkRole());
Optional<FrameworkID> optFrameId = schedulerState.getFrameworkID();
if (optFrameId.isPresent()) {
FrameworkID frameworkId = optFrameId.get();
LOGGER.info("Attempting to re-register with frameworkId: {}", frameworkId.getValue());
frameworkInfoBuilder.setId(frameworkId);
}
String mesosAuthenticationPrincipal = cfg.getMesosAuthenticationPrincipal();
String mesosAuthenticationSecretFilename = cfg.getMesosAuthenticationSecretFilename();
if (StringUtils.isNotEmpty(mesosAuthenticationPrincipal)) {
frameworkInfoBuilder.setPrincipal(mesosAuthenticationPrincipal);
Credential.Builder credentialBuilder = Credential.newBuilder();
credentialBuilder.setPrincipal(mesosAuthenticationPrincipal);
if (StringUtils.isNotEmpty(mesosAuthenticationSecretFilename)) {
try {
credentialBuilder.setSecretBytes(ByteString.readFrom(new FileInputStream(mesosAuthenticationSecretFilename)));
} catch (FileNotFoundException ex) {
LOGGER.error("Mesos authentication secret file was not found", ex);
throw new RuntimeException(ex);
} catch (IOException ex) {
LOGGER.error("Error reading Mesos authentication secret file", ex);
throw new RuntimeException(ex);
}
}
return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster(), credentialBuilder.build());
} else {
return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster());
}
}
Aggregations