本文整理汇总了Java中org.apache.mesos.Protos.FrameworkID方法的典型用法代码示例。如果您正苦于以下问题:Java Protos.FrameworkID方法的具体用法?Java Protos.FrameworkID怎么用?Java Protos.FrameworkID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos
的用法示例。
在下文中一共展示了Protos.FrameworkID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import org.apache.mesos.Protos; //导入方法依赖的package包/类
protected Result check() throws Exception {
try {
final Result unhealthyResult = Result.unhealthy("Framework is not yet registered");
final Optional<Protos.FrameworkID> frameworkID = stateStore.fetchFrameworkId();
if (frameworkID.isPresent()) {
String id = frameworkID.get().getValue();
if (!id.isEmpty()) {
return Result.healthy("Framework registered with id = " + id);
} else {
return unhealthyResult;
}
} else {
return unhealthyResult;
}
} catch (Throwable t) {
throw t;
}
}
示例2: getFrameworkID
import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
* Get the persisted framework ID.
* @return the current ID or empty if none is yet persisted.
* @throws Exception on ZK failures, interruptions.
*/
@Override
public Option<Protos.FrameworkID> getFrameworkID() throws Exception {
synchronized (startStopLock) {
verifyIsRunning();
Option<Protos.FrameworkID> frameworkID;
byte[] value = frameworkIdInZooKeeper.getValue();
if (value.length == 0) {
frameworkID = Option.empty();
} else {
frameworkID = Option.apply(Protos.FrameworkID.newBuilder().setValue(new String(value,
ConfigConstants.DEFAULT_CHARSET)).build());
}
return frameworkID;
}
}
示例3: getFrameworkId
import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
* Produces the configured ID of the framework, or returns an error if reading that data failed.
*/
@Path("/frameworkId")
@GET
public Response getFrameworkId() {
try {
Optional<Protos.FrameworkID> frameworkIDOptional = stateStore.fetchFrameworkId();
if (frameworkIDOptional.isPresent()) {
JSONArray idArray = new JSONArray(Arrays.asList(frameworkIDOptional.get().getValue()));
return ResponseUtils.jsonOkResponse(idArray);
} else {
logger.warn("No framework ID exists");
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (StateStoreException ex) {
logger.error("Failed to fetch framework ID", ex);
return Response.serverError().build();
}
}
示例4: registered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void registered(final SchedulerDriver schedulerDriver, final Protos.FrameworkID frameworkID, final Protos.MasterInfo masterInfo) {
log.info("call registered");
frameworkIDService.save(frameworkID.getValue());
taskScheduler.expireAllLeases();
MesosStateService.register(masterInfo.getHostname(), masterInfo.getPort());
}
示例5: LocalSchedulerDriver
import org.apache.mesos.Protos; //导入方法依赖的package包/类
LocalSchedulerDriver(Scheduler scheduler,
Protos.FrameworkInfo frameworkInfo,
String mesosMaster)
throws InvalidProtocolBufferException {
LOG.info("{} starting", this.getClass().getName());
LOG.warn("Currently this is just a mock to test HTTP server and clients. No jobs will be executed.");
/*
assertNotNull(scheduler);
assertNotNull(frameworkInfo);
assertNotNull(frameworkInfo.getId());
assertNotNull(frameworkInfo.getName());
assertNotNull(mesosMaster);
*/
this.scheduler = scheduler;
Protos.FrameworkID frameworkID = Protos.FrameworkID.newBuilder()
.setValue(UUID.randomUUID().toString())
.build();
this.frameworkInfo = frameworkInfo.toBuilder()
.setId(frameworkID)
.build();
System.err.println(mesosMaster);
String[] master = mesosMaster.split(":");
this.masterInfo = Protos.MasterInfo.newBuilder()
.setHostname(master[0])
.setPort(Integer.parseInt(master[1]))
.setId("mesosMaster")
.setIp(10)
.build();
declined = new ArrayList<>();
accepted = new ArrayList<>();
tasks = new ArrayList<>();
}
示例6: registered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void registered(SchedulerDriver driver, final Protos.FrameworkID frameworkId, final Protos.MasterInfo masterInfo) {
runAsync(new Runnable() {
@Override
public void run() {
MesosResourceManager.this.registered(new Registered(frameworkId, masterInfo));
}
});
}
示例7: registered0
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private void registered0(SchedulerDriver driver, Protos.FrameworkID frameworkId, Protos.MasterInfo masterInfo) throws IOException {
if (!validMesosVersion(masterInfo.getVersion())) {
// TODO: if the master is in maintenance period, Retz does not abort but sleep and retry later?
driver.abort();
return;
}
String newMaster = new StringBuilder()
.append(masterInfo.getHostname())
.append(":")
.append(masterInfo.getPort())
.toString();
LOG.info("Connected to master {} version={}; Framework ID: {}",
newMaster, masterInfo.getVersion(), frameworkId.getValue());
this.master = Optional.of(newMaster);
StatusCache.updateMaster(newMaster);
frameworkInfo = frameworkInfo.toBuilder().setId(frameworkId).build();
Optional<String> oldFrameworkId = Database.getInstance().getFrameworkId();
if (oldFrameworkId.isPresent()) {
if (oldFrameworkId.get().equals(frameworkId.getValue())) {
// framework exists. nothing to do
LOG.info("Framework id={} existed in past. Recovering any running jobs...", frameworkId.getValue());
reconcileAllRunningJobs(driver);
} else {
LOG.error("Old different framework ({}) exists (!= {}). Quitting",
oldFrameworkId.get(), frameworkId.getValue());
driver.stop();
}
} else {
if (!Database.getInstance().setFrameworkId(frameworkId.getValue())) {
LOG.warn("Failed to remember frameworkID...");
}
}
}
示例8: buildOffer
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static Protos.Offer buildOffer(Protos.FrameworkID fid, int slaveNo, String offerId, int cpus, int mem) {
String hostname = "127.0.0." + slaveNo + ":5051";
String slaveId = "slave(" + slaveNo + ")@" + hostname;
Protos.Offer.Builder builder = Protos.Offer.newBuilder()
.addAllResources(ResourceConstructor.construct(cpus, mem))
.setSlaveId(Protos.SlaveID.newBuilder()
.setValue(slaveId)
.build())
.setFrameworkId(fid)
.setHostname(hostname)
.setId(Protos.OfferID.newBuilder().setValue(offerId).build());
return builder.build();
}
示例9: MesosSchedulerDummyDriver
import org.apache.mesos.Protos; //导入方法依赖的package包/类
MesosSchedulerDummyDriver(Scheduler scheduler,
Protos.FrameworkInfo frameworkInfo,
String mesosMaster)
throws InvalidProtocolBufferException {
assertNotNull(scheduler);
assertNotNull(frameworkInfo);
assertNotNull(frameworkInfo.getId());
assertNotNull(frameworkInfo.getName());
assertNotNull(mesosMaster);
this.scheduler = scheduler;
Protos.FrameworkID frameworkID = Protos.FrameworkID.newBuilder()
.setValue(UUID.randomUUID().toString())
.build();
this.frameworkInfo = frameworkInfo.toBuilder()
.setId(frameworkID)
.build();
System.err.println(mesosMaster);
String[] master = mesosMaster.split(":");
assertThat(master.length, is(2));
this.masterInfo = Protos.MasterInfo.newBuilder()
.setHostname(master[0])
.setPort(Integer.parseInt(master[1]))
.setId("mesosMaster")
.setIp(10)
.build();
declined = new ArrayList<>();
accepted = new ArrayList<>();
tasks = new ArrayList<>();
}
示例10: registered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void registered(SchedulerDriver schedulerDriver, Protos.FrameworkID frameworkID, Protos.MasterInfo masterInfo) {
loggerWrapper.debug("Registered master=" + masterInfo.getIp() + ":" + masterInfo.getPort() +", framework=" + frameworkID);
loggerWrapper.masterInfo = masterInfo;
loggerWrapper.frameworkID = frameworkID;
}
示例11: Registered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public Registered(Protos.FrameworkID frameworkId, Protos.MasterInfo masterInfo) {
requireNonNull(frameworkId);
requireNonNull(masterInfo);
this.frameworkId = frameworkId;
this.masterInfo = masterInfo;
}
示例12: testRegistered
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testRegistered() throws Exception {
scheduler.registered(driver, frameworkId, masterInfo);
final Protos.FrameworkID frameworkID = stateStore.fetchFrameworkId().get();
assertEquals(frameworkID, this.frameworkId);
Collection<? extends Step> allSteps = getAllSteps();
assertEquals(allSteps.toString(), 4, allSteps.size());
assertEquals("Reconciliation", allSteps.iterator().next().getName());
Collection<? extends Step> incompleteSteps = getIncompleteSteps();
assertEquals(incompleteSteps.toString(), 3, incompleteSteps.size());
assertEquals("node-0", incompleteSteps.iterator().next().getName());
assertEquals("node-0", getNextStep().getName());
}
示例13: initialize
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
protected void initialize() throws Exception {
LOG.info("Initializing Mesos resource master");
workerStore.start();
// create the scheduler driver to communicate with Mesos
schedulerCallbackHandler = new SchedulerProxy(self());
// register with Mesos
FrameworkInfo.Builder frameworkInfo = mesosConfig.frameworkInfo()
.clone()
.setCheckpoint(true);
Option<Protos.FrameworkID> frameworkID = workerStore.getFrameworkID();
if (frameworkID.isEmpty()) {
LOG.info("Registering as new framework.");
}
else {
LOG.info("Recovery scenario: re-registering using framework ID {}.", frameworkID.get().getValue());
frameworkInfo.setId(frameworkID.get());
}
MesosConfiguration initializedMesosConfig = mesosConfig.withFrameworkInfo(frameworkInfo);
MesosConfiguration.logMesosConfig(LOG, initializedMesosConfig);
schedulerDriver = initializedMesosConfig.createDriver(schedulerCallbackHandler, false);
// create supporting actors
connectionMonitor = createConnectionMonitor();
launchCoordinator = createLaunchCoordinator();
reconciliationCoordinator = createReconciliationCoordinator();
taskRouter = createTaskRouter();
recoverWorkers();
connectionMonitor.tell(new ConnectionMonitor.Start(), self());
schedulerDriver.start();
}
示例14: getFrameworkInfo
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.FrameworkInfo getFrameworkInfo(ServiceSpec serviceSpec, StateStore stateStore) {
Protos.FrameworkInfo.Builder fwkInfoBuilder = Protos.FrameworkInfo.newBuilder()
.setName(serviceSpec.getName())
.setPrincipal(serviceSpec.getPrincipal())
.setFailoverTimeout(TWO_WEEK_SEC)
.setUser(serviceSpec.getUser())
.setCheckpoint(true);
setRoles(fwkInfoBuilder, serviceSpec);
// The framework ID is not available when we're being started for the first time.
Optional<Protos.FrameworkID> optionalFrameworkId = stateStore.fetchFrameworkId();
optionalFrameworkId.ifPresent(fwkInfoBuilder::setId);
if (!StringUtils.isEmpty(serviceSpec.getWebUrl())) {
fwkInfoBuilder.setWebuiUrl(serviceSpec.getWebUrl());
}
if (Capabilities.getInstance().supportsGpuResource()
&& PodSpecsCannotUseUnsupportedFeatures.serviceRequestsGpuResources(serviceSpec)) {
fwkInfoBuilder.addCapabilities(Protos.FrameworkInfo.Capability.newBuilder()
.setType(Protos.FrameworkInfo.Capability.Type.GPU_RESOURCES));
}
if (Capabilities.getInstance().supportsPreReservedResources()) {
fwkInfoBuilder.addCapabilities(Protos.FrameworkInfo.Capability.newBuilder()
.setType(Protos.FrameworkInfo.Capability.Type.RESERVATION_REFINEMENT));
}
if (Capabilities.getInstance().supportsRegionAwareness()) {
fwkInfoBuilder.addCapabilities(Protos.FrameworkInfo.Capability.newBuilder()
.setType(Protos.FrameworkInfo.Capability.Type.REGION_AWARE));
}
return fwkInfoBuilder.build();
}
示例15: setFrameworkID
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void setFrameworkID(Option<Protos.FrameworkID> frameworkID) throws Exception {
this.frameworkID = frameworkID;
}