mirror of
https://gitee.com/BDWare/cm
synced 2025-01-10 09:54:03 +00:00
front: support startMulitipoint with args
fix: ContractClient missing arguments error update: @Router arguments format fix: ContractStatusRecorder null exception
This commit is contained in:
parent
2f874832b8
commit
2b2f57b7cf
@ -18,9 +18,9 @@ import org.bdware.sc.encrypt.HardwareInfo.OSType;
|
|||||||
import org.bdware.sc.event.REvent.REventSemantics;
|
import org.bdware.sc.event.REvent.REventSemantics;
|
||||||
import org.bdware.sc.node.AnnotationNode;
|
import org.bdware.sc.node.AnnotationNode;
|
||||||
import org.bdware.sc.node.YjsType;
|
import org.bdware.sc.node.YjsType;
|
||||||
|
import org.bdware.sc.units.MultiContractMeta;
|
||||||
import org.bdware.sc.util.JsonUtil;
|
import org.bdware.sc.util.JsonUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
@ -218,7 +218,7 @@ public class ContractClient {
|
|||||||
// LOGGER.debug("======= registerPort:" + ret + "-->" + ContractManager.startPort);
|
// LOGGER.debug("======= registerPort:" + ret + "-->" + ContractManager.startPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String startProcess(PrintStream ps) {
|
public String startProcess(PrintStream ps) throws Exception {
|
||||||
isRunning = false;
|
isRunning = false;
|
||||||
port = -1;
|
port = -1;
|
||||||
|
|
||||||
@ -259,30 +259,31 @@ public class ContractClient {
|
|||||||
// "org.bdware.sc.ContractProcess",
|
// "org.bdware.sc.ContractProcess",
|
||||||
// "-port=" + cPort.getPort());
|
// "-port=" + cPort.getPort());
|
||||||
int startPort = ContractManager.cPort.getPortAndInc();
|
int startPort = ContractManager.cPort.getPortAndInc();
|
||||||
|
//(isDebug ? "-Dlog4j.configurationFile=./log4j2.debug.properties" : ""),
|
||||||
ProcessBuilder builder =
|
ProcessBuilder builder =
|
||||||
new ProcessBuilder(
|
new ProcessBuilder(
|
||||||
"java",
|
"java",
|
||||||
"-Dfile.encoding=UTF-8",
|
"-Dfile.encoding=UTF-8",
|
||||||
darg, (isDebug ? "-Dlog4j.configurationFile=./log4j2.cp.properties" : ""),
|
darg,
|
||||||
"-jar",
|
"-jar",
|
||||||
classpath,
|
classpath,
|
||||||
"-port=" + startPort,
|
"-port=" + startPort,
|
||||||
"-cmi=" + cmi, // cmi 区分不同CM的cp
|
"-cmi=" + cmi, // cmi 区分不同CM的cp
|
||||||
(isDebug ? "-debug" : ""));
|
(isDebug ? "-debug" : ""));
|
||||||
File directory = new File("");
|
File directory = new File("./");
|
||||||
LOGGER.debug("[CMD] path: " + directory.getAbsolutePath());
|
LOGGER.debug("[CMD] path: " + directory.getAbsolutePath());
|
||||||
LOGGER.debug(JsonUtil.toPrettyJson(builder.command()));
|
LOGGER.debug(JsonUtil.toPrettyJson(builder.command()));
|
||||||
|
|
||||||
Map<String, String> map = builder.environment();
|
Map<String, String> map = builder.environment();
|
||||||
map.put("java.library.path", jniPath.getAbsolutePath() + osJni);
|
map.put("java.library.path", jniPath.getAbsolutePath() + osJni);
|
||||||
builder.directory(new File("./"));
|
builder.directory(directory);
|
||||||
LOGGER.debug("start process:");
|
LOGGER.debug("start process:");
|
||||||
|
|
||||||
try {
|
|
||||||
process = builder.start();
|
process = builder.start();
|
||||||
|
|
||||||
this.pid = getPid(process);
|
this.pid = getPid(process);
|
||||||
LOGGER.info("[CP PPID ] " + pid);
|
LOGGER.info("[CP PPID] " + pid);
|
||||||
PrintStream printStream = new PrintStream(process.getOutputStream());
|
PrintStream printStream = new PrintStream(process.getOutputStream());
|
||||||
printStream.println("CP PID:" + pid);
|
printStream.println("CP PID:" + pid);
|
||||||
printStream.close();
|
printStream.close();
|
||||||
@ -317,7 +318,7 @@ public class ContractClient {
|
|||||||
ContractManager.cPort.updateDb(port, true);
|
ContractManager.cPort.updateDb(port, true);
|
||||||
get = new SocketGet("127.0.0.1", port);
|
get = new SocketGet("127.0.0.1", port);
|
||||||
get.syncGet("", "setDBInfo", ContractManager.dbPath);
|
get.syncGet("", "setDBInfo", ContractManager.dbPath);
|
||||||
if (isDebug) {
|
if (isDebug || get != null) {
|
||||||
String tagA = (ps == System.out ? "[Contract_" + port + "_out] " : "");
|
String tagA = (ps == System.out ? "[Contract_" + port + "_out] " : "");
|
||||||
String tagB = (ps == System.out ? "[Contract_" + port + "_err] " : "");
|
String tagB = (ps == System.out ? "[Contract_" + port + "_err] " : "");
|
||||||
outputTracer.track(process, sc, tagA, ps);
|
outputTracer.track(process, sc, tagA, ps);
|
||||||
@ -329,6 +330,14 @@ public class ContractClient {
|
|||||||
}
|
}
|
||||||
get.syncGet("", "registerMangerPort", String.valueOf(ContractManager.cPort.getCMPort()));
|
get.syncGet("", "registerMangerPort", String.valueOf(ContractManager.cPort.getCMPort()));
|
||||||
|
|
||||||
|
MultiContractMeta multiContractMeta =
|
||||||
|
ContractManager.instance.multiContractRecorder.getMultiContractMeta(contractMeta.getID());
|
||||||
|
if (multiContractMeta != null && multiContractMeta.getMembers() != null) {
|
||||||
|
String setMemberResult = get.syncGet(
|
||||||
|
"", "setMembers", JsonUtil.toJson(multiContractMeta.getMembers()));
|
||||||
|
LOGGER.debug("setMember:" + setMemberResult);
|
||||||
|
|
||||||
|
}
|
||||||
if (isBundlePath(contractMeta.contract.getScriptStr())) {
|
if (isBundlePath(contractMeta.contract.getScriptStr())) {
|
||||||
status =
|
status =
|
||||||
get.syncGet(
|
get.syncGet(
|
||||||
@ -347,15 +356,12 @@ public class ContractClient {
|
|||||||
status = JsonUtil.toJson(r);
|
status = JsonUtil.toJson(r);
|
||||||
contractMeta.name = get.syncGet("", "getContractName", "");
|
contractMeta.name = get.syncGet("", "getContractName", "");
|
||||||
}
|
}
|
||||||
return status;
|
if (r.status != Status.Success) {
|
||||||
} catch (Exception e) {
|
killProcess();
|
||||||
e.printStackTrace();
|
throw new IllegalStateException(r.result.getAsString());
|
||||||
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
|
||||||
e.printStackTrace(new PrintStream(bo));
|
|
||||||
ContractResult r =
|
|
||||||
new ContractResult(Status.Exception, new JsonPrimitive(bo.toString()));
|
|
||||||
return JsonUtil.toJson(r);
|
|
||||||
}
|
}
|
||||||
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMemory() {
|
public void updateMemory() {
|
||||||
|
@ -423,7 +423,11 @@ public class ContractManager {
|
|||||||
c.setOwner(pair.getPublicKeyStr());
|
c.setOwner(pair.getPublicKeyStr());
|
||||||
c.setScript("contract analysis_client{}");
|
c.setScript("contract analysis_client{}");
|
||||||
analysisClient = new ContractClient(c);
|
analysisClient = new ContractClient(c);
|
||||||
|
try {
|
||||||
analysisClient.startProcess(System.out);
|
analysisClient.startProcess(System.out);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContractIDByName(String name) {
|
public String getContractIDByName(String name) {
|
||||||
@ -742,7 +746,6 @@ public class ContractManager {
|
|||||||
LOGGER.debug("[free memory] " + mem.getFree() + " " + mem.getActualFree());
|
LOGGER.debug("[free memory] " + mem.getFree() + " " + mem.getActualFree());
|
||||||
return mem.getFree();
|
return mem.getFree();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace(System.err);
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return memoryLimit + 1;
|
return memoryLimit + 1;
|
||||||
@ -929,7 +932,7 @@ public class ContractManager {
|
|||||||
return "contract manager can't support:" + c.getType();
|
return "contract manager can't support:" + c.getType();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
statusRecorder.killContract(c.getID());
|
||||||
r = new ContractResult(Status.Error, new JsonPrimitive("exception occurs: " + e.getMessage()));
|
r = new ContractResult(Status.Error, new JsonPrimitive("exception occurs: " + e.getMessage()));
|
||||||
return JsonUtil.toJson(r);
|
return JsonUtil.toJson(r);
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,8 @@ public class ContractStatusRecorder extends StatusRecorder<ContractMeta> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ContractMeta cc : getStatus().values()) {
|
for (ContractMeta cc : getStatus().values()) {
|
||||||
|
if (cc.name == null) continue;
|
||||||
|
if (cc.contract == null) continue;
|
||||||
if (idOrNameOrDOI.equals(cc.name) || idOrNameOrDOI.equals(cc.contract.getDOI())) {
|
if (idOrNameOrDOI.equals(cc.name) || idOrNameOrDOI.equals(cc.contract.getDOI())) {
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user