org.apache.reef.tang.annotations.Name Java Examples

The following examples show how to use org.apache.reef.tang.annotations.Name. 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: JavaConfigurationBuilderImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public JavaConfigurationBuilder bindNamedParameter(final Class<? extends Name<?>> name, final String value)
    throws BindException {
  if (value == null) {
    throw new IllegalStateException("The value null set to the named parameter is illegal: " + name);
  }
  final Node np = getNode(name);
  if (np instanceof NamedParameterNode) {
    super.bindParameter((NamedParameterNode<?>) np, value);
    return this;
  } else {
    throw new BindException(
        "Detected type mismatch when setting named parameter " + name
            + "  Expected NamedParameterNode, but namespace contains a " + np);
  }
}
 
Example #2
Source File: GroupCommDriverImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public CommunicationGroupDriver newCommunicationGroup(final Class<? extends Name<String>> groupName,
                                                      final Class<? extends Topology> topologyClass,
                                                      final int numberOfTasks, final int customFanOut) {
  LOG.entering("GroupCommDriverImpl", "newCommunicationGroup",
      new Object[]{Utils.simpleName(groupName), numberOfTasks});

  final CommunicationGroupDriver commGroupDriver;
  try {
    commGroupDriver
        = commGroupDriverFactory.getNewInstance(groupName, topologyClass, numberOfTasks, customFanOut);
  } catch (final InjectionException e) {
    LOG.log(Level.WARNING, "Cannot inject new CommunicationGroupDriver");
    throw new RuntimeException(e);
  }

  commGroupDrivers.put(groupName, commGroupDriver);
  LOG.exiting("GroupCommDriverImpl", "newCommunicationGroup",
      "Created communication group: " + Utils.simpleName(groupName));
  return commGroupDriver;
}
 
Example #3
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public CommunicationGroupDriver addBroadcast(final Class<? extends Name<String>> operatorName,
                                             final BroadcastOperatorSpec spec) {
  LOG.entering("CommunicationGroupDriverImpl", "addBroadcast",
      new Object[]{getQualifiedName(), Utils.simpleName(operatorName), spec});
  if (finalised) {
    throw new IllegalStateException("Can't add more operators to a finalised spec");
  }
  operatorSpecs.put(operatorName, spec);

  final Topology topology;
  try {
    topology = topologyFactory.getNewInstance(operatorName, topologyClass);
  } catch (final InjectionException e) {
    LOG.log(Level.WARNING, "Cannot inject new topology named {0}", operatorName);
    throw new RuntimeException(e);
  }

  topology.setRootTask(spec.getSenderId());
  topology.setOperatorSpecification(spec);
  topologies.put(operatorName, topology);
  LOG.exiting("CommunicationGroupDriverImpl", "addBroadcast",
      Arrays.toString(new Object[]{getQualifiedName(), Utils.simpleName(operatorName), " added"}));
  return this;
}
 
Example #4
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public CommunicationGroupDriver addReduce(final Class<? extends Name<String>> operatorName,
                                          final ReduceOperatorSpec spec) {
  LOG.entering("CommunicationGroupDriverImpl", "addReduce",
      new Object[]{getQualifiedName(), Utils.simpleName(operatorName), spec});
  if (finalised) {
    throw new IllegalStateException("Can't add more operators to a finalised spec");
  }
  LOG.finer(getQualifiedName() + "Adding reduce operator to tree topology: " + spec);
  operatorSpecs.put(operatorName, spec);

  final Topology topology;
  try {
    topology = topologyFactory.getNewInstance(operatorName, topologyClass);
  } catch (final InjectionException e) {
    LOG.log(Level.WARNING, "Cannot inject new topology named {0}", operatorName);
    throw new RuntimeException(e);
  }

  topology.setRootTask(spec.getReceiverId());
  topology.setOperatorSpecification(spec);
  topologies.put(operatorName, topology);
  LOG.exiting("CommunicationGroupDriverImpl", "addReduce",
      Arrays.toString(new Object[]{getQualifiedName(), Utils.simpleName(operatorName), " added"}));
  return this;
}
 
