本文整理汇总了Java中org.apache.mesos.Protos.FrameworkInfo.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java FrameworkInfo.Builder方法的具体用法?Java FrameworkInfo.Builder怎么用?Java FrameworkInfo.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos.FrameworkInfo
的用法示例。
在下文中一共展示了FrameworkInfo.Builder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFrameworkBuilder
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
private FrameworkInfo.Builder createFrameworkBuilder() throws IOException {
Number failoverTimeout = Optional.fromNullable((Number) _conf.get(CONF_MASTER_FAILOVER_TIMEOUT_SECS)).or(24 * 7 * 3600);
String role = Optional.fromNullable((String) _conf.get(CONF_MESOS_ROLE)).or("*");
Boolean checkpoint = Optional.fromNullable((Boolean) _conf.get(CONF_MESOS_CHECKPOINT)).or(false);
String frameworkName = Optional.fromNullable((String) _conf.get(CONF_MESOS_FRAMEWORK_NAME)).or("Storm!!!");
FrameworkInfo.Builder finfo = FrameworkInfo.newBuilder()
.setName(frameworkName)
.setFailoverTimeout(failoverTimeout.doubleValue())
.setUser("")
.setRole(role)
.setCheckpoint(checkpoint);
String id = _state.get(FRAMEWORK_ID);
if (id != null) {
finfo.setId(FrameworkID.newBuilder().setValue(id).build());
}
return finfo;
}
示例2: run
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
@Override
public void run() {
FrameworkInfo.Builder frameworkInfo = FrameworkInfo.newBuilder()
.setName(hbaseFrameworkConfig.getFrameworkName())
.setFailoverTimeout(hbaseFrameworkConfig.getFailoverTimeout())
.setUser(hbaseFrameworkConfig.getHbaseUser())
.setRole(hbaseFrameworkConfig.getHbaseRole())
.setCheckpoint(true);
try {
FrameworkID frameworkID = persistenceStore.getFrameworkId();
if (frameworkID != null) {
frameworkInfo.setId(frameworkID);
}
} catch (PersistenceException e) {
final String msg = "Error recovering framework id";
log.error(msg, e);
throw new SchedulerException(msg, e);
}
registerFramework(this, frameworkInfo.build(), hbaseFrameworkConfig.getMesosMasterUri());
}
示例3: SingularityDriver
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的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());
}
}
示例4: startUp
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
@Override
protected void startUp() {
Optional<String> frameworkId = storage.read(
storeProvider -> storeProvider.getSchedulerStore().fetchFrameworkId());
LOG.info("Connecting to mesos master: " + driverSettings.getMasterUri());
if (!driverSettings.getCredentials().isPresent()) {
LOG.warn("Connecting to master without authentication!");
}
FrameworkInfo.Builder frameworkBuilder = driverSettings.getFrameworkInfo().toBuilder();
if (frameworkId.isPresent()) {
LOG.info("Found persisted framework ID: " + frameworkId);
frameworkBuilder.setId(FrameworkID.newBuilder().setValue(frameworkId.get()));
} else {
LOG.warn("Did not find a persisted framework ID, connecting as a new framework.");
}
SchedulerDriver schedulerDriver = driverFactory.create(
scheduler,
driverSettings.getCredentials(),
frameworkBuilder.build(),
driverSettings.getMasterUri());
Protos.Status status = schedulerDriver.start();
LOG.info("Driver started with code " + status);
driverFuture.set(schedulerDriver);
}
示例5: getFrameworkInfo
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
public static FrameworkInfo getFrameworkInfo() {
FrameworkInfo.Builder builder = FrameworkInfo.newBuilder();
builder.setFailoverTimeout(5);
builder.setUser("");
builder.setName(FRAMEWORK_NAME);
return builder.build();
}
示例6: initialize
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的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();
}
示例7: getFrameworkInfo
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
private static FrameworkInfo getFrameworkInfo() {
FrameworkInfo.Builder builder = FrameworkInfo.newBuilder();
builder.setFailoverTimeout(120000);
builder.setUser("");
builder.setName(frameworkName);
return builder.build();
}
示例8: main
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
/**
* KibanaFramework entry point
*
* @param args application launch arguments
*/
public static void main(String[] args) {
LOGGER.info("Entering KibanaFramework main().");
LOGGER.info("Setting up the scheduler configuration.");
final SchedulerConfiguration configuration = new SchedulerConfiguration();
try {
configuration.parseLaunchArguments(args); //DCOS-10 Configuration MUST be via CLI parameters or environment variables.
} catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(configuration.getFrameworkName(), configuration.getOptions());
System.exit(1);
}
LOGGER.info("Setting up the Framework.");
FrameworkInfo.Builder framework = FrameworkInfo.newBuilder()
.setName(configuration.getFrameworkName())
.setUser("")
.setCheckpoint(true) //DCOS-04 Scheduler MUST enable checkpointing.
.setFailoverTimeout(ONE_DAY_IN_SECONDS); //DCOS-01 Scheduler MUST register with a failover timeout.
LOGGER.info("Setting up the State.");
State state = new State(configuration.getZookeeper());
configuration.setState(state);
FrameworkID frameworkId = state.getFrameworkId();
if(frameworkId != null){
framework.setId(frameworkId); //DCOS-02 Scheduler MUST persist their FrameworkID for failover.
}
LOGGER.info("Setting up the Scheduler");
final Scheduler scheduler = new KibanaScheduler(configuration);
final MesosSchedulerDriver schedulerDriver = new MesosSchedulerDriver(scheduler, framework.build(), configuration.getZookeeper());
LOGGER.info("Setting up the Spring Web API");
HashMap<String, Object> properties = new HashMap<>();
properties.put("server.port", configuration.getApiPort());
new SpringApplicationBuilder(KibanaFrameworkService.class)
.banner(getBanner())
.properties(properties)
.initializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {
@Override
public void initialize(ConfigurableApplicationContext context) {
context.getBeanFactory().registerSingleton("configuration", configuration);
}
})
.run();
int status = schedulerDriver.run() == Status.DRIVER_STOPPED ? 0 : 1;
schedulerDriver.stop();
System.exit(status);
}
示例9: InternalSchedulerDriver
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
/**
* Creates a new driver for the specified scheduler. The master
* must be specified as
*
* zk://host1:port1,host2:port2,.../path
* zk://username:[email protected]:port1,host2:port2,.../path
*
* The driver will attempt to "failover" if the specified
* FrameworkInfo includes a valid FrameworkID.
*/
protected InternalSchedulerDriver(final Scheduler scheduler,
final FrameworkInfo frameworkInfo,
final String master,
boolean implicitAcknowledges,
final Credential credential)
throws IOException
{
this.scheduler = checkNotNull(scheduler, "scheduler is null");
checkNotNull(frameworkInfo, "frameworkInfo is null");
checkNotNull(master, "master is null");
this.implicitAcknowledges = implicitAcknowledges;
this.credential = credential;
checkState(!master.equals("local"), "Java client can not launch a local cluster!");
// TODO - Any volunteers to do the SASL dance?
checkState(this.credential == null, "Credential is not supported yet.");
final FrameworkInfo.Builder frameworkInfoBuilder = FrameworkInfo.newBuilder(frameworkInfo);
if (!frameworkInfo.hasHostname()) {
frameworkInfoBuilder.setHostname(NetworkUtil.findPublicIp());
}
if (!frameworkInfo.hasUser() || "".equals(frameworkInfo.getUser())) {
frameworkInfoBuilder.setUser(System.getProperty("user.name"));
}
context = new SchedulerDriverContext(frameworkInfoBuilder.build());
this.eventBus = new ManagedEventBus("scheduler");
this.localMessageProcessor = new LocalSchedulerMessageProcessor(context, eventBus, implicitAcknowledges);
// Closer closes in reverse registration order.
// Close the callback executor last, so that everything that was still scheduled to be delivered to the framework still has a chance.
this.callbackExecutor = closer.register(CloseableExecutors.decorate(Executors.newScheduledThreadPool(5, new ThreadFactoryBuilder().setDaemon(true).setNameFormat("scheduler-callback-%d").build())));
this.receiver = closer.register(new HttpProtocolReceiver(context.getDriverUPID(), SchedulerMessageEnvelope.class, eventBus));
// The sender is closed before the receiver, so that possible responses are still caught
this.sender = closer.register(new HttpProtocolSender(context.getDriverUPID()));
// Make sure that the event bus is drained next at shutdown.
closer.register(eventBus);
// Close the master detector first. No more master changes required.
this.detector = closer.register(new ZookeeperMasterDetector(master, eventBus));
}
示例10: construct
import org.apache.mesos.Protos.FrameworkInfo; //导入方法依赖的package包/类
public Scheduler construct() {
try {
String uri = System.getProperty("org.apache.oodt.cas.resource.mesos.executor.uri","./oodt-executor.in");
//Framework info
FrameworkInfo.Builder frameworkBuilder = FrameworkInfo.newBuilder()
.setName("OODT Resource Manager Mesos Framework").setUser("")
.setId(FrameworkID.newBuilder().setValue("OODT-Resource Framework").build());
FrameworkInfo framework = frameworkBuilder.build();
ExecutorInfo executor = ExecutorInfo.newBuilder().setExecutorId(ExecutorID.newBuilder().setValue("OODT-Resource").build())
.setCommand(CommandInfo.newBuilder().setValue(new File(uri).getCanonicalPath()).build())
.setName("OODT Resource Manager Executor").build();
SchedulerDriver driver = null;
//Resource manager properties
String batchmgrClassStr = "org.apache.oodt.cas.resource.batchmgr.MesosBatchManagerFactory";
String monitorClassStr = "org.apache.oodt.cas.resource.monitor.MesosMonitorFactory";
String jobQueueClassStr = System.getProperty("resource.jobqueue.factory","org.apache.oodt.cas.resource.jobqueue.JobStackJobQueueFactory");
String ip = System.getProperty("resource.mesos.master.ip","127.0.0.1:5050");
batch = (MesosBatchManager)GenericResourceManagerObjectFactory.getBatchmgrServiceFromFactory(batchmgrClassStr);
mon = GenericResourceManagerObjectFactory.getMonitorServiceFromFactory(monitorClassStr);
queue = GenericResourceManagerObjectFactory.getJobQueueServiceFromFactory(jobQueueClassStr);
batch.setMonitor(mon);
batch.setDriver(driver);
batch.setJobRepository(queue.getJobRepository());
LOG.log(Level.INFO,"Connecting to Mesos Master at: "+ip);
System.out.println("Connecting to Mesos Master at: "+ip);
ResourceMesosScheduler scheduler = new ResourceMesosScheduler(batch, executor, queue, mon);
final MesosSchedulerDriver mesos = new MesosSchedulerDriver(scheduler, framework, ip);
//Anonymous thread to run
new Thread(new Runnable() {
public void run() {
int status = mesos.run() == Status.DRIVER_STOPPED ? 0 : 1;
mesos.stop();
}
}).start();
return scheduler;
} catch(IOException ioe) {
LOG.log(Level.SEVERE,"Exception detected: "+ioe.getMessage());
ioLOG.log(Level.SEVERE, e.getMessage());
throw new RuntimeException(ioe);
}
}