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); }
@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); }
@Override KVStoreProvider createKKStoreProvider() throws Exception { allocator = new RootAllocator(20 * 1024 * 1024); pool = new CloseableThreadPool("test-remoteindexedkvstore"); localFabricService = new FabricServiceImpl(HOSTNAME, 45678, true, THREAD_COUNT, allocator, RESERVATION, MAX_ALLOCATION, TIMEOUT, pool); localFabricService.start(); final Provider<FabricService> fab = () -> localFabricService; remoteFabricService = new FabricServiceImpl(HOSTNAME, 45679, true, THREAD_COUNT, allocator, RESERVATION, MAX_ALLOCATION, TIMEOUT, pool); remoteFabricService.start(); final Provider<FabricService> rfab = () -> remoteFabricService; localKVStoreProvider = new LocalKVStoreProvider(DremioTest.CLASSPATH_SCAN_RESULT, fab, allocator, HOSTNAME, null, true, true, true, false); localKVStoreProvider.start(); remoteKVStoreProvider = new RemoteKVStoreProvider( DremioTest.CLASSPATH_SCAN_RESULT, DirectProvider.wrap(NodeEndpoint.newBuilder() .setAddress(HOSTNAME) .setFabricPort(localFabricService.getPort()) .build()), rfab, allocator, HOSTNAME); remoteKVStoreProvider.start(); return remoteKVStoreProvider; }
final String rpcBindAddress = (rpcBindAddressOpt.trim().isEmpty()) ? fabric.getAddress() : rpcBindAddressOpt; .setAddress(rpcBindAddress) .setUserPort(userport) .setFabricPort(fabric.getPort()) .setStartTime(System.currentTimeMillis()) .setMaxDirectMemory(VM.getMaxDirectMemory())
@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()); }
@Override public void start() throws Exception { logger.info("Starting LocalKVStoreProvider"); coreStoreProvider.start(); if (fabricService != null) { final DefaultDataStoreRpcHandler rpcHandler = new LocalDataStoreRpcHandler(hostName, coreStoreProvider); final NodeEndpoint thisNode = NodeEndpoint.newBuilder() .setAddress(hostName) .setFabricPort(fabricService.get().getPort()) .build(); try { // DatastoreRpcService registers itself with fabric //noinspection ResultOfObjectAllocationIgnored new DatastoreRpcService(DirectProvider.wrap(thisNode), fabricService.get(), allocator, rpcHandler); } catch (RpcException e) { throw new DatastoreException("Failed to start rpc service", e); } } stores = StoreLoader.buildStores(scan, new StoreBuildingFactory() { @Override public <K, V> StoreBuilder<K, V> newStore() { return LocalKVStoreProvider.this.newStore(); } }); // recover after the stores are built coreStoreProvider.recoverIfPreviouslyCrashed(); logger.info("LocalKVStoreProvider is up"); }
@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); } }
@Override void initProvider() throws Exception { allocator = new RootAllocator(20 * 1024 * 1024); pool = new CloseableThreadPool("test-remoteocckvstore"); localFabricService = new FabricServiceImpl(HOSTNAME, 45678, true, THREAD_COUNT, allocator, RESERVATION, MAX_ALLOCATION, TIMEOUT, pool); localFabricService.start(); remoteFabricService = new FabricServiceImpl(HOSTNAME, 45679, true, THREAD_COUNT, allocator, RESERVATION, MAX_ALLOCATION, TIMEOUT, pool); remoteFabricService.start(); localKVStoreProvider = new LocalKVStoreProvider(DremioTest.CLASSPATH_SCAN_RESULT, DirectProvider.wrap(localFabricService), allocator, HOSTNAME, tmpFolder.getRoot().toString(), true, true, true, false); localKVStoreProvider.start(); remoteKVStoreProvider = new RemoteKVStoreProvider( DremioTest.CLASSPATH_SCAN_RESULT, DirectProvider.wrap(NodeEndpoint.newBuilder() .setAddress(HOSTNAME) .setFabricPort(localFabricService.getPort()) .build()), DirectProvider.wrap(remoteFabricService), allocator, HOSTNAME); remoteKVStoreProvider.start(); }
context.getConfig().getLong("dremio.exec.rpc.bit.server.memory.data.maximum")); final ExecToCoordTunnelCreator creator = new ExecToCoordTunnelCreator(fabricServiceProvider.get().getProtocol(Protocols.COORD_TO_EXEC)); final ExecConnectionCreator connectionCreator = new ExecConnectionCreator(fabricServiceProvider.get().registerProtocol(new ExecProtocol(bitContext.getConfig(), allocator, fragmentExecutors)));
.with(DremioConfig.DIST_WRITE_PATH_STRING, distpath) .clusterMode(ClusterMode.DISTRIBUTED) .localPort(masterDremioDaemon.getBindingProvider().lookup(FabricService.class).getPort() + 1) .isRemote(true) .with(DremioConfig.ENABLE_EXECUTOR_BOOL, false) .with(DremioConfig.DIST_WRITE_PATH_STRING, distpath) .clusterMode(ClusterMode.DISTRIBUTED) .localPort(masterDremioDaemon.getBindingProvider().lookup(FabricService.class).getPort() + 1) .isRemote(true) .zk("localhost:" + zkPort),
@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 KVStoreProvider createKKStoreProvider() throws Exception { allocator = new RootAllocator(20 * 1024 * 1024); pool = new CloseableThreadPool("test-remoteocckvstore"); localFabricService = new FabricServiceImpl(HOSTNAME, 45678, true, THREAD_COUNT, allocator, RESERVATION, MAX_ALLOCATION, TIMEOUT, pool); localFabricService.start(); remoteFabricService = new FabricServiceImpl(HOSTNAME, 45679, true, THREAD_COUNT, allocator, RESERVATION, MAX_ALLOCATION, TIMEOUT, pool); remoteFabricService.start(); localKVStoreProvider = new LocalKVStoreProvider(DremioTest.CLASSPATH_SCAN_RESULT, DirectProvider.<FabricService>wrap(localFabricService), allocator, HOSTNAME, null, true, true, true, false); localKVStoreProvider.start(); remoteKVStoreProvider = new RemoteKVStoreProvider( DremioTest.CLASSPATH_SCAN_RESULT, DirectProvider.wrap(NodeEndpoint.newBuilder() .setAddress(HOSTNAME) .setFabricPort(localFabricService.getPort()) .build()), DirectProvider.<FabricService>wrap(remoteFabricService), allocator, HOSTNAME); remoteKVStoreProvider.start(); return remoteKVStoreProvider; }
@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 { 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(); }
plugins.start(); this.protocol = new CatalogProtocol(allocator, new CatalogChangeListener(), context.getConfig()); tunnelFactory = fabric.get().registerProtocol(protocol);