Example #5
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public CommunicationGroupDriver addGather(final Class<? extends Name<String>> operatorName,
                                          final GatherOperatorSpec spec) {
  LOG.entering("CommunicationGroupDriverImpl", "addGather",
      new Object[]{getQualifiedName(), Utils.simpleName(operatorName), spec});
  if (finalised) {
    throw new IllegalStateException("Can't add more operators to a finalised spec");
  }
  operatorSpecs.put(operatorName, spec);

  final Topology topology;
  try {
    topology = topologyFactory.getNewInstance(operatorName, topologyClass);
  } catch (final InjectionException e) {
    LOG.log(Level.WARNING, "Cannot inject new topology named {0}", operatorName);
    throw new RuntimeException(e);
  }

  topology.setRootTask(spec.getReceiverId());
  topology.setOperatorSpecification(spec);
  topologies.put(operatorName, topology);
  LOG.exiting("CommunicationGroupDriverImpl", "addGather",
      Arrays.toString(new Object[]{getQualifiedName(), Utils.simpleName(operatorName), spec}));
  return this;
}
 
Example #6
Source File: JavaConfigurationBuilderImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T> JavaConfigurationBuilder bindSetEntry(
    final Class<? extends Name<Set<T>>> iface, final Class<? extends T> impl) throws BindException {
  final Node n = getNode(iface);
  final Node m = getNode(impl);

  if (!(n instanceof NamedParameterNode)) {
    throw new BindException("BindSetEntry got an interface that resolved to " + n + "; expected a NamedParameter");
  }
  final Type setType = ReflectionUtilities.getInterfaceTarget(Name.class, iface);
  if (!ReflectionUtilities.getRawClass(setType).equals(Set.class)) {
    throw new BindException("BindSetEntry got a NamedParameter that takes a " + setType + "; expected Set<...>");
  }
  final Type valType = ReflectionUtilities.getInterfaceTarget(Set.class, setType);
  if (!ReflectionUtilities.getRawClass(valType).isAssignableFrom(impl)) {
    throw new BindException("BindSetEntry got implementation " + impl +
        " that is incompatible with expected type " + valType);
  }

  super.bindSetEntry((NamedParameterNode<Set<T>>) n, m);
  return this;
}
 
Example #7
Source File: JobLauncher.java    From incubator-nemo with Apache License 2.0 6 votes vote down vote up
/**
 * Read json file and return its contents as configuration parameter.
 *
 * @param jobConf           job configuration to get json path.
 * @param pathParameter     named parameter represents path to the json file, or an empty string
 * @param contentsParameter named parameter represents contents of the file
 * @param defaultContent    the default configuration
 * @return configuration with contents of the file, or an empty string as value for {@code contentsParameter}
 * @throws InjectionException exception while injection.
 */
