.setJobIdentifier(t.getIdentifier()).build(); final Configuration driverConfiguration = Tang.Factory.getTang() .newConfigurationBuilder(driverConfigurationPart1, driverConfigurationPart2).build(); final File runtimeConfigurationFile = new File(driverFolder, this.filenames.getDriverConfigurationPath());
Tang.Factory.getTang().newConfigurationBuilder(driverConfiguration);
Injector injector = null; try { injector = Tang.Factory.getTang().newInjector(processCommandLine(args)); } catch (final BindException | IOException | InjectionException e) { fail("Error in parsing the command line", e);
@Override public Configuration getServiceConfiguration(final AllocatedEvaluator allocatedEvaluator) { try { final NumberedSplit<InputSplit> numberedSplit = this.evaluatorToPartitionMapper.getInputSplit( allocatedEvaluator.getEvaluatorDescriptor().getNodeDescriptor().getName(), allocatedEvaluator.getId()); final Configuration serviceConfiguration = ServiceConfiguration.CONF .set(ServiceConfiguration.SERVICES, this.inMemory ? InMemoryInputFormatDataSet.class : InputFormatDataSet.class) .build(); return Tang.Factory.getTang().newConfigurationBuilder(serviceConfiguration) .bindImplementation( DataSet.class, this.inMemory ? InMemoryInputFormatDataSet.class : InputFormatDataSet.class) .bindNamedParameter(JobConfExternalConstructor.InputFormatClass.class, inputFormatClass) .bindNamedParameter(JobConfExternalConstructor.InputPath.class, inputPath) .bindNamedParameter( InputSplitExternalConstructor.SerializedInputSplit.class, WritableSerializer.serialize(numberedSplit.getEntry())) .bindConstructor(InputSplit.class, InputSplitExternalConstructor.class) .bindConstructor(JobConf.class, JobConfExternalConstructor.class) .build(); } catch (final BindException ex) { final String evalId = allocatedEvaluator.getId(); final String msg = "Unable to create configuration for evaluator " + evalId; LOG.log(Level.WARNING, msg, ex); throw new RuntimeException(msg, ex); } }
final Injector injector = Tang.Factory.getTang().newInjector(driverConfiguration);
/** * Parse command line options of the launcher. * * @param args Command line as passed into main(). * @return TANG configuration object. */ private static Configuration processCommandLine( final String[] args) throws BindException, IOException, InjectionException { final JavaConfigurationBuilder commandLineBuilder = Tang.Factory.getTang().newConfigurationBuilder(); new CommandLine(commandLineBuilder) .registerShortNameOfClass(ClockConfigurationPath.class) .registerShortNameOfClass(ErrorHandlerRID.class) .registerShortNameOfClass(LaunchID.class) .processCommandLine(args); return commandLineBuilder // Bind the wake error handler .bindNamedParameter(RemoteConfiguration.ErrorHandler.class, REEFErrorHandler.class) .bindNamedParameter(RemoteConfiguration.ManagerName.class, "REEF_LAUNCHER") // Bind the wake codec .bindNamedParameter(RemoteConfiguration.MessageCodec.class, REEFMessageCodec.class) .build(); }
/** * Instantiates the clock. * * @return a clock object. */ private Clock getClock() { try { final Injector clockInjector = Tang.Factory.getTang().newInjector(this.getClockConfiguration()); if (isProfilingEnabled) { clockInjector.bindAspect(profiler); } clockInjector.bindVolatileInstance(RemoteManager.class, this.remoteManager); return clockInjector.getInstance(Clock.class); } catch (final Throwable ex) { fail("Unable to instantiate the clock", ex); throw new RuntimeException("Unable to instantiate the clock", ex); } }
/** * Instantiate a launcher for the given Configuration. * * @param runtimeConfiguration the resourcemanager configuration to be used * @return a DriverLauncher based on the given resourcemanager configuration * @throws BindException on configuration errors * @throws InjectionException on configuration errors */ public static DriverLauncher getLauncher( final Configuration runtimeConfiguration) throws BindException, InjectionException { final Configuration clientConfiguration = ClientConfiguration.CONF .set(ClientConfiguration.ON_JOB_RUNNING, RunningJobHandler.class) .set(ClientConfiguration.ON_JOB_COMPLETED, CompletedJobHandler.class) .set(ClientConfiguration.ON_JOB_FAILED, FailedJobHandler.class) .set(ClientConfiguration.ON_RUNTIME_ERROR, RuntimeErrorHandler.class) .build(); return Tang.Factory.getTang() .newInjector(runtimeConfiguration, clientConfiguration) .getInstance(DriverLauncher.class); }
/** * Write Evaluator info as JSON format to HTTP Response. */ private void writeEvaluatorInfoJsonOutput( final HttpServletResponse response, final List<String> ids) throws IOException { try { final EvaluatorInfoSerializer serializer = Tang.Factory.getTang().newInjector().getInstance(EvaluatorInfoSerializer.class); final AvroEvaluatorsInfo evaluatorsInfo = serializer.toAvro(ids, this.reefStateManager.getEvaluators()); writeResponse(response, serializer.toString(evaluatorsInfo)); } catch (final InjectionException e) { LOG.log(Level.SEVERE, "Error in injecting EvaluatorInfoSerializer.", e); writeResponse(response, "Error in injecting EvaluatorInfoSerializer: " + e); } }
/** * @return the part of the clock configuration *not* read from disk. */ private Configuration getStaticClockConfiguration() { final JavaConfigurationBuilder builder = Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(LaunchID.class, this.launchID) .bindNamedParameter(ErrorHandlerRID.class, this.errorHandlerID) .bindSetEntry(Clock.StartHandler.class, PIDStoreStartHandler.class) .bindNamedParameter(RemoteConfiguration.ErrorHandler.class, REEFErrorHandler.class) .bindNamedParameter(RemoteConfiguration.ManagerName.class, "REEF_LAUNCHER") .bindNamedParameter(RemoteConfiguration.MessageCodec.class, REEFMessageCodec.class); if (this.isProfilingEnabled) { builder.bindSetEntry(Clock.StopHandler.class, ProfilingStopHandler.class); } return builder.build(); }
/** * Extracts a context id from the given configuration. * * @param c * @return the context id in the given configuration. * @throws RuntimeException if the configuration can't be parsed. */ public static String getIdentifier(final Configuration c) { try { return Tang.Factory.getTang().newInjector(c).getNamedInstance( ContextIdentifier.class); } catch (final InjectionException e) { throw new RuntimeException("Unable to determine context identifier. Giving up.", e); } } }
/** * Assembles the configuration for an Evaluator. * * @param resourceLaunchProto * @return * @throws IOException */ private Configuration makeEvaluatorConfiguration( final DriverRuntimeProtocol.ResourceLaunchProto resourceLaunchProto) throws IOException { return Tang.Factory.getTang() .newConfigurationBuilder(this.configurationSerializer.fromString(resourceLaunchProto.getEvaluatorConf())) .bindImplementation(TempFileCreator.class, WorkingDirectoryTempFileCreator.class) .build(); }
/** * Write Driver Info as JSON string to Response. */ private void writeDriverJsonInformation(final HttpServletResponse response) throws IOException { try { final DriverInfoSerializer serializer = Tang.Factory.getTang().newInjector().getInstance(DriverInfoSerializer.class); final AvroDriverInfo driverInfo = serializer.toAvro( this.reefStateManager.getDriverEndpointIdentifier(), this.reefStateManager.getStartTime(), this.reefStateManager.getServicesInfo()); writeResponse(response, serializer.toString(driverInfo)); } catch (final InjectionException e) { LOG.log(Level.SEVERE, "Error in injecting DriverInfoSerializer.", e); writeResponse(response, "Error in injecting DriverInfoSerializer: " + e); } }
/** * Extracts a task id from the given configuration. * * @param config * @return the task id in the given configuration. * @throws RuntimeException if the configuration can't be parsed. */ public static String getTaskId(final Configuration config) { try { return Tang.Factory.getTang().newInjector(config).getNamedInstance(TaskConfigurationOptions.Identifier.class); } catch (final InjectionException ex) { throw new RuntimeException("Unable to determine task identifier. Giving up.", ex); } } }
/** * Get all evaluator ids and send it back to response as JSON. */ private void writeEvaluatorsJsonOutput(final HttpServletResponse response) throws IOException { LOG.log(Level.INFO, "HttpServerReefEventHandler getEvaluators is called"); try { final EvaluatorListSerializer serializer = Tang.Factory.getTang().newInjector().getInstance(EvaluatorListSerializer.class); final AvroEvaluatorList evaluatorList = serializer.toAvro( this.reefStateManager.getEvaluators(), this.reefStateManager.getEvaluators().size(), this.reefStateManager.getStartTime()); writeResponse(response, serializer.toString(evaluatorList)); } catch (final InjectionException e) { LOG.log(Level.SEVERE, "Error in injecting EvaluatorListSerializer.", e); writeResponse(response, "Error in injecting EvaluatorListSerializer: " + e); } }
public static void main(final String[] args) throws Exception { setupLogging(); Tang.Factory.getTang() .newInjector(UnsafeHDInsightRuntimeConfiguration.fromEnvironment()) .getInstance(HDICLI.class).run(args); }