Java Code Examples for org.apache.mesos.v1.Protos#FrameworkInfo

The following examples show how to use org.apache.mesos.v1.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: SchedulerCalls.java    From mesos-rxjava with Apache License 2.0 6 votes vote down vote up
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE}.
 * <p>
 *
 * @param frameworkId               The frameworkId to set on the {@link Protos.FrameworkInfo FrameworkInfo} and
 *                                  {@link Call Call} messages.
 * @param user                      The user to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param frameworkName             The name to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param failoverTimeoutSeconds    The failoverTimeoutSeconds to set on the
 *                                  {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @return An {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE} with the configured
 * {@link Subscribe Subscribe} sub-message.
 */
@NotNull
public static Call subscribe(
    @NotNull final Protos.FrameworkID frameworkId,
    @NotNull final String user,
    @NotNull final String frameworkName,
    final long failoverTimeoutSeconds
) {
    final Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder()
        .setId(frameworkId)
        .setUser(user)
        .setName(frameworkName)
        .setFailoverTimeout(failoverTimeoutSeconds)
        .build();
    return subscribe(frameworkId, frameworkInfo);
}
 
Example 2
Source File: DriverFactoryImpl.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@Override
public SchedulerDriver create(
    Scheduler scheduler,
    Optional<Protos.Credential> credentials,
    Protos.FrameworkInfo frameworkInfo,
    String master) {

  FrameworkInfo convertedFrameworkInfo = convert(frameworkInfo);
  Optional<Credential> convertedCredentials = credentials.map(ProtosConversion::convert);

  if (credentials.isPresent()) {
    return new MesosSchedulerDriver(
        scheduler,
        convertedFrameworkInfo,
        master,
        false, // Disable implicit acknowledgements.
        convertedCredentials.get());
  } else {
    return new MesosSchedulerDriver(
        scheduler,
        convertedFrameworkInfo,
        master,
        false); // Disable implicit acknowledgements.
  }
}
 
Example 3
Source File: CommandLineDriverSettingsModuleTest.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@Test
public void testFrameworkInfoRevocable() {
  Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
      "aurora",
      "user",
      Optional.empty(),
      Amount.of(1L, Time.MINUTES),
      true, // revocable
      false, // allow gpu
      false, // partition aware
      Optional.empty());
  assertEquals("", info.getPrincipal());
  assertEquals(1, info.getCapabilitiesCount());
  assertEquals(REVOCABLE_RESOURCES, info.getCapabilities(0).getType());
  assertFalse(info.hasRole());
}
 
Example 4
Source File: CommandLineDriverSettingsModuleTest.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@Test
public void testFrameworkInfoAllowGpu() {
  Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
      "aurora",
      "user",
      Optional.empty(),
      Amount.of(1L, Time.MINUTES),
      false, // revocable
      true, // allow gpu
      false, // partition aware
      Optional.empty());
  assertEquals("", info.getPrincipal());
  assertEquals(1, info.getCapabilitiesCount());
  assertEquals(GPU_RESOURCES, info.getCapabilities(0).getType());
  assertFalse(info.hasRole());
}
 
Example 5
Source File: CommandLineDriverSettingsModuleTest.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@Test
public void testFrameworkInfoPartitionAware() {
  Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
      "aurora",
      "user",
      Optional.empty(),
      Amount.of(1L, Time.MINUTES),
      false, // revocable
      false, // allow gpu
      true, // partition aware
      Optional.empty());
  assertEquals("", info.getPrincipal());
  assertEquals(1, info.getCapabilitiesCount());
  assertEquals(PARTITION_AWARE, info.getCapabilities(0).getType());
  assertFalse(info.hasRole());
}
 
