feat: support @RouteInfo byFunc
This commit is contained in:
parent
ff78ffc35d
commit
afa327419b
2
cm
2
cm
@ -1 +1 @@
|
|||||||
Subproject commit 71fa74ac14383644e50177ca6512d69a368eb023
|
Subproject commit c84cd3fac0a14afe33e5645044c6421efad2ee11
|
2
common
2
common
@ -1 +1 @@
|
|||||||
Subproject commit 8bf4b1c57d6899c25cde54782e8a3613a30fe506
|
Subproject commit 7a9ce393cdb14495eeb56507d00b8adf26438746
|
@ -1,5 +1,6 @@
|
|||||||
package org.bdware.consistency.plugin.sharding;
|
package org.bdware.consistency.plugin.sharding;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
@ -7,6 +8,7 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bdware.consistency.plugin.common.AbstractContextContractExecutor;
|
import org.bdware.consistency.plugin.common.AbstractContextContractExecutor;
|
||||||
import org.bdware.sc.ComponedContractResult;
|
import org.bdware.sc.ComponedContractResult;
|
||||||
|
import org.bdware.sc.ContractClient;
|
||||||
import org.bdware.sc.ContractMeta;
|
import org.bdware.sc.ContractMeta;
|
||||||
import org.bdware.sc.ContractResult;
|
import org.bdware.sc.ContractResult;
|
||||||
import org.bdware.sc.bean.*;
|
import org.bdware.sc.bean.*;
|
||||||
@ -20,10 +22,7 @@ import org.bdware.sc.util.JsonUtil;
|
|||||||
import org.bdware.server.trustedmodel.MultiReqSeq;
|
import org.bdware.server.trustedmodel.MultiReqSeq;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@ -123,6 +122,31 @@ public class MultiPointCooperationExecutor extends AbstractContextContractExecut
|
|||||||
val = val + members.length;
|
val = val + members.length;
|
||||||
}
|
}
|
||||||
return new String[]{members[val]};
|
return new String[]{members[val]};
|
||||||
|
case byFunc:
|
||||||
|
ContractClient client = cmActions.getManager().getClient(req.getContractID());
|
||||||
|
|
||||||
|
JsonArray membersArr = new JsonArray(members.length);
|
||||||
|
for (String member : members) {
|
||||||
|
membersArr.add(member);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject arg = new JsonObject();
|
||||||
|
arg.addProperty("funcName", routeInfo.funcName);
|
||||||
|
// func myFunc (currentNode, members, membersCount, sourceArg)
|
||||||
|
JsonArray funcArgs = new JsonArray();
|
||||||
|
funcArgs.add(globalConf.getNodeID());
|
||||||
|
funcArgs.add(membersArr);
|
||||||
|
funcArgs.add(membersArr.size());
|
||||||
|
funcArgs.add(req.getArg());
|
||||||
|
arg.add("funcArgs", funcArgs);
|
||||||
|
|
||||||
|
String routeResultStr = client.executeMethod("", "invokeFunctionWithoutLimit", arg.toString());
|
||||||
|
JsonObject routeResult = JsonUtil.parseString(routeResultStr).getAsJsonObject();
|
||||||
|
List<String> nodes = new ArrayList<>();
|
||||||
|
for (String key: routeResult.keySet()) {
|
||||||
|
nodes.add(routeResult.get(key).getAsString());
|
||||||
|
}
|
||||||
|
return nodes.toArray(new String[]{});
|
||||||
default:
|
default:
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
|
2
gmhelper
2
gmhelper
@ -1 +1 @@
|
|||||||
Subproject commit 8f8c0f27dfe7a45728a58c04f2e29c7a07cffeb5
|
Subproject commit a696b5a843a1bd09a84002ba6161a2a07d77e153
|
Loading…
x
Reference in New Issue
Block a user