Java Code Examples for org.apache.reef.wake.Identifier#toString()

The following examples show how to use org.apache.reef.wake.Identifier#toString() . 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: GatherReceiver.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public List<T> receive(final List<? extends Identifier> order) throws NetworkException, InterruptedException {
  LOG.entering("GatherReceiver", "receive");
  final Map<String, T> mapOfTaskIdToData = receiveMapOfTaskIdToData();

  LOG.log(Level.FINE, "{0} Sorting data according to specified order of task identifiers.", this);
  final List<T> retList = new LinkedList<>();
  for (final Identifier key : order) {
    final String keyString = key.toString();
    if (mapOfTaskIdToData.containsKey(keyString)) {
      retList.add(mapOfTaskIdToData.get(key.toString()));
    } else {
      LOG.warning(this + " Received no data from " + keyString + ". Adding null.");
      retList.add(null);
    }
  }

  LOG.exiting("GatherReceiver", "receive");
  return retList;
}
 
Example 2
Source File: NetworkConnectionServiceImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public <T> ConnectionFactory<T> registerConnectionFactory(
    final Identifier connectionFactoryId,
    final Codec<T> codec,
    final EventHandler<Message<T>> eventHandler,
    final LinkListener<Message<T>> linkListener,
    final Identifier localEndPointId) {
  final String id = connectionFactoryId.toString();
  checkBeforeRegistration(id);

  final NetworkConnectionFactory<T> connectionFactory = new NetworkConnectionFactory<>(
      this, connectionFactoryId, codec, eventHandler, linkListener, localEndPointId);
  final Identifier localId = getEndPointIdWithConnectionFactoryId(connectionFactoryId, localEndPointId);
  nameServiceRegisteringStage.onNext(new Tuple<>(localId, (InetSocketAddress) transport.getLocalAddress()));

  if (connFactoryMap.putIfAbsent(id, connectionFactory) != null) {
    throw new NetworkRuntimeException("ConnectionFactory " + connectionFactoryId + " was already registered.");
  }

  LOG.log(Level.INFO, "ConnectionFactory {0} was registered", id);

  return connectionFactory;
}
 
Example 3
Source File: NetworkConnectionServiceImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void unregisterConnectionFactory(final Identifier connFactoryId) {
  final String id = connFactoryId.toString();
  final NetworkConnectionFactory connFactory = connFactoryMap.remove(id);
  if (connFactory != null) {
    LOG.log(Level.INFO, "ConnectionFactory {0} was unregistered", id);

    final Identifier localId = getEndPointIdWithConnectionFactoryId(
          connFactoryId, connFactory.getLocalEndPointId());
    nameServiceUnregisteringStage.onNext(localId);
  } else {
    LOG.log(Level.WARNING, "ConnectionFactory of {0} is null", id);
  }
}
 
Example 4
Source File: NetworkConnectionServiceImpl.java    From reef with Apache License 2.0 4 votes vote down vote up
private Identifier getEndPointIdWithConnectionFactoryId(
    final Identifier connectionFactoryId, final Identifier endPointId) {
  final String identifier = connectionFactoryId.toString() + DELIMITER + endPointId.toString();
  return idFactory.getNewInstance(identifier);
}