mirror of
https://gitee.com/BDWare/common
synced 2025-01-10 01:44:16 +00:00
Merge branch 'master' of gitee.com:BDWare/common
This commit is contained in:
commit
0dba1fe49a
@ -96,8 +96,8 @@ public class HashUtil {
|
||||
return h;
|
||||
}
|
||||
|
||||
public static String sha3(String value) {
|
||||
return Hex.toHexString(DIGEST_SHA3.digest(value.getBytes(StandardCharsets.UTF_8)));
|
||||
public static String sha3(String... value) {
|
||||
return Hex.toHexString(DIGEST_SHA3.digest(String.join("", value).getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
public static String sha3ToFixedLen(String value, int len) {
|
||||
|
@ -22,6 +22,15 @@ public interface NodeCenterConn {
|
||||
|
||||
JsonObject checkIsContract(String requestID, String json);
|
||||
|
||||
/**
|
||||
* get k nearest nodes to the key in the hash function range
|
||||
*
|
||||
* @param key the key
|
||||
* @param k the number of required node ids
|
||||
* @return ids of k nearest nodes
|
||||
*/
|
||||
String[] getClusterByKey(String key, int k);
|
||||
|
||||
class NodeKey {
|
||||
public String id;
|
||||
public BigInteger biId;
|
||||
|
@ -11,51 +11,20 @@ public enum ContractExecType implements Serializable {
|
||||
RequestAllResponseAll,
|
||||
Shading;//分片执行模式
|
||||
|
||||
public static boolean needSeq(ContractExecType ct) {
|
||||
boolean res = true;
|
||||
switch (ct) {
|
||||
case Sole:
|
||||
case RequestOnce:
|
||||
case ResponseOnce:
|
||||
res = false;
|
||||
break;
|
||||
case RequestAllResponseAll:
|
||||
case RequestAllResponseFirst:
|
||||
case RequestAllResponseHalf:
|
||||
case Shading:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static ContractExecType getContractTypeByInt(int i) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
return RequestOnce;
|
||||
case 2:
|
||||
return ResponseOnce;
|
||||
case 3:
|
||||
return RequestAllResponseFirst;
|
||||
case 4:
|
||||
return RequestAllResponseHalf;
|
||||
case 5:
|
||||
return RequestAllResponseAll;
|
||||
case 6:
|
||||
return Shading;
|
||||
default:
|
||||
return Sole;
|
||||
ContractExecType[] values = ContractExecType.values();
|
||||
if (i < 0 || i >= values.length) {
|
||||
return Sole;
|
||||
}
|
||||
return ContractExecType.values()[i];
|
||||
}
|
||||
|
||||
public boolean needSeq() {
|
||||
boolean res = true;
|
||||
switch (this) {
|
||||
case Sole:
|
||||
case RequestOnce:
|
||||
case ResponseOnce:
|
||||
res = false;
|
||||
break;
|
||||
return false;
|
||||
case RequestAllResponseAll:
|
||||
case RequestAllResponseFirst:
|
||||
case RequestAllResponseHalf:
|
||||
@ -63,6 +32,6 @@ public enum ContractExecType implements Serializable {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user