update controlproxy

This commit is contained in:
CaiHQ 2022-06-25 11:11:03 +08:00
parent ed40b7788b
commit e063cb0105
19 changed files with 638 additions and 249 deletions

2
backend/.gitignore vendored
View File

@ -2,6 +2,8 @@
/build/
/cplibs/
cplibs
deploy
contractDB
# Compiled class file
*.class

View File

@ -1,6 +1,12 @@
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath files("buildlibs/simple-ypk-packer-0.2.0.jar")
classpath "org.bdware.bdcontract:simple-ypk-packer:0.5.0"
classpath "org.bdware.bdcontract:ypk-deploy-tool:0.5.2"
}
}
@ -8,6 +14,8 @@ plugins {
id 'java'
id 'java-library'
}
version = "1.2.0"
group = 'org.bdware.sc.controlproxy'
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:none'
@ -34,19 +42,20 @@ sourceSets {
}
dependencies {
api 'org.apache.logging.log4j:log4j-core:2.14.1'
api 'org.apache.logging.log4j:log4j-api:2.14.1'
api 'org.apache.logging.log4j:log4j-core:2.17.2'
api 'org.apache.logging.log4j:log4j-api:2.17.2'
api 'com.google.code.gson:gson:2.8.8'
implementation fileTree(dir: 'cplibs', include: '*.jar')
implementation fileTree(dir: 'cplibs/lib/', include: '*.jar')
implementation 'org.bdware.doip:doip-audit-tool:0.9.0'
implementation 'org.bdware.sc:cp:1.5.7'
implementation 'org.bdware.doip:doip-audit-tool:0.9.4'
implementation 'org.bdware.bdcontract:sdk-java:1.0.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.bdware.bdcontract:ypk-deploy-tool:0.4.0'
}
task copyLibs(type: Copy) {
from configurations.runtimeClasspath
into "./build/output/libs/"
}
task copyYJS(type: Copy) {
@ -69,17 +78,30 @@ task copyJar(type: Copy, dependsOn: [":backend:jar", ":backend:copyLibs"]) {
doFirst {
println "copyJar start"
}
}
task grepCP(dependsOn: [":backend:copyJar"]) {
doLast {
org.bdware.datanet.YPKPacker.grepJarByCPVersion("./backend/build/output/libs", org.bdware.datanet.CPVersion.cp_1_5_3)
// org.bdware.datanet.YPKPacker.grepCPLibWithFilter("./backend/cplibs/libs/", "./backend/build/output/libs", "./backend/grepcp.list")
}
}
task buildZip(type: Zip, dependsOn: ["copyAssets", "copyJar", "copyYJS"]) {
task buildZip(type: Zip, dependsOn: ["copyAssets", "grepCP", "copyJar", "copyYJS"]) {
from './build/output/'
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveFileName = 'ControlProxy.zip'
destinationDirectory = file('build/')
}
task buildYPK(dependsOn: ["buildZip"]) {
task buildYPK(dependsOn: ["buildZip", "grepCP"]) {
doLast {
org.bdware.datanet.YPKPacker.staticPack("./backend/build/ControlProxy.zip", "./backend/build/ControlProxy-${project.version}.ypk")
}
}
task deploy(dependsOn: ["buildYPK"]) {
doLast {
org.bdware.ypkdeploy.HTTPTool.batchRun("./backend/deployconfig.json", true)
}
}

View File

@ -1,14 +1,15 @@
{
"agentHttpAddr": "127.0.0.1:18000",
"agentHttpAddr": "127.0.0.1:18010",
"createParam": {
"privateKey": "4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b",
"publicKey": "04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98",
"prefix": "macjw.ab",
"prefix": "bdtest",
"router": "GlobalRouter",
"routerURI": "tcp://localhost:2042",
"routerURI": "tcp://127.0.0.1:18041",
"auditType": "OnlyHash"
},
"script": "/Users/huaqiancai/BDWare/datanet/ControlProxy/backend/build/ControlProxy-0.8.7.ypk",
"script": "/Users/huaqiancai/BDWare/datanet/ControlProxy/backend/build/ControlProxy-0.9.8.ypk",
"pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd",
"privKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf7repodetail.yjs69f139da36a807911d20f8"
"privKey": "589d94ee5688358a1c5c18430dd9c75097ddddebf769f139da36a807911d20f8"
}

16
backend/deployconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"host": "127.0.0.1",
"privateKey": "d675782acf011dbc01a73c7967ccff9564486f7c3a9f5d5de151caffaa18936",
"publicKey": "04303718771b9323c204e607639f14469f9a94e55b0964a408ad3b3864b0493b645d7070da0d550f0c54b934275a8e88dedc3024467b0566db5c1108b1baeaae27",
"ypkPath": "/Users/huaqiancai/BDWare/datanet/ControlProxy/backend/build/ControlProxy-0.9.6.ypk",
"killBeforeStart": "ControlProxy",
"createParam": {
"privateKey": "4616ff0e2a4f982364914f9be30b51c6bc6ccb6602114a9ee8792f2ccf67465b",
"publicKey": "04f9b9b8f324908464f78a6235e2dd93e4dfdaf045e9b1b5cfd57374516cc61a79a86fc2b42d3321a5b49a0f25381a7bed61901b40b729f72354e716673d551e98",
"prefix": "bdtest",
"router": "GlobalRouter",
"routerURI": "tcp://127.0.0.1:18041",
"auditType": "OnlyHash"
},
"agentPort": 18010
}

1
backend/grepcp.list Normal file
View File

@ -0,0 +1 @@
yjs.jar

View File

@ -4,6 +4,7 @@ import com.google.gson.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.audit.EndpointConfig;
import org.bdware.doip.audit.SM2Signer;
import org.bdware.doip.audit.client.AuditDoipClient;
import org.bdware.doip.audit.client.AuditIrpClient;
import org.bdware.doip.audit.config.TempConfigStorage;
@ -24,6 +25,7 @@ public class RepoProxy {
}
static String prefix;
public static String router;
static EndpointConfig endpointConfig;
public static void init(Object obj) {
@ -37,11 +39,15 @@ public class RepoProxy {
TempConfigStorage storage = new TempConfigStorage((String) obj);
endpointConfig = storage.loadAsEndpointConfig();
prefix = storage.load().get("prefix").getAsString();
router = storage.load().get("router").getAsString();
} else {
JsonElement je = JSONTool.convertMirrorToJson(obj);
TempConfigStorage storage = new TempConfigStorage(je.toString());
endpointConfig = storage.loadAsEndpointConfig();
prefix = storage.load().get("prefix").getAsString();
router = storage.load().get("router").getAsString();
}
}
@ -59,13 +65,12 @@ public class RepoProxy {
if (!doId.contains("/")) {
doId = prefix + "/" + doId;
}
ClientConfig config = null;
AuditType type = null;
try {
AuditIrpClient irpClient = new AuditIrpClient(endpointConfig);
AuditConfig auditConfig = irpClient.getAuditConfig();
AuditDoipClient client = new AuditDoipClient(auditConfig);
AuditDoipClient client = new AuditDoipClient(auditConfig, new SM2Signer(null));
StateInfoBase result = irpClient.resolve(doId);
config = new ClientConfig(result.getValues("address"));
client.connect(config);

View File

@ -0,0 +1,130 @@
package org.bdware.sc.controlproxy;
import com.google.gson.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.client.SmartContractHttpClient;
import org.bdware.sc.ContractResult;
import org.bdware.sc.bean.ContractRequest;
import org.bdware.sc.boundry.JavaScriptEntry;
import org.bdware.sc.engine.JSONTool;
import org.bdware.sc.util.JsonUtil;
import wrp.jdk.nashorn.api.scripting.ScriptObjectMirror;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
public class TopologyCollector {
static Logger LOGGER = LogManager.getLogger(TopologyCollector.class);
public static List<JsonObject> getCurrentTopology() {
TopologyGraph graph = new TopologyGraph();
//通过SearchEngine可拿到本级的Repo或下组的SE)与SearchEngine的关系
//通过Router可拿到本级的Repo列表也可拿到下组Router列表
JsonPrimitive arg = new JsonPrimitive("a");
ContractResult currentRouters = executeContract(RepoProxy.router, "getRouterInfo", arg);
//--------构建Router网
JsonObject root = JsonUtil.parseStringAsJsonObject(currentRouters.result.getAsJsonObject().get("data").getAsString());
JsonObject rootNode = new JsonObject();
rootNode.add("name", root.get("name"));
rootNode.add("doId", root.get("doId"));
rootNode.addProperty("type", "Router");
rootNode.add("previousNode", new JsonArray());
graph.addNode(rootNode);
ContractResult nextRouters = executeContract(RepoProxy.router, "listLRS", arg);
JsonArray routersArray = nextRouters.result.getAsJsonObject().get("data").getAsJsonArray();
for (JsonElement je : routersArray) {
JsonObject node = new JsonObject();
JsonObject from = je.getAsJsonObject();
node.add("name", from.get("name"));
node.add("doId", from.get("doId"));
node.addProperty("type", "Router");
graph.addNode(node);
graph.addEdge(node.get("doId").getAsString(), root.get("doId").getAsString());
}
//--------Router网构建完毕
//--------构建SearchEngine网-----
JsonObject searchEngine = new JsonObject();
searchEngine.addProperty("doId", root.get("doId").getAsString() + "/SearchEngine");
searchEngine.addProperty("type", "SearchEngine");
searchEngine.addProperty("name", root.get("name").getAsString() + "搜索引擎");
graph.addNode(searchEngine);
//下级SearchEngine同步至上级
for (JsonElement je : routersArray) {
JsonObject node = new JsonObject();
JsonObject from = je.getAsJsonObject();
node.addProperty("doId", from.get("doId").getAsString() + "/SearchEngine");
node.addProperty("type", "SearchEngine");
node.addProperty("name", from.get("name").getAsString() + "搜索引擎");
graph.addNode(node);
graph.addEdge(node.get("doId").getAsString(), searchEngine.get("doId").getAsString());
}
JsonObject gateway = new JsonObject();
gateway.addProperty("doId", root.get("doId").getAsString() + "/GateWay");
gateway.addProperty("type", "GateWay");
gateway.addProperty("name", root.get("name").getAsString() + "网关");
graph.addNode(gateway);
//TODO 通过SearchEngine把Repo的关系给弄上
//-----------------
ContractResult currentRepos = executeContract(RepoProxy.router, "listRepo", arg);
JsonArray repos = currentRepos.result.getAsJsonObject().get("data").getAsJsonArray();
for (JsonElement je : repos) {
JsonObject from = je.getAsJsonObject();
String name = from.get("name").getAsString();
if (name.equals("AuditProxy") || name.equals("ControlProxy"))
continue;
if (name.equals("SearchEngine") || name.equals("GateWay"))
continue;
JsonObject node = new JsonObject();
node.add("name", from.get("name"));
node.add("doId", from.get("doId"));
node.addProperty("type", "Repo");
graph.addNode(node);
graph.addEdge(node.get("doId").getAsString(), searchEngine.get("doId").getAsString());
graph.addEdge(node.get("doId").getAsString(), gateway.get("doId").getAsString());
}
graph.pruneEdges();
return graph.ret;
}
private static ContractResult executeContract(String contractName, String operation, JsonElement arg) {
Object jsobj = JavaScriptEntry.executeContract(contractName, operation, arg);
Object som = ScriptObjectMirror.wrap(jsobj, JavaScriptEntry.getEngineGlobal());
JsonElement je = JSONTool.convertMirrorToJson(som);
LOGGER.info(je.toString());
ContractResult contractResult = new Gson().fromJson(je, ContractResult.class);
return contractResult;
}
//{
// "name":"小店区仓库","doId":"bdware.ss.ab/Repo1","type":"Repo","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2","bdware.ss.ab/Repo2","bdware.ss.zz/SearchEngine"]}
//
public static List<JsonObject> getLevelTopology(int arg) {
List<JsonObject> points = getCurrentTopology();
TopologyGraph graph = new TopologyGraph();
graph.addGraph(points);
if (arg > 0) {
ContractResult nextRouters = executeContract(RepoProxy.router, "listLRS", new JsonPrimitive("a"));
JsonArray routersArray = nextRouters.result.getAsJsonObject().get("data").getAsJsonArray();
for (JsonElement je : routersArray) {
try {
String nextControlProxy = je.getAsJsonObject().get("doId").getAsString() + "/ControlProxy";
ContractResult cr = executeContract(RepoProxy.router, "resolveTest", new JsonPrimitive(nextControlProxy));
URI uri = null;
uri = new URI(JsonUtil.parseStringAsJsonObject(cr.result.getAsString()).get("address").getAsString());
SmartContractHttpClient client = new SmartContractHttpClient(JavaScriptEntry.getKeyPair(), uri.getHost(), uri.getPort());
String url = client.getExecuteUrl("ControlProxy", "getLevelTopology", (arg - 1) + "");
LOGGER.info(url);
JsonObject result = client.executeContract("ControlProxy", "getLevelTopology", (arg - 1) + "");
graph.addGraph(result.get("result").getAsJsonArray());
} catch (Exception e) {
e.printStackTrace();
}
}
}
return graph.ret;
}
}

View File

@ -0,0 +1,89 @@
package org.bdware.sc.controlproxy;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.*;
public class TopologyGraph {
List<JsonObject> ret = new ArrayList<>();
Map<String, JsonObject> doIdToNode = new HashMap<>();
public void addNode(JsonObject jsonObject) {
String doId = jsonObject.get("doId").getAsString();
if (doIdToNode.containsKey(doId)) {
JsonObject already = doIdToNode.get(doId);
mergeNode(already, jsonObject);
} else {
ret.add(jsonObject);
doIdToNode.put(doId, jsonObject);
}
}
public void addGraph(TopologyGraph g) {
addGraph(g.ret);
}
public void addGraph(List<JsonObject> points) {
for (JsonObject jo : points) {
addNode(jo);
}
}
public void addGraph(JsonArray points) {
for (JsonElement jo : points) {
addNode(jo.getAsJsonObject());
}
}
private void mergeNode(JsonObject already, JsonObject jsonObject) {
for (String key : jsonObject.keySet()) {
if (!already.has(key))
already.add(key, jsonObject.get(key));
else {
if (key.equals("previousNode")) {
JsonArray current = already.get("previousNode").getAsJsonArray();
current.addAll(jsonObject.get("previousNode").getAsJsonArray());
}
}
}
}
public void pruneEdges() {
for (JsonObject node : ret) {
if (node.has("previousNode")) {
JsonArray array = node.get("previousNode").getAsJsonArray();
Set<String> dedup = new HashSet<>();
for (JsonElement je : array) {
dedup.add(je.getAsString());
}
JsonArray deduped = new JsonArray();
for (String str : dedup) {
deduped.add(str);
}
node.add("previousNode", deduped);
}
}
}
public void addEdge(String from, String to) {
JsonObject fromJO = getOrCreateNode(from);
JsonObject toJo = getOrCreateNode(to);
if (!fromJO.has("previousNode")) {
fromJO.add("previousNode", new JsonArray());
}
fromJO.get("previousNode").getAsJsonArray().add(to);
}
private JsonObject getOrCreateNode(String from) {
if (!doIdToNode.containsKey(from)) {
JsonObject jo = new JsonObject();
jo.addProperty("doId", from);
addNode(jo);
}
return doIdToNode.get(from);
}
}

View File

@ -0,0 +1,10 @@
import org.junit.Test;
import org.bdware.ypkdeploy.HTTPTool;
public class DeployTestNet {
@Test
public void deployControlProxy() {
HTTPTool.batchRun("./deploy/CP_bdtest.json", true);
HTTPTool.batchRun("./deploy/CP_bdtest_eg.json", true);
HTTPTool.batchRun("./deploy/CP_bdtest_rs.json", true);
}
}

View File

@ -1,140 +1,192 @@
import "repodetail.yjs"
import "search.yjs"
import "audit.yjs"
import "networking.yjs"
import "DAC.yjs"
import "repodetail.yjs";
import "search.yjs";
import "audit.yjs";
import "networking.yjs";
import "DAC.yjs";
import "union.yjs";
//网关为Gateway
//路由器改名为Resolver中文名为标识解析系统
//搜索引擎改名为为Registry中文名为注册表系统
//本文接口由李智负责对接。
contract ControlProxy{
function convertArgToJson(arg){
if (typeof(arg)=='string' && !arg.startsWith("{")) return arg;
if (typeof(arg)=='string') return JSON.parse(arg);
return arg;
}
function onCreate(arg){
if (arg==null|| typeof(arg)=='string'){
arg={"prefix":"test.ab.cd",
"router":"GlobalRouter"
};
contract ControlProxy {
function convertArgToJson(arg) {
if (typeof(arg)=='string' && !arg.startsWith("{")) return arg;
if (typeof(arg)=='string') return JSON.parse(arg);
return arg;
}
arg = convertArgToJson(arg);
Global.router = "GlobalRouter";
Global.prefix = arg.prefix;
Global.router = arg.router;
initDAC(requester);
org.bdware.sc.controlproxy.RepoProxy.init(arg);
}
function isString(arg){
return typeof(arg)=='string';
}
export function isOwner(){
return checkPermission(requester);
}
@Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}")
export function addRepo(arg){
arg = convertArgToJson(arg);
if (arg.doId ==undefined ){
return {
"msg":"missing arguments repoId ","code":1};
function onCreate(arg) {
if (arg==null|| typeof(arg)=='string'){
arg = {
"prefix":"test.ab.cd", "router":"GlobalRouter"
};
}
arg = convertArgToJson(arg);
Global.router = "GlobalRouter";
Global.prefix = arg.prefix;
Global.router = arg.router;
initDAC(requester);
org.bdware.sc.controlproxy.RepoProxy.init(arg);
}
executeContract("Gateway","addLocalRepo",arg);
return {
"msg":"success","rrt":"110ms","code":0};
}
//网关需新增的接口
@Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}")
export function pingRepo(arg){
arg = convertArgToJson(arg);
if (arg.doId ==undefined ){
return {
"msg":"missing arguments repoId ","code":1};
}
var ret = executeContract("Gateway","pingRepo",arg.doId);
ret = ret.result
if(ret.rrt > 0)
return {
"msg":"success","rrt":ret.rrt,"code":0,"repoInfo":JSON.parse(ret.repoInfo)};
else
return {
"msg":"repo is unconnected","code":1};
}
//网关的接口
export function getCCCCCCCCCCCCConfInfo(){
return Global;
}
@Descripton("无参数")
export function getRepoList(arg){
function isString(arg) {
return typeof(arg)=='string';
}
export function getControlProxyConfig() {
return org.bdware.sc.controlproxy.RepoProxy.getConfig();
}
export function isOwner() {
return checkPermission(requester);
}
@Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}")
export function addRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId ==undefined ){
return {
"msg":"missing arguments repoId ", "code":1
};
}
executeContract("Gateway", "addLocalRepo", arg);
return {
"msg":"success", "rrt":"110ms", "code":0
};
}
//网关需新增的接口
@Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}")
export function pingRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId ==undefined ){
return {
"msg":"missing arguments repoId ", "code":1
};
}
var ret = executeContract("Gateway", "pingRepo", arg.doId);
ret = ret.result;
if (ret.rrt > 0)
return {
"msg":"success", "rrt":ret.rrt, "code":0, "repoInfo":JSON.parse(ret.repoInfo)
}; else return {
"msg":"repo is unconnected", "code":1
};
}
//网关的接口
@Descripton("无参数")
export function getRepoList(arg) {
//use configed arg.routerId;
//TODO!!
ret = executeContract(Global.router,"listRepo","");
//ret=executeContract("Gateway","listLocalRepo","");
//var list = ret.result
return ret.result;
}
//网关的接口
@Descripton("参数为 {\"doId\":\"bdware.ss/Repox\"}")
export function deleteRepo(arg){
arg = convertArgToJson(arg);
if (arg.doId != null && arg.doId.indexOf(Global.prefix) != -1){
executeContract("Gateway","deleteLocalRepo",arg.doId);
return {
"status":"success","code":0};
ret = executeContract(Global.router, "listRepo", "");
//ret=executeContract("Gateway","listLocalRepo","");
//var list = ret.result
return ret.result;
}
return {
"msg":"can not found repo","code":1};
}
//网关的接口 需新增
@Descripton("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]")
export function deleteRepoList(arg){
arg = convertArgToJson(arg);
var ret = [];
for (var i=0;i<arg.length;i++){
ret.push(deleteRepo(arg[i]));
//网关的接口
@Descripton("参数为 {\"doId\":\"bdware.ss/Repox\"}")
export function deleteRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId != null && arg.doId.indexOf(Global.prefix) != -1){
executeContract("Gateway", "deleteLocalRepo", arg.doId);
return {
"status":"success", "code":0
};
}
return {
"msg":"can not found repo", "code":1
};
}
return ret;
}
//网关的接口
@Descripton("参数为 {\"doId\":..., \"address\":..., \"owner\":..., }")
export function updateRepo(arg){
arg = convertArgToJson(arg);
if (arg.doId!=null){
executeContract("Gateway","addLocalRepo",arg);
return {
"msg":"success","code":0};
//网关的接口 需新增
@Descripton("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]")
export function deleteRepoList(arg) {
arg = convertArgToJson(arg);
var ret = [];
for (var i = 0;
i<arg.length;
i++){
ret.push(deleteRepo(arg[i]));
}
return ret;
}
//网关的接口
@Descripton("参数为 {\"doId\":..., \"address\":..., \"owner\":..., }")
export function updateRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId!=null){
executeContract("Gateway", "addLocalRepo", arg);
return {
"msg":"success", "code":0
};
}
return {
"msg":"missing arguments", "code":1
};
}
export function getLevelTopology(arg) {
return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0);
}
export function getAllTopology(arg) {
if (arg==null|| arg.length==0) {
return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(2);
} else return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0);
}
//总体拓扑图
//@范博
export function getAllTopology2() {
var nodeList = [];
nodeList.push({
"name":"小店区仓库", "doId":"bdware.ss.ab/Repo1", "type":"Repo", "previousNode":["bdware.ss/Gateway1", "bdware.ss/Gateway2", "bdware.ss.ab/Repo2", "bdware.ss.zz/SearchEngine"]
}
);
nodeList.push({
"name":"小山区仓库", "doId":"bdware.ss.ab/Repo2", "type":"Repo", "previousNode":["bdware.ss/Gateway1", "bdware.ss/Gateway2", "bdware.ss.ab/SearchEngine"]
}
);
nodeList.push({
"name":"太原内部共享网关", "doId":"bdware.ss/Gateway1", "type":"Gateway", "previousNode":["bdware/Gateway1", "bdware/Gateway2"]
}
);
nodeList.push({
"name":"太原对外开放网关", "doId":"bdware.ss/Gateway2", "type":"Gateway", "previousNode":["bdware/Gateway1"]
}
);
nodeList.push({
"name":"山西内部共享网关", "doId":"bdware/Gateway1", "type":"Gateway"
}
);
nodeList.push({
"name":"山西内部共享网关2", "doId":"bdware/Gateway2", "type":"Gateway"
}
);
nodeList.push({
"name":"xxx搜索引擎", "doId":"bdware.ss/SearchEngine", "type":"SearchEngine", "previousNode":["bdware.ss.cc/SearchEngine"]
}
);
nodeList.push({
"name":"山西内部共享搜索引擎2", "doId":"bdware.ss.ab/SearchEngine", "type":"SearchEngine", "previousNode":["bdware.ss/SearchEngine"]
}
);
nodeList.push({
"name":"yyy搜索引擎", "doId":"bdware.ss.cc/SearchEngine", "type":"SearchEngine"
}
);
nodeList.push({
"name":"zzz搜索引擎", "doId":"bdware.ss.zz/SearchEngine", "type":"SearchEngine", "previousNode":["bdware.ss.cc/SearchEngine"]
}
);
nodeList.push({
"name":"贵州省域路由器", "doId":"bdware.ss.ab", "type":"Router", "previousNode":["bdware"]
}
);
nodeList.push({
"name":"山西省域路由器", "doId":"bdware.ss", "type":"Router", "previousNode":["bdware"]
}
);
nodeList.push({
"name":"数瑞测试网", "doId":"bdware", "type":"Router"
}
);
return nodeList;
}
return {
"msg":"missing arguments","code":1};
}
//总体拓扑图
//@范博
export function getAllTopology(){
var nodeList = [];
nodeList.push({
"name":"小店区仓库","doId":"bdware.ss.ab/Repo1","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2"]}
);
nodeList.push({
"name":"太原内部共享网关","doId":"bdware.ss/Gateway1","previousNode":["bdware/Gateway1", "bdware/Gateway2"]}
);
nodeList.push({
"name":"太原对外开放网关","doId":"bdware.ss/Gateway2", "previousNode":["bdware/Gateway1"]}
);
nodeList.push({
"name":"山西内部共享网关","doId":"bdware/Gateway1"}
);
nodeList.push({
"name":"山西内部共享网关2","doId":"bdware/Gateway2"}
);
return nodeList;
}
}

