HBASE-16455 Provide API for obtaining all the WAL files
This commit is contained in:
parent
d077219d3a
commit
f174fec391
|
@ -1905,6 +1905,11 @@ public class HRegionServer extends HasThread implements
|
|||
|
||||
private static final byte[] UNSPECIFIED_REGION = new byte[]{};
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
@ -55,6 +56,11 @@ public interface RegionServerServices extends OnlineRegions, FavoredNodesForRegi
|
|||
* default (common) WAL */
|
||||
WAL getWAL(HRegionInfo regionInfo) throws IOException;
|
||||
|
||||
/** @return the List of WALs that are used by this server
|
||||
* Doesn't include the meta WAL
|
||||
*/
|
||||
List<WAL> getWALs() throws IOException;
|
||||
|
||||
/**
|
||||
* @return Implementation of {@link CompactionRequestor} or null.
|
||||
*/
|
||||
|
|
|
@ -239,6 +239,10 @@ public abstract class AbstractFSWAL<W> implements WAL {
|
|||
*/
|
||||
private final ConcurrentMap<Thread, SyncFuture> syncFuturesByHandler;
|
||||
|
||||
public long getFilenum() {
|
||||
return this.filenum.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* A log file has a creation timestamp (in ms) in its file name ({@link #filenum}. This helper
|
||||
* method returns the creation timestamp from a given log file. It extracts the timestamp assuming
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
package org.apache.hadoop.hbase.wal;
|
||||
|
||||
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;
|
||||
|
@ -108,6 +110,16 @@ public abstract class AbstractFSWALProvider<T extends AbstractFSWAL<?>> implemen
|
|||
doInit(conf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WAL> getWALs() throws IOException {
|
||||
if (wal == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<WAL> wals = new ArrayList<WAL>();
|
||||
wals.add(wal);
|
||||
return wals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getWAL(byte[] identifier, byte[] namespace) throws IOException {
|
||||
T walCopy = wal;
|
||||
|
|
|
@ -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;
|
||||
|
@ -64,6 +65,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.AbstractFSWALProvider.META_WAL_PROVIDE
|
|||
import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.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) {
|
||||
|
|
|
@ -233,6 +233,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
|
||||
|
|
|
@ -58,6 +58,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
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hbase;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -245,6 +246,11 @@ public class MockRegionServerServices implements RegionServerServices {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WAL> getWALs() throws IOException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WAL getWAL(HRegionInfo regionInfo) throws IOException {
|
||||
return null;
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.master;
|
|||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -567,9 +568,13 @@ ClientProtos.ClientService.BlockingInterface, RegionServerServices {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WAL> getWALs() throws IOException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WAL getWAL(HRegionInfo regionInfo) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.META_WAL_PROVIDE
|
|||
import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.WAL_FILE_NAME_DELIMITER;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -105,6 +106,13 @@ public class IOTestProvider implements WALProvider {
|
|||
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