org.apache.reef.wake.remote.ports.TcpPortProvider Java Examples

The following examples show how to use org.apache.reef.wake.remote.ports.TcpPortProvider. 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: GRPCDriverService.java    From reef with Apache License 2.0 6 votes vote down vote up
@Inject
private GRPCDriverService(
    final Clock clock,
    final REEFFileNames reefFileNames,
    final EvaluatorRequestor evaluatorRequestor,
    final JVMProcessFactory jvmProcessFactory,
    final CLRProcessFactory clrProcessFactory,
    final DotNetProcessFactory dotNetProcessFactory,
    final TcpPortProvider tcpPortProvider,
    final ExceptionCodec exceptionCodec,
    @Parameter(DriverClientCommand.class) final String driverClientCommand) {
  this.clock = clock;
  this.reefFileNames = reefFileNames;
  this.exceptionCodec = exceptionCodec;
  this.jvmProcessFactory = jvmProcessFactory;
  this.clrProcessFactory = clrProcessFactory;
  this.dotNetProcessFactory = dotNetProcessFactory;
  this.evaluatorRequestor = evaluatorRequestor;
  this.driverClientCommand = driverClientCommand;
  this.tcpPortProvider = tcpPortProvider;
}
 
Example #2
Source File: RemoteManagerTest.java    From reef with Apache License 2.0 6 votes vote down vote up
private RemoteManager getTestRemoteManager(final String rmName, final int localPort,
                                           final int retry, final int retryTimeout) {
  final Map<Class<?>, Codec<?>> clazzToCodecMap = new HashMap<>();
  clazzToCodecMap.put(StartEvent.class, new ObjectSerializableCodec<StartEvent>());
  clazzToCodecMap.put(TestEvent1.class, new ObjectSerializableCodec<TestEvent1>());
  clazzToCodecMap.put(TestEvent2.class, new ObjectSerializableCodec<TestEvent1>());
  final Codec<?> codec = new MultiCodec<Object>(clazzToCodecMap);

  final String hostAddress = localAddressProvider.getLocalAddress();
  try {
    TcpPortProvider tcpPortProvider = Tang.Factory.getTang().newInjector().getInstance(TcpPortProvider.class);
    return remoteManagerFactory.getInstance(rmName, hostAddress, localPort,
            codec, new LoggingEventHandler<Throwable>(), false, retry, retryTimeout,
            localAddressProvider, tcpPortProvider);
  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }
}
 
Example #3
Source File: MessagingTransportFactory.java    From reef with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a transport.
 *
 * @param hostAddress     a host address
 * @param port            a listening port
 * @param clientStage     a client stage
 * @param serverStage     a server stage
 * @param numberOfTries   a number of tries
 * @param retryTimeout    a timeout for retry
 * @param tcpPortProvider a provider for TCP port
 */
@Override
public Transport newInstance(final String hostAddress,
                             final int port,
                             final EStage<TransportEvent> clientStage,
                             final EStage<TransportEvent> serverStage,
                             final int numberOfTries,
                             final int retryTimeout,
                             final TcpPortProvider tcpPortProvider) {

  final Injector injector = Tang.Factory.getTang().newInjector();
  injector.bindVolatileParameter(RemoteConfiguration.HostAddress.class, hostAddress);
  injector.bindVolatileParameter(RemoteConfiguration.Port.class, port);
  injector.bindVolatileParameter(RemoteConfiguration.RemoteClientStage.class, clientStage);
  injector.bindVolatileParameter(RemoteConfiguration.RemoteServerStage.class, serverStage);
  injector.bindVolatileParameter(RemoteConfiguration.NumberOfTries.class, numberOfTries);
  injector.bindVolatileParameter(RemoteConfiguration.RetryTimeout.class, retryTimeout);
  injector.bindVolatileInstance(TcpPortProvider.class, tcpPortProvider);
  try {
    return injector.getInstance(NettyMessagingTransport.class);
  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }
}
 