View File

@ -1,13 +1,86 @@
module Audit{
export function getDoipAction(){
export function getDoipAction(){
return [
{ value: 2048, name: 'Search Engine' },
{ value: 735, name: 'Direct' },
{ value: 380, name: 'Email' },
{ value: 484, name: 'Union Ads' },
{ value: 100, name: 'Video Ads' },
{ value: 0, name: '0.DOIP/Op.Hello' },
{ value: 1, name: '0.DOIP/Op.ListOperations' },
{ value: 2, name: '0.DOIP/Op.Retrieve' },
{ value: 3, name: '0.DOIP/Op.Create' },
{ value: 4, name: '0.DOIP/Op.Update' },
{ value: 5, name: '0.DOIP/Op.Delete' },
{ value: 6, name: '0.DOIP/Op.Search' },
{ value: 7, name: '0.DOIP/Op.Extension' },
{ value: 8, name: '0.DOIP/Op.Unknown' }
]
}
}
export function getAuditRule(arg){
// {"repoId":"xxx"}
var ret = [];
ret.push({"displayName":"原始数据存证","desc":"原始数据存证到指定数据库,哈希数据存证","type":2});
ret.push({"displayName":"哈希数据存证","desc":"仅哈希数据存证","type":1});
ret.push({"displayName":"不存证","desc":"不存证","type":0 });
return ret;
}
//@wyq TODO TODO
// 这个通过DOIPUtil去调用
// DOIP的接口。
@Description("{\"doId\":\"macjw.ab/repofile\"}");
export function getDoAuditRule(arg){
arg = convertArgToJson(arg);
if(arg.count==undefined) arg.count=10;
if(arg.offset==undefined) arg.offset=0;
return org.bdware.sc.controlproxy.RepoProxy.getDoAuditRule(arg);
}
//@wyq
export function setDoAuditRule(arg){
///arg={"doIdList":["dd","ddd.xx/xxx",...],"type":1}
arg = convertArgToJson(arg);
if(arg.count==undefined) arg.count=10;
if(arg.offset==undefined) arg.offset=0;
return {"msg":"success","code":0};
}
//通过AuditProxy实现 @董瑞 需实现支持多标签索引的put接口。
//======在全领监管->总体情况概览
//使用以下参数获取DO数量变化趋势
// interval=1周/1月/1年。。 eventPrefix的数组里为"irp_register"
//使用以下参数获取操作数量统计
// interavl= endTime-startTime eventPrefix的数组里为""
// 使用以下参数数字对象操作统计
//eventPrefix为["doip","irp"] 已完成√
// 使用以下参数获取doip操作统计
//exentPrefix为["doip_create","doip_update","doip_delete","doip_retrieve","doip_hello","doip_list_operations","doip_search"] 已完成√
// 使用以下参数获取irp操作统计
//exentPrefix为["irp_create","irp_delete","irp_update","irp_batch_create","irp_resolution"] 已完成√
// 使用以下参数获取doip、irp的成功率
//exentPrefix为["irp_op_success","irp_op_failed"]
//exentPrefix为["doip_op_success","doip_op_failed"]
//======在全领监管->总体情况概览
@Description("{\"doId\":\"86.20.100/repo4/bcrs\",\"startTime\":1644390000000, \"endTime\":1644404400000,\"interval\":3600000, \"eventPrefix\":[\"doip_retrieve\", \"doip_update\", \"doip_search\", \"doip_delete\"]}")
export function countRecordByDate(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","countRecordByDate",arg).result;
}
export function queryByHash(arg){
arg=convertArgToJson(arg);
var ret = executeContract("AutoAudit","queryByHash",arg.hash).result;
if (typeof(ret)=='string'){
var ret2={};
ret2.code = 1;
ret2.msg = ret;
ret = ret2;
} else {
ret.code = 0;
}
return ret;
}
export function queryByHashOriginal(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","queryByHashOriginal",arg.hash).result;
}
}

