HBASE-16455 Provide API for obtaining all the WAL files
This commit is contained in:
parent
d260108e39
commit
2a35019a31
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 + ")";
|
||||
|
|
|
@ -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<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) {
|
||||
|
|
|
@ -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<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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -562,7 +562,6 @@ ClientProtos.ClientService.BlockingInterface, RegionServerServices {
|
|||
|
||||
@Override
|
||||
public WAL getWAL(HRegionInfo regionInfo) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<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;
|
||||
|
|
Loading…
Reference in New Issue