private static Configuration getJSONConf(final Configuration jobConf,
                                         final Class<? extends Name<String>> pathParameter,
                                         final Class<? extends Name<String>> contentsParameter,
                                         final String defaultContent)
  throws InjectionException {
  final Injector injector = TANG.newInjector(jobConf);
  try {
    final String path = injector.getNamedInstance(pathParameter);
    final String contents = path.isEmpty() ? defaultContent
      : new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8);
    return TANG.newConfigurationBuilder()
      .bindNamedParameter(contentsParameter, contents)
      .build();
  } catch (final IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example #8
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
public void removeTask(final String taskId) {
  LOG.entering("CommunicationGroupDriverImpl", "removeTask", new Object[]{getQualifiedName(), taskId});
  LOG.info(getQualifiedName() + "Removing Task " + taskId +
      " as the evaluator has failed.");
  LOG.finest(getQualifiedName() + "Remove Task(" + taskId +
      "): Waiting to acquire topologiesLock");
  synchronized (topologiesLock) {
    LOG.finest(getQualifiedName() + "Acquired topologiesLock");
    for (final Class<? extends Name<String>> operName : operatorSpecs.keySet()) {
      final Topology topology = topologies.get(operName);
      topology.removeTask(taskId);
    }
    perTaskState.remove(taskId);
    LOG.finest(getQualifiedName() + "Released topologiesLock. Waiting to acquire toBeRemovedLock");
  }
  synchronized (toBeRemovedLock) {
    LOG.finest(getQualifiedName() + "Acquired toBeRemovedLock");
    LOG.finest(getQualifiedName() + "Removed Task " + taskId + " Notifying waiting threads");
    toBeRemovedLock.notifyAll();
    LOG.finest(getQualifiedName() + "Released toBeRemovedLock");
  }
  LOG.fine(getQualifiedName() + "Removed " + taskId + " to topology");
  LOG.exiting("CommunicationGroupDriverImpl", "removeTask",
      Arrays.toString(new Object[]{getQualifiedName(), "Removed task: ", taskId}));
}
 
Example #9
Source File: InjectorImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
<T> void bindVolatileParameterNoCopy(final Class<? extends Name<T>> cl, final T o)
    throws BindException {
  final Node n = javaNamespace.getNode(cl);
  if (n instanceof NamedParameterNode) {
    final NamedParameterNode<?> np = (NamedParameterNode<?>) n;
    final Object old = this.c.getNamedParameter(np);
    if (old != null) {
      // XXX need to get the binding site here!
      throw new BindException(
          "Attempt to re-bind named parameter " + ReflectionUtilities.getFullName(cl) + ".  Old value was [" + old
              + "] new value is [" + o + "]");
    }
    try {
      namedParameterInstances.put(np, o);
    } catch (final IllegalArgumentException e) {
      throw new BindException(
          "Attempt to bind named parameter " + ReflectionUtilities.getFullName(cl) + " failed. "
              + "Value is [" + o + "]", e);

    }
  } else {
    throw new IllegalArgumentException("Expected Name, got " + cl
        + " (probably a class)");
  }
}
 
Example #10
Source File: JavaConfigurationBuilderImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
  @Override
  public <T> JavaConfigurationBuilder bindSetEntry(final Class<? extends Name<Set<T>>> iface, final String value)
      throws BindException {
    final Node n = getNode(iface);

    if (!(n instanceof NamedParameterNode)) {
      throw new BindException("BindSetEntry got an interface that resolved to " + n + "; expected a NamedParameter");
    }
    final Type setType = ReflectionUtilities.getInterfaceTarget(Name.class, iface);
    if (!ReflectionUtilities.getRawClass(setType).equals(Set.class)) {
      throw new BindException("BindSetEntry got a NamedParameter that takes a " + setType + "; expected Set<...>");
    }
//    Type valType = ReflectionUtilities.getInterfaceTarget(Set.class, setType);
    super.bindSetEntry((NamedParameterNode<Set<T>>) n, value);
    return this;
  }
 
Example #11
Source File: CommGroupNetworkHandlerImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public GroupCommunicationMessage waitForTopologyUpdate(final Class<? extends Name<String>> operName) {
  LOG.entering("CommGroupNetworkHandlerImpl", "waitForTopologyUpdate", Utils.simpleName(operName));
  try {
    final GroupCommunicationMessage retVal = topologyNotifications.get(operName).take();
    LOG.exiting("CommGroupNetworkHandlerImpl", "waitForTopologyUpdate", retVal);
    return retVal;
  } catch (final InterruptedException e) {
    throw new RuntimeException("InterruptedException while waiting for topology update of "
        + operName.getSimpleName(), e);
  }
}
 
Example #12
Source File: TaskNodeImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
public TaskNodeImpl(final EStage<GroupCommunicationMessage> senderStage,
                    final Class<? extends Name<String>> groupName,
                    final Class<? extends Name<String>> operatorName,
                    final String taskId, final String driverId, final boolean isRoot) {
  this.senderStage = senderStage;
  this.groupName = groupName;
  this.operName = operatorName;
  this.taskId = taskId;
  this.driverId = driverId;
  this.isRoot = isRoot;
  taskNodeStatus = new TaskNodeStatusImpl(groupName, operatorName, taskId, this);
}
 
Example #13
Source File: CommGroupNetworkHandlerImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] waitForTopologyChanges(final Class<? extends Name<String>> operName) {
  LOG.entering("CommGroupNetworkHandlerImpl", "waitForTopologyChanges", Utils.simpleName(operName));
  try {
    final byte[] retVal = Utils.getData(topologyNotifications.get(operName).take());
    LOG.exiting("CommGroupNetworkHandlerImpl", "waitForTopologyChanges", retVal);
    return retVal;
  } catch (final InterruptedException e) {
    throw new RuntimeException("InterruptedException while waiting for topology update of "
        + operName.getSimpleName(), e);
  }
}
 
