Maxwell-Guo commented on code in PR #2284:
URL: https://github.com/apache/cassandra/pull/2284#discussion_r1172216069


##########
test/unit/org/apache/cassandra/db/DirectoriesTest.java:
##########
@@ -696,4 +732,144 @@ private List<Directories.DataDirectoryCandidate> 
getWriteableDirectories(DataDir
         return candidates;
     }
 
+    private int getDiyThreadId()
+    {
+        return myDiyId = diyThreadId.getAndIncrement();
+    }
+
+    private void detachLogger()
+    {
+        logger.detachAppender(listAppender);
+        MDC.remove(this.MDCID);
+    }
+
+    private void tailLogs()
+    {
+        int diyId = getDiyThreadId();
+        MDC.put(this.MDCID, String.valueOf(diyId));
+        logger = (Logger) LoggerFactory.getLogger(Directories.class);
+
+        // create and start a ListAppender
+        listAppender = new ListAppender<>();
+        listAppender.start();
+
+        // add the appender to the logger
+        logger.addAppender(listAppender);
+    }
+
+    private List<ILoggingEvent> filterLogByDiyId(List<ILoggingEvent> log)
+    {
+        ArrayList<ILoggingEvent> filteredLog = new ArrayList<>();
+        for(ILoggingEvent event : log)
+        {
+            int mdcId = 
Integer.parseInt(event.getMDCPropertyMap().get(this.MDCID));
+            if(mdcId == myDiyId){
+                filteredLog.add(event);
+            }
+        }
+        return filteredLog;
+    }
+
+    private void checkFormattedMessage(List<ILoggingEvent> log, Level 
expectedLevel, String expectedMessage, int expectedCount)
+    {
+        int found=0;
+        for(ILoggingEvent e: log)

Review Comment:
   code format : for ()



##########
src/java/org/apache/cassandra/db/Directories.java:
##########
@@ -485,18 +485,39 @@ public boolean hasAvailableDiskSpace(long 
estimatedSSTables, long expectedTotalW
     {
         long writeSize = expectedTotalWriteSize / estimatedSSTables;
         long totalAvailable = 0L;
+        boolean hasSpace = true;
 
         for (DataDirectory dataDir : paths)
         {
             if 
(DisallowedDirectories.isUnwritable(getLocationForDisk(dataDir)))
                   continue;
             DataDirectoryCandidate candidate = new 
DataDirectoryCandidate(dataDir);
             // exclude directory if its total writeSize does not fit to data 
directory
+            logger.debug("DataDirectory {} has {} bytes available, checking if 
we can write {} bytes", dataDir.location, candidate.availableSpace, writeSize);

Review Comment:
   yeah,I have checked the trunk branch before left the comment and I also saw 
this debug log message, but I think we should  also remove the debug log there.
   
   Besides I think "logger.debug("FileStore {} has {} bytes available, checking 
if we can write {} bytes", toWrite.getKey(), availableForCompaction, 
toWrite.getValue());"   this message just tell us we need a bytes and we have b 
bytes, if the dir have enough space , the message is meaningless and useless to 
me. if we do not have enough space, the warn log below this log can give enough 
information.
   
   
   
    



##########
test/unit/org/apache/cassandra/db/DirectoriesTest.java:
##########
@@ -696,4 +732,144 @@ private List<Directories.DataDirectoryCandidate> 
getWriteableDirectories(DataDir
         return candidates;
     }
 
+    private int getDiyThreadId()
+    {
+        return myDiyId = diyThreadId.getAndIncrement();
+    }
+
+    private void detachLogger()
+    {
+        logger.detachAppender(listAppender);
+        MDC.remove(this.MDCID);
+    }
+
+    private void tailLogs()
+    {
+        int diyId = getDiyThreadId();
+        MDC.put(this.MDCID, String.valueOf(diyId));
+        logger = (Logger) LoggerFactory.getLogger(Directories.class);
+
+        // create and start a ListAppender
+        listAppender = new ListAppender<>();
+        listAppender.start();
+
+        // add the appender to the logger
+        logger.addAppender(listAppender);
+    }
+
+    private List<ILoggingEvent> filterLogByDiyId(List<ILoggingEvent> log)
+    {
+        ArrayList<ILoggingEvent> filteredLog = new ArrayList<>();
+        for(ILoggingEvent event : log)
+        {
+            int mdcId = 
Integer.parseInt(event.getMDCPropertyMap().get(this.MDCID));
+            if(mdcId == myDiyId){
+                filteredLog.add(event);
+            }
+        }
+        return filteredLog;
+    }
+
+    private void checkFormattedMessage(List<ILoggingEvent> log, Level 
expectedLevel, String expectedMessage, int expectedCount)
+    {
+        int found=0;
+        for(ILoggingEvent e: log)
+        {
+            System.err.println(e.getFormattedMessage());
+            if(e.getFormattedMessage().endsWith(expectedMessage))

Review Comment:
   code format : if ()



-- 
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.

To unsubscribe, e-mail: [email protected]

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