diff --git a/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java b/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java index f1b6a87..f54aa3e 100644 --- a/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java +++ b/src/main/java/org/bdware/server/action/p2p/MasterClientTCPAction.java @@ -80,8 +80,8 @@ public class MasterClientTCPAction { request.get("verifiedPubKey").getAsString(), client.getContractID()); MultiContractMeta cei = CMActions.manager.multiContractRecorder.getMultiContractMeta(client.getContractID()); - if (null != cei && cei.contractExecutor instanceof SelfAdaptiveShardingExecutor) { - ((SelfAdaptiveShardingExecutor) cei.contractExecutor).close(); + if (null != cei) { + cei.contractExecutor.close(); } } } diff --git a/src/main/java/org/bdware/server/trustedmodel/SelfAdaptiveShardingExecutor.java b/src/main/java/org/bdware/server/trustedmodel/SelfAdaptiveShardingExecutor.java index 309c040..f2d0f48 100644 --- a/src/main/java/org/bdware/server/trustedmodel/SelfAdaptiveShardingExecutor.java +++ b/src/main/java/org/bdware/server/trustedmodel/SelfAdaptiveShardingExecutor.java @@ -48,7 +48,7 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor { TimeUnit.SECONDS); ContractManager.threadPool.submit(() -> { LOGGER.info( - "[SelfAdaptiveShardingExecutor " + meta.getContractID() + "] starting service..."); + "[SelfAdaptiveShardingExecutor " + meta.getContractID() + "] starting service..." + running); while (running) { LOGGER.info("checking blocks to be executed, latest block=" + this.b.prevHash + ", to be executed size=" + toExecuted.size()); @@ -75,12 +75,6 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor { }); } - public void close() { - this.future.cancel(false); - this.running = false; - LOGGER.info("destruct executor of contract " + meta.getContractID()); - } - @Override public void execute(String requestID, ResultCallback rc, ContractRequest req) { if (executedTxs.containsKey(requestID)) { @@ -100,6 +94,13 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor { } } + @Override + public void close() { + this.future.cancel(false); + this.running = false; + LOGGER.info("destruct executor of contract " + meta.getContractID()); + } + public void execute(String blockStr) { Block block = JsonUtil.fromJson(blockStr, Block.class); if (!toExecuted.containsKey(block.prevHash) && @@ -129,6 +130,7 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor { return; } } + // TODO check status for (ContractRequest request : block.requests) { String ret = ContractManager.instance.executeLocally(request, null); LOGGER.debug("result of request " + request.getRequestID() + ": " + ret); @@ -139,6 +141,7 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor { meta.getContractID(), block.requests.length, block.hash)); + // TODO create check point this.b = new Block(block.hash); executedBlocks.add(block.hash); } @@ -211,7 +214,6 @@ public class SelfAdaptiveShardingExecutor implements ContractExecutor { this.body); } - private String merkle(ContractRequest[] requests) { if (requests.length == 0) { return null;