本文整理汇总了Java中org.apache.mesos.MesosSchedulerDriver类的典型用法代码示例。如果您正苦于以下问题:Java MesosSchedulerDriver类的具体用法?Java MesosSchedulerDriver怎么用?Java MesosSchedulerDriver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MesosSchedulerDriver类属于org.apache.mesos包,在下文中一共展示了MesosSchedulerDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchedulerDriver
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
private SchedulerDriver getSchedulerDriver(final TaskScheduler taskScheduler, final JobEventBus jobEventBus, final FrameworkIDService frameworkIDService) {
Optional<String> frameworkIDOptional = frameworkIDService.fetch();
Protos.FrameworkInfo.Builder builder = Protos.FrameworkInfo.newBuilder();
if (frameworkIDOptional.isPresent()) {
builder.setId(Protos.FrameworkID.newBuilder().setValue(frameworkIDOptional.get()).build());
}
Optional<String> role = env.getMesosRole();
String frameworkName = MesosConfiguration.FRAMEWORK_NAME;
if (role.isPresent()) {
builder.setRole(role.get());
frameworkName += "-" + role.get();
}
builder.addCapabilitiesBuilder().setType(Protos.FrameworkInfo.Capability.Type.PARTITION_AWARE);
MesosConfiguration mesosConfig = env.getMesosConfiguration();
Protos.FrameworkInfo frameworkInfo = builder.setUser(mesosConfig.getUser()).setName(frameworkName)
.setHostname(mesosConfig.getHostname()).setFailoverTimeout(MesosConfiguration.FRAMEWORK_FAILOVER_TIMEOUT_SECONDS)
.setWebuiUrl(WEB_UI_PROTOCOL + env.getFrameworkHostPort()).setCheckpoint(true).build();
return new MesosSchedulerDriver(new SchedulerEngine(taskScheduler, facadeService, jobEventBus, frameworkIDService, statisticManager), frameworkInfo, mesosConfig.getUrl());
}
示例2: create
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
@Override
public SchedulerDriver create(
Scheduler scheduler,
Optional<Protos.Credential> credentials,
FrameworkInfo frameworkInfo,
String master) {
if (credentials.isPresent()) {
return new MesosSchedulerDriver(
scheduler,
frameworkInfo,
master,
false, // Disable implicit acknowledgements.
credentials.get());
} else {
return new MesosSchedulerDriver(
scheduler,
frameworkInfo,
master,
false); // Disable implicit acknowledgements.
}
}
示例3: prepare
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
@Override
public void prepare(Map conf, String localDir) {
try {
initialize(conf, localDir);
MesosSchedulerDriver driver = createMesosDriver();
driver.start();
LOG.info("Waiting for scheduler driver to register MesosNimbus with mesos-master and complete initialization...");
_scheduler.waitUntilRegistered();
LOG.info("Scheduler registration and initialization complete...");
} catch (Exception e) {
LOG.error("Failed to prepare scheduler ", e);
throw new RuntimeException(e);
}
}
示例4: createMesosSchedulerDriver
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
static MesosSchedulerDriver createMesosSchedulerDriver(Scheduler scheduler, Launcher.Configuration conf, Protos.FrameworkInfo fw)
throws IOException {
Protos.Credential credential = null;
if (conf.fileConfig.hasSecretFile()) {
credential = Protos.Credential.newBuilder()
.setPrincipal(conf.fileConfig.getPrincipal())
.setSecretBytes(ByteString.readFrom(new FileInputStream(conf.fileConfig.getSecretFile())))
.build();
}
LOG.info("{} starting", MesosSchedulerDriver.class.getName());
if (credential != null) {
return new MesosSchedulerDriver(scheduler, fw, conf.getMesosMaster(), credential);
}
return new MesosSchedulerDriver(scheduler, fw, conf.getMesosMaster());
}
示例5: createInternal
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
/**
* Avoid calls to the MesosSchedulerDriver constructor, which triggers errors about libmesos not
* being present.
*/
@Override
protected MesosSchedulerDriver createInternal(
final Scheduler scheduler,
final FrameworkInfo frameworkInfo,
final String masterUrl,
final Credential credential,
final String mesosAPIVersion) {
createCalls++;
if (credential != null) {
lastCallHadCredential = true;
lastCallHadSecret = credential.hasSecret();
} else {
lastCallHadCredential = false;
lastCallHadSecret = false;
}
return null; // avoid requiring a NoOpSchedulerDriver
}
示例6: start
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
@PostConstruct
public void start() {
configManager.setOnConfigUpdate(this::updateExecutorConfig);
if (!settings.getWebServerDebug()) {
Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder()
.setName(settings.getFrameworkName())
.setUser(settings.getLogstashUser())
.setRole(settings.getLogstashRole())
.setFailoverTimeout(settings.getFailoverTimeout());
try {
FrameworkID frameworkID = persistentState.getFrameworkID();
if (frameworkID != null) {
frameworkInfo.setId(frameworkID);
}
} catch (InterruptedException | ExecutionException | InvalidProtocolBufferException e) {
throw new SchedulerException("Error recovering framework id", e);
}
driver = new MesosSchedulerDriver(this, frameworkInfo.build(),
settings.getMesosMasterUri());
driver.start();
}
}
示例7: MyriadDriver
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
@Inject
public MyriadDriver(final MyriadScheduler scheduler,
final MyriadConfiguration cfg, final SchedulerState schedulerState) {
this.scheduler = scheduler;
FrameworkID frameworkId = schedulerState.getFrameworkId();
Builder frameworkInfoBuilder = FrameworkInfo.newBuilder().setUser("")
.setName(cfg.getFrameworkName())
.setCheckpoint(cfg.getCheckpoint())
.setFailoverTimeout(cfg.getFrameworkFailoverTimeout());
if (frameworkId != null) {
frameworkInfoBuilder.setId(frameworkId);
}
this.myriadFrameworkInfo = frameworkInfoBuilder.build();
this.driver = new MesosSchedulerDriver(this.scheduler,
this.myriadFrameworkInfo, cfg.getMesosMaster());
}
示例8: SingularityDriver
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
@Inject
SingularityDriver(final SingularityMesosSchedulerDelegator scheduler, final SingularityConfiguration singularityConfiguration, final MesosConfiguration configuration,
@Named(SingularityMainModule.SINGULARITY_URI_BASE) final String singularityUriBase) throws IOException {
final FrameworkInfo.Builder frameworkInfoBuilder = Protos.FrameworkInfo.newBuilder()
.setCheckpoint(configuration.getCheckpoint())
.setFailoverTimeout(configuration.getFrameworkFailoverTimeout())
.setName(configuration.getFrameworkName())
.setId(FrameworkID.newBuilder().setValue(configuration.getFrameworkId()))
.setUser(""); // let mesos assign
if (singularityConfiguration.getHostname().isPresent()) {
frameworkInfoBuilder.setHostname(singularityConfiguration.getHostname().get());
}
// only set the web UI URL if it's fully qualified
if (singularityUriBase.startsWith("http://") || singularityUriBase.startsWith("https://")) {
if (singularityConfiguration.getUiConfiguration().getRootUrlMode() == UIConfiguration.RootUrlMode.INDEX_CATCHALL) {
frameworkInfoBuilder.setWebuiUrl(singularityUriBase);
} else {
frameworkInfoBuilder.setWebuiUrl(singularityUriBase + UiResource.UI_RESOURCE_LOCATION);
}
}
this.frameworkInfo = frameworkInfoBuilder.build();
this.scheduler = scheduler;
if (configuration.getCredentialPrincipal().isPresent() && configuration.getCredentialSecret().isPresent()) {
Credential credential = Credential.newBuilder()
.setPrincipal(configuration.getCredentialPrincipal().get())
.setSecret(ByteString.copyFrom(configuration.getCredentialSecret().get().getBytes(StandardCharsets.UTF_8)))
.build();
this.driver = new MesosSchedulerDriver(scheduler, frameworkInfo, configuration.getMaster(), credential);
} else {
this.driver = new MesosSchedulerDriver(scheduler, frameworkInfo, configuration.getMaster());
}
}
示例9: main
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
public static void main(String[] args) {
String path = System.getProperty("user.dir") + "/target/scala-2.10/mesos-pi-assembly-1.0.jar";
Protos.CommandInfo.URI uri = Protos.CommandInfo.URI.newBuilder().setValue(path).setExtract(false).build();
String commandPi = "java -cp mesos-pi-assembly-1.0.jar PiExecutor";
Protos.CommandInfo piCommandInfo = Protos.CommandInfo.newBuilder().setValue(commandPi).addUris(uri)
.build();
Protos.ExecutorInfo piExecutorInfo = Protos.ExecutorInfo.newBuilder()
.setExecutorId(Protos.ExecutorID.newBuilder()
.setValue("CalculatePi")).setCommand(piCommandInfo)
.setName("PiExecutor").setSource("java").build();
Protos.FrameworkInfo.Builder frameworkBuilder = Protos.FrameworkInfo.newBuilder()
.setFailoverTimeout(120000).setUser("")
.setName("PiFramework")
.setPrincipal("test-framework-java");
if (System.getenv("MESOS_CHECKPOINT") != null) {
System.out.println("Enabling checkpoint for the framework");
frameworkBuilder.setCheckpoint(true);
}
Scheduler scheduler = new PiScheduler(piExecutorInfo, 1);
MesosSchedulerDriver schedulerDriver = new MesosSchedulerDriver(scheduler, frameworkBuilder.build(), args[0]);;
int status = schedulerDriver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
schedulerDriver.stop();
System.exit(status);
}
示例10: Framework
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
/**
* Constructor for the framework
*
* @param processor
* The processor that this framework is responsible for
* @param configuration
* Configuration that came from environment variables
*/
public Framework(Processor processor, Configuration configuration) {
this.configuration = configuration;
this.leasesQueue = new LinkedBlockingQueue<>();
scheduler = new TaskScheduler.Builder().withLeaseOfferExpirySecs(10)
.withLeaseRejectAction(new Action1<VirtualMachineLease>() {
@Override
public void call(VirtualMachineLease lease) {
LOG.trace("Declining offer on " + lease.hostname());
ref.get().declineOffer(lease.getOffer().getId());
}
}).build();
// Construct the Framework
String frameworkName = configuration.frameworkName + "_" + processor.name + "_" + VERSION;
Protos.FrameworkInfo framework = Protos.FrameworkInfo.newBuilder().setName(frameworkName).setUser("").build();
// Build the Kafka components
input = new KafkaInput(this, configuration, processor);
output = new KafkaOutput(this, configuration, processor);
// Build the Scheduler
Scheduler mesosScheduler = new MesosScheduler(scheduler, leasesQueue, input, this);
mesosSchedulerDriver = new MesosSchedulerDriver(mesosScheduler, framework, configuration.mesosMaster);
ref.set(mesosSchedulerDriver);
}
示例11: runFramework
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
private static void runFramework(String mesosMaster) {
Scheduler scheduler = new FederatorScheduler(getExecutorInfo());
MesosSchedulerDriver driver = new MesosSchedulerDriver(scheduler, getFrameworkInfo(), mesosMaster);
int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
driver.stop();
System.exit(status);
}
示例12: SampleFramework
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
/**
* Create a sample mesos framework with the given task queue and mesos master connection string. As would be typical
* for frameworks that wish to use Fenzo task scheduler, a lease queue is created for mesos scheduler callback to
* insert offers received from mesos. This sample implementation obtains the tasks to run via a task queue. The
* {@link SampleFramework#runAll()} method implements the scheduling loop that continuously takes pending tasks from
* the queue and uses Fenzo's task scheduler to assign resources to them.
*
* The task scheduler created in this sample is a rather simple one, with no advanced features.
*
* @param taskQueue The task queue.
* @param mesosMaster Connection string for mesos master.
* @param onTaskComplete A single argument action trigger to invoke upon task completion, with task ID is the argument.
* @param taskCmdGetter A single argument function to invoke to get the command line to execute for a given task ID,
* passed as the only argument.
*/
public SampleFramework(BlockingQueue<TaskRequest> taskQueue, String mesosMaster, Action1<String> onTaskComplete,
Func1<String, String> taskCmdGetter) {
this.taskQueue = taskQueue;
this.leasesQueue = new LinkedBlockingQueue<>();
this.onTaskComplete = onTaskComplete;
this.taskCmdGetter = taskCmdGetter;
launchedTasks = new HashMap<>();
scheduler = new TaskScheduler.Builder()
.withLeaseOfferExpirySecs(1000000000)
.withLeaseRejectAction(new Action1<VirtualMachineLease>() {
@Override
public void call(VirtualMachineLease lease) {
System.out.println("Declining offer on " + lease.hostname());
ref.get().declineOffer(lease.getOffer().getId());
}
})
.build();
Protos.FrameworkInfo framework = Protos.FrameworkInfo.newBuilder()
.setName("Sample Fenzo Framework")
.setUser("")
.build();
Scheduler mesosScheduler = new MesosScheduler();
mesosSchedulerDriver = new MesosSchedulerDriver(mesosScheduler, framework, mesosMaster);
ref.set(mesosSchedulerDriver);
new Thread() {
public void run() {
mesosSchedulerDriver.run();
}
}.start();
}
示例13: main
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
BasicConfigurator.configure(); // log4j setup
LOGGER.info("Starting Scheduler");
Scheduler scheduler = new EchoScheduler();
Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder().setUser("").setName("Echo Framework").build();
MesosSchedulerDriver driver = new MesosSchedulerDriver(scheduler, frameworkInfo, args[0]);
int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
driver.stop(); //
System.exit(status);
}
示例14: getSchedulerDriver
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
protected SchedulerDriver getSchedulerDriver(String masterURI, MesosFramework framework) {
Protos.FrameworkInfo.Builder frameworkBuilder = Protos.FrameworkInfo.newBuilder()
.setUser("") // Have Mesos fill in the current user.
.setName("heron_scheduler_" + Context.topologyName(config))
.setCheckpoint(true);
return new MesosSchedulerDriver(
framework,
frameworkBuilder.build(),
masterURI);
}
示例15: registerFramework
import org.apache.mesos.MesosSchedulerDriver; //导入依赖的package包/类
private void registerFramework(HBaseScheduler sched, FrameworkInfo fInfo, String masterUri) {
Credential cred = getCredential();
if (cred != null) {
log.info("Registering with credentials.");
new MesosSchedulerDriver(sched, fInfo, masterUri, cred).run();
} else {
log.info("Registering without authentication");
new MesosSchedulerDriver(sched, fInfo, masterUri).run();
}
}