HBASE-19408 Remove WALActionsListener.Base

This commit is contained in:
Chia-Ping Tsai 2017-12-03 01:17:03 +08:00
parent a5853221b4
commit 5f8b459cc1
17 changed files with 36 additions and 73 deletions

View File

@ -778,7 +778,7 @@ public class TestCellBasedImportExport2 {
* This listens to the {@link #visitLogEntryBeforeWrite(RegionInfo, WALKey, WALEdit)} to
* identify that an entry is written to the Write Ahead Log for the given table.
*/
private static class TableWALActionListener extends WALActionsListener.Base {
private static class TableWALActionListener implements WALActionsListener {
private RegionInfo regionInfo;
private boolean isVisited = false;

View File

@ -778,7 +778,7 @@ public class TestImportExport {
* This listens to the {@link #visitLogEntryBeforeWrite(RegionInfo, WALKey, WALEdit)} to
* identify that an entry is written to the Write Ahead Log for the given table.
*/
private static class TableWALActionListener extends WALActionsListener.Base {
private static class TableWALActionListener implements WALActionsListener {
private RegionInfo regionInfo;
private boolean isVisited = false;

View File

@ -69,7 +69,7 @@ public class LogRoller extends HasThread implements Closeable {
public void addWAL(final WAL wal) {
if (null == walNeedsRoll.putIfAbsent(wal, Boolean.FALSE)) {
wal.registerWALActionsListener(new WALActionsListener.Base() {
wal.registerWALActionsListener(new WALActionsListener() {
@Override
public void logRollRequested(boolean lowReplicas) {
walNeedsRoll.put(wal, Boolean.TRUE);

View File

@ -36,7 +36,7 @@ import org.apache.hadoop.util.StringUtils;
* single function call and turn it into multiple manipulations of the hadoop metrics system.
*/
@InterfaceAudience.Private
public class MetricsWAL extends WALActionsListener.Base {
public class MetricsWAL implements WALActionsListener {
private static final Log LOG = LogFactory.getLog(MetricsWAL.class);
private final MetricsWALSource source;

View File

@ -19,13 +19,11 @@
package org.apache.hadoop.hbase.regionserver.wal;
import java.io.IOException;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.hadoop.hbase.wal.WALKey;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Get notification of WAL events. The invocations are inline
@ -40,7 +38,7 @@ public interface WALActionsListener {
* @param oldPath the path to the old wal
* @param newPath the path to the new wal
*/
void preLogRoll(Path oldPath, Path newPath) throws IOException;
default void preLogRoll(Path oldPath, Path newPath) throws IOException {}
/**
* The WAL has been rolled. The oldPath can be null if this is
@ -48,31 +46,31 @@ public interface WALActionsListener {
* @param oldPath the path to the old wal
* @param newPath the path to the new wal
*/
void postLogRoll(Path oldPath, Path newPath) throws IOException;
default void postLogRoll(Path oldPath, Path newPath) throws IOException {}
/**
* The WAL is going to be archived.
* @param oldPath the path to the old wal
* @param newPath the path to the new wal
*/
void preLogArchive(Path oldPath, Path newPath) throws IOException;
default void preLogArchive(Path oldPath, Path newPath) throws IOException {}
/**
* The WAL has been archived.
* @param oldPath the path to the old wal
* @param newPath the path to the new wal
*/
void postLogArchive(Path oldPath, Path newPath) throws IOException;
default void postLogArchive(Path oldPath, Path newPath) throws IOException {}
/**
* A request was made that the WAL be rolled.
*/
void logRollRequested(boolean tooFewReplicas);
default void logRollRequested(boolean tooFewReplicas) {}
/**
* The WAL is about to close.
*/
void logCloseRequested();
default void logCloseRequested() {}
/**
* Called before each write.
@ -80,19 +78,19 @@ public interface WALActionsListener {
* @param logKey
* @param logEdit
*/
void visitLogEntryBeforeWrite(
HRegionInfo info, WALKey logKey, WALEdit logEdit
);
default void visitLogEntryBeforeWrite(
RegionInfo info, WALKey logKey, WALEdit logEdit
) {}
/**
* @param logKey
* @param logEdit TODO: Retire this in favor of
* {@link #visitLogEntryBeforeWrite(HRegionInfo, WALKey, WALEdit)} It only exists to get
* {@link #visitLogEntryBeforeWrite(RegionInfo, WALKey, WALEdit)} It only exists to get
* scope when replicating. Scope should be in the WALKey and not need us passing in a
* <code>htd</code>.
* @throws IOException If failed to parse the WALEdit
*/
void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) throws IOException;
default void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) throws IOException {}
/**
* For notification post append to the writer. Used by metrics system at least.
@ -103,8 +101,8 @@ public interface WALActionsListener {
* @param logEdit A WAL edit containing list of cells.
* @throws IOException if any network or I/O error occurred
*/
void postAppend(final long entryLen, final long elapsedTimeMillis, final WALKey logKey,
final WALEdit logEdit) throws IOException;
default void postAppend(final long entryLen, final long elapsedTimeMillis, final WALKey logKey,
final WALEdit logEdit) throws IOException {}
/**
* For notification post writer sync. Used by metrics system at least.
@ -112,40 +110,5 @@ public interface WALActionsListener {
* @param handlerSyncs How many sync handler calls were released by this call to filesystem
* sync.
*/
void postSync(final long timeInNanos, final int handlerSyncs);
static class Base implements WALActionsListener {
@Override
public void preLogRoll(Path oldPath, Path newPath) throws IOException {}
@Override
public void postLogRoll(Path oldPath, Path newPath) throws IOException {}
@Override
public void preLogArchive(Path oldPath, Path newPath) throws IOException {}
@Override
public void postLogArchive(Path oldPath, Path newPath) throws IOException {}
@Override
public void logRollRequested(boolean tooFewReplicas) {}
@Override
public void logCloseRequested() {}
@Override
public void visitLogEntryBeforeWrite(HRegionInfo info, WALKey logKey, WALEdit logEdit) {}
@Override
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) throws IOException {
}
@Override
public void postAppend(final long entryLen, final long elapsedTimeMillis, final WALKey logKey,
final WALEdit logEdit) throws IOException {
}
@Override
public void postSync(final long timeInNanos, final int handlerSyncs) {}
}
default void postSync(final long timeInNanos, final int handlerSyncs) {}
}

View File

@ -68,8 +68,8 @@ import org.apache.hadoop.hbase.shaded.com.google.common.util.concurrent.ThreadFa
* Gateway to Replication. Used by {@link org.apache.hadoop.hbase.regionserver.HRegionServer}.
*/
@InterfaceAudience.Private
public class Replication extends WALActionsListener.Base implements
ReplicationSourceService, ReplicationSinkService {
public class Replication implements
ReplicationSourceService, ReplicationSinkService, WALActionsListener {
private static final Log LOG =
LogFactory.getLog(Replication.class);
private boolean replicationForBulkLoadData;

View File

@ -295,7 +295,7 @@ public class TestBlockReorder {
final List<HRegion> regions = targetRs.getRegions(h.getName());
final CountDownLatch latch = new CountDownLatch(regions.size());
// listen for successful log rolls
final WALActionsListener listener = new WALActionsListener.Base() {
final WALActionsListener listener = new WALActionsListener() {
@Override
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
latch.countDown();

View File

@ -577,7 +577,7 @@ public class TestWALLockup {
}
}
static class DummyWALActionsListener extends WALActionsListener.Base {
static class DummyWALActionsListener implements WALActionsListener {
@Override
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit)

View File

@ -131,7 +131,7 @@ public abstract class AbstractTestLogRollPeriod {
private void checkMinLogRolls(final WAL log, final int minRolls)
throws Exception {
final List<Path> paths = new ArrayList<>();
log.registerWALActionsListener(new WALActionsListener.Base() {
log.registerWALActionsListener(new WALActionsListener() {
@Override
public void postLogRoll(Path oldFile, Path newFile) {
LOG.debug("postLogRoll: oldFile="+oldFile+" newFile="+newFile);

View File

@ -136,7 +136,7 @@ public class TestFSHLog extends AbstractTestFSWAL {
new FSHLog(FS, FSUtils.getRootDir(CONF), name, HConstants.HREGION_OLDLOGDIR_NAME, CONF,
null, true, null, null)) {
log.registerWALActionsListener(new WALActionsListener.Base() {
log.registerWALActionsListener(new WALActionsListener() {
@Override
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit)
throws IOException {

View File

@ -145,7 +145,7 @@ public class TestLogRolling extends AbstractTestLogRolling {
final FSHLog log = (FSHLog) server.getWAL(region);
final AtomicBoolean lowReplicationHookCalled = new AtomicBoolean(false);
log.registerWALActionsListener(new WALActionsListener.Base() {
log.registerWALActionsListener(new WALActionsListener() {
@Override
public void logRollRequested(boolean lowReplication) {
if (lowReplication) {
@ -255,7 +255,7 @@ public class TestLogRolling extends AbstractTestLogRolling {
final List<Integer> preLogRolledCalled = new ArrayList<>();
paths.add(AbstractFSWALProvider.getCurrentFileName(log));
log.registerWALActionsListener(new WALActionsListener.Base() {
log.registerWALActionsListener(new WALActionsListener() {
@Override
public void preLogRoll(Path oldFile, Path newFile) {

View File

@ -139,7 +139,7 @@ public class TestWALActionsListener {
/**
* Just counts when methods are called
*/
public static class DummyWALActionsListener extends WALActionsListener.Base {
public static class DummyWALActionsListener implements WALActionsListener {
public int preLogRollCounter = 0;
public int postLogRollCounter = 0;
public int closedCount = 0;

View File

@ -692,7 +692,7 @@ public class TestMasterReplication {
final CountDownLatch latch = new CountDownLatch(1);
// listen for successful log rolls
final WALActionsListener listener = new WALActionsListener.Base() {
final WALActionsListener listener = new WALActionsListener() {
@Override
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
latch.countDown();

View File

@ -218,7 +218,7 @@ public class TestMultiSlaveReplication {
final CountDownLatch latch = new CountDownLatch(1);
// listen for successful log rolls
final WALActionsListener listener = new WALActionsListener.Base() {
final WALActionsListener listener = new WALActionsListener() {
@Override
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
latch.countDown();

View File

@ -422,7 +422,7 @@ public class TestWALEntryStream {
};
}
class PathWatcher extends WALActionsListener.Base {
class PathWatcher implements WALActionsListener {
Path currentPath;

View File

@ -30,7 +30,6 @@ import java.net.BindException;
import java.util.List;
import java.util.NavigableMap;
import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@ -50,6 +49,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.coprocessor.SampleRegionWALCoprocessor;
import org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl;
@ -673,11 +673,11 @@ public class TestWALFactory {
assertNotNull(c);
}
static class DumbWALActionsListener extends WALActionsListener.Base {
static class DumbWALActionsListener implements WALActionsListener {
int increments = 0;
@Override
public void visitLogEntryBeforeWrite(HRegionInfo info, WALKey logKey,
public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey,
WALEdit logEdit) {
increments++;
}

View File

@ -503,7 +503,7 @@ public final class WALPerformanceEvaluation extends Configured implements Tool {
// If we haven't already, attach a listener to this wal to handle rolls and metrics.
if (walsListenedTo.add(wal)) {
roller.addWAL(wal);
wal.registerWALActionsListener(new WALActionsListener.Base() {
wal.registerWALActionsListener(new WALActionsListener() {
private int appends = 0;
@Override