Example #4
Source File: DefaultRemoteManagerFactory.java    From reef with Apache License 2.0 6 votes vote down vote up
@Inject
private DefaultRemoteManagerFactory(
    @Parameter(RemoteConfiguration.MessageCodec.class) final Codec<?> codec,
    @Parameter(RemoteConfiguration.ErrorHandler.class) final EventHandler<Throwable> errorHandler,
    @Parameter(RemoteConfiguration.OrderingGuarantee.class) final boolean orderingGuarantee,
    @Parameter(RemoteConfiguration.NumberOfTries.class) final int numberOfTries,
    @Parameter(RemoteConfiguration.RetryTimeout.class) final int retryTimeout,
    final LocalAddressProvider localAddressProvider,
    final TransportFactory tpFactory,
    final TcpPortProvider tcpPortProvider) {

  this.codec = codec;
  this.errorHandler = errorHandler;
  this.orderingGuarantee = orderingGuarantee;
  this.numberOfTries = numberOfTries;
  this.retryTimeout = retryTimeout;
  this.localAddressProvider = localAddressProvider;
  this.transportFactory = tpFactory;
  this.tcpPortProvider = tcpPortProvider;
}
 
Example #5
Source File: MessagingTransportFactory.java    From reef with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a transport.
 *
 * @param hostAddress   a host address
 * @param port          a listening port
 * @param clientStage   a client stage
 * @param serverStage   a server stage
 * @param numberOfTries a number of tries
 * @param retryTimeout  a timeout for retry
 */
@Override
public Transport newInstance(final String hostAddress,
                             final int port,
                             final EStage<TransportEvent> clientStage,
                             final EStage<TransportEvent> serverStage,
                             final int numberOfTries,
                             final int retryTimeout) {
  try {
    TcpPortProvider tcpPortProvider = Tang.Factory.getTang().newInjector().getInstance(TcpPortProvider.class);
    return newInstance(hostAddress, port, clientStage,
            serverStage, numberOfTries, retryTimeout, tcpPortProvider);
  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }
}
 
Example #6
Source File: HttpServerImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor of HttpServer that wraps Jetty Server.
 *
 * @param jettyHandler
 * @throws Exception
 */
@Inject
HttpServerImpl(@Parameter(RemoteConfiguration.HostAddress.class) final String hostAddress,
               final JettyHandler jettyHandler,
               final LocalAddressProvider addressProvider,
               final TcpPortProvider tcpPortProvider,
               final LoggingScopeFactory loggingScopeFactory) throws Exception {
  this.loggingScopeFactory = loggingScopeFactory;
  this.jettyHandler = jettyHandler;

  this.hostAddress = UNKNOWN_HOST_NAME.equals(hostAddress) ? addressProvider.getLocalAddress() : hostAddress;
  try (LoggingScope ls = this.loggingScopeFactory.httpServer()) {

    Server srv = null;
    int availablePort = -1;
    for (final int p : tcpPortProvider) {
      srv = tryPort(p);
      if (srv != null) {
        availablePort = p;
        break;
      }
    }

    if (srv  != null) {
      this.server = srv;
      this.port = availablePort;
      this.server.setHandler(jettyHandler);
      LOG.log(Level.INFO, "Jetty Server started with port: {0}", availablePort);
    } else {
      throw new RuntimeException("Could not find available port for http");
    }
  }
}
 
Example #7
Source File: NameServerImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * @param port    a listening port number
 * @param factory an identifier factory
 * @param localAddressProvider a local address provider
 * Constructs a name server
 */
@Inject
private NameServerImpl(
    @Parameter(RemoteConfiguration.HostAddress.class) final String hostAddress,
    @Parameter(NameServerParameters.NameServerPort.class) final int port,
    @Parameter(NameServerParameters.NameServerIdentifierFactory.class) final IdentifierFactory factory,
    final TcpPortProvider portProvider,
    final LocalAddressProvider localAddressProvider) {

  final Injector injector = Tang.Factory.getTang().newInjector();

  this.localAddressProvider = localAddressProvider;
  this.reefEventStateManager = null;
  final Codec<NamingMessage> codec = NamingCodecFactory.createFullCodec(factory);
  final EventHandler<NamingMessage> handler = createEventHandler(codec);

  String host = UNKNOWN_HOST_NAME.equals(hostAddress) ? localAddressProvider.getLocalAddress() : hostAddress;
  injector.bindVolatileParameter(RemoteConfiguration.HostAddress.class, host);
  injector.bindVolatileParameter(RemoteConfiguration.Port.class, port);
  injector.bindVolatileInstance(TcpPortProvider.class, portProvider);
  injector.bindVolatileParameter(RemoteConfiguration.RemoteServerStage.class,
      new SyncStage<>(new NamingServerHandler(handler, codec)));

  try {
    this.transport = injector.getInstance(NettyMessagingTransport.class);
  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }

  this.port = transport.getListeningPort();
  this.idToAddrMap = Collections.synchronizedMap(new HashMap<Identifier, InetSocketAddress>());

  LOG.log(Level.FINE, "NameServer starting, listening at port {0}", this.port);
}
 
