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