View File

@ -1,12 +0,0 @@
oracle ContractExample {
function onCreate(){
Global.owner = requester;
}
export function callHello(arg){
return Hello.call()+requester;
}
export function getOwner(){
return Global.owner;
}
}

View File

@ -4,6 +4,6 @@
"insnLimit": 0,
"buildTime": 1650245588814,
"builder": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926",
"startAtUnpack": true,
"startAtUnpack": false,
"sourcePath": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926/ControlProxy"
}

View File

@ -287,21 +287,16 @@ module networking{
}
@ArgSchema({"!doId": "string","!address":"string"})
export function resolveDoId(arg){
var ret=executeContract(Global.router,"resolveDoId",arg);
var obj = ret.result;
var obj1 = obj.data;
var obj2 = JSON.parse(obj1);
if (obj.result=="success" || obj.result == undefined) {
if (obj2.name != "NotFound") {
obj.result=undefined;
obj.code=0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
}
arg = convertArgToJson(arg);
var ret = executeContract(Global.router,"resolveTest",arg.doId);
var retObj = {};
if (ret.status == "Success" && ret.result != undefined) {
retObj.data = ret.result;
retObj.code = 0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
YancloudUtil.exceptionReturn({"msg":obj1,"code":1});
}
return obj;
return retObj;
}
}