Example 6
Source File: CommandLineDriverSettingsModuleTest.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
@Test
public void testFrameworkInfoRevocableWithAnnouncedPrincipalAndRole() {
  Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
      "aurora",
      "user",
      Optional.of("auroraprincipal"),
      Amount.of(1L, Time.MINUTES),
      true, // revocable
      true, // allow gpu
      false, // partition aware
      Optional.of(TEST_ROLE));
  assertEquals("auroraprincipal", info.getPrincipal());
  assertEquals(2, info.getCapabilitiesCount());
  assertEquals(REVOCABLE_RESOURCES, info.getCapabilities(0).getType());
  assertEquals(GPU_RESOURCES, info.getCapabilities(1).getType());
  assertTrue(info.hasRole());
  assertEquals(TEST_ROLE, info.getRole());
}
 
Example 7
Source File: SchedulerCalls.java    From mesos-rxjava with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE}.
 * <p>
 *
 * @param frameworkId   The frameworkId to set on the {@link Call Call} messages.
 * @param frameworkInfo The frameworkInfo to set on the {@link Subscribe Subscribe} sub-message.
 * @return An {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE} with the configured
 * {@link Subscribe Subscribe} sub-message.
 */
@NotNull
public static Call subscribe(
    @NotNull final Protos.FrameworkID frameworkId,
    @NotNull final Protos.FrameworkInfo frameworkInfo
) {
    return newBuilder()
        .setFrameworkId(frameworkId)
        .setType(Type.SUBSCRIBE)
        .setSubscribe(
            Subscribe.newBuilder()
                .setFrameworkInfo(frameworkInfo)
        )
        .build();
}
 
Example 8
Source File: FrameworkInfoFactoryImplTest.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Test
public void testHostnameAndURLAdded() {
  expect(service.getAddress()).andReturn(HostAndPort.fromParts("hostname", 80));

  control.replay();
  Protos.FrameworkInfo result = factory.getFrameworkInfo();

  assertEquals(result.getHostname(), "hostname");
  assertEquals(result.getWebuiUrl(), "http://hostname:80");
}
 
Example 9
Source File: CommandLineDriverSettingsModuleTest.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Test
public void testFrameworkInfoNoRevocable() {
  Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
      "aurora",
      "user",
      Optional.empty(),
      Amount.of(1L, Time.MINUTES),
      false, // revocable
      false, // allow gpu
      false, // partition aware
      Optional.empty());
  assertEquals("", info.getPrincipal());
  assertEquals(0, info.getCapabilitiesCount());
  assertFalse(info.hasRole());
}
 
Example 10
Source File: CommandLineDriverSettingsModuleTest.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Test
public void testFrameworkInfoNoRevocableWithAnnouncedPrincipal() {
  Protos.FrameworkInfo info = CommandLineDriverSettingsModule.buildFrameworkInfo(
      "aurora",
      "user",
      Optional.of("auroraprincipal"),
      Amount.of(1L, Time.MINUTES),
      false, // revocable
      false, // allow gpu
      false, // partition aware
      Optional.empty());
  assertEquals("auroraprincipal", info.getPrincipal());
  assertEquals(0, info.getCapabilitiesCount());
  assertFalse(info.hasRole());
}
 
Example 11
Source File: FakeMaster.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Override
public SchedulerDriver create(
    Scheduler scheduler,
    Optional<Protos.Credential> credentials,
    Protos.FrameworkInfo frameworkInfo,
    String master) {

  schedulerFuture.set(scheduler);
  return this;
}
 
Example 12
Source File: DriverFactory.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
SchedulerDriver create(
Scheduler scheduler,
Optional<Protos.Credential> credentials,
Protos.FrameworkInfo frameworkInfo,
String master);
 
Example 13
Source File: ProtosConversion.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
public static org.apache.mesos.Protos.FrameworkInfo convert(Protos.FrameworkInfo f) {
  return convert(f, org.apache.mesos.Protos.FrameworkInfo.newBuilder());
}
 
Example 14
Source File: VersionedDriverFactory.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
Mesos create(
Scheduler scheduler,
Protos.FrameworkInfo frameworkInfo,
String master,
Optional<Protos.Credential> credentials);