use of org.apache.mesos.Protos.FrameworkInfo.Builder in project incubator-myriad by apache.
the class MesosModule method providesSchedulerDriver.
@Provides
@Singleton
SchedulerDriver providesSchedulerDriver(MyriadScheduler scheduler, MyriadConfiguration cfg, SchedulerState schedulerState) {
Builder frameworkInfoBuilder = FrameworkInfo.newBuilder().setUser("").setName(cfg.getFrameworkName()).setCheckpoint(cfg.isCheckpoint()).setFailoverTimeout(cfg.getFrameworkFailoverTimeout());
frameworkInfoBuilder.setRole(cfg.getFrameworkRole());
Optional<FrameworkID> optFrameId = schedulerState.getFrameworkID();
if (optFrameId.isPresent()) {
FrameworkID frameworkId = optFrameId.get();
LOGGER.info("Attempting to re-register with frameworkId: {}", frameworkId.getValue());
frameworkInfoBuilder.setId(frameworkId);
}
String mesosAuthenticationPrincipal = cfg.getMesosAuthenticationPrincipal();
String mesosAuthenticationSecretFilename = cfg.getMesosAuthenticationSecretFilename();
if (StringUtils.isNotEmpty(mesosAuthenticationPrincipal)) {
frameworkInfoBuilder.setPrincipal(mesosAuthenticationPrincipal);
Credential.Builder credentialBuilder = Credential.newBuilder();
credentialBuilder.setPrincipal(mesosAuthenticationPrincipal);
if (StringUtils.isNotEmpty(mesosAuthenticationSecretFilename)) {
try {
credentialBuilder.setSecretBytes(ByteString.readFrom(new FileInputStream(mesosAuthenticationSecretFilename)));
} catch (FileNotFoundException ex) {
LOGGER.error("Mesos authentication secret file was not found", ex);
throw new RuntimeException(ex);
} catch (IOException ex) {
LOGGER.error("Error reading Mesos authentication secret file", ex);
throw new RuntimeException(ex);
}
}
return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster(), credentialBuilder.build());
} else {
return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster());
}
}
Aggregations