View File

@ -1,37 +1,4 @@
module RepoDetail{
export function getControlProxyConfig(){
return org.bdware.sc.controlproxy.RepoProxy.getConfig();
}
//@wyq 通过DOIP请求
export function getAuditRule(arg){
// {"repoId":"xxx"}
var ret = [];
ret.push({"displayName":"原始数据存证","desc":"原始数据存证到指定数据库,哈希数据存证","type":2});
ret.push({"displayName":"哈希数据存证","desc":"仅哈希数据存证","type":1});
ret.push({"displayName":"不存证","desc":"不存证","type":0 });
return ret;
}
//@wyq TODO TODO
// 这个通过DOIPUtil去调用
// DOIP的接口。
@Description("{\"doId\":\"macjw.ab/repofile\"}");
export function getDoAuditRule(arg){
arg = convertArgToJson(arg);
if(arg.count==undefined) arg.count=10;
if(arg.offset==undefined) arg.offset=0;
return org.bdware.sc.controlproxy.RepoProxy.getDoAuditRule(arg);
}
//@wyq
export function setDoAuditRule(arg){
///arg={"doIdList":["dd","ddd.xx/xxx",...],"type":1}
arg = convertArgToJson(arg);
if(arg.count==undefined) arg.count=10;
if(arg.offset==undefined) arg.offset=0;
return {"msg":"success","code":0};
}
//宏伟
//如果有指定repo那就是指定repo的DOlist。
//如果没指定repo那就是全部的。
@ -99,8 +66,6 @@ module RepoDetail{
//比如查询总搜索次数参数格式为eventPrefix:["doip_search"]
//查询调用统计参数格式为eventPrefix:[""]然后interval/startTime/fromTime传对了就行。
//索引统计,暂时还没有。
export function getStaticIndex(arg){
arg = convertArgToJson(arg);
if (arg.from==undefined)

View File

@ -42,28 +42,7 @@ module SearchModule{
// "doId":"bdware.txte/Repo2","count":12}
// ]};
}
//通过AuditProxy实现 @董瑞 需实现支持多标签索引的put接口。
//======在全领监管->总体情况概览
//使用以下参数获取DO数量变化趋势
// interval=1周/1月/1年。。 eventPrefix的数组里为"irp_register"
//使用以下参数获取操作数量统计
// interavl= endTime-startTime eventPrefix的数组里为""
// 使用以下参数数字对象操作统计
//eventPrefix为["doip","irp"] 已完成√
// 使用以下参数获取doip操作统计
//exentPrefix为["doip_create","doip_update","doip_delete","doip_retrieve","doip_hello","doip_list_operations","doip_search"] 已完成√
// 使用以下参数获取irp操作统计
//exentPrefix为["irp_create","irp_delete","irp_update","irp_batch_create","irp_resolution"] 已完成√
// 使用以下参数获取doip、irp的成功率
//exentPrefix为["irp_op_success","irp_op_failed"]
//exentPrefix为["doip_op_success","doip_op_failed"]
//======在全领监管->总体情况概览
@Description("{\"doId\":\"86.20.100/repo4/bcrs\",\"startTime\":1644390000000, \"endTime\":1644404400000,\"interval\":3600000, \"eventPrefix\":[\"doip_retrieve\", \"doip_update\", \"doip_search\", \"doip_delete\"]}")
export function countRecordByDate(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","countRecordByDate",arg).result;
}
export function testCount(arg){
return {"data":"key"};
}
@ -101,6 +80,7 @@ module SearchModule{
var res=executeContract("SearchEngine","searchByRange",arg);
return res.result;
}
//支持模糊查询、按创建时间查询。
//输入参数:
//type要查询的字段
@ -127,14 +107,4 @@ module SearchModule{
// );
//return {"data":ret,"total":3};
}
export function queryByHash(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","queryByHash",arg.hash).result;
}
export function queryByHashOriginal(arg){
arg=convertArgToJson(arg);
return executeContract("AutoAudit","queryByHashOriginal",arg.hash).result;
}
}

73
backend/yjs/union.yjs Executable file
View File

@ -0,0 +1,73 @@
module unions {
@Descripton("无参数")
export function getUnionMembers(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret = {
};
ret.code = 0;
if (Global.unions==undefined){
ret.data = [];
} else {
ret.data = Global.unions;
}
return ret;
}
export function resetUnionConfig() {
Global.unions = null;
}
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\"\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({
"!unionName": "string", "!orgName":"string", "!email": "string", "!contact":"string"
})
export function createUnion(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
Global.unions = [];
Global.unions.push({
"name":"北大", "address":"ws://39.106.6.6:18010", "status":"在线", "contact":"网管1号", "email":"abc@pku.edu.cn"
});
Global.unions.push({
"name":"南大大", "address":"ws://39.106.6.9:18010", "status":"在线", "contact":"网管1号", "email":"abc@pku.edu.cn"
});
return {
"code":0
};
}
export function getUnionConfig() {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret = {
};
ret.controlAddress = "ws://192.168.1.1:18000";
ret.apiKey = "dafdsafdsa";
ret.unionName = "高校联盟";
return ret;
}
@ArgSchema({
"!controlAddress": "string", "!apiKey": "string"
})
export function joinUnion(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret = {
};
ret.controlAddress = "ws://192.168.1.1:18000";
ret.apiKey = "dafdsafdsa";
ret.unionName = "高校联盟";
return ret;
}
}

View File

@ -2,8 +2,6 @@ plugins {
id 'java'
id 'idea'
}
def currVersion = "0.8.8"
ext.projectIds = ['group': 'org.bdware.sc.controlproxy', 'version': currVersion]
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:none'
@ -15,10 +13,9 @@ repositories {
}
project(':backend') {
group = "org.bdware.sc.controlproxy"
version = projectIds.version
repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
mavenLocal()
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public' }
}
}