Example #8
Source File: RemoteManagerTest.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void testRemoteManagerPBufTest() throws Exception {
  System.out.println(LOG_PREFIX + name.getMethodName());
  LoggingUtils.setLoggingLevel(Level.INFO);

  final Monitor monitor = new Monitor();
  final TimerStage timer = new TimerStage(new TimeoutHandler(monitor), 2000, 2000);

  final Map<Class<?>, Codec<?>> clazzToCodecMap = new HashMap<>();
  clazzToCodecMap.put(TestEvent.class, new TestEventCodec());
  final Codec<?> codec = new MultiCodec<Object>(clazzToCodecMap);

  final String hostAddress = localAddressProvider.getLocalAddress();

  final RemoteManager rm = this.remoteManagerFactory.getInstance(
      "name", hostAddress, 0, codec, new LoggingEventHandler<Throwable>(), false, 3, 10000,
      localAddressProvider, Tang.Factory.getTang().newInjector().getInstance(TcpPortProvider.class));

  final RemoteIdentifier remoteId = rm.getMyIdentifier();

  final EventHandler<TestEvent> proxyHandler = rm.getHandler(remoteId, TestEvent.class);

  final AtomicInteger counter = new AtomicInteger(0);
  final int finalSize = 0;
  rm.registerHandler(TestEvent.class, new MessageTypeEventHandler<TestEvent>(rm, monitor, counter, finalSize));

  proxyHandler.onNext(new TestEvent("hello", 0.0));

  monitor.mwait();

  Assert.assertEquals(finalSize, counter.get());

  rm.close();
  timer.close();
}
 
Example #9
Source File: DefaultRemoteManagerFactory.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public <T> RemoteManager getInstance(final String newRmName,
                                     final String newHostAddress,
                                     final int newListeningPort,
                                     final Codec<T> newCodec,
                                     final EventHandler<Throwable> newErrorHandler,
                                     final boolean newOrderingGuarantee,
                                     final int newNumberOfTries,
                                     final int newRetryTimeout,
                                     final LocalAddressProvider newLocalAddressProvider,
                                     final TcpPortProvider newTcpPortProvider) {
  try {

    final Injector newInjector = injector.forkInjector();

    if (newHostAddress != null) {
      newInjector.bindVolatileParameter(RemoteConfiguration.HostAddress.class, newHostAddress);
    }

    if (newListeningPort > 0) {
      newInjector.bindVolatileParameter(RemoteConfiguration.Port.class, newListeningPort);
    }

    newInjector.bindVolatileParameter(RemoteConfiguration.ManagerName.class, newRmName);
    newInjector.bindVolatileParameter(RemoteConfiguration.MessageCodec.class, newCodec);
    newInjector.bindVolatileParameter(RemoteConfiguration.ErrorHandler.class, newErrorHandler);
    newInjector.bindVolatileParameter(RemoteConfiguration.OrderingGuarantee.class, newOrderingGuarantee);
    newInjector.bindVolatileParameter(RemoteConfiguration.NumberOfTries.class, newNumberOfTries);
    newInjector.bindVolatileParameter(RemoteConfiguration.RetryTimeout.class, newRetryTimeout);
    newInjector.bindVolatileInstance(LocalAddressProvider.class, newLocalAddressProvider);
    newInjector.bindVolatileInstance(TransportFactory.class, this.transportFactory);
    newInjector.bindVolatileInstance(TcpPortProvider.class, newTcpPortProvider);

    return newInjector.getInstance(RemoteManager.class);

  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }
}
 
Example #10
Source File: AzureBatchDriverConfigurationProviderImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Assembles the Driver configuration.
 *
 * @param jobFolder the job folder.
 * @param clientRemoteId the client remote id.
 * @param jobId the job id.
 * @param applicationConfiguration the application configuration.
 * @return the Driver configuration.
 */
