org.apache.reef.tang.exceptions.InjectionException Java Examples

The following examples show how to use org.apache.reef.tang.exceptions.InjectionException. 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: DriverFailOnFailTest.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void testDriverFailOnFail() throws BindException, InjectionException {

  final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();

  final Configuration driverConfig = DriverConfiguration.CONF
      .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(this.getClass()))
      .set(DriverConfiguration.DRIVER_IDENTIFIER, "Fail2")
      .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, DriverFailOnFail.AllocatedEvaluatorHandler.class)
      .set(DriverConfiguration.ON_TASK_FAILED, DriverFailOnFail.FailedTaskHandler.class)
      .set(DriverConfiguration.ON_DRIVER_STARTED, DriverFailOnFail.StartHandler.class)
      .build();

  TestUtils.assertLauncherFailure(
      TestDriverLauncher.getLauncher(runtimeConfiguration).run(
          driverConfig, this.testEnvironment.getTestTimeout()),
      SimulatedDriverFailure.class);
}
 
Example #2
Source File: HelloREEF.java    From reef with Apache License 2.0 6 votes vote down vote up
/**
 * Start Hello REEF job with local runtime.
 * @param args command line parameters.
 * @throws InjectionException configuration error.
 */
public static void main(final String[] args) throws InjectionException, IOException {

  final ClientProtocol.DriverClientConfiguration.Builder builder =
      ClientProtocol.DriverClientConfiguration.newBuilder();
  builder.setJobid("HelloREEF");
  builder.setEnableHttpDriver(false);
  builder.setOperatingSystem(ClientProtocol.DriverClientConfiguration.OS.LINUX);
  builder.setAzbatchRuntime(ClientProtocol.AzureBatchRuntimeParameters.newBuilder()
      .build());
  builder.addGlobalLibraries(EnvironmentUtils.getClassLocation(HelloDriver.class));

  JavaClientLauncher.submit(builder.build(), DRIVER_CONFIG);
  LOG.log(Level.INFO, "REEF job completed");
  ThreadLogger.logThreads(LOG, Level.FINE, "Threads running at the end of HelloREEF:");
}
 
Example #3
Source File: TestHttpConfiguration.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void activeContextStateHandlerTest() throws InjectionException {

  final ReefEventStateManager.ActiveContextStateHandler h =
      this.injector.getInstance(ReefEventStateManager.ActiveContextStateHandler.class);
  Assert.assertNotNull(h);

  final MockActiveContext activityContext = injector.getInstance(MockActiveContext.class);
  h.onNext(activityContext);

  final ReefEventStateManager reefEventStateManager =
      this.injector.getInstance(ReefEventStateManager.class);

  final Map<String, ActiveContext> contexts = reefEventStateManager.getContexts();
  Assert.assertEquals(1, contexts.size());

  for (final ActiveContext context : contexts.values()) {
    Assert.assertEquals(activityContext.getId(), context.getId());
  }
}
 
Example #4
Source File: Launch.java    From reef with Apache License 2.0 6 votes vote down vote up
/**
 * Parse command line arguments and create TANG configuration ready to be submitted to REEF.
 *
 * @param commandLineConf Parsed command line arguments, as passed into main().
 * @return (immutable) TANG Configuration object.
 * @throws BindException      if configuration commandLineInjector fails.
 * @throws InjectionException if configuration commandLineInjector fails.
 */
private static Configuration getClientConfiguration(
    final Configuration commandLineConf, final boolean isLocal) throws BindException, InjectionException {

  final Configuration runtimeConfiguration;

  if (isLocal) {
    LOG.log(Level.FINE, "Running on the local runtime");
    runtimeConfiguration = LocalRuntimeConfiguration.CONF
        .set(LocalRuntimeConfiguration.MAX_NUMBER_OF_EVALUATORS, MAX_NUMBER_OF_EVALUATORS)
        .build();
  } else {
    LOG.log(Level.FINE, "Running on YARN");
    runtimeConfiguration = YarnClientConfiguration.CONF.build();
  }

  return Configurations.merge(runtimeConfiguration, cloneCommandLineConfiguration(commandLineConf));
}
 
