public void register(FabricService fabric){ Preconditions.checkArgument(proxyFactory.factory == null, "You can only register a protocol builder once."); validateProtocol(); Preconditions.checkNotNull(name, "Name must be set."); Preconditions.checkNotNull(allocator, "Allocator must be set."); Preconditions.checkArgument(handlers.size() > 0, "You must add at least one handler to your protocol."); FabricProtocol protocol = new SimpleProtocol(protocolId, handlers, allocator, name); proxyFactory.factory = fabric.registerProtocol(protocol); }
@Override public void start() { final FabricRunnerFactory reflectionTunnelFactory = fabric.get().registerProtocol(new ReflectionProtocol (contextProvider.get().getAllocator(), reflectionStatusService.get(), reflectionService.get(), contextProvider.get().getConfig())); reflectionTunnelCreator = new ReflectionTunnelCreator(reflectionTunnelFactory); bindingCreator.bindSelf(reflectionTunnelCreator); }
@Override public void start() throws Exception { FabricService fabricService = this.fabricService.get(); pool = new CloseableThreadPool("pdfs"); FabricRunnerFactory factory = fabricService.registerProtocol(PDFSProtocol.newInstance(identityProvider.get(), this.config, allocator, allowLocalAccess)); final PDFSConfig config = new PDFSConfig(pool, factory, allocator, nodeProvider, identityProvider.get(), allowLocalAccess); PseudoDistributedFileSystem.configure(config); // A hack until DX-4639 is addressed. createFileSystem(); }
@Override public void start() throws Exception { fabricService.get().registerProtocol(new CoordExecProtocol()); final String prefix = "rpc"; Metrics.registerGauge(prefix + "bit.control.current", new Gauge<Long>() { @Override public Long getValue() { return allocator.getAllocatedMemory(); } }); Metrics.registerGauge(prefix + "bit.control.peak", new Gauge<Long>() { @Override public Long getValue() { return allocator.getPeakMemoryAllocation(); } }); }
@Override public void start() throws Exception { coordinator = coord.get(); coordinator.getServiceSet(ClusterCoordinator.Role.EXECUTOR).addNodeStatusListener(nodeListener); tunnelCreator = new CoordToExecTunnelCreator(fabric.get().getProtocol(Protocols.COORD_TO_EXEC)); bindingCreator.replace(ExecToCoordHandler.class, new ExecToCoordHandlerImpl()); final ForemenTool tool = new ForemenToolImpl(); boolean succeeded = bindingCreator.bindIfUnbound(ForemenTool.class, tool); if (!succeeded) { // then it is already bound, force set by replacing bindingCreator.replace(ForemenTool.class, tool); } final FabricRunnerFactory coordFactory = fabric.get() .registerProtocol(new CoordProtocol(dbContext.get().getAllocator(), tool, dbContext.get().getConfig())); bindingCreator.bindSelf(new CoordTunnelCreator(coordFactory)); final QueryCancelTool queryCancelTool = new QueryCancelToolImpl(); succeeded = bindingCreator.bindIfUnbound(QueryCancelTool.class, queryCancelTool); if (!succeeded) { bindingCreator.replace(QueryCancelTool.class, queryCancelTool); } // accept enduser rpc requests (replaces noop implementation). bindingCreator.bind(UserWorker.class, new UserWorkerImpl(dbContext.get().getOptionManager(), pool)); // accept local query execution requests. bindingCreator.bind(LocalQueryExecutor.class, new LocalQueryExecutorImpl(dbContext.get().getOptionManager(), pool)); // allow other components to see running queries bindingCreator.bind(RunningQueryProvider.class, new RunningQueryProviderImpl()); }
plugins.start(); this.protocol = new CatalogProtocol(allocator, new CatalogChangeListener(), context.getConfig()); tunnelFactory = fabric.get().registerProtocol(protocol);
final ExecConnectionCreator connectionCreator = new ExecConnectionCreator(fabricServiceProvider.get().registerProtocol(new ExecProtocol(bitContext.getConfig(), allocator, fragmentExecutors)));
@Test public void firstDisconnectRecovery() throws Exception { CountDownLatch closeLatch = new CountDownLatch(1); FabricRunnerFactory factory = getFabric().registerProtocol(new Protocol(closeLatch)); FabricCommandRunner runner = factory.getCommandRunner(getFabric().getAddress(), getFabric().getPort()); // send a message, establishing the connection. { SimpleMessage m = new SimpleMessage(1); runner.runCommand(m); m.getFuture().checkedGet(1000, TimeUnit.MILLISECONDS); } closeLatch.countDown(); // wait for the local connection to be closed. Thread.sleep(1000); // ensure we can send message again. { SimpleMessage m = new SimpleMessage(1); runner.runCommand(m); m.getFuture().checkedGet(1000, TimeUnit.MILLISECONDS); } }
@Test(expected=ChannelClosedException.class) public void failureOnDisconnection() throws Exception { FabricRunnerFactory factory = getFabric().registerProtocol(new Protocol(null)); FabricCommandRunner runner = factory.getCommandRunner(getFabric().getAddress(), getFabric().getPort()); SimpleMessage m = new SimpleMessage(2); runner.runCommand(m); m.getFuture().checkedGet(1000, TimeUnit.MILLISECONDS); }