@Override
public Configuration getDriverConfiguration(final URI jobFolder,
                                            final String clientRemoteId,
                                            final String jobId,
                                            final Configuration applicationConfiguration) {
  ConfigurationModuleBuilder driverConfigurationBuilder = AzureBatchDriverConfiguration.CONF.getBuilder()
      .bindImplementation(CommandBuilder.class, this.commandBuilder.getClass());

  // If using docker containers, then use a different set of bindings
  if (this.containerRegistryProvider.isValid()) {
    driverConfigurationBuilder = driverConfigurationBuilder
        .bindImplementation(LocalAddressProvider.class, ContainerBasedLocalAddressProvider.class)
        .bindImplementation(TcpPortProvider.class, SetTcpPortProvider.class);
  }

  final Configuration driverConfiguration = driverConfigurationBuilder.build()
      .set(AzureBatchDriverConfiguration.JOB_IDENTIFIER, jobId)
      .set(AzureBatchDriverConfiguration.CLIENT_REMOTE_IDENTIFIER, clientRemoteId)
      .set(AzureBatchDriverConfiguration.JVM_HEAP_SLACK, this.jvmSlack)
      .set(AzureBatchDriverConfiguration.RUNTIME_NAME, RuntimeIdentifier.RUNTIME_NAME)
      .set(AzureBatchDriverConfiguration.AZURE_BATCH_ACCOUNT_URI, this.azureBatchAccountUri)
      .set(AzureBatchDriverConfiguration.AZURE_BATCH_ACCOUNT_NAME, this.azureBatchAccountName)
      .set(AzureBatchDriverConfiguration.AZURE_BATCH_POOL_ID, this.azureBatchPoolId)
      .set(AzureBatchDriverConfiguration.AZURE_STORAGE_ACCOUNT_NAME, this.azureStorageAccountName)
      .set(AzureBatchDriverConfiguration.AZURE_STORAGE_CONTAINER_NAME, this.azureStorageContainerName)
      .set(AzureBatchDriverConfiguration.CONTAINER_REGISTRY_SERVER,
          this.containerRegistryProvider.getContainerRegistryServer())
      .set(AzureBatchDriverConfiguration.CONTAINER_REGISTRY_USERNAME,
          this.containerRegistryProvider.getContainerRegistryUsername())
      .set(AzureBatchDriverConfiguration.CONTAINER_REGISTRY_PASSWORD,
          this.containerRegistryProvider.getContainerRegistryPassword())
      .set(AzureBatchDriverConfiguration.CONTAINER_IMAGE_NAME,
          this.containerRegistryProvider.getContainerImageName())
      .setMultiple(AzureBatchDriverConfiguration.TCP_PORT_SET, this.tcpPortSet)
      .build();
  return Configurations.merge(driverConfiguration, applicationConfiguration);
}
 
Example #11
Source File: EvaluatorShimConfiguration.java    From reef with Apache License 2.0 5 votes vote down vote up
public static ConfigurationModule getConfigurationModule(final boolean includeContainerConfiguration) {
  ConfigurationModuleBuilder shimConfigurationBuilder = EvaluatorShimConfiguration.CONF.getBuilder();

  // If using docker containers, then use a different set of bindings
  if (includeContainerConfiguration) {
    shimConfigurationBuilder = shimConfigurationBuilder
        .bindImplementation(LocalAddressProvider.class, ContainerBasedLocalAddressProvider.class)
        .bindImplementation(TcpPortProvider.class, SetTcpPortProvider.class);
  }

  return shimConfigurationBuilder.build();
}
 
Example #12
Source File: GRPCDriverClientService.java    From reef with Apache License 2.0 5 votes vote down vote up
@Inject
private GRPCDriverClientService(
    final EvaluatorDescriptorBuilderFactory evaluatorDescriptorBuilderFactory,
    final ExceptionCodec exceptionCodec,
    final GRPCDriverServiceClient driverServiceClient,
    final TcpPortProvider tcpPortProvider,
    final InjectionFuture<Clock> clock,
    final InjectionFuture<DriverClientDispatcher> clientDriverDispatcher) {
  this.evaluatorDescriptorBuilderFactory = evaluatorDescriptorBuilderFactory;
  this.exceptionCodec = exceptionCodec;
  this.driverServiceClient = driverServiceClient;
  this.tcpPortProvider = tcpPortProvider;
  this.clock = clock;
  this.clientDriverDispatcher = clientDriverDispatcher;
}
 