Example #5
Source File: TestTang.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoNamedStringArgsBindVolatile() throws BindException,
    InjectionException {
  final JavaConfigurationBuilder cb = tang.newConfigurationBuilder();
  final TwoNamedStringArgs a = tang.newInjector(cb.build()).getInstance(
      TwoNamedStringArgs.class);
  Assert.assertEquals("defaultA", a.a);
  Assert.assertEquals("defaultB", a.b);
  final Injector i = tang.newInjector(cb.build());
  i.bindVolatileParameter(TwoNamedStringArgs.A.class, "not defaultA");
  i.bindVolatileParameter(TwoNamedStringArgs.B.class, "not defaultB");
  Assert.assertEquals("not defaultA",
      i.getInstance(TwoNamedStringArgs.class).a);
  Assert.assertEquals("not defaultB",
      i.getInstance(TwoNamedStringArgs.class).b);

}
 
Example #6
Source File: ResourceManagerTest.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoAllocationsOnFourContainersAvailableInDefaultRack() throws InjectionException {
  // Given
  containerManager = injector.getInstance(ContainerManager.class);
  sendNodeDescriptors();
  resourceManager = new ResourceManager(containerManager, mockResourceAllocationHandler, mockRuntimeStatusHandler,
      JVM_HEAP_SLACK, configurationSerializer, remoteManager,
      filenames, loggingScopeFactory);
  final ResourceRequestEvent request = ResourceRequestEventImpl.newBuilder().setResourceCount(2).setVirtualCores(1)
      .setMemorySize(64).build();
  // When
  resourceManager.onResourceRequest(request);
  // Then
  verify(mockResourceAllocationHandler, times(2)).onNext(any(ResourceAllocationEvent.class));
  verify(mockRuntimeStatusHandler, times(3)).onNext(any(RuntimeStatusEvent.class));
}
 
Example #7
Source File: GroupCommClientImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Inject
private GroupCommClientImpl(@Parameter(SerializedGroupConfigs.class) final Set<String> groupConfigs,
                            final GroupCommNetworkHandler groupCommNetworkHandler,
                            final ConfigurationSerializer configSerializer,
                            final Injector injector) {

  LOG.log(Level.FINEST, "GroupCommHandler-{0}", groupCommNetworkHandler);

  for (final String groupConfigStr : groupConfigs) {
    try {
      final Configuration groupConfig = configSerializer.fromString(groupConfigStr);
      final Injector forkedInjector = injector.forkInjector(groupConfig);

      final CommunicationGroupServiceClient commGroupClient =
          forkedInjector.getInstance(CommunicationGroupServiceClient.class);

      this.communicationGroups.put(commGroupClient.getName(), commGroupClient);

    } catch (final InjectionException | IOException e) {
      throw new RuntimeException("Unable to deserialize operator config", e);
    }
  }
}
 
Example #8
Source File: TestAvroSerializerForHttp.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void driverInfoSerializerInjectionTest() {
  try {
    final DriverInfoSerializer serializer =
        Tang.Factory.getTang().newInjector().getInstance(DriverInfoSerializer.class);
    final ArrayList<AvroReefServiceInfo> services = new ArrayList<>();
    final AvroReefServiceInfo exampleService =
        AvroReefServiceInfo.newBuilder().setServiceName("exampleService").setServiceInfo("serviceInformation")
            .build();
    services.add(exampleService);
    final AvroDriverInfo driverInfo = serializer.toAvro("abc", "xxxxxx", services);
    final String driverInfoString = serializer.toString(driverInfo);
    Assert.assertEquals(driverInfoString, "{\"remoteId\":\"abc\",\"startTime\":\"xxxxxx\"," +
        "\"services\":[{\"serviceName\":\"exampleService\",\"serviceInfo\":\"serviceInformation\"}]}");
  } catch (final InjectionException e) {
    Assert.fail("Not able to inject DriverInfoSerializer");
  }
}
 
