protected RemoteConnection(RemoteConnection connection){ this.channel = connection.channel; this.clientName = connection.clientName; this.writeManager = new WriteManager(); this.requestIdMap = new RequestIdMap(getName()); writeManager.disable(); }
public static RpcConfig getMapping(int rpcTimeout, Executor executor, Optional<SSLConfig> sslConfig) { return RpcConfig.newBuilder() .name("FABRIC") .executor(executor) .timeout(rpcTimeout) .sslConfig(sslConfig) .add(RpcType.HANDSHAKE, FabricHandshake.class, RpcType.HANDSHAKE, FabricHandshake.class) .add(RpcType.MESSAGE, FabricMessage.class, RpcType.MESSAGE, FabricMessage.class) .build(); }
@Override public RpcConfig getConfig() { return RpcConfig.newBuilder().name("pdfs") .timeout(rpcTimeoutInSecs) .add(DFS.RpcType.GET_FILE_STATUS_REQUEST, DFS.GetFileStatusRequest.class, DFS.RpcType.GET_FILE_STATUS_RESPONSE, DFS.GetFileStatusResponse.class) .add(DFS.RpcType.GET_FILE_DATA_REQUEST, DFS.GetFileDataRequest.class, DFS.RpcType.GET_FILE_DATA_RESPONSE, DFS.GetFileDataResponse.class) .add(DFS.RpcType.LIST_STATUS_REQUEST, DFS.ListStatusRequest.class, DFS.RpcType.LIST_STATUS_RESPONSE, DFS.ListStatusResponse.class) .add(DFS.RpcType.MKDIRS_REQUEST, DFS.MkdirsRequest.class, DFS.RpcType.MKDIRS_RESPONSE, DFS.MkdirsResponse.class) .add(DFS.RpcType.RENAME_REQUEST, DFS.RenameRequest.class, DFS.RpcType.RENAME_RESPONSE, DFS.RenameResponse.class) .add(DFS.RpcType.DELETE_REQUEST, DFS.DeleteRequest.class, DFS.RpcType.DELETE_RESPONSE, DFS.DeleteResponse.class) .add(DFS.RpcType.WRITE_DATA_REQUEST, DFS.WriteDataRequest.class, DFS.RpcType.WRITE_DATA_RESPONSE, DFS.WriteDataResponse.class) .build(); }
@Override public void connectionFailed(FailureType type, Throwable t) { listener.failed( ConnectionFailedException.mapException(RpcException.mapException( String.format("Command failed while establishing connection. Failure type %s.", type), t), type)); }
@Override public void setException(Throwable t) { handler.failed(RpcException.mapException(t)); }
@Override public void interrupted(InterruptedException e) { inner.interrupted(e); decrement(); } }
public void setWritable(boolean isWritable) { if (isWritable) { barrier.openBarrier(); } else if (!disabled) { barrier.closeBarrier(); } }
<SEND extends MessageLite, RECEIVE extends MessageLite> RpcFuture<RECEIVE> send(C connection, T rpcType, SEND protobufBody, Class<RECEIVE> clazz, ByteBuf... dataBodies) { RpcFutureImpl<RECEIVE> rpcFuture = new RpcFutureImpl<>(); this.send(rpcFuture, connection, rpcType, protobufBody, clazz, dataBodies); return rpcFuture; }
@Override protected ChannelFutureListener newCloseListener(SocketChannel ch, FabricConnection connection) { return closeHandlerFactory.getHandler(connection, super.newCloseListener(ch, connection)); }
@Override public void failed(RpcException ex) { ( (InnerFuture<V>)delegate()).setException(ex); }
@Override public void connectionAvailable(C connection) { doRpcCall(new DeferredRpcOutcome(), connection); }
@Override public void connectionAvailable(C connection) { doRpcCall(new DeferredRpcOutcome(), connection); }
/** * Delegates to {@link RpcBus#send} for this client. */ public <SEND extends MessageLite, RECEIVE extends MessageLite> RpcFuture<RECEIVE> send(T rpcType, SEND protobufBody, Class<RECEIVE> clazz, ByteBuf... dataBodies) { return super.send(connection, rpcType, protobufBody, clazz, dataBodies); }
public static RpcException mapException(RpcException ex, FailureType failureType) { if (failureType == RpcConnectionHandler.FailureType.CONNECTION) { return new ConnectionFailedException(ex); } return ex; } }
@Override public void connectionFailed(FailureType type, Throwable t) { parentHandler.connectionFailed(type, t); } }
public RemoteConnection(SocketChannel channel, String name, boolean blockOnSocket) { super(); this.channel = channel; this.clientName = name; this.writeManager = new WriteManager(); this.requestIdMap = new RequestIdMap(getName()); if(!blockOnSocket){ writeManager.disable(); } channel.pipeline() .addLast(BACK_PRESSURE_HANDLER, new BackPressureHandler()); }