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 5dda768f391..03dcd4e74aa 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 getWALs() throws IOException { + return walFactory.getWALs(); + } + @Override public WAL getWAL(HRegionInfo regionInfo) throws IOException { WAL wal; 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 993b072e456..99a7b12fdd7 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; 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 097101be3f4..ceced2f20c0 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 + ")"; 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 b618a0f7a24..4b355d3afd4 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; @@ -119,6 +121,16 @@ public class DefaultWALProvider implements WALProvider { logPrefix = sb.toString(); } + @Override + public List getWALs() throws IOException { + if (log == null) { + return Collections.emptyList(); + } + List wals = new ArrayList(); + wals.add(log); + return wals; + } + @Override public WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException { if (log == null) { 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 1816238fc33..868ee910a58 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; @@ -65,6 +66,13 @@ class DisabledWALProvider implements WALProvider { disabled = new DisabledWAL(new Path(FSUtils.getRootDir(conf), providerId), conf, null); } + @Override + public List getWALs() throws IOException { + List wals = new ArrayList(); + wals.add(disabled); + return wals; + } + @Override public WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException { return disabled; 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 a72598970fe..b853c5bffcc 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 getWALs() throws IOException { + List wals = new ArrayList(); + 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) { 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 cf704ba8062..5452742800e 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 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 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 b3d86748c30..57ffd6b5aa3 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 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 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 74dd7d40638..90752a91fb0 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; } 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 6b1ca037650..d27939d9605 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; @@ -107,6 +108,13 @@ public class IOTestProvider implements WALProvider { true, logPrefix, META_WAL_PROVIDER_ID.equals(providerId) ? META_WAL_PROVIDER_ID : null); } + @Override + public List getWALs() throws IOException { + List wals = new ArrayList(); + wals.add(log); + return wals; + } + @Override public WAL getWAL(final byte[] identifier, byte[] namespace) throws IOException { return log;