From f53c2374df871da48188b7e55944905223a5ad84 Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Fri, 15 Dec 2023 16:39:32 +0800 Subject: [PATCH] update doip-sdk --- .../java/org/bdware/sc/ContractManager.java | 1 - .../org/bdware/sc/event/EventRecorder.java | 31 +++++++------------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/bdware/sc/ContractManager.java b/src/main/java/org/bdware/sc/ContractManager.java index 66e6096..774a2e7 100644 --- a/src/main/java/org/bdware/sc/ContractManager.java +++ b/src/main/java/org/bdware/sc/ContractManager.java @@ -445,7 +445,6 @@ public class ContractManager { } public ContractClient getContractClientByDoi(String doi) { - ContractMeta meta = statusRecorder.getContractMeta(doi); return statusRecorder.getContractClient(meta.id); } diff --git a/src/main/java/org/bdware/sc/event/EventRecorder.java b/src/main/java/org/bdware/sc/event/EventRecorder.java index 87dbe73..4fcf8ef 100644 --- a/src/main/java/org/bdware/sc/event/EventRecorder.java +++ b/src/main/java/org/bdware/sc/event/EventRecorder.java @@ -53,7 +53,7 @@ public class EventRecorder { } public void createCheckPoint(Map> topic2cIds, - Map id2Consumers) { + Map id2Consumers) { CheckPoint cp = new CheckPoint(topic2cIds, id2Consumers); synchronized (latestEvent) { if (!latestEvent.isCp()) { @@ -79,10 +79,8 @@ public class EventRecorder { String key = KeyValueRocksDBUtil.instance.getValue(dbName, LATEST_EVENT_KEY); latestEvent.set(key); CheckPoint cp = new CheckPoint(); - Type topic2cIdsType = TypeToken - .getParameterized(ConcurrentHashMap.class, String.class, - TypeToken.getParameterized(Set.class, String.class, String.class).getType()) - .getType(); + Type topic2cIdsType = TypeToken.getParameterized(ConcurrentHashMap.class, String.class, + TypeToken.getParameterized(Set.class, String.class).getType()).getType(); // retrieving transactions from database while (null != key && !key.isEmpty()) { String json = KeyValueRocksDBUtil.instance.getValue(dbName, key); @@ -94,16 +92,14 @@ public class EventRecorder { if (json.startsWith("cp")) { // create check point by the transaction and stop retrieving JsonObject data = JsonUtil.parseStringAsJsonObject(json.substring(2)); - cp.topic2cIds = - JsonUtil.fromJson(data.get("topic2cIds").toString(), topic2cIdsType); + cp.topic2cIds = JsonUtil.fromJson(data.get("topic2cIds").toString(), topic2cIdsType); JsonObject id2Consumers = data.getAsJsonObject("id2Consumers"); for (String k : id2Consumers.keySet()) { JsonObject consumer = id2Consumers.getAsJsonObject(k); if (!consumer.has("type")) { continue; } - ConsumerType type = - ConsumerType.valueOf(consumer.get("type").getAsString()); + ConsumerType type = ConsumerType.valueOf(consumer.get("type").getAsString()); switch (type) { case Contract: cp.id2Consumers.put(k, @@ -148,8 +144,7 @@ public class EventRecorder { // if empty, return the check point latestEvent.setCp(true); } else { - // on the base of old check point, process following sub or unsub events to recover - // registry + // on the base of old check point, process following sub or unsub events to recover registry while (!stack.empty()) { Object record = stack.pop(); if (record instanceof CheckPoint) { @@ -159,19 +154,15 @@ public class EventRecorder { IEventConsumer consumer = broker.parseConsumer(tran.content); switch (tran.type) { case SUBSCRIBE: - if (!broker.subInReg(tran.topic, consumer, cp.topic2cIds, - cp.id2Consumers)) { + if (!broker.subInReg(tran.topic, consumer, cp.topic2cIds, cp.id2Consumers)) { LOGGER.warn("record damaged! " + key); - LOGGER.debug( - "record damaged! " + key + ": " + JsonUtil.toJson(tran)); + LOGGER.debug("record damaged! " + key + ": " + JsonUtil.toJson(tran)); } break; case UNSUBSCRIBE: - if (!broker.unsubInReg(tran.topic, consumer, cp.topic2cIds, - cp.id2Consumers)) { + if (!broker.unsubInReg(tran.topic, consumer, cp.topic2cIds, cp.id2Consumers)) { LOGGER.warn("record damaged! " + key); - LOGGER.debug( - "record damaged! " + key + ": " + JsonUtil.toJson(tran)); + LOGGER.debug("record damaged! " + key + ": " + JsonUtil.toJson(tran)); } default: break; @@ -233,7 +224,7 @@ public class EventRecorder { } public CheckPoint(Map> topic2cIds, - Map id2Consumers) { + Map id2Consumers) { this.topic2cIds = topic2cIds; this.id2Consumers = id2Consumers; }