runzhiwang commented on a change in pull request #1601:
URL: https://github.com/apache/ozone/pull/1601#discussion_r528493460



##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java
##########
@@ -190,16 +211,29 @@ void setShutdownGracefully() {
   public boolean getShutdownOnError() {
     return shutdownOnError;
   }
+
   /**
    * Adds the report to report queue.
    *
    * @param report report to be added
    */
   public void addReport(GeneratedMessage report) {
     if (report != null) {
-      synchronized (reports) {
-        for (InetSocketAddress endpoint : endpoints) {
-          reports.get(endpoint).add(report);
+      // TODO: Check report.getDescriptorForType() != null as well?
+      final String reportType = report.getDescriptorForType().getFullName();
+      for (InetSocketAddress endpoint : endpoints) {
+        // We only keep the latest container, node and pipeline report
+        if (reportType.equals(CONTAINER_REPORTS_PROTO_NAME)) {

Review comment:
       one thread write containerReport and another thread read 
containerReport, it's not thread safe, we can use 
`AtomicReference<GeneratedMessage> containerReport`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to