Java Code Examples for org.apache.mesos.Protos.FrameworkInfo#Builder
The following examples show how to use
org.apache.mesos.Protos.FrameworkInfo#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MesosNimbus.java From storm with Apache License 2.0 | 6 votes |
private FrameworkInfo.Builder createFrameworkBuilder() throws IOException { Number failoverTimeout = Optional.fromNullable((Number) mesosStormConf.get(CONF_MASTER_FAILOVER_TIMEOUT_SECS)).or(24 * 7 * 3600); String role = Optional.fromNullable((String) mesosStormConf.get(CONF_MESOS_ROLE)).or("*"); Boolean checkpoint = Optional.fromNullable((Boolean) mesosStormConf.get(CONF_MESOS_CHECKPOINT)).or(false); String frameworkUser = Optional.fromNullable((String) mesosStormConf.get(CONF_MESOS_FRAMEWORK_USER)).or(""); FrameworkInfo.Builder finfo = FrameworkInfo.newBuilder() .setName(frameworkName) .setFailoverTimeout(failoverTimeout.doubleValue()) .setUser(frameworkUser) .setRole(role) .setCheckpoint(checkpoint); String id = _state.get(FRAMEWORK_ID); if (id != null) { finfo.setId(FrameworkID.newBuilder().setValue(id).build()); } return finfo; }
Example 2
Source File: InternalSchedulerDriver.java From jesos with Apache License 2.0 | 4 votes |
/** * Creates a new driver for the specified scheduler. The master * must be specified as * * zk://host1:port1,host2:port2,.../path * zk://username:password@host1: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)); }
Example 3
Source File: ResourceMesosSchedulerFactory.java From oodt with Apache License 2.0 | 4 votes |
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); } }
Example 4
Source File: HelloWorldMain.java From tutorials with MIT License | 3 votes |
public static void main(String[] args) { String path = System.getProperty("user.dir") + "/target/libraries2-1.0.0-SNAPSHOT.jar"; CommandInfo.URI uri = CommandInfo.URI.newBuilder().setValue(path).setExtract(false).build(); String helloWorldCommand = "java -cp libraries2-1.0.0-SNAPSHOT.jar com.baeldung.mesos.executors.HelloWorldExecutor"; CommandInfo commandInfoHelloWorld = CommandInfo.newBuilder().setValue(helloWorldCommand).addUris(uri) .build(); ExecutorInfo executorHelloWorld = ExecutorInfo.newBuilder() .setExecutorId(Protos.ExecutorID.newBuilder().setValue("HelloWorldExecutor")) .setCommand(commandInfoHelloWorld).setName("Hello World (Java)").setSource("java").build(); FrameworkInfo.Builder frameworkBuilder = FrameworkInfo.newBuilder().setFailoverTimeout(120000) .setUser("") .setName("Hello World Framework (Java)"); frameworkBuilder.setPrincipal("test-framework-java"); MesosSchedulerDriver driver = new MesosSchedulerDriver(new HelloWorldScheduler(executorHelloWorld), frameworkBuilder.build(), args[0]); int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1; // Ensure that the driver process terminates. driver.stop(); System.exit(status); }