diff --git a/src/main/java/org/bdware/server/action/TemporyTestAction.java b/src/main/java/org/bdware/server/action/TemporyTestAction.java index d069afa..a655e52 100644 --- a/src/main/java/org/bdware/server/action/TemporyTestAction.java +++ b/src/main/java/org/bdware/server/action/TemporyTestAction.java @@ -7,6 +7,7 @@ import org.bdware.sc.*; import org.bdware.sc.bean.Contract; import org.bdware.sc.bean.ContractExecType; import org.bdware.sc.conn.ResultCallback; +import org.bdware.sc.units.MultiContractMeta; import org.bdware.sc.util.JsonUtil; import org.bdware.server.GlobalConf; import org.bdware.server.action.p2p.MasterServerRecoverMechAction; @@ -175,6 +176,25 @@ public class TemporyTestAction { resultCallback.onResult(jo.toString()); } + @Action(async = true) + public void pruneKilledContract(JsonObject args, ResultCallback resultCallback) { + Map map = CMActions.manager.statusRecorder.getStatus(); + LOGGER.info("pruneKilledContract!!!"); + Set toRemove = new HashSet<>(); + for (ContractMeta meta : map.values()) { + if (meta.getStatus().equals(ContractStatusEnum.KILLED)) + toRemove.add(meta); + } + LOGGER.info("pruneKilledContract!!! size:" + toRemove.size()); + for (ContractMeta key : toRemove) { + CMActions.manager.statusRecorder.remove(key); + MultiContractMeta multiMeta = CMActions.manager.multiContractRecorder.getMultiContractMeta(key.getID()); + CMActions.manager.multiContractRecorder.remove(multiMeta); + } + resultCallback.onResult("size:" + toRemove.size()); + + } + @Action(async = true) public void reconnectPort(JsonObject args, ResultCallback resultCallback) { ContractPort.PortVisitor reconnectVisitor = CMActions.manager.statusRecorder.getVisitor(); diff --git a/src/main/java/org/bdware/server/executor/Context.java b/src/main/java/org/bdware/server/executor/Context.java new file mode 100644 index 0000000..327456b --- /dev/null +++ b/src/main/java/org/bdware/server/executor/Context.java @@ -0,0 +1,12 @@ +package org.bdware.server.executor; + +import org.bdware.sc.conn.ResultCallback; + +public interface Context { + + public String[] getMembers(String contractID); + + public void sendToAgent(String pubkey, String content); + + public void sleepWithTimeout(final String requestID, ResultCallback cb, int timeOut); +}