mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +00:00
fix:typo error (shading->sharding)
This commit is contained in:
parent
9dba1ff749
commit
d634ebefb3
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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个,聚合后返回结果。
|
||||
|
@ -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();
|
||||
|
@ -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<String> members; //pubKey
|
||||
public List<Integer> shadingId; //shading id 初始化时被分配
|
||||
public List<Integer> shardingId; //sharding id 初始化时被分配
|
||||
public String masterNode;
|
||||
public ContractExecType type;
|
||||
public ContractUnitStatus unitStatus = ContractUnitStatus.CommonMode;
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user