Example #14
Source File: CommGroupNetworkHandlerImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final GroupCommunicationMessage msg) {
  LOG.entering("CommGroupNetworkHandlerImpl", "onNext", msg);
  final Class<? extends Name<String>> operName = Utils.getClass(msg.getOperatorname());
  if (msg.getType() == ReefNetworkGroupCommProtos.GroupCommMessage.Type.TopologyUpdated ||
      msg.getType() == ReefNetworkGroupCommProtos.GroupCommMessage.Type.TopologyChanges) {
    topologyNotifications.get(operName).add(msg);
  } else {
    operHandlers.get(operName).onNext(msg);
  }
  LOG.exiting("CommGroupNetworkHandlerImpl", "onNext", msg);
}
 
Example #15
Source File: CommunicationGroupClientImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public Gather.Receiver getGatherReceiver(final Class<? extends Name<String>> operatorName) {
  LOG.entering("CommunicationGroupClientImpl", "getGatherReceiver", new Object[]{getQualifiedName(),
      Utils.simpleName(operatorName)});
  final GroupCommOperator op = operators.get(operatorName);
  if (!(op instanceof Gather.Receiver)) {
    throw new RuntimeException("Configured operator is not a gather receiver");
  }
  commGroupNetworkHandler.addTopologyElement(operatorName);
  LOG.exiting("CommunicationGroupClientImpl", "getGatherReceiver", getQualifiedName() + op);
  return (Gather.Receiver) op;
}
 
Example #16
Source File: GroupCommMessageHandler.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final GroupCommunicationMessage msg) {
  LOG.entering("GroupCommMessageHandler", "onNext", msg);
  final Class<? extends Name<String>> groupName = Utils.getClass(msg.getGroupname());
  commGroupMessageStages.get(groupName).onNext(msg);
  LOG.exiting("GroupCommMessageHandler", "onNext", msg);
}
 
Example #17
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void addTask(final Configuration partialTaskConf) {
  LOG.entering("CommunicationGroupDriverImpl", "addTask",
      new Object[]{getQualifiedName(), confSerializer.toString(partialTaskConf)});
  final String taskId = taskId(partialTaskConf);
  LOG.finest(getQualifiedName() + "AddTask(" + taskId + "). Waiting to acquire toBeRemovedLock");
  synchronized (toBeRemovedLock) {
    LOG.finest(getQualifiedName() + "Acquired toBeRemovedLock");
    while (perTaskState.containsKey(taskId)) {
      LOG.finest(getQualifiedName() + "Trying to add an existing task. Will wait for removeTask");
      try {
        toBeRemovedLock.wait();
      } catch (final InterruptedException e) {
        throw new RuntimeException(getQualifiedName() + "InterruptedException while waiting on toBeRemovedLock", e);
      }
    }
    LOG.finest(getQualifiedName() + "Released toBeRemovedLock. Waiting to acquire topologiesLock");
  }
  synchronized (topologiesLock) {
    LOG.finest(getQualifiedName() + "Acquired topologiesLock");

    boolean isRootOfSomeTopology = false;
    for (final Class<? extends Name<String>> operName : operatorSpecs.keySet()) {
      final Topology topology = topologies.get(operName);
      topology.addTask(taskId);
      isRootOfSomeTopology |= topology.getRootId().equals(taskId);
    }

    if (isRootOfSomeTopology) {
      topologiesLock.notifyAll();
    }

    perTaskState.put(taskId, TaskState.NOT_STARTED);
    LOG.finest(getQualifiedName() + "Released topologiesLock");
  }
  LOG.fine(getQualifiedName() + "Added " + taskId + " to topology");
  LOG.exiting("CommunicationGroupDriverImpl", "addTask",
      Arrays.toString(new Object[]{getQualifiedName(), "Added task: ", taskId}));
}
 
Example #18
Source File: CommunicationGroupClientImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public Scatter.Sender getScatterSender(final Class<? extends Name<String>> operatorName) {
  LOG.entering("CommunicationGroupClientImpl", "getScatterSender", new Object[]{getQualifiedName(),
      Utils.simpleName(operatorName)});
  final GroupCommOperator op = operators.get(operatorName);
  if (!(op instanceof Scatter.Sender)) {
    throw new RuntimeException("Configured operator is not a scatter sender");
  }
  commGroupNetworkHandler.addTopologyElement(operatorName);
  LOG.exiting("CommunicationGroupClientImpl", "getScatterSender", getQualifiedName() + op);
  return (Scatter.Sender) op;
}
 