Example #9
Source File: TestBindSingleton.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void testIncestuousInterfaceSingletons2() throws BindException,
    InjectionException {
  final Tang t = Tang.Factory.getTang();
  final JavaConfigurationBuilder b = t.newConfigurationBuilder();
  b.bindImplementation(IncestuousInterfaceSingletons.AI.class,
      IncestuousInterfaceSingletons.A.class);
  b.bindImplementation(IncestuousInterfaceSingletons.BI.class,
      IncestuousInterfaceSingletons.B.class);
  // TODO: Should we require bind(A,B), then bind(B,B) if B has subclasses?
  b.bindImplementation(IncestuousInterfaceSingletons.B.class,
      IncestuousInterfaceSingletons.B.class);
  b.bindImplementation(IncestuousInterfaceSingletons.CI.class,
      IncestuousInterfaceSingletons.C.class);
  final Injector i = t.newInjector(b.build());
  i.getInstance(IncestuousInterfaceSingletons.AI.class);
}
 
Example #10
Source File: TestHelloREEFMultiRuntime.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void testHelloREEFMultiRuntime() throws InjectionException {
  if(this.testEnvironment instanceof YarnTestEnvironment){
    // multi runtime can be tested on yarn only
    final Configuration driverConf = DriverConfiguration.CONF
            .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(this.getClass()))
            .set(DriverConfiguration.DRIVER_IDENTIFIER, "TEST_HelloREEFMultiRunitme")
            .set(DriverConfiguration.ON_DRIVER_STARTED, HelloMultiRuntimeDriver.StartHandler.class)
            .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, HelloMultiRuntimeDriver.EvaluatorAllocatedHandler.class)
            .build();

    // create the multi runtime environment
    Configuration multiruntimeConfig = new MultiRuntimeConfigurationBuilder()
            .addRuntime(RuntimeIdentifier.RUNTIME_NAME)
            .addRuntime(org.apache.reef.runtime.local.driver.RuntimeIdentifier.RUNTIME_NAME)
            .setDefaultRuntime(RuntimeIdentifier.RUNTIME_NAME)
            .setMaxEvaluatorsNumberForLocalRuntime(1)
            .setSubmissionRuntime(RuntimeIdentifier.RUNTIME_NAME)
            .build();

    final LauncherStatus state = DriverLauncher.getLauncher(multiruntimeConfig).run(driverConf, this
            .testEnvironment.getTestTimeout());
    Assert.assertTrue("Job state after execution: " + state, state.isSuccess());
  }
}
 
Example #11
Source File: TestInjectionFuture.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void testFutures() throws InjectionException, BindException {
  final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder();
  final Injector i = Tang.Factory.getTang().newInjector(cb.build());
  final Injector i2 = Tang.Factory.getTang().newInjector(cb.build());

  final Futurist f = i.getInstance(Futurist.class);
  Assert.assertTrue(f == f.getMyCar().getDriver());
  Assert.assertTrue(f.getMyCar() == f.getMyCar().getDriver().getMyCar());

  final Futurist f2 = i2.getInstance(Futurist.class);
  Assert.assertTrue(f2 == f2.getMyCar().getDriver());
  Assert.assertTrue(f2.getMyCar() == f2.getMyCar().getDriver().getMyCar());

  Assert.assertTrue(f != f2.getMyCar().getDriver());
  Assert.assertTrue(f.getMyCar() != f2.getMyCar().getDriver().getMyCar());

}
 
Example #12
Source File: TestListInjection.java    From reef with Apache License 2.0 6 votes vote down vote up
/**
 * Test code for injectiong list with ConfigurationModule.
 *
 * @throws InjectionException
 */
@Test
public void testInjectConfigurationModule() throws InjectionException {
  final List<String> injected = new ArrayList<>();
  injected.add("hi");
  injected.add("hello");
  injected.add("bye");
  final Configuration conf = StringClassConfiguration.CONF
      .set(StringClassConfiguration.STRING_LIST, injected)
      .build();
  final List<String> actual = Tang.Factory.getTang().newInjector(conf).getInstance(StringClass.class).getStringList();
  final List<String> expected = new ArrayList<>();
  expected.add("hi");
  expected.add("hello");
  expected.add("bye");
  Assert.assertEquals(expected, actual);
}
 
