/** * @param jobIdentifier * @param remoteIdentifier * @return * @throws BindException * @throws InjectionException */ private synchronized RunningJobImpl newRunningJob(final String jobIdentifier, final String remoteIdentifier) throws BindException, InjectionException { final Injector child = this.injector.forkInjector(); child.bindVolatileParameter(REEFImplementation.DriverRemoteIdentifier.class, remoteIdentifier); child.bindVolatileParameter(DriverIdentifier.class, jobIdentifier); return child.getInstance(RunningJobImpl.class); } }
/** * @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(); }
public final Configuration build() { return this.builder.build(); }
/** * 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); }
/** * 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(); }
/** * 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); } }
public static void main(final String[] args) throws Exception { setupLogging(); Tang.Factory.getTang() .newInjector(UnsafeHDInsightRuntimeConfiguration.fromEnvironment()) .getInstance(HDICLI.class).run(args); }
/** * 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); } } }
@Override public synchronized void onNext(final IdleClock idleClock) { this.driverIdleManager.get().onPotentiallyIdle(IDLE_MESSAGE); } }
/** * Loads the client and resource manager configuration files from disk. */ private Configuration getClockConfiguration() { return Configurations.merge(readConfigurationFromDisk(), getStaticClockConfiguration()); }
public final AbstractDriverRuntimeConfiguration setClientRemoteIdentifier(final String rid) { try { this.builder.bindNamedParameter(ClientRemoteIdentifier.class, rid.toString()); return this; } catch (final BindException e) { throw new RuntimeException(e); } }
protected AbstractDriverRuntimeConfiguration( final Class<? extends ResourceLaunchHandler> resourceLaunchHandlerClass, final Class<? extends ResourceReleaseHandler> resourceReleaseHandlerClass, final Class<? extends ResourceRequestHandler> resourceRequestHandlerClass) { try { this.builder.bind(ResourceLaunchHandler.class, resourceLaunchHandlerClass); this.builder.bind(ResourceReleaseHandler.class, resourceReleaseHandlerClass); this.builder.bind(ResourceRequestHandler.class, resourceRequestHandlerClass); } catch (final BindException e) { throw new RuntimeException(e); } }
public final AbstractDriverRuntimeConfiguration addClientConfiguration(final Configuration conf) { try { this.builder.addConfiguration(conf); return this; } catch (final BindException e) { throw new RuntimeException(e); } }
/** * 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 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); } } }
private synchronized EventHandler<Void> getClientCloseDispatcher() { if (clientCloseDispatcher != null) { return clientCloseDispatcher; } else { synchronized (this) { if (clientCloseDispatcher == null) clientCloseDispatcher = new BroadCastEventHandler<>(clientCloseHandlers.get()); } return clientCloseDispatcher; } }
private EventHandler<byte[]> getClientMessageDispatcher() { if (clientMessageDispatcher != null) { return clientMessageDispatcher; } else { synchronized (this) { if (clientMessageDispatcher == null) clientMessageDispatcher = new BroadCastEventHandler<>(clientMessageHandlers.get()); } return clientMessageDispatcher; } }
private EventHandler<byte[]> getClientCloseWithMessageDispatcher() { if (clientCloseWithMessageDispatcher != null) { return clientCloseWithMessageDispatcher; } else { synchronized (this) { if (clientCloseWithMessageDispatcher == null) clientCloseWithMessageDispatcher = new BroadCastEventHandler<>(clientCloseWithMessageHandlers.get()); } return clientCloseWithMessageDispatcher; } }
@Override public IdleMessage getIdleStatus() { if (this.evaluators.get().allEvaluatorsAreClosed()) { return IDLE_MESSAGE; } else { return NOT_IDLE_MESSAGE; } }