Java Code Examples for org.apache.reef.driver.evaluator.AllocatedEvaluator#getId()

The following examples show how to use org.apache.reef.driver.evaluator.AllocatedEvaluator#getId() . 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: InputFormatLoadingService.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public Configuration getServiceConfiguration(final AllocatedEvaluator allocatedEvaluator) {

  try {

    final NumberedSplit<InputSplit> numberedSplit =
        this.evaluatorToPartitionStrategy.getInputSplit(
            allocatedEvaluator.getEvaluatorDescriptor().getNodeDescriptor(),
            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, numberedSplit.getPath())
        .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);
  }
}
 
Example 2
Source File: TaskMessagingDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final AllocatedEvaluator eval) {
  final String taskId = "Task_" + eval.getId();
  LOG.log(Level.INFO, "Submit task: {0}", taskId);

  final Configuration taskConfig = TaskConfiguration.CONF
      .set(TaskConfiguration.IDENTIFIER, taskId)
      .set(TaskConfiguration.TASK, TaskMessagingTask.class)
      .set(TaskConfiguration.ON_MESSAGE, TaskMessagingTask.DriverMessageHandler.class)
      .set(TaskConfiguration.ON_SEND_MESSAGE, TaskMessagingTask.class)
      .build();
  eval.submitTask(taskConfig);
}
 
Example 3
Source File: AllocatedEvaluatorBridge.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * This constructor should only be called by the AllocatedEvaluatorBridgeFactory.
 */
AllocatedEvaluatorBridge(final AllocatedEvaluator allocatedEvaluator,
                         final String serverInfo) {
  this.jallocatedEvaluator = allocatedEvaluator;
  this.evaluatorId = allocatedEvaluator.getId();
  this.nameServerInfo = serverInfo;
}
 
Example 4
Source File: Driver.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final AllocatedEvaluator eval) {

  try {

    taskId = failTaskName + "_" + eval.getId();
    LOG.log(Level.INFO, "Submit task: {0}", taskId);

    final Configuration contextConfig =
        ContextConfiguration.CONF.set(ContextConfiguration.IDENTIFIER, taskId).build();

    ConfigurationModule taskConfig =
        TaskConfiguration.CONF.set(TaskConfiguration.IDENTIFIER, taskId);

    switch (failTaskName) {
    case "FailTask":
      taskConfig = taskConfig.set(TaskConfiguration.TASK, FailTask.class);
      break;
    case "FailTaskCall":
      taskConfig = taskConfig.set(TaskConfiguration.TASK, FailTaskCall.class);
      break;
    case "FailTaskMsg":
      taskConfig = taskConfig
            .set(TaskConfiguration.TASK, FailTaskMsg.class)
            .set(TaskConfiguration.ON_MESSAGE, FailTaskMsg.class);
      break;
    case "FailTaskSuspend":
      taskConfig = taskConfig
            .set(TaskConfiguration.TASK, FailTaskSuspend.class)
            .set(TaskConfiguration.ON_SUSPEND, FailTaskSuspend.class);
      break;
    case "FailTaskStart":
      taskConfig = taskConfig
            .set(TaskConfiguration.TASK, FailTaskStart.class)
            .set(TaskConfiguration.ON_TASK_STARTED, FailTaskStart.class);
      break;
    case "FailTaskStop":
      taskConfig = taskConfig
            .set(TaskConfiguration.TASK, FailTaskStop.class)
            .set(TaskConfiguration.ON_TASK_STOP, FailTaskStop.class)
            .set(TaskConfiguration.ON_CLOSE, FailTaskStop.CloseEventHandler.class);
      break;
    case "FailTaskClose":
      taskConfig = taskConfig
            .set(TaskConfiguration.TASK, FailTaskClose.class)
            .set(TaskConfiguration.ON_CLOSE, FailTaskClose.class);
      break;
    default:
      break;
    }

    eval.submitContextAndTask(contextConfig, taskConfig.build());

  } catch (final BindException ex) {
    LOG.log(Level.WARNING, "Configuration error", ex);
    throw new DriverSideFailure("Configuration error", ex);
  }
}