Example #13
Source File: TestClassLoaders.java    From reef with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoClasses() throws MalformedURLException,
    ClassNotFoundException, BindException, InjectionException {
  final Tang t = Tang.Factory.getTang();
  final JavaConfigurationBuilder cbA = t.newConfigurationBuilder(new File(
      "../tang-test-jarAB/target").listFiles(JAR_FILE_FILTER)[0].toURI()
      .toURL());
  final JavaConfigurationBuilder cbB = t.newConfigurationBuilder(new File(
      "../tang-test-jarAB/target").listFiles(JAR_FILE_FILTER)[0].toURI()
      .toURL());
  cbA.addConfiguration(cbB.build());

  cbA.getClassHierarchy().getNode("org.apache.reef.tang.examples.A");
  cbA.getClassHierarchy().getNode("org.apache.reef.tang.examples.B");

  t.newInjector(cbA.build());
}
 
Example #14
Source File: DataTransferTest.java    From nemo with Apache License 2.0 6 votes vote down vote up
private Injector createNameClientInjector() {
  try {
    final Configuration configuration = TANG.newConfigurationBuilder()
        .bindImplementation(IdentifierFactory.class, StringIdentifierFactory.class)
        .build();
    final Injector injector = TANG.newInjector(configuration);
    final LocalAddressProvider localAddressProvider = injector.getInstance(LocalAddressProvider.class);
    final NameServer nameServer = injector.getInstance(NameServer.class);
    final Configuration nameClientConfiguration = NameResolverConfiguration.CONF
        .set(NameResolverConfiguration.NAME_SERVER_HOSTNAME, localAddressProvider.getLocalAddress())
        .set(NameResolverConfiguration.NAME_SERVICE_PORT, nameServer.getPort())
        .build();
    return injector.forkInjector(nameClientConfiguration);
  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }
}
 
Example #15
Source File: LocalRuntimeDriverConfigurationGenerator.java    From reef with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) throws InjectionException, IOException {
  final File localAppSubmissionParametersFile = new File(args[0]);
  final File jobSubmissionParametersFile = new File(args[1]);

  if (!(jobSubmissionParametersFile.exists() && jobSubmissionParametersFile.canRead())) {
    throw new IOException("Unable to open and read " + jobSubmissionParametersFile.getAbsolutePath());
  }

  if (!(localAppSubmissionParametersFile.exists() && localAppSubmissionParametersFile.canRead())) {
    throw new IOException("Unable to open and read " + localAppSubmissionParametersFile.getAbsolutePath());
  }

  final LocalSubmissionFromCS localSubmission =
      LocalSubmissionFromCS.fromSubmissionParameterFiles(
          jobSubmissionParametersFile, localAppSubmissionParametersFile);

  LOG.log(Level.FINE, "Local driver config generation received from C#: {0}", localSubmission);
  final Configuration localRuntimeConfiguration = localSubmission.getRuntimeConfiguration();
  final LocalRuntimeDriverConfigurationGenerator localConfigurationGenerator = Tang.Factory.getTang()
      .newInjector(localRuntimeConfiguration)
      .getInstance(LocalRuntimeDriverConfigurationGenerator.class);
  localConfigurationGenerator.writeConfiguration(localSubmission.getJobFolder(),
      localSubmission.getJobId(), ClientRemoteIdentifier.NONE);
}
 
Example #16
Source File: Launch.java    From reef with Apache License 2.0 5 votes vote down vote up
private static Configuration cloneCommandLineConfiguration(final Configuration commandLineConf)
    throws InjectionException, BindException {
  final Injector injector = Tang.Factory.getTang().newInjector(commandLineConf);
  final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder();
  cb.bindNamedParameter(Piggyback.class, String.valueOf(injector.getNamedInstance(Piggyback.class)));
  cb.bindNamedParameter(NumEvaluators.class, String.valueOf(injector.getNamedInstance(NumEvaluators.class)));
  cb.bindNamedParameter(NumTasks.class, String.valueOf(injector.getNamedInstance(NumTasks.class)));
  cb.bindNamedParameter(Delay.class, String.valueOf(injector.getNamedInstance(Delay.class)));
  return cb.build();
}
 