Example #13
Source File: DefaultRemoteManagerImplementation.java    From reef with Apache License 2.0 4 votes vote down vote up
@Inject
private <T> DefaultRemoteManagerImplementation(
      @Parameter(RemoteConfiguration.ManagerName.class) final String name,
      @Parameter(RemoteConfiguration.HostAddress.class) final String hostAddress,
      @Parameter(RemoteConfiguration.Port.class) final int listeningPort,
      @Parameter(RemoteConfiguration.MessageCodec.class) final Codec<T> codec,
      @Parameter(RemoteConfiguration.ErrorHandler.class) final EventHandler<Throwable> errorHandler,
      @Parameter(RemoteConfiguration.OrderingGuarantee.class) final boolean orderingGuarantee,
      @Parameter(RemoteConfiguration.NumberOfTries.class) final int numberOfTries,
      @Parameter(RemoteConfiguration.RetryTimeout.class) final int retryTimeout,
      final LocalAddressProvider localAddressProvider,
      final TransportFactory tpFactory,
      final TcpPortProvider tcpPortProvider) {

  this.name = name;
  this.handlerContainer = new HandlerContainer<>(name, codec);

  this.reRecvStage = orderingGuarantee ?
      new OrderedRemoteReceiverStage(this.handlerContainer, errorHandler) :
      new RemoteReceiverStage(this.handlerContainer, errorHandler, 10);

  this.transport = tpFactory.newInstance(hostAddress, listeningPort,
      this.reRecvStage, this.reRecvStage, numberOfTries, retryTimeout, tcpPortProvider);

  this.handlerContainer.setTransport(this.transport);

  InetSocketAddress address = new InetSocketAddress(
      localAddressProvider.getLocalAddress(),
      this.transport.getListeningPort());
  this.myIdentifier = new SocketRemoteIdentifier(address);

  this.reSendStage = new RemoteSenderStage(codec, this.transport, 10);

  StageManager.instance().register(this);

  final int counter = COUNTER.incrementAndGet();

  LOG.log(Level.FINEST,
      "RemoteManager {0} instantiated id {1} counter {2} listening on {3} Binding address provided by {4}",
      new Object[] {this.name, this.myIdentifier, counter, this.transport.getLocalAddress(), localAddressProvider});
}
 
Example #14
Source File: RemoteManagerTest.java    From reef with Apache License 2.0 4 votes vote down vote up
@Test
public void testRemoteManagerTest() throws Exception {
  System.out.println(LOG_PREFIX + name.getMethodName());
  LoggingUtils.setLoggingLevel(Level.INFO);

  final Monitor monitor = new Monitor();
  final TimerStage timer = new TimerStage(new TimeoutHandler(monitor), 2000, 2000);

  final Map<Class<?>, Codec<?>> clazzToCodecMap = new HashMap<>();
  clazzToCodecMap.put(StartEvent.class, new ObjectSerializableCodec<StartEvent>());
  clazzToCodecMap.put(TestEvent.class, new ObjectSerializableCodec<TestEvent>());
  clazzToCodecMap.put(TestEvent1.class, new ObjectSerializableCodec<TestEvent1>());
  clazzToCodecMap.put(TestEvent2.class, new ObjectSerializableCodec<TestEvent2>());
  final Codec<?> codec = new MultiCodec<Object>(clazzToCodecMap);

  final String hostAddress = localAddressProvider.getLocalAddress();

  final RemoteManager rm = this.remoteManagerFactory.getInstance(
      "name", hostAddress, 0, codec, new LoggingEventHandler<Throwable>(), false, 3, 10000,
      localAddressProvider, Tang.Factory.getTang().newInjector().getInstance(TcpPortProvider.class));

  final RemoteIdentifier remoteId = rm.getMyIdentifier();
  Assert.assertTrue(rm.getMyIdentifier().equals(remoteId));

  final EventHandler<StartEvent> proxyConnection = rm.getHandler(remoteId, StartEvent.class);
  final EventHandler<TestEvent1> proxyHandler1 = rm.getHandler(remoteId, TestEvent1.class);
  final EventHandler<TestEvent2> proxyHandler2 = rm.getHandler(remoteId, TestEvent2.class);

  final AtomicInteger counter = new AtomicInteger(0);
  final int finalSize = 2;
  rm.registerHandler(StartEvent.class, new MessageTypeEventHandler<StartEvent>(rm, monitor, counter, finalSize));

  proxyConnection.onNext(new StartEvent());

  monitor.mwait();
  proxyHandler1.onNext(new TestEvent1("hello1", 0.0)); // registration after send expected to fail
  proxyHandler2.onNext(new TestEvent2("hello2", 1.0));

  monitor.mwait();

  Assert.assertEquals(finalSize, counter.get());

  rm.close();
  timer.close();
}
 
