diff --git a/src/main/java/org/bdware/server/action/CMActions.java b/src/main/java/org/bdware/server/action/CMActions.java index bca6703..6fd3620 100644 --- a/src/main/java/org/bdware/server/action/CMActions.java +++ b/src/main/java/org/bdware/server/action/CMActions.java @@ -164,7 +164,7 @@ public class CMActions implements OnHashCallback { return; } cReq.setAction(jo.get("action").getAsString()); - cReq.setArg(jo.get("arg").getAsString()); + cReq.setArg(jo.get("arg")); if (cReq.withEvaluatesAnalysis) { cReq.setValue(jo.get("hasValue").getAsLong()); } @@ -1391,6 +1391,59 @@ public class CMActions implements OnHashCallback { } } + @Action(userPermission = 1L << 26, async = true, httpAccess = false) + public void killAllContract(JsonObject args, ResultCallback resultCallback) { + if (args.has("verifiedPubKey")) { + if (ContractManager.checkNodeManager(args.get(("verifiedPubKey")).getAsString())) { + StringBuilder sb = new StringBuilder(); + sb.append("Kill:"); + try { + // TODO too many opend files + ProcessBuilder builder = new ProcessBuilder("ps", "-ef"); + Process process = builder.start(); + Scanner sc = new Scanner(process.getInputStream()); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + if (line.contains("java") + && (line.contains("ContractProcess") || line.contains("yjs.jar"))) { + LOGGER.debug(line); + { + Scanner sc2 = + new Scanner(new ByteArrayInputStream(line.getBytes())); + String pid = null; + + if (sc2.hasNext()) { + sc2.next(); + if (sc2.hasNextInt()) pid = sc2.nextInt() + ""; + } + sc2.close(); + + if (pid != null) { + ProcessBuilder subProcess = + new ProcessBuilder("kill", "-9", pid); + sb.append(pid); + sb.append(","); + subProcess.start(); + } + } + } + } + sc.close(); + } catch (Exception e) { + e.printStackTrace(); + } + ExecutionManager.instance.updateLocalContractToNodeCenter(); + ReplyUtil.simpleReply(resultCallback, "onKillAllContract", sb.toString()); + manager.stopAllContracts(); + } else { + manager.stopAllContractsWithOwner(args.get(("verifiedPubKey")).getAsString()); + ReplyUtil.simpleReply(resultCallback, "onKillAllContract", "Success"); + } + } else { + ReplyUtil.simpleReply(resultCallback, "onKillAllContract", "Failed: Illegal user"); + } + } + // @Action(userPermission = 1L << 26, async = true) // public void queryContractInstanceInfoByDOI(JsonObject args, ResultCallback resultCallback) // { @@ -1482,59 +1535,6 @@ public class CMActions implements OnHashCallback { * resultCallback.onResult(gson.toJson(r)); } */ - @Action(userPermission = 1L << 26, async = true, httpAccess = false) - public void killAllContract(JsonObject args, ResultCallback resultCallback) { - if (args.has("verifiedPubKey")) { - if (ContractManager.checkNodeManager(args.get(("verifiedPubKey")).getAsString())) { - StringBuilder sb = new StringBuilder(); - sb.append("Kill:"); - try { - // TODO too many opend files - ProcessBuilder builder = new ProcessBuilder("ps", "-ef"); - Process process = builder.start(); - Scanner sc = new Scanner(process.getInputStream()); - while (sc.hasNextLine()) { - String line = sc.nextLine(); - if (line.contains("java") - && (line.contains("ContractProcess") || line.contains("yjs.jar"))) { - LOGGER.debug(line); - { - Scanner sc2 = - new Scanner(new ByteArrayInputStream(line.getBytes())); - String pid = null; - - if (sc2.hasNext()) { - sc2.next(); - if (sc2.hasNextInt()) pid = sc2.nextInt() + ""; - } - sc2.close(); - - if (pid != null) { - ProcessBuilder subProcess = - new ProcessBuilder("kill", "-9", pid); - sb.append(pid); - sb.append(","); - subProcess.start(); - } - } - } - } - sc.close(); - } catch (Exception e) { - e.printStackTrace(); - } - ExecutionManager.instance.updateLocalContractToNodeCenter(); - ReplyUtil.simpleReply(resultCallback, "onKillAllContract", sb.toString()); - manager.stopAllContracts(); - } else { - manager.stopAllContractsWithOwner(args.get(("verifiedPubKey")).getAsString()); - ReplyUtil.simpleReply(resultCallback, "onKillAllContract", "Success"); - } - } else { - ReplyUtil.simpleReply(resultCallback, "onKillAllContract", "Failed: Illegal user"); - } - } - @Action(userPermission = 1L << 26, async = true, httpAccess = false) public void setPermission(JsonObject json, ResultCallback resultCallback) { String closePermission = json.get("closePer").getAsString(); diff --git a/src/main/java/org/bdware/server/ws/ContractManagerFrameHandler.java b/src/main/java/org/bdware/server/ws/ContractManagerFrameHandler.java index 5238cda..cd0d698 100644 --- a/src/main/java/org/bdware/server/ws/ContractManagerFrameHandler.java +++ b/src/main/java/org/bdware/server/ws/ContractManagerFrameHandler.java @@ -1,7 +1,6 @@ package org.bdware.server.ws; import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; @@ -138,7 +137,7 @@ public class ContractManagerFrameHandler extends SimpleChannelInboundHandler