Example #17
Source File: TestHttpConfiguration.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void startStateHandlerTest() throws InjectionException {

  final ReefEventStateManager.StartStateHandler h =
      this.injector.getInstance(ReefEventStateManager.StartStateHandler.class);
  Assert.assertNotNull(h);

  final StartTime st = new StartTime(new Date().getTime());
  h.onNext(st);

  final ReefEventStateManager reefEventStateManager =
      this.injector.getInstance(ReefEventStateManager.class);
  Assert.assertEquals(reefEventStateManager.getStartTime(), convertTime(st.getTimestamp()));
}
 
Example #18
Source File: ClientLauncher.java    From reef with Apache License 2.0 5 votes vote down vote up
static LauncherStatus submit(final int port,
    final ClientProtocol.DriverClientConfiguration driverClientConfiguration)
    throws InjectionException {
  final Configuration driverServiceLauncherConfiguration;
  switch (driverClientConfiguration.getRuntimeCase()) {
  case YARN_RUNTIME:
    driverServiceLauncherConfiguration = TANG.newConfigurationBuilder()
        .bindImplementation(DriverServiceConfigurationProvider.class,
            GRPCDriverServiceConfigurationProvider.class)
        .bind(RuntimeConfigurationProvider.class, YarnConfigurationProvider.class)
        .build();
    break;
  case LOCAL_RUNTIME:
    driverServiceLauncherConfiguration = TANG.newConfigurationBuilder()
        .bind(RuntimeConfigurationProvider.class, LocalConfigurationProvider.class)
        .bindImplementation(DriverServiceConfigurationProvider.class,
            GRPCDriverServiceConfigurationProvider.class)
        .build();
    break;
  case AZBATCH_RUNTIME:
    driverServiceLauncherConfiguration = TANG.newConfigurationBuilder()
        .bind(RuntimeConfigurationProvider.class, AzureBatchConfigurationProvider.class)
        .bindImplementation(DriverServiceConfigurationProvider.class,
            GRPCDriverServiceConfigurationProvider.class)
        .build();
    break;
  case HDI_RUNTIME:
    driverServiceLauncherConfiguration = TANG.newConfigurationBuilder()
        .bind(RuntimeConfigurationProvider.class, HDInsightConfigurationProvider.class)
        .bindImplementation(DriverServiceConfigurationProvider.class,
            GRPCDriverServiceConfigurationProvider.class)
        .build();
    break;
  default:
    throw new RuntimeException("unknown runtime " + driverClientConfiguration.getRuntimeCase());
  }
  return TANG.newInjector(driverServiceLauncherConfiguration).getInstance(ClientLauncher.class)
      .launch(port, driverClientConfiguration);
}
 
Example #19
Source File: DefaultVortexMasterTest.java    From reef with Apache License 2.0 5 votes vote down vote up
private VortexFuture createTaskletCancellationFuture(
    final RunningWorkers runningWorkers, final PendingTasklets pendingTasklets) throws InjectionException {
  final VortexFunction vortexFunction = testUtil.newInfiniteLoopFunction();
  final DefaultVortexMaster vortexMaster = new DefaultVortexMaster(
      runningWorkers, pendingTasklets,
      testUtil.newAggregateFunctionRepository(), 5);
  final VortexWorkerManager vortexWorkerManager1 = testUtil.newWorker(vortexMaster);


  // Allocate worker & tasklet and schedule
  vortexMaster.workerAllocated(vortexWorkerManager1);
  return vortexMaster.enqueueTasklet(vortexFunction, null, Optional.<FutureCallback<Integer>>empty());
}
 
Example #20
Source File: TestTang.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void testRepeatedOKArgs() throws BindException, InjectionException {
  final JavaConfigurationBuilder t = tang.newConfigurationBuilder();
  t.bindNamedParameter(RepeatedNamedArgs.A.class, "1");
  t.bindNamedParameter(RepeatedNamedArgs.B.class, "2");
  final Injector injector = tang.newInjector(t.build());
  injector.getInstance(RepeatedNamedArgs.class);
}
 