Example #15
Source File: RemoteManagerTest.java    From reef with Apache License 2.0 4 votes vote down vote up
@Test
public void testRemoteManagerOrderingGuaranteeTest() throws Exception {
  System.out.println(LOG_PREFIX + name.getMethodName());
  LoggingUtils.setLoggingLevel(Level.INFO);

  final Monitor monitor = new Monitor();
  final TimerStage timer = new TimerStage(new TimeoutHandler(monitor), 2000, 2000);

  final Map<Class<?>, Codec<?>> clazzToCodecMap = new HashMap<>();
  clazzToCodecMap.put(StartEvent.class, new ObjectSerializableCodec<StartEvent>());
  clazzToCodecMap.put(TestEvent.class, new ObjectSerializableCodec<TestEvent>());
  clazzToCodecMap.put(TestEvent1.class, new ObjectSerializableCodec<TestEvent1>());
  clazzToCodecMap.put(TestEvent2.class, new ObjectSerializableCodec<TestEvent2>());
  final Codec<?> codec = new MultiCodec<Object>(clazzToCodecMap);

  final String hostAddress = localAddressProvider.getLocalAddress();

  final RemoteManager rm = this.remoteManagerFactory.getInstance(
      "name", hostAddress, 0, codec, new LoggingEventHandler<Throwable>(), true, 3, 10000,
      localAddressProvider, Tang.Factory.getTang().newInjector().getInstance(TcpPortProvider.class));

  final RemoteIdentifier remoteId = rm.getMyIdentifier();

  final EventHandler<StartEvent> proxyConnection = rm.getHandler(remoteId, StartEvent.class);
  final EventHandler<TestEvent1> proxyHandler1 = rm.getHandler(remoteId, TestEvent1.class);
  final EventHandler<TestEvent2> proxyHandler2 = rm.getHandler(remoteId, TestEvent2.class);

  final AtomicInteger counter = new AtomicInteger(0);
  final int finalSize = 2;
  rm.registerHandler(StartEvent.class, new MessageTypeEventHandler<StartEvent>(rm, monitor, counter, finalSize));

  proxyConnection.onNext(new StartEvent());

  monitor.mwait();

  proxyHandler1.onNext(new TestEvent1("hello1", 0.0));
  proxyHandler2.onNext(new TestEvent2("hello2", 1.0));

  monitor.mwait();

  Assert.assertEquals(finalSize, counter.get());

  rm.close();
  timer.close();
}
 
Example #16
Source File: TransportFactory.java    From reef with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a transport.
 *
 * @param hostAddress     a host address
 * @param port            a listening port
 * @param clientStage     a transport client-side stage
 * @param serverStage     a transport server-side stage
 * @param numberOfTries   the number of retries for connection
 * @param retryTimeout    retry timeout
 * @param tcpPortProvider tcpPortProvider
 * @return transport
 */
Transport newInstance(String hostAddress,
                      int port,
                      EStage<TransportEvent> clientStage,
                      EStage<TransportEvent> serverStage,
                      int numberOfTries,
                      int retryTimeout,
                      TcpPortProvider tcpPortProvider);
 
Example #17
Source File: RemoteManagerFactory.java    From reef with Apache License 2.0 3 votes vote down vote up
/**
 * The all-out constructor of DefaultRemoteManagerImplementation. Avoid if you can.
 *
 * @param name                 the name of the returned RemoteManager to instantiate.
 * @param hostAddress          the address the returned RemoteManager binds to.
 * @param listeningPort        the port on which the returned RemoteManager listens.
 * @param codec                the codec to use to decode the messages sent to / by this RemoteManager.
 * @param errorHandler         the error handler invoked for exceptions by the returned RemoteManager.
 * @param orderingGuarantee    whether or not the returned RemoteManager should guarantee message orders.
 * @param numberOfTries        the number of retries before the returned RemoteManager declares sending a failure.
 * @param retryTimeout         the time (in ms) after which the returned RemoteManager considers a sending attempt
 *                             failed.
 * @param localAddressProvider the LocalAddressProvider used by the returned RemoteManager to determine the address
 *                             to bind to.
 * @param tcpPortProvider      the TcpPortProvider used by the returned RemoteManager to determine the port
 *                             to listen to.
 * @param <T>                  the message type sent / received by the returned RemoteManager.
 * @return a new instance of RemoteManager with all parameters but the given one injected via Tang.
 */
<T> RemoteManager getInstance(String name,
                              String hostAddress,
                              int listeningPort,
                              Codec<T> codec,
                              EventHandler<Throwable> errorHandler,
                              boolean orderingGuarantee,
                              int numberOfTries,
                              int retryTimeout,
                              LocalAddressProvider localAddressProvider,
                              TcpPortProvider tcpPortProvider);