本文整理汇总了Java中org.apache.mesos.Scheduler类的典型用法代码示例。如果您正苦于以下问题:Java Scheduler类的具体用法?Java Scheduler怎么用?Java Scheduler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Scheduler类属于org.apache.mesos包,在下文中一共展示了Scheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Override
protected void configure() {
install(new PrivateModule() {
@Override
protected void configure() {
bind(Driver.class).to(SchedulerDriverService.class);
bind(SchedulerDriverService.class).in(Singleton.class);
expose(Driver.class);
bind(Scheduler.class).to(MesosSchedulerImpl.class);
bind(MesosSchedulerImpl.class).in(Singleton.class);
expose(Scheduler.class);
// TODO(zmanji): Create singleThreadedExecutor (non-scheduled) variant.
bind(Executor.class).annotatedWith(MesosSchedulerImpl.SchedulerExecutor.class)
.toInstance(AsyncUtil.singleThreadLoggingScheduledExecutor("SchedulerImpl-%d", LOG));
}
});
PubsubEventModule.bindSubscriber(binder(), TaskStatusStats.class);
bind(TaskStatusStats.class).in(Singleton.class);
}
示例2: create
import org.apache.mesos.Scheduler; //导入依赖的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: createMesosSchedulerDriver
import org.apache.mesos.Scheduler; //导入依赖的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());
}
示例4: testUpdateHasUUIDSendAck
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Test
public void testUpdateHasUUIDSendAck() {
Scheduler scheduler = mock(Scheduler.class);
Mesos mesos = mock(Mesos.class);
CustomMesosToSchedulerDriverAdapter driver = new CustomMesosToSchedulerDriverAdapter(scheduler, mesos);
assertEquals(org.apache.mesos.Protos.Status.DRIVER_RUNNING, driver.start());
Protos.Event event = Protos.Event.newBuilder()
.setType(Protos.Event.Type.UPDATE)
.setUpdate(Protos.Event.Update.newBuilder()
.setStatus(org.apache.mesos.v1.Protos.TaskStatus.newBuilder()
.setUuid(ByteString.copyFromUtf8(UUID.randomUUID().toString()))
.setAgentId(agentId)
.setTaskId(taskId)
.buildPartial())
.buildPartial())
.buildPartial();
driver.received(mesos, event);
verify(scheduler, times(1)).statusUpdate(any(), any());
verify(mesos, times(1)).send(any());
}
示例5: testFailureHasSlaveAndExec
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Test
public void testFailureHasSlaveAndExec() {
Scheduler scheduler = mock(Scheduler.class);
Mesos mesos = mock(Mesos.class);
CustomMesosToSchedulerDriverAdapter driver = new CustomMesosToSchedulerDriverAdapter(scheduler, mesos);
assertEquals(org.apache.mesos.Protos.Status.DRIVER_RUNNING, driver.start());
final org.apache.mesos.v1.scheduler.Protos.Event.Failure.Builder failure =
org.apache.mesos.v1.scheduler.Protos.Event.Failure.newBuilder()
.setAgentId(agentId)
.setExecutorId(executorIdV1)
.setStatus(0);
Protos.Event event = Protos.Event.newBuilder()
.setType(Protos.Event.Type.FAILURE)
.setFailure(failure)
.buildPartial();
driver.received(mesos, event);
verify(scheduler, times(1)).executorLost(any(), any(), any(), anyInt());
}
示例6: testFailureNoExecId
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Test
public void testFailureNoExecId() {
Scheduler scheduler = mock(Scheduler.class);
Mesos mesos = mock(Mesos.class);
CustomMesosToSchedulerDriverAdapter driver = new CustomMesosToSchedulerDriverAdapter(scheduler, mesos);
assertEquals(org.apache.mesos.Protos.Status.DRIVER_RUNNING, driver.start());
final org.apache.mesos.v1.scheduler.Protos.Event.Failure.Builder failure = org.apache.mesos.v1.scheduler.Protos.Event.Failure.newBuilder()
.setAgentId(agentId)
.setStatus(0);
Protos.Event event = Protos.Event.newBuilder()
.setType(Protos.Event.Type.FAILURE)
.setFailure(failure)
.buildPartial();
driver.received(mesos, event);
verify(scheduler, times(1)).slaveLost(any(), any());
}
示例7: testLaunchTasksWithFilters
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Test
public void testLaunchTasksWithFilters() {
Scheduler scheduler = mock(Scheduler.class);
Mesos mesos = mock(Mesos.class);
CustomMesosToSchedulerDriverAdapter driver = new CustomMesosToSchedulerDriverAdapter(scheduler, mesos);
assertEquals(org.apache.mesos.Protos.Status.DRIVER_RUNNING, driver.start());
driver.launchTasks(
Collections.EMPTY_LIST,
Collections.EMPTY_LIST,
org.apache.mesos.Protos.Filters.getDefaultInstance());
final ArgumentCaptor<Protos.Call> callCaptor = ArgumentCaptor.forClass(Protos.Call.class);
verify(mesos, times(1)).send(callCaptor.capture());
assertEquals(Protos.Call.Type.ACCEPT, callCaptor.getValue().getType());
}
示例8: testAck
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Test
public void testAck() {
Scheduler scheduler = mock(Scheduler.class);
Mesos mesos = mock(Mesos.class);
CustomMesosToSchedulerDriverAdapter driver = new CustomMesosToSchedulerDriverAdapter(scheduler, mesos);
assertEquals(org.apache.mesos.Protos.Status.DRIVER_RUNNING, driver.start());
final org.apache.mesos.Protos.TaskStatus status = org.apache.mesos.Protos.TaskStatus.newBuilder()
.setSlaveId(slaveId)
.setTaskId(taskIdV0)
.setState(org.apache.mesos.Protos.TaskState.TASK_ERROR)
.build();
driver.acknowledgeStatusUpdate(status);
final ArgumentCaptor<Protos.Call> callCaptor = ArgumentCaptor.forClass(Protos.Call.class);
verify(mesos, times(1)).send(callCaptor.capture());
assertEquals(Protos.Call.Type.ACKNOWLEDGE, callCaptor.getValue().getType());
}
示例9: testReconcile
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Test
public void testReconcile() {
Scheduler scheduler = mock(Scheduler.class);
Mesos mesos = mock(Mesos.class);
CustomMesosToSchedulerDriverAdapter driver = new CustomMesosToSchedulerDriverAdapter(scheduler, mesos);
assertEquals(org.apache.mesos.Protos.Status.DRIVER_RUNNING, driver.start());
final ArrayList<org.apache.mesos.Protos.TaskStatus> taskStatuses = new ArrayList<>();
taskStatuses.add(org.apache.mesos.Protos.TaskStatus.newBuilder()
.setSlaveId(slaveId)
.setTaskId(taskIdV0)
.setState(org.apache.mesos.Protos.TaskState.TASK_ERROR)
.build());
driver.reconcileTasks(taskStatuses);
final ArgumentCaptor<Protos.Call> callCaptor = ArgumentCaptor.forClass(Protos.Call.class);
verify(mesos, times(1)).send(callCaptor.capture());
assertEquals(Protos.Call.Type.RECONCILE, callCaptor.getValue().getType());
}
示例10: testAbortOnError
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Test
public void testAbortOnError() {
Scheduler scheduler = mock(Scheduler.class);
Mesos mesos = mock(Mesos.class);
CustomMesosToSchedulerDriverAdapter driver = new CustomMesosToSchedulerDriverAdapter(scheduler, mesos);
assertEquals(org.apache.mesos.Protos.Status.DRIVER_RUNNING, driver.start());
Protos.Event errorEvent = org.apache.mesos.v1.scheduler.Protos.Event.newBuilder()
.setType(Protos.Event.Type.ERROR)
.setError(org.apache.mesos.v1.scheduler.Protos.Event.Error.newBuilder()
.setMessage("Framework has been removed")).build();
driver.received(mesos, errorEvent);
verify(scheduler, times(1)).error(any(), any());
assertEquals(org.apache.mesos.Protos.Status.DRIVER_ABORTED, driver.join());
}
示例11: createInternal
import org.apache.mesos.Scheduler; //导入依赖的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
}
示例12: register
import org.apache.mesos.Scheduler; //导入依赖的package包/类
public static Send register() {
return new Send() {
@Override
public void send(ClusterState state, SchedulerDriver mockDriver, Scheduler scheduler) {
scheduler.registered(
mockDriver,
Protos.FrameworkID.newBuilder()
.setValue("test-framework-id")
.build(),
Protos.MasterInfo.newBuilder()
.setId("test-master-id")
.setIp(1)
.setPort(2)
.build());
}
@Override
public String getDescription() {
return String.format("Framework registration completed");
}
};
}
示例13: send
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Override
public void send(ClusterState state, SchedulerDriver mockDriver, Scheduler scheduler) {
Protos.TaskID taskId = builder.taskId == null ?
state.getTaskId(builder.taskName) :
Protos.TaskID.newBuilder().setValue(builder.taskId).build();
Protos.TaskStatus.Builder taskStatusBuilder = Protos.TaskStatus.newBuilder()
.setTaskId(taskId)
.setState(builder.taskState)
.setMessage("This is a test status");
if (builder.readinessCheckExitCode.isPresent()) {
taskStatusBuilder
.getCheckStatusBuilder()
.getCommandBuilder()
.setExitCode(builder.readinessCheckExitCode.get());
}
scheduler.statusUpdate(mockDriver, taskStatusBuilder.build());
}
示例14: SchedulerDriverService
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Inject
SchedulerDriverService(
Scheduler scheduler,
Storage storage,
DriverSettings driverSettings,
DriverFactory driverFactory) {
this.scheduler = requireNonNull(scheduler);
this.storage = requireNonNull(storage);
this.driverSettings = requireNonNull(driverSettings);
this.driverFactory = requireNonNull(driverFactory);
}
示例15: configure
import org.apache.mesos.Scheduler; //导入依赖的package包/类
@Override
protected void configure() {
bind(ConfigurationManagerSettings.class).toInstance(configurationManagerSettings);
bind(Thresholds.class)
.toInstance(new Thresholds(MAX_TASKS_PER_JOB.get(), MAX_UPDATE_INSTANCE_FAILURES.get()));
// Enable intercepted method timings and context classloader repair.
TimedInterceptor.bind(binder());
GuiceUtils.bindJNIContextClassLoader(binder(), Scheduler.class);
GuiceUtils.bindExceptionTrap(binder(), Scheduler.class);
bind(Clock.class).toInstance(Clock.SYSTEM_CLOCK);
install(new PubsubEventModule());
// Filter layering: notifier filter -> base impl
PubsubEventModule.bindSchedulingFilterDelegate(binder()).to(SchedulingFilterImpl.class);
bind(SchedulingFilterImpl.class).in(Singleton.class);
install(new AsyncModule());
install(new OffersModule());
install(new PruningModule());
install(new ReconciliationModule());
install(new SchedulingModule());
install(new AsyncStatsModule());
install(new MetadataModule());
install(new QuotaModule());
install(new JettyServerModule());
install(new PreemptorModule());
install(new SchedulerDriverModule());
install(new SchedulerServicesModule());
install(new SchedulerModule());
install(new StateModule());
install(new SlaModule());
install(new UpdaterModule());
bind(StatsProvider.class).toInstance(Stats.STATS_PROVIDER);
}