Example #21
Source File: FileResourceTest.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void testDriverFiles() throws IOException, BindException, InjectionException {

  final Set<File> theFiles = getTempFiles(this.nFiles);
  final Configuration finalDriverConfiguration = Configurations.merge(
      getDriverConfiguration(theFiles), getTestDriverConfiguration(theFiles));

  final LauncherStatus status = DriverLauncher
      .getLauncher(this.testEnvironment.getRuntimeConfiguration())
      .run(finalDriverConfiguration, testEnvironment.getTestTimeout());

  Assert.assertTrue("Job state after execution: " + status, status.isSuccess());
}
 
Example #22
Source File: TestTang.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void testCanOverrideDefaultedInterface() throws BindException, InjectionException {
  final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder();
  cb.bindImplementation(HaveDefaultImpl.class, OverrideDefaultImpl.class);
  Assert.assertTrue(Tang.Factory.getTang().newInjector(cb.build())
      .getInstance(HaveDefaultImpl.class) instanceof OverrideDefaultImpl);
}
 
Example #23
Source File: TestTang.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void testSingletonWithMultipleConstructors() throws BindException, InjectionException {
  final JavaConfigurationBuilder cb = Tang.Factory.getTang().newConfigurationBuilder();
  cb.bindImplementation(SMC.class, SingletonMultiConst.class);
  cb.bindNamedParameter(SingletonMultiConst.A.class, "foo");
  final Injector i = Tang.Factory.getTang().newInjector(cb.build());
  i.getInstance(SMC.class);
}
 
Example #24
Source File: TestTang.java    From reef with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
public void testGenericEventHandlers() throws BindException, InjectionException {
  final JavaConfigurationBuilder cba = Tang.Factory.getTang().newConfigurationBuilder();
  cba.bindNamedParameter(XName.class, (Class) XAA.class);
  Tang.Factory.getTang().newInjector(cba.build()).getNamedInstance(XName.class);
  final JavaConfigurationBuilder cbb = Tang.Factory.getTang().newConfigurationBuilder();
  cbb.bindNamedParameter(XName.class, XBB.class);
  Tang.Factory.getTang().newInjector(cbb.build()).getNamedInstance(XName.class);
  final JavaConfigurationBuilder cbc = Tang.Factory.getTang().newConfigurationBuilder();
  cbc.bindNamedParameter(XName.class, (Class) XCC.class);
  Tang.Factory.getTang().newInjector(cbc.build()).getNamedInstance(XName.class);
}
 
Example #25
Source File: HelloREEFHttp.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Main program.
 *
 * @param args
 * @throws InjectionException
 */
public static void main(final String[] args) throws InjectionException {
  final Configuration runtimeConfiguration = LocalRuntimeConfiguration.CONF
      .set(LocalRuntimeConfiguration.MAX_NUMBER_OF_EVALUATORS, MAX_NUMBER_OF_EVALUATORS)
      .build();
  runHelloReef(runtimeConfiguration, HelloREEFHttp.JOB_TIMEOUT);
}
 
Example #26
Source File: BlockStoreTest.java    From nemo with Apache License 2.0 5 votes vote down vote up
private GlusterFileStore createGlusterFileStore(final String executorId)
    throws InjectionException {
  final LocalMessageEnvironment localMessageEnvironment =
      new LocalMessageEnvironment(executorId, messageDispatcher);
  final Injector injector = Tang.Factory.getTang().newInjector();
  injector.bindVolatileParameter(JobConf.GlusterVolumeDirectory.class, TMP_FILE_DIRECTORY);
  injector.bindVolatileParameter(JobConf.JobId.class, "GFS test");
  injector.bindVolatileParameter(JobConf.ExecutorId.class, executorId);
  injector.bindVolatileInstance(SerializerManager.class, serializerManager);
  injector.bindVolatileInstance(MessageEnvironment.class, localMessageEnvironment);
  return injector.getInstance(GlusterFileStore.class);
}
 
