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

The following examples show how to use org.apache.mesos.v1.Protos#Credential . 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: CommandLineDriverSettingsModule.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
private static Optional<Protos.Credential> getCredentials(Options opts) {
  if (opts.frameworkAuthenticationFile == null) {
    return Optional.empty();
  } else {
    Properties properties;
    try {
      properties = parseCredentials(new FileInputStream(opts.frameworkAuthenticationFile));
    } catch (FileNotFoundException e) {
      LOG.error("Authentication File not Found");
      throw new RuntimeException(e);
    }

    LOG.info(
        "Connecting to master using authentication (principal: {}).",
        properties.get(Options.PRINCIPAL_KEY));

    return Optional.of(Protos.Credential.newBuilder()
        .setPrincipal(properties.getProperty(Options.PRINCIPAL_KEY))
        .setSecret(properties.getProperty(Options.SECRET_KEY))
        .build());
  }
}
 
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: CommandLineDriverSettingsModule.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
  Optional<Protos.Credential> credentials = getCredentials(options);
  Optional<String> principal = Optional.empty();
  if (options.frameworkAnnouncePrincipal && credentials.isPresent()) {
    principal = Optional.of(credentials.get().getPrincipal());
  }
  Optional<String> role = Optional.ofNullable(options.mesosRole);
  DriverSettings settings = new DriverSettings(options.mesosMasterAddress, credentials);
  bind(DriverSettings.class).toInstance(settings);

  FrameworkInfo base =
      buildFrameworkInfo(
          options.frameworkName,
          options.executorUser,
          principal,
          options.frameworkFailoverTimeout,
          options.receiveRevocableResources,
          allowGpuResource,
          options.isPartitionAware,
          role);
  bind(FrameworkInfo.class)
      .annotatedWith(FrameworkInfoFactory.FrameworkInfoFactoryImpl.BaseFrameworkInfo.class)
      .toInstance(base);
  bind(FrameworkInfoFactory.class).to(FrameworkInfoFactory.FrameworkInfoFactoryImpl.class);
  bind(FrameworkInfoFactory.FrameworkInfoFactoryImpl.class).in(Singleton.class);

}
 
Example 4
Source File: DriverSettings.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
public DriverSettings(
    String masterUri,
    Optional<Protos.Credential> credentials) {

  this.masterUri = requireNonNull(masterUri);
  this.credentials = requireNonNull(credentials);
}
 
Example 5
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 6
Source File: DriverSettings.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
public Optional<Protos.Credential> getCredentials() {
  return credentials;
}
 
Example 7
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 8
Source File: ProtosConversion.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
public static org.apache.mesos.Protos.Credential convert(Protos.Credential f) {
  return convert(f, org.apache.mesos.Protos.Credential.newBuilder());
}
 
Example 9
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);