feat: more default router function

This commit is contained in:
CaiHQ 2022-07-09 09:30:54 +08:00
parent 4ef2806c20
commit e336865cc1
4 changed files with 7 additions and 12 deletions

View File

@ -45,10 +45,8 @@ public class ComponedContractResult {
LOGGER.info("加入一个节点的执行结果是Error!该节点下线!"); LOGGER.info("加入一个节点的执行结果是Error!该节点下线!");
return; return;
} }
ContractResult cr2; ContractResult cr2;
try { try {
cr2 = JsonUtil.fromJson(obj.get("data").getAsString(), ContractResult.class); cr2 = JsonUtil.fromJson(obj.get("data").getAsString(), ContractResult.class);
if (cr2.status == ContractResult.Status.Error if (cr2.status == ContractResult.Status.Error
&& cr2.result.getAsString().equals(EXPIRED_REQ)) { && cr2.result.getAsString().equals(EXPIRED_REQ)) {
@ -122,7 +120,7 @@ public class ComponedContractResult {
} }
public ContractResult mergeFinalResult() { public ContractResult mergeFinalResult() {
LOGGER.info("mergeFinalResult"); // LOGGER.info("mergeFinalResult");
Map<JsonElement, Integer> map = new ConcurrentHashMap<>(); // <结果出现次数> Map<JsonElement, Integer> map = new ConcurrentHashMap<>(); // <结果出现次数>

View File

@ -165,13 +165,12 @@ public class SocketGet {
public void asyncGet(String pkgName, String method, String arg, ResultCallback cb) { public void asyncGet(String pkgName, String method, String arg, ResultCallback cb) {
try { try {
long id = random.nextLong(); long id;
if (!r.waitObj.containsKey(id) && null != cb) { for (id = random.nextLong(); r.waitObj.containsKey(id); id = random.nextLong()) ;
if (cb != null) {
r.waitObj.put(id, cb); r.waitObj.put(id, cb);
} else { r.sleep(id, cb);
LOGGER.warn("id conflict! " + id);
} }
r.sleep(id, cb);
request(pkgName, method, arg, id); request(pkgName, method, arg, id);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -1,8 +1,5 @@
package org.bdware.sc.bean; package org.bdware.sc.bean;
public enum DefaultRouteRule { public enum DefaultRouteRule {
byRequester, byRequester, byArgHash, byJsonPropHash, byShardingIDTree, byFunc;
byArgHash,
byTarget,
byFunc;
} }

View File

@ -11,6 +11,7 @@ public class RouteInfo implements Serializable {
// The signature of RouteFunction is // The signature of RouteFunction is
// function myFunc(requester, sourceArg) // function myFunc(requester, sourceArg)
public String funcName; public String funcName;
public String param;
public static RouteInfo create(AnnotationNode annotationNode, ContractNode contractNode) { public static RouteInfo create(AnnotationNode annotationNode, ContractNode contractNode) {
RouteInfo info = new RouteInfo(); RouteInfo info = new RouteInfo();