mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-09 17:34:13 +00:00
feat: sharding executor exec locally
This commit is contained in:
parent
5a4fdb8a13
commit
da1f524a06
@ -1,5 +1,6 @@
|
||||
package org.bdware.server;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.bdware.sc.ContractManager;
|
||||
import org.bdware.sc.conn.ResultCallback;
|
||||
import org.bdware.sc.units.RecoverFlag;
|
||||
@ -7,6 +8,7 @@ import org.bdware.sc.units.RequestCache;
|
||||
import org.bdware.sdk.consistency.api.context.*;
|
||||
import org.bdware.server.action.CMActions;
|
||||
import org.bdware.server.action.SyncResult;
|
||||
import org.bdware.server.action.p2p.MasterClientTCPAction;
|
||||
import org.bdware.server.action.p2p.MasterServerRecoverMechAction;
|
||||
import org.bdware.server.action.p2p.MasterServerTCPAction;
|
||||
import org.bdware.server.trustedmodel.ResultCollector;
|
||||
@ -14,10 +16,14 @@ import org.bdware.units.NetworkManager;
|
||||
import org.zz.gmhelper.SM2KeyPair;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class SDKContext implements ISDKContext {
|
||||
IMasterServerTCPAction masterServerTCPActionProxy = new MasterServerTCPActionProxy();
|
||||
|
||||
IMasterClientTCPAction masterClientTCPAction = new MasterClientTCPActionProxy();
|
||||
|
||||
INetworkManager networkManagerProxy = new NetworkManagerProxy();
|
||||
|
||||
ICMActions cmActionsProxy = new CMActionsProxy();
|
||||
@ -26,6 +32,11 @@ public class SDKContext implements ISDKContext {
|
||||
|
||||
IGlobalConf globalConfProxy = new GlobalProxy();
|
||||
|
||||
@Override
|
||||
public IMasterClientTCPAction getMasterClientTCPAction() {
|
||||
return masterClientTCPAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMasterServerTCPAction getMasterServerTCPAction() {
|
||||
return masterServerTCPActionProxy;
|
||||
@ -63,6 +74,19 @@ public class SDKContext implements ISDKContext {
|
||||
}
|
||||
}
|
||||
|
||||
public static class MasterClientTCPActionProxy implements IMasterClientTCPAction {
|
||||
private final ExecutorService executorService = Executors.newFixedThreadPool(10);
|
||||
|
||||
private final MasterClientTCPAction _masterClientTCPAction = new MasterClientTCPAction();
|
||||
|
||||
@Override
|
||||
public void asyncExecuteContractLocally(JsonObject jo, ResultCallback rc) {
|
||||
executorService.execute(
|
||||
() -> _masterClientTCPAction.executeContractLocally(jo, rc)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static class NetworkManagerProxy implements INetworkManager {
|
||||
@Override
|
||||
public void sendToAgent(String pubkey, String content) {
|
||||
|
Loading…
Reference in New Issue
Block a user