From d634ebefb3747664c1d0782bcdfd34be78c9d7c7 Mon Sep 17 00:00:00 2001 From: bitvincent <896112698@qq.com> Date: Thu, 4 Nov 2021 18:00:43 +0800 Subject: [PATCH] fix:typo error (shading->sharding) --- .../org/bdware/server/action/MasterWSAction.java | 16 ++++++++-------- .../server/action/p2p/MasterClientTCPAction.java | 16 ++++++++-------- .../p2p/MasterServerRecoverMechAction.java | 2 +- .../server/action/p2p/MasterServerTCPAction.java | 2 +- .../bdware/server/trustedmodel/MasterProxy.java | 2 +- ...java => MultiPointCooperateContractInfo.java} | 4 ++-- ...r.java => MultiPointCooperationExecutor.java} | 14 +++++++------- 7 files changed, 28 insertions(+), 28 deletions(-) rename src/main/java/org/bdware/server/trustedmodel/{ShadingMultiPointContractInfo.java => MultiPointCooperateContractInfo.java} (81%) rename src/main/java/org/bdware/server/trustedmodel/{ShadingExecutor.java => MultiPointCooperationExecutor.java} (96%) diff --git a/src/main/java/org/bdware/server/action/MasterWSAction.java b/src/main/java/org/bdware/server/action/MasterWSAction.java index ee0e7a7..a4ab0ac 100644 --- a/src/main/java/org/bdware/server/action/MasterWSAction.java +++ b/src/main/java/org/bdware/server/action/MasterWSAction.java @@ -20,7 +20,7 @@ import org.bdware.server.action.p2p.MasterServerRecoverMechAction; import org.bdware.server.action.p2p.MasterServerTCPAction; import org.bdware.server.trustedmodel.MultiPointContractInfo; import org.bdware.server.trustedmodel.ResultCollector; -import org.bdware.server.trustedmodel.ShadingMultiPointContractInfo; +import org.bdware.server.trustedmodel.MultiPointCooperateContractInfo; import org.bdware.server.trustedmodel.SlaveNode; import org.bdware.units.NetworkManager; import org.zz.gmhelper.SM2KeyPair; @@ -59,8 +59,8 @@ public class MasterWSAction { // this multiPointContractInfo problem // this multiPointContractInfo problem MultiPointContractInfo multiPointContractInfo = new MultiPointContractInfo(); - if (contract.getType() == ContractExecType.Shading) { - multiPointContractInfo = new ShadingMultiPointContractInfo(); + if (contract.getType() == ContractExecType.Sharding) { + multiPointContractInfo = new MultiPointCooperateContractInfo(); } multiPointContractInfo.type = contract.getType(); LOGGER.debug(JsonUtil.toPrettyJson(args)); @@ -158,7 +158,7 @@ public class MasterWSAction { String masterNode = keyPair.getPublicKeyStr(); requestConnect.put("master", masterNode); // 从哪个节点启动,哪个节点就是master requestConnect.put("members", nodeNames); - if (contract.getType() == ContractExecType.Shading) { + if (contract.getType() == ContractExecType.Sharding) { requestConnect.put("connectAll", true); } NetworkManager.instance.sendToNodeCenter(JsonUtil.toJson(requestConnect)); // 向NC发 @@ -223,12 +223,12 @@ public class MasterWSAction { request.put("requestID", requestID); request.put("members", nodeNames); // 执行这个合约的所有节点的pubKey - contract.setShadingId(0); // 默认 + contract.setShardingId(0); // 默认 switch (contract.getType()) { case RequestAllResponseFirst: case RequestAllResponseHalf: case RequestAllResponseAll: - case Shading: + case Sharding: contract.setNumOfCopies(nodeSize); break; default: @@ -245,8 +245,8 @@ public class MasterWSAction { String nodeID = nodeNames.get(i); // 根据i获得nodeID // for (String nodeID : nodeNames) { // 设置字段 - if (multiPointContractInfo.type == ContractExecType.Shading) { - contract.setShadingId(i); + if (multiPointContractInfo.type == ContractExecType.Sharding) { + contract.setShardingId(i); request.put("contractStr", JsonUtil.toJson(contract)); startReq = JsonUtil.toJson(request); LOGGER.debug("start contract: " + startReq); diff --git a/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java b/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java index 9775fab..e4e81d1 100644 --- a/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java +++ b/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java @@ -151,8 +151,8 @@ public class MasterClientTCPAction { new RequestAllExecutor( ContractExecType.RequestAllResponseAll, nodeSize, contractID); break; - case Shading: - executor = new ShadingExecutor(ContractExecType.Shading, nodeSize, contractID); + case Sharding: + executor = new MultiPointCooperationExecutor(ContractExecType.Sharding, nodeSize, contractID); break; } return executor; @@ -367,10 +367,10 @@ public class MasterClientTCPAction { String contractID = contract.getID(); // 获取contract type LOGGER.info(contract.getType()); - if (contract.getType() == ContractExecType.Shading) { - // 每节点都是master,且MPCI中需要实例化出ShadingExecutor, - // 需要计算出自己的ShadingID?路由规则(id/requester/arg-->shadingid), - // 也在shadingexecutor中实现 + if (contract.getType() == ContractExecType.Sharding) { + // 每节点都是master,且MPCI中需要实例化出MultiPointCooperationExecutor, + // 需要计算出自己的ShardingID?路由规则(id/requester/arg-->shardingId), + // 也在MultiPointCooperationExecutor中实现 } contractID2MasterInfo.put(contractID, this); // 记录contractID 和 master之间的对应关系 MultiContractMeta cei = @@ -418,7 +418,7 @@ public class MasterClientTCPAction { } // 这个地方判定,从参数中的master数据 和 globalConf中的数据 进行对比,如果一致的话,说明该节点为master cei.setMaster(jo.get("master").getAsString()); - if (contract.getType() != ContractExecType.Shading) + if (contract.getType() != ContractExecType.Sharding) cei.setIsMaster(GlobalConf.getNodeID().equals(jo.get("master").getAsString())); else cei.setIsMaster(true); @@ -448,7 +448,7 @@ public class MasterClientTCPAction { resultMap.put("pubKey", GlobalConf.instance.keyPair.getPublicKeyStr()); result.onResult(JsonUtil.toJson(resultMap)); } - if (contract.getType() == ContractExecType.Shading) { + if (contract.getType() == ContractExecType.Sharding) { for (String str : cei.getMembers()) { NetworkManager.instance.getNCClientHandler().controller.connectToMaster(str, null); } diff --git a/src/main/java/org/bdware/server/action/p2p/MasterServerRecoverMechAction.java b/src/main/java/org/bdware/server/action/p2p/MasterServerRecoverMechAction.java index f29ebf3..81a7e86 100644 --- a/src/main/java/org/bdware/server/action/p2p/MasterServerRecoverMechAction.java +++ b/src/main/java/org/bdware/server/action/p2p/MasterServerRecoverMechAction.java @@ -323,7 +323,7 @@ public class MasterServerRecoverMechAction { case RequestAllResponseFirst: case RequestAllResponseHalf: case RequestAllResponseAll: - case Shading: + case Sharding: ((RequestAllExecutor) cei.contractExecutor).setSeq(cei.getLastExeSeq() + 1); break; default: diff --git a/src/main/java/org/bdware/server/action/p2p/MasterServerTCPAction.java b/src/main/java/org/bdware/server/action/p2p/MasterServerTCPAction.java index 972c2fe..152544e 100644 --- a/src/main/java/org/bdware/server/action/p2p/MasterServerTCPAction.java +++ b/src/main/java/org/bdware/server/action/p2p/MasterServerTCPAction.java @@ -330,7 +330,7 @@ public class MasterServerTCPAction { // null") + // "\n"); - if (info != null && contractMeta.contract.getType() != ContractExecType.Shading) { + if (info != null && contractMeta.contract.getType() != ContractExecType.Sharding) { // 这个是个多节点的合约 // Just forward it to the correct Node // Master节点直接发3个,聚合后返回结果。 diff --git a/src/main/java/org/bdware/server/trustedmodel/MasterProxy.java b/src/main/java/org/bdware/server/trustedmodel/MasterProxy.java index 45b10fe..8e6a858 100644 --- a/src/main/java/org/bdware/server/trustedmodel/MasterProxy.java +++ b/src/main/java/org/bdware/server/trustedmodel/MasterProxy.java @@ -67,7 +67,7 @@ public class MasterProxy implements MasterStub { assert client.isUnit(); // ********** hyy ********** // // 修改这个地方的执行逻辑,判断路由 - LOGGER.debug(client.getContractType());//shading + LOGGER.debug(client.getContractType());//sharding // ********** hyy ********** // // assert client.isMaster(); diff --git a/src/main/java/org/bdware/server/trustedmodel/ShadingMultiPointContractInfo.java b/src/main/java/org/bdware/server/trustedmodel/MultiPointCooperateContractInfo.java similarity index 81% rename from src/main/java/org/bdware/server/trustedmodel/ShadingMultiPointContractInfo.java rename to src/main/java/org/bdware/server/trustedmodel/MultiPointCooperateContractInfo.java index 3317d95..997124e 100644 --- a/src/main/java/org/bdware/server/trustedmodel/ShadingMultiPointContractInfo.java +++ b/src/main/java/org/bdware/server/trustedmodel/MultiPointCooperateContractInfo.java @@ -6,9 +6,9 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; //改名 MultiPointCooperateContractInfo -public class ShadingMultiPointContractInfo extends MultiPointContractInfo { +public class MultiPointCooperateContractInfo extends MultiPointContractInfo { public List members; //pubKey - public List shadingId; //shading id 初始化时被分配 + public List shardingId; //sharding id 初始化时被分配 public String masterNode; public ContractExecType type; public ContractUnitStatus unitStatus = ContractUnitStatus.CommonMode; diff --git a/src/main/java/org/bdware/server/trustedmodel/ShadingExecutor.java b/src/main/java/org/bdware/server/trustedmodel/MultiPointCooperationExecutor.java similarity index 96% rename from src/main/java/org/bdware/server/trustedmodel/ShadingExecutor.java rename to src/main/java/org/bdware/server/trustedmodel/MultiPointCooperationExecutor.java index 805e50e..fbbb12b 100644 --- a/src/main/java/org/bdware/server/trustedmodel/ShadingExecutor.java +++ b/src/main/java/org/bdware/server/trustedmodel/MultiPointCooperationExecutor.java @@ -31,8 +31,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; // 改为MultiPointCooperationExecutor -public class ShadingExecutor implements ContractExecutor { - private static final Logger LOGGER = LogManager.getLogger(ShadingExecutor.class); +public class MultiPointCooperationExecutor implements ContractExecutor { + private static final Logger LOGGER = LogManager.getLogger(MultiPointCooperationExecutor.class); final Object lock = new Object(); int resultCount; AtomicInteger request_index = new AtomicInteger(0); @@ -43,8 +43,8 @@ public class ShadingExecutor implements ContractExecutor { // MultiPointContractInfo info; String contractID; - public ShadingExecutor(ContractExecType t, int c, String con_id) { - LOGGER.info("-- shading executor---"); + public MultiPointCooperationExecutor(ContractExecType t, int c, String con_id) { + LOGGER.info("-- sharding executor---"); type = t; resultCount = c; contractID = con_id; @@ -64,7 +64,7 @@ public class ShadingExecutor implements ContractExecutor { // TODO 加对应的超时? return new ResultCollector( requestID, - new ShadingExecutor.ResultMerger(originalCb, count, request_seq, contractID), + new MultiPointCooperationExecutor.ResultMerger(originalCb, count, request_seq, contractID), count); // 把count改成了1,设置成获得1个响应就行 } @@ -189,14 +189,14 @@ public class ShadingExecutor implements ContractExecutor { int c = resultCount; // TODO - if (type == ContractExecType.Shading) c = (int) Math.ceil((double) c / 2); + if (type == ContractExecType.Sharding) c = (int) Math.ceil((double) c / 2); LOGGER.info("c=" + c + " validNode=" + validNode); return validNode >= c; } @Override public void execute(String requestID, ResultCallback rc, ContractRequest req) { - LOGGER.info("[ShadingExecutor] execute " + JsonUtil.toJson(req)); + LOGGER.info("[MultiPointCooperationExecutor] execute " + JsonUtil.toJson(req)); // 获得action 函数名 LOGGER.info("action is : " + req.getAction());