This commit is contained in:
Frank.R.Wu 2021-11-21 23:48:32 +08:00
parent b136681526
commit 9876ccc2e2
3 changed files with 7 additions and 3 deletions

View File

@ -8,7 +8,6 @@ import org.bdware.sc.bean.Contract;
import org.bdware.sc.bean.ContractRequest; import org.bdware.sc.bean.ContractRequest;
import org.bdware.sc.db.CMTables; import org.bdware.sc.db.CMTables;
import org.bdware.sc.db.StatusRecorder; import org.bdware.sc.db.StatusRecorder;
import org.bdware.sc.units.MultiContractMeta;
import org.bdware.sc.util.JsonUtil; import org.bdware.sc.util.JsonUtil;
import org.bdware.sc.util.LRUList; import org.bdware.sc.util.LRUList;
@ -148,6 +147,7 @@ public class ContractStatusRecorder extends StatusRecorder<ContractMeta> {
id2ContractClient.put(meta.id, client); id2ContractClient.put(meta.id, client);
runningProcess.add(meta); runningProcess.add(meta);
} }
public ContractMeta createIfNotExist(String contractID) { public ContractMeta createIfNotExist(String contractID) {
ContractMeta ret = getContractMeta(contractID); ContractMeta ret = getContractMeta(contractID);
if (null == ret) { if (null == ret) {
@ -199,7 +199,9 @@ public class ContractStatusRecorder extends StatusRecorder<ContractMeta> {
public String killContract(String idOrName) { public String killContract(String idOrName) {
ContractMeta meta = getContractMeta(idOrName); ContractMeta meta = getContractMeta(idOrName);
if (meta != null) return killContract(meta); if (null != meta) {
return killContract(meta);
}
return "no such contract " + idOrName; return "no such contract " + idOrName;
} }
@ -227,6 +229,7 @@ public class ContractStatusRecorder extends StatusRecorder<ContractMeta> {
ContractManager.instance.invokeContractSuicide(client); ContractManager.instance.invokeContractSuicide(client);
ContractManager.cPort.updateDb(client.port, false); ContractManager.cPort.updateDb(client.port, false);
} }
meta.contractExecutor.close();
id2ContractClient.remove(meta.id); id2ContractClient.remove(meta.id);
runningProcess.remove(meta); runningProcess.remove(meta);
return "success"; return "success";

View File

@ -11,7 +11,6 @@ import org.bdware.sc.db.CMTables;
import org.bdware.sc.db.KeyValueDBUtil; import org.bdware.sc.db.KeyValueDBUtil;
import org.bdware.sc.redo.TransRecord; import org.bdware.sc.redo.TransRecord;
import org.bdware.sc.util.JsonUtil; import org.bdware.sc.util.JsonUtil;
import org.bdware.server.trustedmodel.ContractExecutor;
import org.bdware.server.trustedmodel.ContractUnitStatus; import org.bdware.server.trustedmodel.ContractUnitStatus;
import java.util.Map; import java.util.Map;

View File

@ -8,6 +8,8 @@ import org.bdware.sc.conn.ResultCallback;
public interface ContractExecutor { public interface ContractExecutor {
void execute(String requestID, ContractRequest req, ResultCallback rcb, OnHashCallback hcb); void execute(String requestID, ContractRequest req, ResultCallback rcb, OnHashCallback hcb);
default void close() {
}
default void onSyncMessage(Node node, byte[] data) { default void onSyncMessage(Node node, byte[] data) {
} }