Example #27
Source File: Launch.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Parse command line arguments and create TANG configuration ready to be submitted to REEF.
 *
 * @param args Command line arguments, as passed into main().
 * @return (immutable) TANG Configuration object.
 * @throws BindException      if configuration commandLineInjector fails.
 * @throws InjectionException if configuration commandLineInjector fails.
 * @throws IOException        error reading the configuration.
 */
private static Configuration getClientConfiguration(final String[] args)
    throws BindException, InjectionException, IOException {
  final Configuration commandLineConf = parseCommandLine(args);

  final Configuration clientConfiguration = ClientConfiguration.CONF
      .set(ClientConfiguration.ON_JOB_RUNNING, SuspendClient.RunningJobHandler.class)
      .set(ClientConfiguration.ON_JOB_FAILED, SuspendClient.FailedJobHandler.class)
      .set(ClientConfiguration.ON_JOB_COMPLETED, SuspendClient.CompletedJobHandler.class)
      .set(ClientConfiguration.ON_RUNTIME_ERROR, SuspendClient.RuntimeErrorHandler.class)
      .build();

  final Injector commandLineInjector = Tang.Factory.getTang().newInjector(commandLineConf);
  final boolean isLocal = commandLineInjector.getNamedInstance(Local.class);
  final Configuration runtimeConfiguration;
  if (isLocal) {
    LOG.log(Level.INFO, "Running on the local runtime");
    runtimeConfiguration = LocalRuntimeConfiguration.CONF
        .set(LocalRuntimeConfiguration.MAX_NUMBER_OF_EVALUATORS, MAX_NUMBER_OF_EVALUATORS)
        .build();
  } else {
    LOG.log(Level.INFO, "Running on YARN");
    runtimeConfiguration = YarnClientConfiguration.CONF.build();
  }

  return Configurations.merge(
      runtimeConfiguration, clientConfiguration, cloneCommandLineConfiguration(commandLineConf));
}
 
Example #28
Source File: JobLauncher.java    From nemo with Apache License 2.0 5 votes vote down vote up
/**
 * Get executor resource configuration.
 * @param jobConf job configuration to get executor json path.
 * @return executor resource configuration.
 * @throws InjectionException exception while injection.
 */
public static Configuration getExecutorResourceConf(final Configuration jobConf) throws InjectionException {
  final Injector injector = TANG.newInjector(jobConf);
  try {
    final String path = injector.getNamedInstance(JobConf.ExecutorJsonPath.class);
    final String contents = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8);
    return TANG.newConfigurationBuilder()
        .bindNamedParameter(JobConf.ExecutorJsonContents.class, contents)
        .build();
  } catch (final IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example #29
Source File: FailBridgeDriverTest.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void testDriverCompleted() throws BindException, InjectionException {
  final Configuration runtimeConfiguration = this.testEnvironment.getRuntimeConfiguration();
  // FailDriverTest can be replaced with any other class never used in FailDriver
  final LauncherStatus status = FailClient.runClient(
      FailDriverTest.class, runtimeConfiguration, this.testEnvironment.getTestTimeout());
  Assert.assertEquals(LauncherStatus.COMPLETED, status);
}
 
Example #30
Source File: BridgeClient.java    From reef with Apache License 2.0 5 votes vote down vote up
public static LauncherStatus run(
    final Class<? extends Task> failTaskClass,
    final Configuration runtimeConfig,
    final int timeOut) throws IOException, InjectionException {
  ClientProtocol.DriverClientConfiguration.Builder builder =
      ClientProtocol.DriverClientConfiguration.newBuilder()
          .setJobid("FailBridge_" + failTaskClass.getSimpleName())
          .addGlobalLibraries(EnvironmentUtils.getClassLocation(Driver.class));
  builder.setOperatingSystem(
      OSUtils.isWindows() ?
          ClientProtocol.DriverClientConfiguration.OS.WINDOWS :
          ClientProtocol.DriverClientConfiguration.OS.LINUX);

  return run(failTaskClass, runtimeConfig, builder.build(), timeOut);
}