Example #19
Source File: CommunicationGroupDriverFactory.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new CommunicationGroupDriver instance.
 * @param groupName specified name of the communication group
 * @param topologyClass topology implementation
 * @param numberOfTasks minimum number of tasks needed in this group before start
 * @param customFanOut fanOut for TreeTopology
 * @return CommunicationGroupDriver instance
 * @throws InjectionException
 */
public CommunicationGroupDriver getNewInstance(
    final Class<? extends Name<String>> groupName,
    final Class<? extends Topology> topologyClass,
    final int numberOfTasks,
    final int customFanOut) throws InjectionException {

  final Injector newInjector = injector.forkInjector();
  newInjector.bindVolatileParameter(CommGroupNameClass.class, groupName);
  newInjector.bindVolatileParameter(TopologyClass.class, topologyClass);
  newInjector.bindVolatileParameter(CommGroupNumTask.class, numberOfTasks);
  newInjector.bindVolatileParameter(TreeTopologyFanOut.class, customFanOut);
  return newInjector.getInstance(CommunicationGroupDriver.class);
}
 
Example #20
Source File: CommunicationGroupClientImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public Reduce.Receiver getReduceReceiver(final Class<? extends Name<String>> operatorName) {
  LOG.entering("CommunicationGroupClientImpl", "getReduceReceiver", new Object[]{getQualifiedName(),
      Utils.simpleName(operatorName)});
  final GroupCommOperator op = operators.get(operatorName);
  if (!(op instanceof Reduce.Receiver)) {
    throw new RuntimeException("Configured operator is not a reduce receiver");
  }
  commGroupNetworkHandler.addTopologyElement(operatorName);
  LOG.exiting("CommunicationGroupClientImpl", "getReduceReceiver", getQualifiedName() + op);
  return (Reduce.Receiver) op;
}
 
Example #21
Source File: OperatorTopologyImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
public OperatorTopologyImpl(final Class<? extends Name<String>> groupName,
                            final Class<? extends Name<String>> operName, final String selfId,
                            final String driverId, final Sender sender, final int version) {
  super();
  this.groupName = groupName;
  this.operName = operName;
  this.selfId = selfId;
  this.driverId = driverId;
  this.sender = sender;
  this.version = version;
}
 
Example #22
Source File: GroupCommNetworkHandlerImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void register(final Class<? extends Name<String>> groupName,
                     final EventHandler<GroupCommunicationMessage> commGroupNetworkHandler) {
  LOG.entering("GroupCommNetworkHandlerImpl", "register", new Object[]{groupName,
      commGroupNetworkHandler});
  commGroupHandlers.put(groupName, commGroupNetworkHandler);
  LOG.exiting("GroupCommNetworkHandlerImpl", "register", Arrays.toString(new Object[]{groupName,
      commGroupNetworkHandler}));
}
 
Example #23
Source File: CommunicationGroupClientImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public Broadcast.Receiver getBroadcastReceiver(final Class<? extends Name<String>> operatorName) {
  LOG.entering("CommunicationGroupClientImpl", "getBroadcastReceiver", new Object[]{getQualifiedName(),
      Utils.simpleName(operatorName)});
  final GroupCommOperator op = operators.get(operatorName);
  if (!(op instanceof Broadcast.Receiver)) {
    throw new RuntimeException("Configured operator is not a broadcast receiver");
  }
  commGroupNetworkHandler.addTopologyElement(operatorName);
  LOG.exiting("CommunicationGroupClientImpl", "getBroadcastReceiver", getQualifiedName() + op);
  return (Broadcast.Receiver) op;
}
 
Example #24
Source File: InjectorImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public <U> U getInstance(final Class<U> clazz) throws InjectionException {
  if (Name.class.isAssignableFrom(clazz)) {
    throw new InjectionException("getInstance() called on Name "
        + ReflectionUtilities.getFullName(clazz)
        + " Did you mean to call getNamedInstance() instead?");
  }
  return getInstance(javaNamespace.getNode(clazz));
}
 
Example #25
Source File: ConfigurationModuleBuilder.java    From reef with Apache License 2.0 5 votes vote down vote up
public final <T> ConfigurationModuleBuilder bindList(final Class<? extends Name<List<T>>> iface,
                                                     final Param<List> opt) {
  final ConfigurationModuleBuilder c = deepCopy();
  c.processUse(opt);
  c.freeParams.put(iface, opt);
  return c;
}
 
