tedyu commented on a change in pull request #2202:
URL: https://github.com/apache/hbase/pull/2202#discussion_r467843318



##########
File path: hbase-protocol-shaded/src/main/protobuf/server/region/Admin.proto
##########
@@ -219,6 +219,12 @@ message RollWALWriterResponse {
   repeated bytes region_to_flush = 1;
 }
 
+message ArchiveWALRequest {

Review comment:
       Should this be renamed to go with the updated method name ?
   
   

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java
##########
@@ -872,6 +874,33 @@ private IOException 
convertInterruptedExceptionToIOException(final InterruptedEx
     }
   }
 
+  public void archive(RegionServerServices services) throws IOException{
+    if (getNumRolledLogFiles() < 1) {
+      return;
+    }
+    // get the earliest log of this WAL instance
+    Map.Entry<Path, WalProps> firstWALEntry = this.walFile2Props.firstEntry();
+    // flush reigons if necessary
+    Map<byte[], List<byte[]>> regions =
+      
this.sequenceIdAccounting.findLower(firstWALEntry.getValue().encodedName2HighestSequenceId);
+    if (regions != null) {
+      for (Map.Entry<byte[], List<byte[]>> entry : regions.entrySet()) {
+        String encodedRegionName = Bytes.toString(entry.getKey());
+        HRegion r = (HRegion) services.getRegion(encodedRegionName);
+        if (r == null) {
+          LOG.warn("Failed to flush of {} when archive manually, because it is 
not online on us",
+            encodedRegionName);
+          return;
+        }
+        r.flushcache(entry.getValue(), false, FlushLifeCycleTracker.DUMMY);
+      }
+    }
+    // move the log file to archive dir
+    this.totalLogSize.addAndGet(-firstWALEntry.getValue().logSize);
+    moveLogFileToArchiveDir(firstWALEntry.getKey());

Review comment:
       What if IOException is thrown from this call ?
   Would totalLogSize be correct ?

##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java
##########
@@ -872,6 +874,33 @@ private IOException 
convertInterruptedExceptionToIOException(final InterruptedEx
     }
   }
 
+  public void archive(RegionServerServices services) throws IOException{
+    if (getNumRolledLogFiles() < 1) {
+      return;
+    }
+    // get the earliest log of this WAL instance
+    Map.Entry<Path, WalProps> firstWALEntry = this.walFile2Props.firstEntry();
+    // flush reigons if necessary
+    Map<byte[], List<byte[]>> regions =
+      
this.sequenceIdAccounting.findLower(firstWALEntry.getValue().encodedName2HighestSequenceId);
+    if (regions != null) {
+      for (Map.Entry<byte[], List<byte[]>> entry : regions.entrySet()) {
+        String encodedRegionName = Bytes.toString(entry.getKey());
+        HRegion r = (HRegion) services.getRegion(encodedRegionName);
+        if (r == null) {
+          LOG.warn("Failed to flush of {} when archive manually, because it is 
not online on us",
+            encodedRegionName);
+          return;

Review comment:
       It seems the return value should not be void - otherwise the caller 
wouldn't know this scenario (region not found).




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


Reply via email to