mirror of
https://gitee.com/BDWare/cm
synced 2025-01-10 09:54:03 +00:00
add support for doipPort
This commit is contained in:
parent
9cf42f1381
commit
630bb2eb7e
@ -269,31 +269,6 @@ public class ContractClient {
|
|||||||
pbParameters.toArray(result);
|
pbParameters.toArray(result);
|
||||||
Constructor<ProcessBuilder> pbc = ProcessBuilder.class.getDeclaredConstructor(String[].class);
|
Constructor<ProcessBuilder> pbc = ProcessBuilder.class.getDeclaredConstructor(String[].class);
|
||||||
builder = pbc.newInstance(new Object[]{result});
|
builder = pbc.newInstance(new Object[]{result});
|
||||||
|
|
||||||
// if (remoteDebug.length() == 0)
|
|
||||||
// builder =
|
|
||||||
// new ProcessBuilder(
|
|
||||||
// "java",
|
|
||||||
// "-Dfile.encoding=UTF-8",
|
|
||||||
// darg,
|
|
||||||
// "-jar",
|
|
||||||
// classpath,
|
|
||||||
// "-port=" + startPort,
|
|
||||||
// "-cmi=" + cmi, // cmi 区分不同CM的cp
|
|
||||||
// (isDebug ? "-debug" : ""));
|
|
||||||
// else
|
|
||||||
// builder =
|
|
||||||
//
|
|
||||||
// new ProcessBuilder(
|
|
||||||
// "java",
|
|
||||||
// "-Dfile.encoding=UTF-8",
|
|
||||||
// darg, remoteDebug,
|
|
||||||
// "-jar",
|
|
||||||
// classpath,
|
|
||||||
// "-port=" + startPort,
|
|
||||||
// "-cmi=" + cmi, // cmi 区分不同CM的cp
|
|
||||||
// (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()));
|
||||||
@ -415,19 +390,10 @@ public class ContractClient {
|
|||||||
return contractMeta.getExportedFunctions();
|
return contractMeta.getExportedFunctions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
|
||||||
return get.syncGet("", "getIdentifier", " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String executeMethod(String pkgName, String method, String arg) {
|
public String executeMethod(String pkgName, String method, String arg) {
|
||||||
return get.syncGet(pkgName, method, arg);
|
return get.syncGet(pkgName, method, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdentifier(String alias) {
|
|
||||||
get.asyncGet("", "setIdentifier", alias, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getPubkey() {
|
public String getPubkey() {
|
||||||
return contractMeta.contract.getPublicKey();
|
return contractMeta.contract.getPublicKey();
|
||||||
}
|
}
|
||||||
@ -440,10 +406,6 @@ public class ContractClient {
|
|||||||
return contractMeta.name;
|
return contractMeta.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContractDOI() {
|
|
||||||
return contractMeta.contract.getDOI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContractKey() {
|
public String getContractKey() {
|
||||||
return contractMeta.contract.getKey();
|
return contractMeta.contract.getKey();
|
||||||
}
|
}
|
||||||
|
@ -786,7 +786,7 @@ public class ContractManager {
|
|||||||
addLocalContractLog(action, meta.contract.getID(), meta.name, meta.contract.getOwner());
|
addLocalContractLog(action, meta.contract.getID(), meta.name, meta.contract.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String startContractAndRedirect(Contract c, PrintStream ps, String alias) {
|
public String startContractAndRedirect(Contract c, PrintStream ps) {
|
||||||
long freeMemory = getFreeMemory();
|
long freeMemory = getFreeMemory();
|
||||||
if (statusRecorder.runningProcess.size() > 5 && (freeMemory < memoryLimit)) {
|
if (statusRecorder.runningProcess.size() > 5 && (freeMemory < memoryLimit)) {
|
||||||
statusRecorder.hangLeastUsedContractProcess();
|
statusRecorder.hangLeastUsedContractProcess();
|
||||||
@ -817,7 +817,6 @@ public class ContractManager {
|
|||||||
LOGGER.debug("contract pubKey: " + c.getPublicKey());
|
LOGGER.debug("contract pubKey: " + c.getPublicKey());
|
||||||
|
|
||||||
// 合约启动时读取Manifest文件设置合约DOI
|
// 合约启动时读取Manifest文件设置合约DOI
|
||||||
setContractDOI(c);
|
|
||||||
setContractStateful(c);
|
setContractStateful(c);
|
||||||
ContractClient client = new ContractClient(c);
|
ContractClient client = new ContractClient(c);
|
||||||
String ret;
|
String ret;
|
||||||
@ -856,14 +855,6 @@ public class ContractManager {
|
|||||||
client.traffic += ret.length();
|
client.traffic += ret.length();
|
||||||
// TODO @ZYX
|
// TODO @ZYX
|
||||||
// updateContractInfo(client);
|
// updateContractInfo(client);
|
||||||
|
|
||||||
if (alias != null) {
|
|
||||||
client.setIdentifier(alias);
|
|
||||||
}
|
|
||||||
if (c.getDoipFlag() && !c.getDOI().equals("registerFailed")) {
|
|
||||||
client.setIdentifier(c.getDOI());
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (BDOAHandler.cm != null) {
|
// if (BDOAHandler.cm != null) {
|
||||||
// BDOAHandler.cm.name2Contract = name2Contract;
|
// BDOAHandler.cm.name2Contract = name2Contract;
|
||||||
// }
|
// }
|
||||||
@ -982,24 +973,6 @@ public class ContractManager {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setContractDOI(Contract c) {
|
|
||||||
//@TODO add Automatically register a doi instead.
|
|
||||||
ContractManifest cm = YJSPacker.getManifest(c.getScriptStr());
|
|
||||||
if (cm != null && cm.doi != null) {
|
|
||||||
if (!cm.doi.equals("")
|
|
||||||
&& !cm.doi.equals("null")
|
|
||||||
&& c.getType() == ContractExecType.Sole && chainOpener != null) {
|
|
||||||
c.setDOI(cm.doi);
|
|
||||||
c.setBuildTime(cm.buildTime);
|
|
||||||
c.setDoipFlag(true);
|
|
||||||
chainOpener.reRegister(cm.doi);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
c.setDoipFlag(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setContractStateful(Contract c) {
|
private void setContractStateful(Contract c) {
|
||||||
ContractManifest cm = YJSPacker.getManifest(c.getScriptStr());
|
ContractManifest cm = YJSPacker.getManifest(c.getScriptStr());
|
||||||
if (cm != null && cm.stateful != null && cm.stateful.equals("false")) {
|
if (cm != null && cm.stateful != null && cm.stateful.equals("false")) {
|
||||||
@ -1008,7 +981,7 @@ public class ContractManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String startContract(Contract c) {
|
public String startContract(Contract c) {
|
||||||
return startContractAndRedirect(c, System.out, null);
|
return startContractAndRedirect(c, System.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String queryDEPort(String contractID) {
|
public String queryDEPort(String contractID) {
|
||||||
|
@ -95,7 +95,7 @@ public class ContractStatusRecorder extends StatusRecorder<ContractMeta> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String resumeStartContract(Contract contract) {
|
private static String resumeStartContract(Contract contract) {
|
||||||
return ContractManager.instance.startContractAndRedirect(contract, null, null);
|
return ContractManager.instance.startContractAndRedirect(contract, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPID(int pid) {
|
public boolean hasPID(int pid) {
|
||||||
@ -179,14 +179,14 @@ public class ContractStatusRecorder extends StatusRecorder<ContractMeta> {
|
|||||||
if (meta != null) return meta;
|
if (meta != null) return meta;
|
||||||
for (ContractMeta cc : getStatus().values()) {
|
for (ContractMeta cc : getStatus().values()) {
|
||||||
if (cc.status == ContractStatusEnum.RUNNING || cc.status == ContractStatusEnum.HANGED)
|
if (cc.status == ContractStatusEnum.RUNNING || cc.status == ContractStatusEnum.HANGED)
|
||||||
if (idOrNameOrDOI.equals(cc.name) || idOrNameOrDOI.equals(cc.contract.getDOI())) {
|
if (idOrNameOrDOI.equals(cc.name)) {
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ContractMeta cc : getStatus().values()) {
|
for (ContractMeta cc : getStatus().values()) {
|
||||||
if (cc.name == null) continue;
|
if (cc.name == null) continue;
|
||||||
if (cc.contract == null) continue;
|
if (cc.contract == null) continue;
|
||||||
if (idOrNameOrDOI.equals(cc.name) || idOrNameOrDOI.equals(cc.contract.getDOI())) {
|
if (idOrNameOrDOI.equals(cc.name)) {
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user