Example #26
Source File: ConfigurationModuleBuilder.java    From reef with Apache License 2.0 5 votes vote down vote up
public final <T> ConfigurationModuleBuilder bindNamedParameter(
    final Class<? extends Name<T>> iface, final Impl<? extends T> opt) {
  final ConfigurationModuleBuilder c = deepCopy();
  c.processUse(opt);
  c.freeImpls.put(iface, opt);
  return c;
}
 
Example #27
Source File: ConfigurationModuleBuilder.java    From reef with Apache License 2.0 5 votes vote down vote up
public final <T> ConfigurationModuleBuilder bindSetEntry(
    final Class<? extends Name<Set<T>>> iface, final String impl) {
  final ConfigurationModuleBuilder c = deepCopy();
  try {
    c.b.bindSetEntry(iface, impl);
  } catch (final BindException e) {
    throw new ClassHierarchyException(e);
  }
  return c;
}
 
Example #28
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated in 0.14. Use Tang to obtain an instance of this instead.
 */
@Deprecated
public CommunicationGroupDriverImpl(final Class<? extends Name<String>> groupName,
                                    final ConfigurationSerializer confSerializer,
                                    final EStage<GroupCommunicationMessage> senderStage,
                                    final BroadcastingEventHandler<RunningTask> groupCommRunningTaskHandler,
                                    final BroadcastingEventHandler<FailedTask> groupCommFailedTaskHandler,
                                    final BroadcastingEventHandler<FailedEvaluator> groupCommFailedEvaluatorHandler,
                                    final BroadcastingEventHandler<GroupCommunicationMessage> commGroupMessageHandler,
                                    final String driverId, final int numberOfTasks, final int fanOut) {
  super();
  this.groupName = groupName;
  this.driverId = driverId;
  this.confSerializer = confSerializer;
  this.allInitialTasksRunning = new CountingSemaphore(numberOfTasks, getQualifiedName(), topologiesLock);

  groupCommRunningTaskHandler.addHandler(new TopologyRunningTaskHandler(this));
  groupCommFailedTaskHandler.addHandler(new TopologyFailedTaskHandler(this));
  groupCommFailedEvaluatorHandler.addHandler(new TopologyFailedEvaluatorHandler(this));
  commGroupMessageHandler.addHandler(new TopologyMessageHandler(this));
  final Injector injector = Tang.Factory.getTang().newInjector();
  injector.bindVolatileParameter(CommGroupNameClass.class, groupName);
  injector.bindVolatileParameter(GroupCommSenderStage.class, senderStage);
  injector.bindVolatileParameter(DriverIdentifier.class, driverId);
  injector.bindVolatileParameter(CommGroupNumTask.class, numberOfTasks);
  injector.bindVolatileParameter(TreeTopologyFanOut.class, fanOut);
  try {
    topologyFactory = injector.getInstance(TopologyFactory.class);
  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }
  this.topologyClass = TreeTopology.class;
}
 
Example #29
Source File: TreeTopology.java    From reef with Apache License 2.0 5 votes vote down vote up
@Inject
private TreeTopology(@Parameter(GroupCommSenderStage.class) final EStage<GroupCommunicationMessage> senderStage,
                     @Parameter(CommGroupNameClass.class) final Class<? extends Name<String>> groupName,
                     @Parameter(OperatorNameClass.class) final Class<? extends Name<String>> operatorName,
                     @Parameter(DriverIdentifier.class) final String driverId,
                     @Parameter(TreeTopologyFanOut.class) final int fanOut) {
  this.senderStage = senderStage;
  this.groupName = groupName;
  this.operName = operatorName;
  this.driverId = driverId;
  this.fanOut = fanOut;
  LOG.config(getQualifiedName() + "Tree Topology running with a fan-out of " + fanOut);
}
 
Example #30
Source File: FlatTopology.java    From reef with Apache License 2.0 5 votes vote down vote up
@Inject
private FlatTopology(@Parameter(GroupCommSenderStage.class) final EStage<GroupCommunicationMessage> senderStage,
                     @Parameter(CommGroupNameClass.class) final Class<? extends Name<String>> groupName,
                     @Parameter(OperatorNameClass.class) final Class<? extends Name<String>> operatorName,
                     @Parameter(DriverIdentifier.class) final String driverId) {
  this.senderStage = senderStage;
  this.groupName = groupName;
  this.operName = operatorName;
  this.driverId = driverId;
}