TODO: 完善逻辑
This commit is contained in:
parent
849821fd8b
commit
159e25ddc6
|
@ -52,13 +52,14 @@ public class PacketsProcessor implements RpcProcessor<PacketsProcessor.PacketsRe
|
||||||
@Override
|
@Override
|
||||||
public void handleRequest(RpcContext rpcCtx, PacketsRequest request) {
|
public void handleRequest(RpcContext rpcCtx, PacketsRequest request) {
|
||||||
// StateServerFactory.getStateServer().updateFsmStateAsync(s, onCompleted);
|
// StateServerFactory.getStateServer().updateFsmStateAsync(s, onCompleted);
|
||||||
log.info("request.packets.size(): {}",request.packets.size());
|
|
||||||
var resp = new RaftResponse();
|
var resp = new RaftResponse();
|
||||||
resp.setMsg(rpcCtx.getRemoteAddress());
|
resp.setMsg(rpcCtx.getRemoteAddress());
|
||||||
resp.setSuccess(true);
|
resp.setSuccess(true);
|
||||||
|
|
||||||
var ss = StateServerFactory.getStateServer();
|
var ss = StateServerFactory.getStateServer();
|
||||||
|
|
||||||
|
log.info("{} handler request.packets.size(): {}", ss.getNode().getNodeId().getPeerId() ,request.packets.size());
|
||||||
ss.useFsmStateNotLock((state)->{
|
ss.useFsmStateNotLock((state)->{
|
||||||
|
|
||||||
var work = state.getWorkers().get( ss.getCluster().getServerId());
|
var work = state.getWorkers().get( ss.getCluster().getServerId());
|
||||||
|
@ -75,7 +76,9 @@ public class PacketsProcessor implements RpcProcessor<PacketsProcessor.PacketsRe
|
||||||
@Override
|
@Override
|
||||||
public void run(Status status) {
|
public void run(Status status) {
|
||||||
log.info("{}", this.getResponse());
|
log.info("{}", this.getResponse());
|
||||||
rpcCtx.sendResponse(this.getResponse());
|
var resp = new RaftResponse();
|
||||||
|
resp.setRedirect(StateServerFactory.getStateServer().getNode().getLeaderId());
|
||||||
|
rpcCtx.sendResponse(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -80,9 +80,6 @@ public class StateFactory {
|
||||||
ws.setUpdateAt(Instant.now());
|
ws.setUpdateAt(Instant.now());
|
||||||
ws.setTaskQueueSize(100);
|
ws.setTaskQueueSize(100);
|
||||||
|
|
||||||
var op = new Operate(OperateType.PUT);
|
|
||||||
op.setValue(ws);
|
|
||||||
|
|
||||||
var request = new PacketsRequest();
|
var request = new PacketsRequest();
|
||||||
for (int i = 0; i < cap; i++) {
|
for (int i = 0; i < cap; i++) {
|
||||||
var p = Any.pack(
|
var p = Any.pack(
|
||||||
|
@ -92,27 +89,29 @@ public class StateFactory {
|
||||||
request.getPackets().add(p);
|
request.getPackets().add(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operate.CallOperate(op, new OperateClosure() {
|
var op = new Operate(OperateType.PUT);
|
||||||
// @Override
|
op.setValue(ws);
|
||||||
// public void run(Status status) {
|
Operate.CallOperate(op, new OperateClosure() {
|
||||||
// // TODO Auto-generated method stub
|
@Override
|
||||||
// log.info("{}", status);
|
public void run(Status status) {
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
try {
|
log.info("{}", status);
|
||||||
ss.getRpcClient().invokeAsync(peer.getEndpoint(),
|
|
||||||
request, new InvokeCallback() {
|
|
||||||
|
|
||||||
@Override
|
try {
|
||||||
public void complete(Object result, Throwable err) {
|
ss.getRpcClient().invokeAsync(peer.getEndpoint(),
|
||||||
log.info("{}", result);
|
request, new InvokeCallback() {
|
||||||
}
|
|
||||||
|
|
||||||
}, 5000);
|
@Override
|
||||||
} catch (InterruptedException | RemotingException e) {
|
public void complete(Object result, Throwable err) {
|
||||||
log.info("error send packets {}", e.toString());
|
log.info("{}", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}, 5000);
|
||||||
|
} catch (InterruptedException | RemotingException e) {
|
||||||
|
log.info("error send packets {}", e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user