MCPcopy Create free account
hub / github.com/e2wugui/zeze / send

Method send

ZezeJava/ZezeJava/src/main/java/Zeze/Raft/ProxyServer.java:103–134  ·  view source on GitHub ↗

如果启用了代理,则把rpc包装成代理协议,发送出去; 否则按原始raft请求发送出去。 @param proxyServer 启用代理的服务器 @param rpc 待发送rpc @param sender 连接 @see ProxyAgent send

(Service localService, ProxyServer proxyServer, Rpc<?, ?> rpc, String raftName, AsyncSocket sender)

Source from the content-addressed store, hash-verified

101 * @see ProxyAgent send
102 */
103 @SuppressWarnings("unchecked")
104 public static boolean send(Service localService, ProxyServer proxyServer, Rpc<?, ?> rpc, String raftName, AsyncSocket sender) {
105 if (null == sender)
106 return false; // 没有连接,直接失败。
107
108 if (null != proxyServer) {
109 var proxyArgument = new ProxyArgument(raftName, rpc);
110 var proxyRpc = new ProxyRequest(proxyArgument);
111 return proxyRpc.Send(sender, (proxyRpcThis) -> {
112 if (proxyRpc.getResultCode() == 0) {
113 var outFh = new OutObject<ProtocolFactoryHandle<?>>();
114 var resultRpc = Protocol.decode(
115 localService::findProtocolFactoryHandle,
116 ByteBuffer.Wrap(proxyRpc.Result.getData()),
117 outFh);
118 if (null != resultRpc && null != rpc.getResponseHandle()) {
119 @SuppressWarnings("rawtypes")
120 var originHandle = (ProtocolHandle)rpc.getResponseHandle();
121 localService.dispatchRpcResponse(resultRpc, originHandle, outFh.value);
122 }
123 // todo error handle
124 } else {
125 // todo error handle
126 logger.error("Server ProxyRequest error={}", IModule.getErrorCode(proxyRpc.getResultCode()));
127 }
128 return 0;
129 }, proxyServer.rpcTimeout);
130 }
131
132 // 旧的独立的直接的raft访问发送方式。
133 return rpc.Send(sender); // ignore response
134 }
135}

Callers 1

trySendLeaderIsMethod · 0.95

Calls 8

decodeMethod · 0.95
WrapMethod · 0.95
getErrorCodeMethod · 0.95
getResponseHandleMethod · 0.80
getDataMethod · 0.65
SendMethod · 0.45
getResultCodeMethod · 0.45
dispatchRpcResponseMethod · 0.45

Tested by

no test coverage detected