/** * Runs the RPC server. * Specifically, creates a {@link NettyMessagingTransport} and binds it to a listening port. */ public void run() { // Calling 'run' multiple times is considered invalid, since it will override state variables like // 'transport', and 'host'. ensureServerState(false); try { final Injector injector = Tang.Factory.getTang().newInjector(); final LocalAddressProvider localAddressProvider = injector.getInstance(LocalAddressProvider.class); host = localAddressProvider.getLocalAddress(); injector.bindVolatileParameter(RemoteConfiguration.HostAddress.class, host); injector.bindVolatileParameter(RemoteConfiguration.Port.class, 0); injector.bindVolatileParameter(RemoteConfiguration.RemoteServerStage.class, new SyncStage<>(new ServerEventHandler())); transport = injector.getInstance(NettyMessagingTransport.class); LOG.info("DriverRPCServer running at {}", transport.getListeningPort()); isRunning = true; } catch (final InjectionException e) { throw new RuntimeException(e); } }