diff --git a/build.gradle b/build.gradle index 875cddff7d6..9f15d93f1f9 100644 --- a/build.gradle +++ b/build.gradle @@ -489,8 +489,10 @@ configure(project(':seednode')) { dependencies { implementation project(':common') + implementation project(':proto') implementation project(':p2p') implementation project(':core') + implementation libs.protobuf.java annotationProcessor libs.lombok compileOnly libs.lombok implementation libs.google.guava diff --git a/common/src/main/java/bisq/common/util/Utilities.java b/common/src/main/java/bisq/common/util/Utilities.java index ae97e2c2bef..72a9ffe94f5 100644 --- a/common/src/main/java/bisq/common/util/Utilities.java +++ b/common/src/main/java/bisq/common/util/Utilities.java @@ -63,6 +63,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadFactory; @@ -136,10 +137,16 @@ private static ThreadPoolExecutor getThreadPoolExecutor(String name, return executor; } - public static ExecutorService newCachedThreadPool(int maximumPoolSize) { - return new ThreadPoolExecutor(0, maximumPoolSize, - 60, TimeUnit.SECONDS, - new SynchronousQueue<>()); + public static ExecutorService newCachedThreadPool(int maximumPoolSize, + long keepAliveTime, + TimeUnit timeUnit, + RejectedExecutionHandler rejectedExecutionHandler) { + return new ThreadPoolExecutor(0, + maximumPoolSize, + keepAliveTime, + timeUnit, + new SynchronousQueue<>(), + rejectedExecutionHandler); } @SuppressWarnings("SameParameterValue") diff --git a/p2p/src/main/java/bisq/network/p2p/network/NetworkNode.java b/p2p/src/main/java/bisq/network/p2p/network/NetworkNode.java index 35a4edd03f3..d24bb03a164 100644 --- a/p2p/src/main/java/bisq/network/p2p/network/NetworkNode.java +++ b/p2p/src/main/java/bisq/network/p2p/network/NetworkNode.java @@ -162,7 +162,9 @@ public SettableFuture sendMessage(@NotNull NodeAddress peersNodeAddr try { socket.close(); } catch (Throwable throwable) { - log.error("Error at closing socket " + throwable); + if (!shutDownInProgress) { + log.error("Error at closing socket " + throwable); + } } existingConnection.sendMessage(networkEnvelope); return existingConnection; @@ -188,7 +190,9 @@ public void onDisconnect(CloseConnectionReason closeConnectionReason, @Override public void onError(Throwable throwable) { - log.error("new OutboundConnection.ConnectionListener.onError " + throwable.getMessage()); + if (!shutDownInProgress) { + log.error("new OutboundConnection.ConnectionListener.onError " + throwable.getMessage()); + } connectionListeners.forEach(e -> e.onError(throwable)); } }; diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 6d229e5b126..a3f13e71018 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -2494,20 +2494,20 @@ message ReportingItem { string key = 1; string group = 2; oneof message { - StringValueItem string_value_item = 3; - LongValueItem long_value_item = 4; - DoubleValueItem double_value_item = 5; + StringValueReportingItem string_value_reporting_item = 3; + LongValueReportingItem long_value_reporting_item = 4; + DoubleValueReportingItem double_value_reporting_item = 5; } } -message StringValueItem { +message StringValueReportingItem { string value = 1; } -message LongValueItem { +message LongValueReportingItem { uint64 value = 1; } -message DoubleValueItem { +message DoubleValueReportingItem { double value = 1; } diff --git a/seednode/src/main/java/bisq/seednode/SeedNode.java b/seednode/src/main/java/bisq/seednode/SeedNode.java index 996acedb9b0..25aff603483 100644 --- a/seednode/src/main/java/bisq/seednode/SeedNode.java +++ b/seednode/src/main/java/bisq/seednode/SeedNode.java @@ -17,6 +17,8 @@ package bisq.seednode; +import bisq.seednode.reporting.SeedNodeReportingService; + import bisq.core.app.misc.AppSetup; import bisq.core.app.misc.AppSetupWithP2PAndDAO; import bisq.core.network.p2p.inventory.GetInventoryRequestHandler; diff --git a/core/src/main/java/bisq/core/monitor/DoubleValueItem.java b/seednode/src/main/java/bisq/seednode/reporting/DoubleValueReportingItem.java similarity index 67% rename from core/src/main/java/bisq/core/monitor/DoubleValueItem.java rename to seednode/src/main/java/bisq/seednode/reporting/DoubleValueReportingItem.java index 15530d7cb38..b4a7486127f 100644 --- a/core/src/main/java/bisq/core/monitor/DoubleValueItem.java +++ b/seednode/src/main/java/bisq/seednode/reporting/DoubleValueReportingItem.java @@ -15,13 +15,13 @@ * along with Bisq. If not, see . */ -package bisq.core.monitor; +package bisq.seednode.reporting; import lombok.Getter; import lombok.Setter; -public enum DoubleValueItem implements ReportingItem { +public enum DoubleValueReportingItem implements ReportingItem { Unspecified("", "Unspecified"), sentBytesPerSec("network", "sentBytesPerSec"), receivedBytesPerSec("network", "receivedBytesPerSec"), @@ -30,32 +30,29 @@ public enum DoubleValueItem implements ReportingItem { @Getter - @Setter - private String key; + private final String key; @Getter - @Setter - private String group; + private final String group; @Getter @Setter private double value; - DoubleValueItem(String group, String key) { + DoubleValueReportingItem(String group, String key) { this.group = group; this.key = key; } - public DoubleValueItem withValue(double value) { + public DoubleValueReportingItem withValue(double value) { setValue(value); return this; } - public static DoubleValueItem from(String key, double value) { - DoubleValueItem item; + public static DoubleValueReportingItem from(String key, double value) { + DoubleValueReportingItem item; try { - item = DoubleValueItem.valueOf(key); + item = DoubleValueReportingItem.valueOf(key); } catch (Throwable t) { - item = DoubleValueItem.Unspecified; - item.setKey(key); + item = Unspecified; } item.setValue(value); @@ -64,13 +61,14 @@ public static DoubleValueItem from(String key, double value) { @Override public protobuf.ReportingItem toProtoMessage() { - return getBuilder().setDoubleValueItem(protobuf.DoubleValueItem.newBuilder() + return getBuilder().setDoubleValueReportingItem(protobuf.DoubleValueReportingItem.newBuilder() .setValue(value)) .build(); } - public static DoubleValueItem fromProto(protobuf.ReportingItem baseProto, protobuf.DoubleValueItem proto) { - return DoubleValueItem.from(baseProto.getKey(), proto.getValue()); + public static DoubleValueReportingItem fromProto(protobuf.ReportingItem baseProto, + protobuf.DoubleValueReportingItem proto) { + return DoubleValueReportingItem.from(baseProto.getKey(), proto.getValue()); } @Override diff --git a/core/src/main/java/bisq/core/monitor/LongValueItem.java b/seednode/src/main/java/bisq/seednode/reporting/LongValueReportingItem.java similarity index 75% rename from core/src/main/java/bisq/core/monitor/LongValueItem.java rename to seednode/src/main/java/bisq/seednode/reporting/LongValueReportingItem.java index 590e852ab8f..a62a2d381cb 100644 --- a/core/src/main/java/bisq/core/monitor/LongValueItem.java +++ b/seednode/src/main/java/bisq/seednode/reporting/LongValueReportingItem.java @@ -15,13 +15,13 @@ * along with Bisq. If not, see . */ -package bisq.core.monitor; +package bisq.seednode.reporting; import lombok.Getter; import lombok.Setter; -public enum LongValueItem implements ReportingItem { +public enum LongValueReportingItem implements ReportingItem { Unspecified("", "Unspecified"), OfferPayload("data", "OfferPayload"), MailboxStoragePayload("data", "MailboxStoragePayload"), @@ -52,32 +52,29 @@ public enum LongValueItem implements ReportingItem { jvmStartTimeInSec("node", "jvmStartTimeInSec"); @Getter - @Setter - private String key; + private final String key; @Getter - @Setter - private String group; + private final String group; @Getter @Setter private long value; - LongValueItem(String group, String key) { + LongValueReportingItem(String group, String key) { this.group = group; this.key = key; } - public LongValueItem withValue(long value) { + public LongValueReportingItem withValue(long value) { setValue(value); return this; } - public static LongValueItem from(String key, long value) { - LongValueItem item; + public static LongValueReportingItem from(String key, long value) { + LongValueReportingItem item; try { - item = LongValueItem.valueOf(key); + item = LongValueReportingItem.valueOf(key); } catch (Throwable t) { - item = LongValueItem.Unspecified; - item.setKey(key); + item = Unspecified; } item.setValue(value); @@ -86,13 +83,14 @@ public static LongValueItem from(String key, long value) { @Override public protobuf.ReportingItem toProtoMessage() { - return getBuilder().setLongValueItem(protobuf.LongValueItem.newBuilder() + return getBuilder().setLongValueReportingItem(protobuf.LongValueReportingItem.newBuilder() .setValue(value)) .build(); } - public static LongValueItem fromProto(protobuf.ReportingItem baseProto, protobuf.LongValueItem proto) { - return LongValueItem.from(baseProto.getKey(), proto.getValue()); + public static LongValueReportingItem fromProto(protobuf.ReportingItem baseProto, + protobuf.LongValueReportingItem proto) { + return LongValueReportingItem.from(baseProto.getKey(), proto.getValue()); } @Override diff --git a/core/src/main/java/bisq/core/monitor/ReportingItem.java b/seednode/src/main/java/bisq/seednode/reporting/ReportingItem.java similarity index 74% rename from core/src/main/java/bisq/core/monitor/ReportingItem.java rename to seednode/src/main/java/bisq/seednode/reporting/ReportingItem.java index 54ad91f040f..828b6585429 100644 --- a/core/src/main/java/bisq/core/monitor/ReportingItem.java +++ b/seednode/src/main/java/bisq/seednode/reporting/ReportingItem.java @@ -15,7 +15,7 @@ * along with Bisq. If not, see . */ -package bisq.core.monitor; +package bisq.seednode.reporting; import bisq.common.proto.ProtobufferRuntimeException; import bisq.common.proto.network.NetworkPayload; @@ -37,12 +37,12 @@ default protobuf.ReportingItem.Builder getBuilder() { static ReportingItem fromProto(protobuf.ReportingItem proto) { switch (proto.getMessageCase()) { - case STRING_VALUE_ITEM: - return StringValueItem.fromProto(proto, proto.getStringValueItem()); - case LONG_VALUE_ITEM: - return LongValueItem.fromProto(proto, proto.getLongValueItem()); - case DOUBLE_VALUE_ITEM: - return DoubleValueItem.fromProto(proto, proto.getDoubleValueItem()); + case STRING_VALUE_REPORTING_ITEM: + return StringValueReportingItem.fromProto(proto, proto.getStringValueReportingItem()); + case LONG_VALUE_REPORTING_ITEM: + return LongValueReportingItem.fromProto(proto, proto.getLongValueReportingItem()); + case DOUBLE_VALUE_REPORTING_ITEM: + return DoubleValueReportingItem.fromProto(proto, proto.getDoubleValueReportingItem()); case MESSAGE_NOT_SET: default: throw new ProtobufferRuntimeException("Unknown message case: " + proto); diff --git a/core/src/main/java/bisq/core/monitor/ReportingItems.java b/seednode/src/main/java/bisq/seednode/reporting/ReportingItems.java similarity index 98% rename from core/src/main/java/bisq/core/monitor/ReportingItems.java rename to seednode/src/main/java/bisq/seednode/reporting/ReportingItems.java index 254fda19449..d5cb51057dc 100644 --- a/core/src/main/java/bisq/core/monitor/ReportingItems.java +++ b/seednode/src/main/java/bisq/seednode/reporting/ReportingItems.java @@ -15,7 +15,7 @@ * along with Bisq. If not, see . */ -package bisq.core.monitor; +package bisq.seednode.reporting; import bisq.common.proto.network.NetworkPayload; diff --git a/seednode/src/main/java/bisq/seednode/SeedNodeReportingService.java b/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java similarity index 71% rename from seednode/src/main/java/bisq/seednode/SeedNodeReportingService.java rename to seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java index 9fc2bc8b201..59a8135bb88 100644 --- a/seednode/src/main/java/bisq/seednode/SeedNodeReportingService.java +++ b/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java @@ -15,7 +15,7 @@ * along with Bisq. If not, see . */ -package bisq.seednode; +package bisq.seednode.reporting; import bisq.core.dao.DaoFacade; import bisq.core.dao.monitoring.BlindVoteStateMonitoringService; @@ -26,10 +26,6 @@ import bisq.core.dao.monitoring.model.ProposalStateBlock; import bisq.core.dao.state.DaoStateListener; import bisq.core.dao.state.DaoStateService; -import bisq.core.monitor.DoubleValueItem; -import bisq.core.monitor.LongValueItem; -import bisq.core.monitor.ReportingItems; -import bisq.core.monitor.StringValueItem; import bisq.network.p2p.P2PService; import bisq.network.p2p.network.NetworkNode; @@ -54,12 +50,9 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; -import java.io.IOException; - import java.util.HashMap; import java.util.LinkedList; import java.util.Map; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; @@ -122,8 +115,11 @@ public SeedNodeReportingService(P2PService p2PService, this.maxConnections = maxConnections; this.seedNodeReportingServerUrl = seedNodeReportingServerUrl; - executor = Utilities.newCachedThreadPool(5); - httpClient = HttpClient.newHttpClient(); + executor = Utilities.newCachedThreadPool(5, + 8, + TimeUnit.MINUTES, + (runnable, executor) -> log.error("Execution was rejected. We skip the {} task.", runnable.toString())); + httpClient = HttpClient.newBuilder().executor(executor).build(); heartBeatTimer = UserThread.runPeriodically(this::sendHeartBeat, HEART_BEAT_DELAY_SEC); @@ -164,7 +160,7 @@ private void sendHeartBeat() { return; } ReportingItems reportingItems = new ReportingItems(getMyAddress()); - reportingItems.add(LongValueItem.usedMemoryInMB.withValue(Profiler.getUsedMemoryInMB())); + reportingItems.add(LongValueReportingItem.usedMemoryInMB.withValue(Profiler.getUsedMemoryInMB())); sendReportingItems(reportingItems); } @@ -175,25 +171,25 @@ private void sendBlockRelatedData() { ReportingItems reportingItems = new ReportingItems(getMyAddress()); int daoStateChainHeight = daoStateService.getChainHeight(); - reportingItems.add(LongValueItem.daoStateChainHeight.withValue(daoStateChainHeight)); + reportingItems.add(LongValueReportingItem.daoStateChainHeight.withValue(daoStateChainHeight)); daoStateService.getLastBlock().map(block -> (block.getTime() / 1000)) - .ifPresent(blockTime -> reportingItems.add(LongValueItem.blockTimeIsSec.withValue(blockTime))); + .ifPresent(blockTime -> reportingItems.add(LongValueReportingItem.blockTimeIsSec.withValue(blockTime))); LinkedList daoStateBlockChain = daoStateMonitoringService.getDaoStateBlockChain(); if (!daoStateBlockChain.isEmpty()) { String daoStateHash = Utilities.bytesAsHexString(daoStateBlockChain.getLast().getMyStateHash().getHash()); - reportingItems.add(StringValueItem.daoStateHash.withValue(daoStateHash)); + reportingItems.add(StringValueReportingItem.daoStateHash.withValue(daoStateHash)); } LinkedList proposalStateBlockChain = proposalStateMonitoringService.getProposalStateBlockChain(); if (!proposalStateBlockChain.isEmpty()) { String proposalHash = Utilities.bytesAsHexString(proposalStateBlockChain.getLast().getMyStateHash().getHash()); - reportingItems.add(StringValueItem.proposalHash.withValue(proposalHash)); + reportingItems.add(StringValueReportingItem.proposalHash.withValue(proposalHash)); } LinkedList blindVoteStateBlockChain = blindVoteStateMonitoringService.getBlindVoteStateBlockChain(); if (!blindVoteStateBlockChain.isEmpty()) { String blindVoteHash = Utilities.bytesAsHexString(blindVoteStateBlockChain.getLast().getMyStateHash().getHash()); - reportingItems.add(StringValueItem.blindVoteHash.withValue(blindVoteHash)); + reportingItems.add(StringValueReportingItem.blindVoteHash.withValue(blindVoteHash)); } sendReportingItems(reportingItems); @@ -217,56 +213,53 @@ private void sendDataReport() { numItemsByType.putIfAbsent(className, 0); numItemsByType.put(className, numItemsByType.get(className) + 1); }); - numItemsByType.forEach((key, value) -> reportingItems.add(LongValueItem.from(key, value))); + numItemsByType.forEach((key, value) -> reportingItems.add(LongValueReportingItem.from(key, value))); // Network - reportingItems.add(LongValueItem.numConnections.withValue(networkNode.getAllConnections().size())); - reportingItems.add(LongValueItem.peakNumConnections.withValue(peerManager.getPeakNumConnections())); - reportingItems.add(LongValueItem.numAllConnectionsLostEvents.withValue(peerManager.getNumAllConnectionsLostEvents())); - reportingItems.add(LongValueItem.sentBytes.withValue(Statistic.getTotalSentBytes())); - reportingItems.add(LongValueItem.receivedBytes.withValue(Statistic.getTotalReceivedBytes())); - reportingItems.add(DoubleValueItem.sentBytesPerSec.withValue(Statistic.getTotalSentBytesPerSec())); - reportingItems.add(DoubleValueItem.sentMessagesPerSec.withValue(Statistic.getNumTotalSentMessagesPerSec())); - reportingItems.add(DoubleValueItem.receivedBytesPerSec.withValue(Statistic.getTotalReceivedBytesPerSec())); - reportingItems.add(DoubleValueItem.receivedMessagesPerSec.withValue(Statistic.numTotalReceivedMessagesPerSec())); + reportingItems.add(LongValueReportingItem.numConnections.withValue(networkNode.getAllConnections().size())); + reportingItems.add(LongValueReportingItem.peakNumConnections.withValue(peerManager.getPeakNumConnections())); + reportingItems.add(LongValueReportingItem.numAllConnectionsLostEvents.withValue(peerManager.getNumAllConnectionsLostEvents())); + reportingItems.add(LongValueReportingItem.sentBytes.withValue(Statistic.getTotalSentBytes())); + reportingItems.add(LongValueReportingItem.receivedBytes.withValue(Statistic.getTotalReceivedBytes())); + reportingItems.add(DoubleValueReportingItem.sentBytesPerSec.withValue(Statistic.getTotalSentBytesPerSec())); + reportingItems.add(DoubleValueReportingItem.sentMessagesPerSec.withValue(Statistic.getNumTotalSentMessagesPerSec())); + reportingItems.add(DoubleValueReportingItem.receivedBytesPerSec.withValue(Statistic.getTotalReceivedBytesPerSec())); + reportingItems.add(DoubleValueReportingItem.receivedMessagesPerSec.withValue(Statistic.numTotalReceivedMessagesPerSec())); // Node - reportingItems.add(LongValueItem.usedMemoryInMB.withValue(Profiler.getUsedMemoryInMB())); - reportingItems.add(LongValueItem.totalMemoryInMB.withValue(Profiler.getTotalMemoryInMB())); - reportingItems.add(LongValueItem.jvmStartTimeInSec.withValue((ManagementFactory.getRuntimeMXBean().getStartTime() / 1000))); - reportingItems.add(LongValueItem.maxConnections.withValue(maxConnections)); - reportingItems.add(StringValueItem.version.withValue(Version.VERSION)); + reportingItems.add(LongValueReportingItem.usedMemoryInMB.withValue(Profiler.getUsedMemoryInMB())); + reportingItems.add(LongValueReportingItem.totalMemoryInMB.withValue(Profiler.getTotalMemoryInMB())); + reportingItems.add(LongValueReportingItem.jvmStartTimeInSec.withValue((ManagementFactory.getRuntimeMXBean().getStartTime() / 1000))); + reportingItems.add(LongValueReportingItem.maxConnections.withValue(maxConnections)); + reportingItems.add(StringValueReportingItem.version.withValue(Version.VERSION)); // If no commit hash is found we use 0 in hex format String commitHash = Version.findCommitHash().orElse("00"); - reportingItems.add(StringValueItem.commitHash.withValue(commitHash)); + reportingItems.add(StringValueReportingItem.commitHash.withValue(commitHash)); sendReportingItems(reportingItems); } private void sendReportingItems(ReportingItems reportingItems) { try { - CompletableFuture.runAsync(() -> { - log.info("Send report to monitor server: {}", reportingItems.toString()); - // We send the data as hex encoded protobuf data. We do not use the envelope as it is not part of the p2p system. - byte[] protoMessageAsBytes = reportingItems.toProtoMessageAsBytes(); - try { - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(seedNodeReportingServerUrl)) - .POST(HttpRequest.BodyPublishers.ofByteArray(protoMessageAsBytes)) - .header("User-Agent", getMyAddress()) - .build(); - HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); - if (response.statusCode() != 200) { - log.error("Response error message: {}", response); - } - } catch (IOException e) { - log.warn("IOException at sending reporting. {}", e.getMessage()); - } catch (InterruptedException e) { - throw new RuntimeException(e); + log.info("Send report to monitor server: {}", reportingItems.toString()); + // We send the data as hex encoded protobuf data. We do not use the envelope as it is not part of the p2p system. + byte[] protoMessageAsBytes = reportingItems.toProtoMessageAsBytes(); + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(seedNodeReportingServerUrl)) + .POST(HttpRequest.BodyPublishers.ofByteArray(protoMessageAsBytes)) + .header("User-Agent", getMyAddress()) + .header("Connection", "keep-alive") + .build(); + httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()).whenComplete((response, throwable) -> { + if (throwable != null) { + log.warn("Exception at sending reporting data. {}", throwable.getMessage()); + } else if (response.statusCode() != 200) { + log.error("Response error message: {}", response); } - }, executor); + }); } catch (Throwable t) { + // RejectedExecutionException is thrown if we exceed our pool size. log.error("Did not send reportingItems {} because of exception {}", reportingItems, t.toString()); } } diff --git a/core/src/main/java/bisq/core/monitor/StringValueItem.java b/seednode/src/main/java/bisq/seednode/reporting/StringValueReportingItem.java similarity index 65% rename from core/src/main/java/bisq/core/monitor/StringValueItem.java rename to seednode/src/main/java/bisq/seednode/reporting/StringValueReportingItem.java index f698b30bae0..65f9edbf1f6 100644 --- a/core/src/main/java/bisq/core/monitor/StringValueItem.java +++ b/seednode/src/main/java/bisq/seednode/reporting/StringValueReportingItem.java @@ -15,13 +15,13 @@ * along with Bisq. If not, see . */ -package bisq.core.monitor; +package bisq.seednode.reporting; import lombok.Getter; import lombok.Setter; -public enum StringValueItem implements ReportingItem { +public enum StringValueReportingItem implements ReportingItem { Unspecified("", "Unspecified"), daoStateHash("dao", "daoStateHash"), @@ -32,32 +32,29 @@ public enum StringValueItem implements ReportingItem { commitHash("node", "commitHash"); @Getter - @Setter - private String key; + private final String key; @Getter - @Setter - private String group; + private final String group; @Getter @Setter private String value; - StringValueItem(String group, String key) { + StringValueReportingItem(String group, String key) { this.group = group; this.key = key; } - public StringValueItem withValue(String value) { + public StringValueReportingItem withValue(String value) { setValue(value); return this; } - public static StringValueItem from(String key, String value) { - StringValueItem item; + public static StringValueReportingItem from(String key, String value) { + StringValueReportingItem item; try { - item = StringValueItem.valueOf(key); + item = StringValueReportingItem.valueOf(key); } catch (Throwable t) { - item = StringValueItem.Unspecified; - item.setKey(key); + item = Unspecified; } item.setValue(value); @@ -71,13 +68,14 @@ public String getPath() { @Override public protobuf.ReportingItem toProtoMessage() { - return getBuilder().setStringValueItem(protobuf.StringValueItem.newBuilder() + return getBuilder().setStringValueReportingItem(protobuf.StringValueReportingItem.newBuilder() .setValue(value)) .build(); } - public static StringValueItem fromProto(protobuf.ReportingItem baseProto, protobuf.StringValueItem proto) { - return StringValueItem.from(baseProto.getKey(), proto.getValue()); + public static StringValueReportingItem fromProto(protobuf.ReportingItem baseProto, + protobuf.StringValueReportingItem proto) { + return StringValueReportingItem.from(baseProto.getKey(), proto.getValue()); } @Override