hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-16455 Provide API for obtaining all the WAL files
Date Mon, 22 Aug 2016 13:57:20 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 d260108e3 -> 2a35019a3


HBASE-16455 Provide API for obtaining all the WAL files


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2a35019a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2a35019a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2a35019a

Branch: refs/heads/branch-1
Commit: 2a35019a31e5616b364a0363b3ee1be1d3aaefcf
Parents: d260108
Author: tedyu <yuzhihong@gmail.com>
Authored: Mon Aug 22 06:56:14 2016 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Mon Aug 22 06:56:14 2016 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/regionserver/HRegionServer.java |  4 ++++
 .../hadoop/hbase/regionserver/RegionServerServices.java |  1 +
 .../apache/hadoop/hbase/regionserver/wal/FSHLog.java    |  7 +++++++
 .../org/apache/hadoop/hbase/wal/DefaultWALProvider.java | 12 ++++++++++++
 .../apache/hadoop/hbase/wal/DisabledWALProvider.java    |  8 ++++++++
 .../apache/hadoop/hbase/wal/RegionGroupingProvider.java | 10 ++++++++++
 .../java/org/apache/hadoop/hbase/wal/WALFactory.java    |  4 ++++
 .../java/org/apache/hadoop/hbase/wal/WALProvider.java   |  4 ++++
 .../apache/hadoop/hbase/master/MockRegionServer.java    |  1 -
 .../org/apache/hadoop/hbase/wal/IOTestProvider.java     |  8 ++++++++
 10 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 5dda768..03dcd4e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -1882,6 +1882,10 @@ public class HRegionServer extends HasThread implements
 
   private static final byte[] UNSPECIFIED_REGION = new byte[]{};
 
+  public List<WAL> getWALs() throws IOException {
+    return walFactory.getWALs();
+  }
+
   @Override
   public WAL getWAL(HRegionInfo regionInfo) throws IOException {
     WAL wal;

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
index 993b072..99a7b12 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hbase.regionserver;
 
 import java.io.IOException;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java
index 097101b..ceced2f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java
@@ -986,6 +986,13 @@ public class FSHLog implements WAL {
     return computeFilename(this.filenum.get());
   }
 
+  /**
+   * @return current file number (timestamp)
+   */
+  public long getFilenum() {
+    return filenum.get();
+  }
+  
   @Override
   public String toString() {
     return "FSHLog " + logFilePrefix + ":" + logFileSuffix + "(num " + filenum + ")";

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DefaultWALProvider.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DefaultWALProvider.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DefaultWALProvider.java
index b618a0f..4b355d3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DefaultWALProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DefaultWALProvider.java
@@ -22,6 +22,8 @@ import java.io.Closeable;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Pattern;
@@ -120,6 +122,16 @@ public class DefaultWALProvider implements WALProvider {
   }
 
   @Override
+  public List<WAL> getWALs() throws IOException {
+    if (log == null) {
+      return Collections.emptyList();
+    }
+    List<WAL> wals = new ArrayList<WAL>();
+    wals.add(log);
+    return wals;
+  }
+
+  @Override
   public WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException {
     if (log == null) {
       // only lock when need to create wal, and need to lock since

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
index 1816238..868ee91 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.wal;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -66,6 +67,13 @@ class DisabledWALProvider implements WALProvider {
   }
 
   @Override
+  public List<WAL> getWALs() throws IOException {
+    List<WAL> wals = new ArrayList<WAL>();
+    wals.add(disabled);
+    return wals;
+  }
+
+  @Override
   public WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException {
     return disabled;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
index a725989..b853c5b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
@@ -22,6 +22,7 @@ import static org.apache.hadoop.hbase.wal.DefaultWALProvider.META_WAL_PROVIDER_I
 import static org.apache.hadoop.hbase.wal.DefaultWALProvider.WAL_FILE_NAME_DELIMITER;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
@@ -168,6 +169,15 @@ public class RegionGroupingProvider implements WALProvider {
     }
   }
 
+  @Override
+  public List<WAL> getWALs() throws IOException {
+    List<WAL> wals = new ArrayList<WAL>();
+    for (WALProvider provider : cached.values()) {
+      wals.addAll(provider.getWALs());
+    }
+    return wals;
+  }
+
   private WAL getWAL(final String group) throws IOException {
     WALProvider provider = cached.get(group);
     if (provider == null) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
index cf704ba..5452742 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
@@ -232,6 +232,10 @@ public class WALFactory {
     }
   }
 
+  public List<WAL> getWALs() throws IOException {
+    return provider.getWALs();
+  }
+
   /**
    * @param identifier may not be null, contents will not be altered
    * @param namespace could be null, and will use default namespace if null

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java
index b3d8674..57ffd6b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java
@@ -59,6 +59,10 @@ public interface WALProvider {
    */
   WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException;
 
+  /** @return the List of WALs that are used by this server
+   */
+  List<WAL> getWALs() throws IOException;
+
   /**
    * persist outstanding WALs to storage and stop accepting new appends.
    * This method serves as shorthand for sending a sync to every WAL provided by a given

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
index 74dd7d4..90752a9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
@@ -562,7 +562,6 @@ ClientProtos.ClientService.BlockingInterface, RegionServerServices {
 
   @Override
   public WAL getWAL(HRegionInfo regionInfo) throws IOException {
-    // TODO Auto-generated method stub
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a35019a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java
index 6b1ca03..d27939d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hbase.wal;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -108,6 +109,13 @@ public class IOTestProvider implements WALProvider {
   }
 
   @Override
+  public List<WAL> getWALs() throws IOException {
+    List<WAL> wals = new ArrayList<WAL>();
+    wals.add(log);
+    return wals;
+  }
+
+  @Override
   public WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException {
    return log;
   }


Mime
View raw message