test action: prune killed Contract

This commit is contained in:
CaiHQ 2022-02-17 16:42:17 +08:00
parent fc7512f50f
commit f3f146b30a
2 changed files with 32 additions and 0 deletions

View File

@ -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<String, ContractMeta> map = CMActions.manager.statusRecorder.getStatus();
LOGGER.info("pruneKilledContract!!!");
Set<ContractMeta> 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();

View File

@ -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);
}