From 1943db557124439f9f41c18a618455ccf4c3e6cc Mon Sep 17 00:00:00 2001 From: Gabor Bota Date: Fri, 12 Apr 2019 18:27:41 -0700 Subject: [PATCH] HADOOP-16237. Fix new findbugs issues after updating guava to 27.0-jre. Author: Gabor Bota --- .../dev-support/findbugsExcludeFile.xml | 8 ++++ .../dev-support/findbugs-exclude.xml | 37 +++++++++++++++++++ .../entity/TimelineEntityDocument.java | 22 +++++++---- .../document/flowrun/FlowRunDocument.java | 13 +++++-- .../cosmosdb/CosmosDBDocumentStoreReader.java | 2 +- .../cosmosdb/CosmosDBDocumentStoreWriter.java | 2 +- 6 files changed, 71 insertions(+), 13 deletions(-) diff --git a/hadoop-common-project/hadoop-kms/dev-support/findbugsExcludeFile.xml b/hadoop-common-project/hadoop-kms/dev-support/findbugsExcludeFile.xml index f864c03145..356189b2ba 100644 --- a/hadoop-common-project/hadoop-kms/dev-support/findbugsExcludeFile.xml +++ b/hadoop-common-project/hadoop-kms/dev-support/findbugsExcludeFile.xml @@ -15,6 +15,14 @@ limitations under the License. --> + + + + + + + + diff --git a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml index dd42129830..eaab7e3c47 100644 --- a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml +++ b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml @@ -660,4 +660,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/entity/TimelineEntityDocument.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/entity/TimelineEntityDocument.java index ea72ee3653..a0b42ebf1f 100755 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/entity/TimelineEntityDocument.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/entity/TimelineEntityDocument.java @@ -138,14 +138,18 @@ public Map> getMetrics() { } public void setMetrics(Map> metrics) { - for (String metricId : metrics.keySet()) { - for(TimelineMetricSubDoc metricSubDoc : metrics.get(metricId)) { + for (Map.Entry> metricEntry : + metrics.entrySet()) { + final String metricId = metricEntry.getKey(); + final Set metricValue = metricEntry.getValue(); + + for(TimelineMetricSubDoc metricSubDoc : metricValue) { timelineEntity.addMetric(metricSubDoc.fetchTimelineMetric()); } if (this.metrics.containsKey(metricId)) { - this.metrics.get(metricId).addAll(metrics.get(metricId)); + this.metrics.get(metricId).addAll(metricValue); } else { - this.metrics.put(metricId, new HashSet<>(metrics.get(metricId))); + this.metrics.put(metricId, new HashSet<>(metricValue)); } } } @@ -155,14 +159,18 @@ public Map> getEvents() { } public void setEvents(Map> events) { - for (String eventId : events.keySet()) { - for(TimelineEventSubDoc eventSubDoc: events.get(eventId)) { + for (Map.Entry> eventEntry : + events.entrySet()) { + final String eventId = eventEntry.getKey(); + final Set eventValue = eventEntry.getValue(); + + for(TimelineEventSubDoc eventSubDoc : eventValue) { timelineEntity.addEvent(eventSubDoc.fetchTimelineEvent()); } if (this.events.containsKey(eventId)) { this.events.get(eventId).addAll(events.get(eventId)); } else { - this.events.put(eventId, new HashSet<>(events.get(eventId))); + this.events.put(eventId, new HashSet<>(eventValue)); } } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/flowrun/FlowRunDocument.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/flowrun/FlowRunDocument.java index 8ee87ab3c9..d131cf24de 100755 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/flowrun/FlowRunDocument.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/collection/document/flowrun/FlowRunDocument.java @@ -97,10 +97,14 @@ public void merge(FlowRunDocument flowRunDoc) { private void aggregateMetrics( Map metricSubDocMap) { - for(String metricId : metricSubDocMap.keySet()) { + for(Map.Entry metricEntry : + metricSubDocMap.entrySet()) { + final String metricId = metricEntry.getKey(); + final TimelineMetricSubDoc metricValue = metricEntry.getValue(); + if (this.metrics.containsKey(metricId)) { TimelineMetric incomingMetric = - metricSubDocMap.get(metricId).fetchTimelineMetric(); + metricValue.fetchTimelineMetric(); TimelineMetric baseMetric = this.metrics.get(metricId).fetchTimelineMetric(); if (incomingMetric.getValues().size() > 0) { @@ -111,7 +115,7 @@ private void aggregateMetrics( baseMetric.getId()); } } else { - this.metrics.put(metricId, metricSubDocMap.get(metricId)); + this.metrics.put(metricId, metricValue); } } } @@ -135,7 +139,8 @@ private TimelineMetric aggregate(TimelineMetric incomingMetric, baseMetric = TimelineMetricOperation.REPLACE .aggregate(incomingMetric, baseMetric, null); default: - //NoOP + LOG.warn("Unknown TimelineMetricOperation: {}", + baseMetric.getRealtimeAggregationOp()); } return baseMetric; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/reader/cosmosdb/CosmosDBDocumentStoreReader.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/reader/cosmosdb/CosmosDBDocumentStoreReader.java index 64468ac456..834ebd55ae 100755 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/reader/cosmosdb/CosmosDBDocumentStoreReader.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/reader/cosmosdb/CosmosDBDocumentStoreReader.java @@ -49,7 +49,7 @@ public class CosmosDBDocumentStoreReader .getLogger(CosmosDBDocumentStoreReader.class); private static final int DEFAULT_DOCUMENTS_SIZE = 1; - private static DocumentClient client; + private static volatile DocumentClient client; private final String databaseName; private final static String COLLECTION_LINK = "/dbs/%s/colls/%s"; private final static String SELECT_TOP_FROM_COLLECTION = "SELECT TOP %d * " + diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/writer/cosmosdb/CosmosDBDocumentStoreWriter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/writer/cosmosdb/CosmosDBDocumentStoreWriter.java index b345276b67..16ed207be9 100755 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/writer/cosmosdb/CosmosDBDocumentStoreWriter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-documentstore/src/main/java/org/apache/hadoop/yarn/server/timelineservice/documentstore/writer/cosmosdb/CosmosDBDocumentStoreWriter.java @@ -51,7 +51,7 @@ public class CosmosDBDocumentStoreWriter private static final Logger LOG = LoggerFactory .getLogger(CosmosDBDocumentStoreWriter.class); - private static DocumentClient client; + private static volatile DocumentClient client; private final String databaseName; private static final PerNodeAggTimelineCollectorMetrics METRICS = PerNodeAggTimelineCollectorMetrics.getInstance();