use of org.apache.mesos.Scheduler in project alluxio by Alluxio.
the class AlluxioFramework method run.
/**
* Runs the mesos framework.
*/
public void run() {
Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder().setName("alluxio").setCheckpoint(true);
if (Configuration.containsKey(PropertyKey.INTEGRATION_MESOS_ROLE)) {
frameworkInfo.setRole(Configuration.get(PropertyKey.INTEGRATION_MESOS_ROLE));
}
// Setting the user to an empty string will prompt Mesos to set it to the current user.
if (Configuration.containsKey(PropertyKey.INTEGRATION_MESOS_USER)) {
frameworkInfo.setUser(Configuration.get(PropertyKey.INTEGRATION_MESOS_USER));
}
if (Configuration.containsKey(PropertyKey.INTEGRATION_MESOS_PRINCIPAL)) {
frameworkInfo.setPrincipal(Configuration.get(PropertyKey.INTEGRATION_MESOS_PRINCIPAL));
}
Scheduler scheduler = new AlluxioScheduler(mAlluxioMasterHostname);
Protos.Credential cred = createCredential();
MesosSchedulerDriver driver;
if (cred == null) {
driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster);
} else {
driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster, cred);
}
int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
System.exit(status);
}
use of org.apache.mesos.Scheduler in project ignite by apache.
the class IgniteFramework method main.
/**
* Main methods has only one optional parameter - path to properties files.
*
* @param args Args.
* @throws Exception If failed.
*/
public static void main(String[] args) throws Exception {
IgniteFramework igniteFramework = new IgniteFramework();
ClusterProperties clusterProps = ClusterProperties.from(args.length >= 1 ? args[0] : null);
String baseUrl = String.format("http://%s:%d", clusterProps.httpServerHost(), clusterProps.httpServerPort());
JettyServer httpSrv = new JettyServer();
httpSrv.start(new ResourceHandler(clusterProps.userLibs(), clusterProps.igniteCfg(), clusterProps.igniteWorkDir()), clusterProps);
ResourceProvider provider = new ResourceProvider();
IgniteProvider igniteProvider = new IgniteProvider(clusterProps.igniteWorkDir());
provider.init(clusterProps, igniteProvider, baseUrl);
// Create the scheduler.
Scheduler scheduler = new IgniteScheduler(clusterProps, provider);
// Create the driver.
MesosSchedulerDriver driver;
if (System.getenv(MESOS_AUTHENTICATE) != null) {
log.info("Enabling authentication for the framework");
if (System.getenv(DEFAULT_PRINCIPAL) == null) {
log.log(Level.SEVERE, "Expecting authentication principal in the environment");
System.exit(1);
}
if (System.getenv(DEFAULT_SECRET) == null) {
log.log(Level.SEVERE, "Expecting authentication secret in the environment");
System.exit(1);
}
Protos.Credential cred = Protos.Credential.newBuilder().setPrincipal(System.getenv(DEFAULT_PRINCIPAL)).setSecret(ByteString.copyFrom(System.getenv(DEFAULT_SECRET).getBytes())).build();
driver = new MesosSchedulerDriver(scheduler, igniteFramework.getFrameworkInfo(), clusterProps.masterUrl(), cred);
} else
driver = new MesosSchedulerDriver(scheduler, igniteFramework.getFrameworkInfo(), clusterProps.masterUrl());
int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
httpSrv.stop();
// Ensure that the driver process terminates.
driver.stop();
System.exit(status);
}
use of org.apache.mesos.Scheduler in project jesos by groupon.
the class LocalSchedulerMessageProcessor method frameworkError.
@Subscribe
public void frameworkError(final FrameworkErrorMessageEnvelope envelope) {
checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
final UPID sender = envelope.getSender();
if (!driverIsConnected(sender)) {
return;
}
final FrameworkErrorMessage frameworkErrorMessage = envelope.getMessage();
eventBus.post(new SchedulerCallback() {
@Override
public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
return new Runnable() {
@Override
public void run() {
schedulerDriver.abort();
scheduler.error(schedulerDriver, frameworkErrorMessage.getMessage());
}
};
}
});
}
use of org.apache.mesos.Scheduler 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.Scheduler 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