Java Code Examples for org.apache.mesos.Protos#FrameworkInfo
The following examples show how to use
org.apache.mesos.Protos#FrameworkInfo .
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: SchedulerService.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 6 votes |
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()); }
Example 2
Source File: FrameworkRunnerTest.java From dcos-commons with Apache License 2.0 | 6 votes |
@Test public void testMinimalFrameworkInfoRelaunch() { EnvStore envStore = EnvStore.fromMap(getMinimalMap()); SchedulerConfig schedulerConfig = SchedulerConfig.fromEnvStore(envStore); FrameworkConfig frameworkConfig = FrameworkConfig.fromEnvStore(envStore); FrameworkRunner runner = new FrameworkRunner(schedulerConfig, frameworkConfig, false, false); Protos.FrameworkInfo info = runner.getFrameworkInfo(Optional.of(TestConstants.FRAMEWORK_ID)); Assert.assertEquals("/path/to/test-service", info.getName()); Assert.assertEquals(DcosConstants.DEFAULT_SERVICE_USER, info.getUser()); Assert.assertEquals(1209600, info.getFailoverTimeout(), 0.1); Assert.assertTrue(info.getCheckpoint()); Assert.assertEquals("/path/to/test-service-principal", info.getPrincipal()); Assert.assertEquals(TestConstants.FRAMEWORK_ID, info.getId()); checkRole(Optional.of("path__to__test-service-role"), info); Assert.assertEquals(0, info.getRolesCount()); Assert.assertEquals(0, info.getCapabilitiesCount()); Assert.assertFalse(info.hasWebuiUrl()); }
Example 3
Source File: SingularityExecutor.java From Singularity with Apache License 2.0 | 6 votes |
/** * Invoked once the executor driver has been able to successfully * connect with Mesos. In particular, a scheduler can pass some * data to it's executors through the FrameworkInfo.ExecutorInfo's * data field. */ @Override public void registered( ExecutorDriver executorDriver, Protos.ExecutorInfo executorInfo, Protos.FrameworkInfo frameworkInfo, Protos.SlaveInfo slaveInfo ) { LOG.debug( "Registered {} with Mesos slave {} for framework {}", executorInfo.getExecutorId().getValue(), slaveInfo.getId().getValue(), frameworkInfo.getId().getValue() ); LOG.trace( "Registered {} with Mesos slave {} for framework {}", MesosUtils.formatForLogging(executorInfo), MesosUtils.formatForLogging(slaveInfo), MesosUtils.formatForLogging(frameworkInfo) ); }
Example 4
Source File: IgniteSchedulerSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception If failed. */ @Test public void testIgniteFramework() throws Exception { final String mesosUserValue = "userAAAAA"; final String mesosRoleValue = "role1"; IgniteFramework igniteFramework = new IgniteFramework() { @Override protected String getUser() { return mesosUserValue; } @Override protected String getRole() { return mesosRoleValue; } }; Protos.FrameworkInfo info = igniteFramework.getFrameworkInfo(); String actualUserValue = info.getUser(); String actualRoleValue = info.getRole(); assertEquals(actualUserValue, mesosUserValue); assertEquals(actualRoleValue, mesosRoleValue); }
Example 5
Source File: TaskExecutor.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 5 votes |
@Override public void registered(final ExecutorDriver executorDriver, final Protos.ExecutorInfo executorInfo, final Protos.FrameworkInfo frameworkInfo, final Protos.SlaveInfo slaveInfo) { if (!executorInfo.getData().isEmpty()) { Map<String, String> data = SerializationUtils.deserialize(executorInfo.getData().toByteArray()); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(data.get("event_trace_rdb_driver")); dataSource.setUrl(data.get("event_trace_rdb_url")); dataSource.setPassword(data.get("event_trace_rdb_password")); dataSource.setUsername(data.get("event_trace_rdb_username")); jobEventBus = new JobEventBus(new JobEventRdbConfiguration(dataSource)); } }
Example 6
Source File: FrameworkRunnerTest.java From dcos-commons with Apache License 2.0 | 5 votes |
@Test public void testExhaustiveFrameworkInfo() { Map<String, String> env = getMinimalMap(); env.put("FRAMEWORK_PRINCIPAL", "custom-principal"); env.put("FRAMEWORK_USER", "custom-user"); env.put("FRAMEWORK_PRERESERVED_ROLES", "role1,role2,role3"); env.put("FRAMEWORK_WEB_URL", "custom-url"); EnvStore envStore = EnvStore.fromMap(env); SchedulerConfig schedulerConfig = SchedulerConfig.fromEnvStore(envStore); FrameworkConfig frameworkConfig = FrameworkConfig.fromEnvStore(envStore); when(mockCapabilities.supportsGpuResource()).thenReturn(true); when(mockCapabilities.supportsPreReservedResources()).thenReturn(true); when(mockCapabilities.supportsDomains()).thenReturn(true); when(mockCapabilities.supportsGpuResource()).thenReturn(true); FrameworkRunner runner = new FrameworkRunner(schedulerConfig, frameworkConfig, true, true); Protos.FrameworkInfo info = runner.getFrameworkInfo(Optional.of(TestConstants.FRAMEWORK_ID)); Assert.assertEquals("/path/to/test-service", info.getName()); Assert.assertEquals("custom-user", info.getUser()); Assert.assertEquals(1209600, info.getFailoverTimeout(), 0.1); Assert.assertTrue(info.getCheckpoint()); Assert.assertEquals("custom-principal", info.getPrincipal()); Assert.assertEquals(TestConstants.FRAMEWORK_ID, info.getId()); checkRole(Optional.empty(), info); Assert.assertTrue(info.getRolesList().containsAll(Arrays.asList("path__to__test-service-role", "role1", "role2", "role3"))); Assert.assertEquals(Arrays.asList( getCapability(Protos.FrameworkInfo.Capability.Type.MULTI_ROLE), getCapability(Protos.FrameworkInfo.Capability.Type.GPU_RESOURCES), getCapability(Protos.FrameworkInfo.Capability.Type.RESERVATION_REFINEMENT), getCapability(Protos.FrameworkInfo.Capability.Type.REGION_AWARE)), info.getCapabilitiesList()); Assert.assertEquals("custom-url", info.getWebuiUrl()); }
Example 7
Source File: REEFScheduler.java From reef with Apache License 2.0 | 5 votes |
@Inject REEFScheduler(final REEFEventHandlers reefEventHandlers, final MesosRemoteManager mesosRemoteManager, final REEFExecutors executors, final REEFFileNames fileNames, final EStage<SchedulerDriver> schedulerDriverEStage, final ClasspathProvider classpath, @Parameter(JobIdentifier.class) final String jobIdentifier, @Parameter(MesosMasterIp.class) final String masterIp, @Parameter(MesosSlavePort.class) final int slavePort, @Parameter(JobSubmissionDirectoryPrefix.class) final String jobSubmissionDirectoryPrefix) { this.mesosRemoteManager = mesosRemoteManager; this.reefEventHandlers = reefEventHandlers; this.executors = executors; this.fileNames = fileNames; this.jobSubmissionDirectoryPrefix = jobSubmissionDirectoryPrefix; this.reefTarUri = getReefTarUri(jobIdentifier); this.classpath = classpath; this.schedulerDriverEStage = schedulerDriverEStage; final Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder() .setUser("") .setName(REEF_JOB_NAME_PREFIX + jobIdentifier) .build(); this.mesosMaster = new MesosSchedulerDriver(this, frameworkInfo, masterIp); this.mesosSlavePort = slavePort; }
Example 8
Source File: CassandraExecutor.java From dcos-cassandra-service with Apache License 2.0 | 5 votes |
@Override public void registered(ExecutorDriver driver, Protos.ExecutorInfo executorInfo, Protos.FrameworkInfo frameworkInfo, Protos.SlaveInfo slaveInfo) { cassandraTaskFactory = new CassandraTaskFactory(driver); customExecutor = new CustomExecutor(clusterJobExecutorService, cassandraTaskFactory); }
Example 9
Source File: FrameworkRunnerTest.java From dcos-commons with Apache License 2.0 | 5 votes |
@Test public void testMesosRole_FTFF() { final String SERVICE_ROLE = "path"; final String MESOS_ALLOCATION_ROLE = "path"; Map<String, String> env = getMinimalMap(); env.put("MESOS_ALLOCATION_ROLE", MESOS_ALLOCATION_ROLE); env.put("MARATHON_APP_ENFORCE_GROUP_ROLE", "false"); env.put("ENABLE_ROLE_MIGRATION", "false"); EnvStore envStore = EnvStore.fromMap(env); SchedulerConfig schedulerConfig = SchedulerConfig.fromEnvStore(envStore); FrameworkConfig frameworkConfig = FrameworkConfig.fromEnvStore(envStore); FrameworkRunner runner = new FrameworkRunner(schedulerConfig, frameworkConfig, false, false); Protos.FrameworkInfo info = runner.getFrameworkInfo(Optional.of(TestConstants.FRAMEWORK_ID)); Assert.assertEquals("/path/to/test-service", info.getName()); Assert.assertEquals(DcosConstants.DEFAULT_SERVICE_USER, info.getUser()); Assert.assertEquals(1209600, info.getFailoverTimeout(), 0.1); Assert.assertTrue(info.getCheckpoint()); Assert.assertEquals("/path/to/test-service-principal", info.getPrincipal()); Assert.assertEquals(TestConstants.FRAMEWORK_ID, info.getId()); checkRole(Optional.of(SERVICE_ROLE), info); Assert.assertEquals(0, info.getRolesCount()); Assert.assertEquals(0, info.getCapabilitiesCount()); Assert.assertFalse(info.hasWebuiUrl()); }
Example 10
Source File: FrameworkRunnerTest.java From dcos-commons with Apache License 2.0 | 5 votes |
@Test public void testMesosRole_FFFT() { final String SERVICE_ROLE = "path"; final String MESOS_ALLOCATION_ROLE = "slave_public"; Map<String, String> env = getMinimalMap(); env.put("MESOS_ALLOCATION_ROLE", MESOS_ALLOCATION_ROLE); env.put("MARATHON_APP_ENFORCE_GROUP_ROLE", "false"); env.put("ENABLE_ROLE_MIGRATION", "true"); EnvStore envStore = EnvStore.fromMap(env); SchedulerConfig schedulerConfig = SchedulerConfig.fromEnvStore(envStore); FrameworkConfig frameworkConfig = FrameworkConfig.fromEnvStore(envStore); FrameworkRunner runner = new FrameworkRunner(schedulerConfig, frameworkConfig, false, false); Protos.FrameworkInfo info = runner.getFrameworkInfo(Optional.of(TestConstants.FRAMEWORK_ID)); Assert.assertEquals("/path/to/test-service", info.getName()); Assert.assertEquals(DcosConstants.DEFAULT_SERVICE_USER, info.getUser()); Assert.assertEquals(1209600, info.getFailoverTimeout(), 0.1); Assert.assertTrue(info.getCheckpoint()); Assert.assertEquals("/path/to/test-service-principal", info.getPrincipal()); Assert.assertEquals(TestConstants.FRAMEWORK_ID, info.getId()); Assert.assertTrue(info.getRolesList().containsAll(Arrays.asList(SERVICE_ROLE, "path__to__test-service-role"))); Assert.assertEquals(2, info.getRolesCount()); Assert.assertEquals(1, info.getCapabilitiesCount()); //MULTI_ROLE gets enabled. Assert.assertFalse(info.hasWebuiUrl()); }
Example 11
Source File: FrameworkRunnerTest.java From dcos-commons with Apache License 2.0 | 5 votes |
@Test public void testMesosRole_TTTT() { final String MESOS_ALLOCATION_ROLE = "path"; Map<String, String> env = getMinimalMap(); env.put("MESOS_ALLOCATION_ROLE", MESOS_ALLOCATION_ROLE); env.put("MARATHON_APP_ENFORCE_GROUP_ROLE", "true"); env.put("FRAMEWORK_PRERESERVED_ROLES", "role1,role2,role3"); env.put("ENABLE_ROLE_MIGRATION", "true"); EnvStore envStore = EnvStore.fromMap(env); SchedulerConfig schedulerConfig = SchedulerConfig.fromEnvStore(envStore); FrameworkConfig frameworkConfig = FrameworkConfig.fromEnvStore(envStore); when(mockCapabilities.supportsPreReservedResources()).thenReturn(true); FrameworkRunner runner = new FrameworkRunner(schedulerConfig, frameworkConfig, false, false); Protos.FrameworkInfo info = runner.getFrameworkInfo(Optional.of(TestConstants.FRAMEWORK_ID)); Assert.assertEquals("/path/to/test-service", info.getName()); Assert.assertEquals(DcosConstants.DEFAULT_SERVICE_USER, info.getUser()); Assert.assertEquals(1209600, info.getFailoverTimeout(), 0.1); Assert.assertTrue(info.getCheckpoint()); Assert.assertEquals("/path/to/test-service-principal", info.getPrincipal()); Assert.assertEquals(TestConstants.FRAMEWORK_ID, info.getId()); Assert.assertTrue(info.getRolesList().containsAll(Arrays.asList(MESOS_ALLOCATION_ROLE, "path__to__test-service-role", "role1", "role2", "role3"))); Assert.assertEquals(5, info.getRolesCount()); Assert.assertEquals(2, info.getCapabilitiesCount()); //MULTI_ROLE gets enabled. Assert.assertFalse(info.hasWebuiUrl()); }
Example 12
Source File: FrameworkInfoFactoryTest.java From elasticsearch with Apache License 2.0 | 5 votes |
@Test public void shouldGetBuilder() { FrameworkInfoFactory frameworkInfoFactory = new FrameworkInfoFactory(configuration, frameworkState); Protos.FrameworkInfo frameworkInfo = frameworkInfoFactory.getBuilder().build(); assertTrue(frameworkInfo.getWebuiUrl().contains("http://")); assertTrue(frameworkInfo.getWebuiUrl().contains(Integer.toString(DUMMY_PORT))); assertEquals(DUMMY_FRAMEWORK_ROLE, frameworkInfo.getRole()); }
Example 13
Source File: SimulatedLocalMesosSchedulerDriver.java From titus-control-plane with Apache License 2.0 | 5 votes |
public SimulatedLocalMesosSchedulerDriver(SimulatedCloud simulatedCloud, Protos.FrameworkInfo framework, Scheduler scheduler) { this.simulatedCloud = simulatedCloud; this.framework = framework; this.masterInfo = Protos.MasterInfo.newBuilder() .setHostname("titus.embedded") .setId("titusEmbedded") .setIp(0) .setPort(5050) .build(); this.scheduler = scheduler; }
Example 14
Source File: MesosController.java From twister2 with Apache License 2.0 | 5 votes |
public Protos.FrameworkInfo getFrameworkInfo() { String frameworkName = MesosContext.MesosFrameworkName(config); Protos.FrameworkInfo.Builder builder = Protos.FrameworkInfo.newBuilder(); builder.setFailoverTimeout(120000); builder.setUser(""); builder.setName(frameworkName); return builder.build(); }
Example 15
Source File: StdSchedulerDriverFactory.java From titus-control-plane with Apache License 2.0 | 4 votes |
@Override public SchedulerDriver createDriver(Protos.FrameworkInfo framework, String mesosMaster, Scheduler scheduler) { return new MesosSchedulerDriver(scheduler, framework, mesosMaster); }
Example 16
Source File: HelloWorldExecutor.java From tutorials with MIT License | 4 votes |
@Override public void registered(ExecutorDriver driver, Protos.ExecutorInfo executorInfo, Protos.FrameworkInfo frameworkInfo, Protos.SlaveInfo slaveInfo) { }
Example 17
Source File: FrameworkRunner.java From dcos-commons with Apache License 2.0 | 4 votes |
/** * Registers the framework with Mesos and starts running the framework. * This function should never return. */ public void registerAndRunFramework(Persister persister, MesosEventClient mesosEventClient) { // During uninstall, the Framework ID is the last thing to be removed (along with the rest of // zk). If it's gone and the framework is still in uninstall mode, and that indicates we // previously finished an uninstall and then got restarted before getting pruned from Marathon. // If we tried to register again, it would be with an unset framework id, which would in turn // result in us registering a new framework with Mesos from scratch. We avoid that situation // by instead just running the process in a bare-bones state where it's only serving the // endpoints necessary for Cosmos to remove the process it from Marathon, and where it's not // actually registering with Mesos. if (schedulerConfig.isUninstallEnabled() && !new FrameworkStore(persister).fetchFrameworkId().isPresent()) { LOGGER.info("Not registering with Mesos because uninstall is complete."); try { // Just in case, try to clear any other remaining data from ZK. In practice there shouldn't // be any left? PersisterUtils.clearAllData(persister); } catch (PersisterException e) { throw new IllegalStateException("Unable to clear all data", e); } runSkeletonScheduler(); // The skeleton scheduler should never exit. But just in case...: ProcessExit.exit(ProcessExit.DRIVER_EXITED); } FrameworkStore frameworkStore = new FrameworkStore(persister); FrameworkScheduler frameworkScheduler = new FrameworkScheduler( getResourceRoles(), schedulerConfig, persister, frameworkStore, mesosEventClient); // Notify the framework that it can start accepting offers. // This is to avoid the following scenario: // - We accept an offer/launch a task // - The task has config templates to be retrieved from the scheduler HTTP service... // - ... but the scheduler hasn't finishing launching its HTTP service ApiServer httpServer = ApiServer.start( EndpointUtils.toSchedulerAutoIpHostname( frameworkConfig.getFrameworkName(), schedulerConfig ), schedulerConfig, mesosEventClient.getHTTPEndpoints(), frameworkScheduler::setApiServerStarted ); Protos.FrameworkInfo frameworkInfo = getFrameworkInfo(frameworkStore.fetchFrameworkId()); LOGGER.info("Registering framework: {}", TextFormat.shortDebugString(frameworkInfo)); String zkUri = String.format("zk://%s/mesos", frameworkConfig.getZookeeperHostPort()); Protos.Status status = new SchedulerDriverFactory() .create(frameworkScheduler, frameworkInfo, zkUri, schedulerConfig) .run(); LOGGER.info("Scheduler driver exited with status: {}", status); // DRIVER_STOPPED will occur when we call stop(boolean) during uninstall. // When this happens, we want to continue running so that we can advertise that the uninstall // plan is complete. if (status == Protos.Status.DRIVER_STOPPED) { // Following Mesos driver thread exit, attach to the API server thread. // It should run indefinitely. httpServer.join(); } ProcessExit.exit(ProcessExit.DRIVER_EXITED); }
Example 18
Source File: FrameworkRunner.java From dcos-commons with Apache License 2.0 | 4 votes |
@VisibleForTesting Protos.FrameworkInfo getFrameworkInfo(Optional<Protos.FrameworkID> frameworkId) { Protos.FrameworkInfo.Builder fwkInfoBuilder = Protos.FrameworkInfo.newBuilder() .setName(frameworkConfig.getFrameworkName()) .setPrincipal(frameworkConfig.getPrincipal()) .setUser(frameworkConfig.getUser()) .setFailoverTimeout(TWO_WEEK_SEC) .setCheckpoint(true); // The framework ID is not available when we're being started for the first time. frameworkId.ifPresent(fwkInfoBuilder::setId); if (getResourceRoles().size() > 1) { // We have more than one role, set to MULTI_ROLE by default and add all the necessary roles. fwkInfoBuilder.addCapabilitiesBuilder() .setType(Protos.FrameworkInfo.Capability.Type.MULTI_ROLE); fwkInfoBuilder.addAllRoles(getResourceRoles()); } else { fwkInfoBuilder.setRole(frameworkConfig.getRole()); } if (!StringUtils.isEmpty(frameworkConfig.getWebUrl())) { fwkInfoBuilder.setWebuiUrl(frameworkConfig.getWebUrl()); } Capabilities capabilities = Capabilities.getInstance(); if (capabilities.supportsPartitionAwareness()) { //required to receive TASK_GONE_BY_OPERATOR and other messages fwkInfoBuilder.addCapabilitiesBuilder() .setType(Protos.FrameworkInfo.Capability.Type.PARTITION_AWARE); } if (usingGpus && capabilities.supportsGpuResource()) { fwkInfoBuilder.addCapabilitiesBuilder() .setType(Protos.FrameworkInfo.Capability.Type.GPU_RESOURCES); } if (capabilities.supportsPreReservedResources()) { fwkInfoBuilder.addCapabilitiesBuilder() .setType(Protos.FrameworkInfo.Capability.Type.RESERVATION_REFINEMENT); } // Only enable if opted-in by the developer or user. if (usingRegions && capabilities.supportsDomains()) { fwkInfoBuilder.addCapabilitiesBuilder() .setType(Protos.FrameworkInfo.Capability.Type.REGION_AWARE); } return fwkInfoBuilder.build(); }
Example 19
Source File: MesosWorker.java From twister2 with Apache License 2.0 | 4 votes |
@Override public void registered(ExecutorDriver executorDriver, Protos.ExecutorInfo executorInfo, Protos.FrameworkInfo frameworkInfo, Protos.SlaveInfo slaveInfo) { }
Example 20
Source File: MesosSchedulerDriverFactory.java From titus-control-plane with Apache License 2.0 | votes |
SchedulerDriver createDriver(Protos.FrameworkInfo framework, String mesosMaster, Scheduler scheduler);