org.apache.reef.io.network.ConnectionFactory Java Examples

The following examples show how to use org.apache.reef.io.network.ConnectionFactory. 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: 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 #2
Source File: NcsMessageContext.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
NcsMessageContext(final String senderId,
                  final ConnectionFactory connectionFactory,
                  final IdentifierFactory idFactory) {
  this.senderId = senderId;
  this.connectionFactory = connectionFactory;
  this.idFactory = idFactory;
}
 
Example #3
Source File: NcsMessageContext.java    From nemo with Apache License 2.0 5 votes vote down vote up
NcsMessageContext(final String senderId,
                  final ConnectionFactory connectionFactory,
                  final IdentifierFactory idFactory) {
  this.senderId = senderId;
  this.connectionFactory = connectionFactory;
  this.idFactory = idFactory;
}
 
Example #4
Source File: NetworkConnectionServiceImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a ConnectionFactory.
 * @param connFactoryId the identifier of the ConnectionFactory
 */
@Override
public <T> ConnectionFactory<T> getConnectionFactory(final Identifier connFactoryId) {
  final ConnectionFactory<T> connFactory = connFactoryMap.get(connFactoryId.toString());
  if (connFactory == null) {
    throw new RuntimeException("Cannot find ConnectionFactory of " + connFactoryId + ".");
  }
  return connFactory;
}