HADOOP-16237. Fix new findbugs issues after updating guava to 27.0-jre.

Author:    Gabor Bota <gabor.bota@cloudera.com>
This commit is contained in:
Gabor Bota 2019-04-12 18:27:41 -07:00 committed by Steve Loughran
parent 2382f63fc0
commit 1943db5571
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0
6 changed files with 71 additions and 13 deletions

View File

@ -15,6 +15,14 @@
limitations under the License.
-->
<FindBugsFilter>
<!-- The called method signature is isNullOrEmpty(@Nullable String string) in guava 27, so this should be ignored. -->
<Match>
<Class name="org.apache.hadoop.crypto.key.kms.server.KMSAudit"/>
<Method name="op" />
<Bug pattern="NP_NULL_PARAM_DEREF"/>
</Match>
<!--
Findbug is complaining about System.out being NULL
-->

View File

@ -660,4 +660,41 @@
<Bug pattern="EI_EXPOSE_REP" />
</Match>
<!-- The called method signature is String emptyToNull(@Nullable String string) in guava 27, so this should be ignored -->
<Match>
<Class name="org.apache.hadoop.yarn.server.nodemanager.NodeHealthCheckerService"/>
<Method name="getHealthReport" />
<Bug pattern="NP_NULL_PARAM_DEREF"/>
</Match>
<!-- The variable is not used, but it's defined for the document model. -->
<Match>
<Class name="org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.entity.TimelineEventSubDoc"/>
<Method name="setValid" />
<Bug pattern="URF_UNREAD_FIELD"/>
</Match>
<!-- The variable is not used, but it's defined for the document model. -->
<Match>
<Class name="org.apache.hadoop.yarn.server.timelineservice.documentstore.collection.document.entity.TimelineMetricSubDoc"/>
<Method name="setValid" />
<Bug pattern="URF_UNREAD_FIELD"/>
</Match>
<!-- The called method signature is public boolean set(@Nullable V value) in guava 27, so this should be ignored -->
<Match>
<Class name="org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore$UpdateAppTransition"/>
<Method name="transition" />
<Local name="result" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
</Match>
<!-- The called method signature is public boolean set(@Nullable V value) in guava 27, so this should be ignored -->
<Match>
<Class name="org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler"/>
<Method name="updateApplicationPriority" />
<Local name="result" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
</Match>
</FindBugsFilter>

View File

@ -138,14 +138,18 @@ public class TimelineEntityDocument implements
}
public void setMetrics(Map<String, Set<TimelineMetricSubDoc>> metrics) {
for (String metricId : metrics.keySet()) {
for(TimelineMetricSubDoc metricSubDoc : metrics.get(metricId)) {
for (Map.Entry<String, Set<TimelineMetricSubDoc>> metricEntry :
metrics.entrySet()) {
final String metricId = metricEntry.getKey();
final Set<TimelineMetricSubDoc> 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 class TimelineEntityDocument implements
}
public void setEvents(Map<String, Set<TimelineEventSubDoc>> events) {
for (String eventId : events.keySet()) {
for(TimelineEventSubDoc eventSubDoc: events.get(eventId)) {
for (Map.Entry<String, Set<TimelineEventSubDoc>> eventEntry :
events.entrySet()) {
final String eventId = eventEntry.getKey();
final Set<TimelineEventSubDoc> 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));
}
}
}

View File

@ -97,10 +97,14 @@ public class FlowRunDocument implements TimelineDocument<FlowRunDocument> {
private void aggregateMetrics(
Map<String, TimelineMetricSubDoc> metricSubDocMap) {
for(String metricId : metricSubDocMap.keySet()) {
for(Map.Entry<String, TimelineMetricSubDoc> 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 @@ public class FlowRunDocument implements TimelineDocument<FlowRunDocument> {
baseMetric.getId());
}
} else {
this.metrics.put(metricId, metricSubDocMap.get(metricId));
this.metrics.put(metricId, metricValue);
}
}
}
@ -135,7 +139,8 @@ public class FlowRunDocument implements TimelineDocument<FlowRunDocument> {
baseMetric = TimelineMetricOperation.REPLACE
.aggregate(incomingMetric, baseMetric, null);
default:
//NoOP
LOG.warn("Unknown TimelineMetricOperation: {}",
baseMetric.getRealtimeAggregationOp());
}
return baseMetric;
}

View File

@ -49,7 +49,7 @@ public class CosmosDBDocumentStoreReader<TimelineDoc extends TimelineDocument>
.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 * " +

View File

@ -51,7 +51,7 @@ public class CosmosDBDocumentStoreWriter<TimelineDoc extends TimelineDocument>
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();