当前位置: 首页>>代码示例>>Java>>正文


Java FrameworkID类代码示例

本文整理汇总了Java中org.apache.mesos.Protos.FrameworkID的典型用法代码示例。如果您正苦于以下问题:Java FrameworkID类的具体用法?Java FrameworkID怎么用?Java FrameworkID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FrameworkID类属于org.apache.mesos.Protos包,在下文中一共展示了FrameworkID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMocks

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
@Before
public void createMocks() {
  pendingTask = new SingularityPendingTask(new SingularityPendingTaskId("test", "1", 0, 1, PendingType.IMMEDIATE, 0), Optional.<List<String>> absent(),
      Optional.<String> absent(), Optional.<String> absent(), Optional.<Boolean> absent(), Optional.<String> absent());

  final SingularitySlaveAndRackHelper slaveAndRackHelper = mock(SingularitySlaveAndRackHelper.class);
  final ExecutorIdGenerator idGenerator = mock(ExecutorIdGenerator.class);

  when(idGenerator.getNextExecutorId()).then(new CreateFakeId());

  builder = new SingularityMesosTaskBuilder(new ObjectMapper(), slaveAndRackHelper, idGenerator, new SingularityConfiguration());

  taskResources = new Resources(1, 1, 0);
  executorResources = new Resources(0.1, 1, 0);

  offer = Offer.newBuilder()
      .setSlaveId(SlaveID.newBuilder().setValue("1"))
      .setId(OfferID.newBuilder().setValue("1"))
      .setFrameworkId(FrameworkID.newBuilder().setValue("1"))
      .setHostname("test")
      .build();

  when(slaveAndRackHelper.getRackId(offer)).thenReturn(Optional.<String> absent());
  when(slaveAndRackHelper.getMaybeTruncatedHost(offer)).thenReturn("host");
  when(slaveAndRackHelper.getRackIdOrDefault(offer)).thenReturn("DEFAULT");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:27,代码来源:SingularityMesosTaskBuilderTest.java

示例2: createFrameworkBuilder

import org.apache.mesos.Protos.FrameworkID; //导入依赖的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;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:22,代码来源:MesosNimbus.java

示例3: getFrameworkId

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
/**
 * Returns the Framework ID stored in the Zookeeper state.
 *
 * @return the Framework ID stored in the Zookeeper state. Null if no Framework ID was found.
 */
public FrameworkID getFrameworkId() {
    try {
        byte[] existingFrameworkId = state.fetch("frameworkId").get().value();
        if (existingFrameworkId.length > 0) {
            FrameworkID frameworkId = FrameworkID.parseFrom(existingFrameworkId);
            LOGGER.info("Found FrameworkID " + frameworkId.getValue());
            return frameworkId;
        } else {
            LOGGER.info("No existing FrameworkID found");
            return null;
        }
    } catch (InterruptedException | ExecutionException | InvalidProtocolBufferException e) {
        LOGGER.error("Failed to get framework ID from Zookeeper state", e);
        throw new RuntimeException("Failed to get framework ID from Zookeeper state", e);
    }
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:22,代码来源:State.java

示例4: getValidOffers

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
/**
 * Creates given amount of offers with adequate resources
 *
 * @param amount amount of offers to create
 * @return given amount of offers with adequate resources
 */
public static List<Offer> getValidOffers(int amount) {
    List<Offer> offers = new ArrayList<>();
    SchedulerConfiguration config = new SchedulerConfiguration();
    for (int i = 0; i < amount; i++) {
        Offer offer = Offer.newBuilder()
                .setId(OfferID.newBuilder().setValue("valid-offer-" + i).build())
                .setSlaveId(SlaveID.newBuilder().setValue("slave-" + i).build())
                .setFrameworkId(FrameworkID.newBuilder().setValue("kibana").build())
                .setHostname("localhost")
                .addResources(Resources.buildCpuResource(config.getRequiredCpu()))
                .addResources(Resources.buildMemResource(config.getRequiredMem()))
                .addResources(Resources.buildDiskResource(config.getRequiredDisk()))
                .addResources(Resources.buildPortResource(9000, (long) (8999 + SchedulerConfiguration.getRequiredPortCount())))
                .build();
        offers.add(offer);
    }
    return offers;
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:25,代码来源:TestUtils.java

示例5: getInvalidOffers

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
/**
 * Creates given amount of offers with inadequate resources
 *
 * @param amount amount of offers to create
 * @return given amount of offers with inadequate resources
 */
public static List<Offer> getInvalidOffers(int amount) {
    List<Offer> offers = new ArrayList<>();
    SchedulerConfiguration config = new SchedulerConfiguration();
    for (int i = 0; i < amount; i++) {
        Offer offer = Offer.newBuilder()
                .setId(OfferID.newBuilder().setValue("invalid-offer-" + i).build())
                .setSlaveId(SlaveID.newBuilder().setValue("slave-" + i).build())
                .setFrameworkId(FrameworkID.newBuilder().setValue("kibana").build())
                .setHostname("localhost")
                .addResources(Resources.buildCpuResource(config.getRequiredCpu() / 2))
                .addResources(Resources.buildMemResource(config.getRequiredMem() / 2))
                .addResources(Resources.buildDiskResource(config.getRequiredDisk() / 2))
                .build();
        offers.add(offer);
    }
    return offers;
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:24,代码来源:TestUtils.java

示例6: getSchedulerState

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
private SchedulerState getSchedulerState() throws Exception {
  SchedulerState state = new SchedulerState(new MyriadFileSystemRMStateStore());
  idOne = Protos.TaskID.newBuilder().setValue("nt-1").build();
  idTwo = Protos.TaskID.newBuilder().setValue("nt-2").build();
  idThree = Protos.TaskID.newBuilder().setValue("nt-3").build();
  TreeMap<String, Long> ports = new TreeMap<>();

  state.addTask(idOne, new NodeTask(new ServiceResourceProfile("profile1", 0.2, 1024.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));
  state.addTask(idTwo, new NodeTask(new ServiceResourceProfile("profile2", 0.4, 2048.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));
  state.addTask(idThree, new NodeTask(new ServiceResourceProfile("profile3", 0.6, 3072.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));

  state.setFrameworkId(FrameworkID.newBuilder().setValue("mock-framework").build());
  state.makeTaskActive(idOne);
  state.makeTaskPending(idTwo);
  state.makeTaskStaging(idThree);

  return state;
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:19,代码来源:SchedulerStateResourceTest.java

示例7: registered

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
@Override
public void registered(SchedulerDriver driver, FrameworkID frameworkId, MasterInfo masterInfo) {

  try {
    persistenceStore.setFrameworkId(frameworkId);
  } catch (PersistenceException e) {
    // these are zk exceptions... we are unable to maintain state.
    final String msg = "Error setting framework id in persistent state";
    log.error(msg, e);
    throw new SchedulerException(msg, e);
  }
  this.masterInfo = masterInfo;
  log.info("Registered framework frameworkId=" + frameworkId.getValue());
  // reconcile tasks upon registration
  reconcileTasks(driver);
}
 
开发者ID:jan-zajic,项目名称:mesos-hbase,代码行数:17,代码来源:HBaseScheduler.java

示例8: run

import org.apache.mesos.Protos.FrameworkID; //导入依赖的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());
}
 
开发者ID:jan-zajic,项目名称:mesos-hbase,代码行数:23,代码来源:HBaseScheduler.java

示例9: MyriadDriver

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
@Inject
public MyriadDriver(final MyriadScheduler scheduler,
		final MyriadConfiguration cfg, final SchedulerState schedulerState) {
	this.scheduler = scheduler;
	FrameworkID frameworkId = schedulerState.getFrameworkId();
	Builder frameworkInfoBuilder = FrameworkInfo.newBuilder().setUser("")
			.setName(cfg.getFrameworkName())
			.setCheckpoint(cfg.getCheckpoint())
			.setFailoverTimeout(cfg.getFrameworkFailoverTimeout());
	if (frameworkId != null) {
		frameworkInfoBuilder.setId(frameworkId);
	}
	this.myriadFrameworkInfo = frameworkInfoBuilder.build();
	this.driver = new MesosSchedulerDriver(this.scheduler,
			this.myriadFrameworkInfo, cfg.getMesosMaster());
}
 
开发者ID:eBay,项目名称:myriad,代码行数:17,代码来源:MyriadDriver.java

示例10: registered

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
@Override
public void registered(SchedulerDriver driver, FrameworkID frameworkId, MasterInfo masterInfo) {
  lock.lock();

  try {
    scheduler.registered(driver, frameworkId, masterInfo);

    startup(driver, masterInfo);
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:15,代码来源:SingularityMesosSchedulerDelegator.java

示例11: SingularityDriver

import org.apache.mesos.Protos.FrameworkID; //导入依赖的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());
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:38,代码来源:SingularityDriver.java

示例12: createOffer

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
protected Offer createOffer(double cpus, double memory, String slave, String host, Optional<String> rack, Map<String, String> attributes, String[] portRanges) {
  SlaveID slaveId = SlaveID.newBuilder().setValue(slave).build();
  FrameworkID frameworkId = FrameworkID.newBuilder().setValue("framework1").build();

  Random r = new Random();

  List<Attribute> attributesList = new ArrayList<>();
  for (Map.Entry<String, String> entry : attributes.entrySet()) {
    attributesList.add(Attribute.newBuilder()
        .setType(Type.TEXT)
        .setName(entry.getKey())
        .setText(Text.newBuilder().setValue(entry.getValue()).build())
        .build());
  }

  return Offer.newBuilder()
      .setId(OfferID.newBuilder().setValue("offer" + r.nextInt(1000)).build())
      .setFrameworkId(frameworkId)
      .setSlaveId(slaveId)
      .setHostname(host)
      .addAttributes(Attribute.newBuilder().setType(Type.TEXT).setText(Text.newBuilder().setValue(rack.or(configuration.getMesosConfiguration().getDefaultRackId()))).setName(configuration.getMesosConfiguration().getRackIdAttributeKey()))
      .addResources(Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.CPUS).setScalar(Scalar.newBuilder().setValue(cpus)))
      .addResources(Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.MEMORY).setScalar(Scalar.newBuilder().setValue(memory)))
      .addResources(MesosUtilsTest.buildPortRanges(portRanges))
      .addAllAttributes(attributesList)
      .build();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:28,代码来源:SingularitySchedulerTestBase.java

示例13: buildOffer

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
private Offer buildOffer(String... ranges) {
  Offer.Builder offer = Offer.newBuilder()
      .setId(OfferID.newBuilder().setValue("offerid").build())
      .setFrameworkId(FrameworkID.newBuilder().setValue("frameworkid").build())
      .setHostname("hostname")
      .setSlaveId(SlaveID.newBuilder().setValue("slaveid").build());

  offer.addResources(buildPortRanges(ranges));

  return offer.build();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:MesosUtilsTest.java

示例14: registered

import org.apache.mesos.Protos.FrameworkID; //导入依赖的package包/类
@Override
public void registered(
    SchedulerDriver driver,
    final FrameworkID frameworkId,
    MasterInfo masterInfo) {

  log.info("Registered with ID " + frameworkId + ", master: " + masterInfo);

  storage.write(
      (NoResult.Quiet) storeProvider ->
          storeProvider.getSchedulerStore().saveFrameworkId(frameworkId.getValue()));
  isRegistered = true;
  eventSink.post(new DriverRegistered());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:15,代码来源:MesosSchedulerImpl.java

示例15: startUp

import org.apache.mesos.Protos.FrameworkID; //导入依赖的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);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:30,代码来源:SchedulerDriverService.java


注:本文中的org.apache.mesos.Protos.FrameworkID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。