@Override public FabricCommandRunner getCommandRunner(String address, int port) { Preconditions.checkNotNull(factory, "You must register your protocol before you attempt to send a message."); return factory.getCommandRunner(address, port); }
@Override public SendEndpoint<REQUEST, RESPONSE> getEndpoint(String address, int port) { return new RequestSender(factory.getCommandRunner(address, port)); }
public ExecToCoordTunnel getTunnel(NodeEndpoint identity){ Preconditions.checkArgument(ClusterCoordinator.Role.fromEndpointRoles(identity.getRoles()).contains(ClusterCoordinator.Role.COORDINATOR), "SabotNode %s is not a coordinator node.", identity); return new ExecToCoordTunnel(identity, factory.getCommandRunner(identity.getAddress(), identity.getFabricPort())); } }
public ExecTunnel getTunnel(NodeEndpoint endpoint) { return new ExecTunnel(factory.getCommandRunner(endpoint.getAddress(), endpoint.getFabricPort())); } }
public CoordTunnel getTunnel(NodeEndpoint ep){ return new CoordTunnel(ep, factory.getCommandRunner(ep.getAddress(), ep.getFabricPort())); } }
public CoordToExecTunnel getTunnel(NodeEndpoint ep){ return new CoordToExecTunnel(ep, factory.getCommandRunner(ep.getAddress(), ep.getFabricPort())); } }
public ReflectionTunnel getTunnel(CoordinationProtos.NodeEndpoint ep){ return new ReflectionTunnel(ep, factory.getCommandRunner(ep.getAddress(), ep.getFabricPort())); }
/** * Creates a {@link RemoteNodeFileSystem} instance. * * Only exposed for unit testing */ @VisibleForTesting FileSystem newRemoteFileSystem(final NodeEndpoint endpoint) throws IOException { final FabricCommandRunner runner = runnerFactory.getCommandRunner(endpoint.getAddress(), endpoint.getFabricPort()); RemoteNodeFileSystem rdfs = new RemoteNodeFileSystem(runner, allocator); rdfs.initialize(URI.create(format("sabot://%s:%d", endpoint.getAddress(), endpoint.getFabricPort())), getConf()); return rdfs; }
private void communicateChange(SourceConfig config, RpcType rpcType) { final Set<NodeEndpoint> endpoints = new HashSet<>(); endpoints.add(context.get().getEndpoint()); List<RpcFuture<Ack>> futures = new ArrayList<>(); SourceWrapper wrapper = SourceWrapper.newBuilder().setBytes(ByteString.copyFrom(ProtobufIOUtil.toByteArray(config, SourceConfig.getSchema(), LinkedBuffer.allocate()))).build(); for(NodeEndpoint e : Iterables.concat(this.context.get().getCoordinators(), this.context.get().getExecutors())) { if(!endpoints.add(e)) { continue; } SendSource send = new SendSource(wrapper, rpcType); tunnelFactory.getCommandRunner(e.getAddress(), e.getFabricPort()).runCommand(send);; logger.trace("Sending [{}] to {}:{}", config.getName(), e.getAddress(), e.getUserPort()); futures.add(send.getFuture()); } try { Futures.successfulAsList(futures).get(CHANGE_COMMUNICATION_WAIT, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e1) { logger.warn("Failure while communicating source change [{}].", config.getName(), e1); } }
@Before public void setUpPDFSService() throws IOException { NodeEndpoint endpoint = NodeEndpoint.newBuilder() .setAddress(fabric.getAddress()).setFabricPort(fabric.getPort()) .build(); PDFSProtocol pdfsProtocol = PDFSProtocol.newInstance(endpoint, DremioTest.DEFAULT_SABOT_CONFIG, allocator, true); FabricRunnerFactory factory = fabric.registerProtocol(pdfsProtocol); sabotFS = new RemoteNodeFileSystem(factory.getCommandRunner(fabric.getAddress(), fabric.getPort()), allocator); sabotFS.initialize(URI.create(format("sabot://%s:%d", fabric.getAddress(), fabric.getPort())), new Configuration(false)); }
@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); }