diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index 6ef7a1b..5fe0161 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -1295,7 +1295,7 @@ public class ContractManager { long start = System.currentTimeMillis(); // 9000 - if (request.getRequester() != null && !request.getRequester().startsWith("event")) { + if (null != request.getRequester() && !request.getRequester().startsWith("event")) { if (client.contractMeta.sigRequired) { if (!request.verifySignature()) { cr = new ContractResult(Status.Error, new JsonPrimitive("sign verified failed")); diff --git a/src/main/java/org/bdware/sc/event/EventCenter.java b/src/main/java/org/bdware/sc/event/EventCenter.java index dc95d0e..17a678c 100644 --- a/src/main/java/org/bdware/sc/event/EventCenter.java +++ b/src/main/java/org/bdware/sc/event/EventCenter.java @@ -47,7 +47,7 @@ public class EventCenter { msg.setSemantics(semantics); msg.doSignature(instance.nodeCenterConn.getNodeKeyPair()); String nodeId = getCenterByTopic(topic); - instance.masterStub.deliverEvent(JsonUtil.toJson(msg), nodeId); + instance.masterStub.deliverEvent(nodeId, JsonUtil.toJson(msg)); } /** @@ -62,18 +62,18 @@ public class EventCenter { return false; } String nodeId = getCenterByTopic(topic); - return instance.masterStub.deliverEvent(JsonUtil.toJson(event), nodeId); + return instance.masterStub.deliverEvent(nodeId, JsonUtil.toJson(event)); } /** * publish an event to another node; used by NodeConsumer * - * @param eStr event string * @param target id of the target node + * @param eStr event string */ - public void publishEvent(String eStr, String target) { + public void publishEvent(String target, String eStr) { if (null != instance.masterStub) { - instance.masterStub.deliverEvent(eStr, target); + instance.masterStub.deliverEvent(target, eStr); } } } \ No newline at end of file diff --git a/src/main/java/org/bdware/sc/event/clients/ContractConsumer.java b/src/main/java/org/bdware/sc/event/clients/ContractConsumer.java index 782d8e8..8fef7c0 100644 --- a/src/main/java/org/bdware/sc/event/clients/ContractConsumer.java +++ b/src/main/java/org/bdware/sc/event/clients/ContractConsumer.java @@ -75,10 +75,12 @@ public class ContractConsumer implements IEventConsumer { cr.setRequestID(options[0]); ContractClient cc = ContractManager.instance.getClient(contract); if (null == cc) { + LOGGER.error("contract " + contract + " doesn't exists!"); rc.onResult((String) null); return; } AtomicInteger callCount = new AtomicInteger(0); + // TODO sending requests at a high frequency maybe cause that some requests are ignored ScheduledFuture future = ContractManager.scheduledThreadPool.scheduleAtFixedRate( () -> ContractManager.instance.executeContractInternal(cr, new ResultCallback() { @Override @@ -90,6 +92,7 @@ public class ContractConsumer implements IEventConsumer { if (callCount.get() == TIMEOUT_COUNT || (result.status == ContractResult.Status.Exception && result.result.toString().contains("not exported"))) { + LOGGER.warn("receiving event error: request failed!"); rc.onResult((String) null); } else { ret = false; diff --git a/src/main/java/org/bdware/sc/event/clients/NodeConsumer.java b/src/main/java/org/bdware/sc/event/clients/NodeConsumer.java index e9378e2..0fdeabb 100644 --- a/src/main/java/org/bdware/sc/event/clients/NodeConsumer.java +++ b/src/main/java/org/bdware/sc/event/clients/NodeConsumer.java @@ -33,7 +33,7 @@ public class NodeConsumer implements IEventConsumer { @Override public void publishEvent(Object msg, ResultCallback rc, String... options) { - center.publishEvent(msg.toString(), nodeId); + center.publishEvent(nodeId, msg.toString()); if (null != rc) { rc.onResult(""); }