HBASE-19408 Remove WALActionsListener.Base
This commit is contained in:
parent
a5853221b4
commit
5f8b459cc1
@ -778,7 +778,7 @@ public class TestCellBasedImportExport2 {
|
|||||||
* This listens to the {@link #visitLogEntryBeforeWrite(RegionInfo, WALKey, WALEdit)} to
|
* 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.
|
* 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 RegionInfo regionInfo;
|
||||||
private boolean isVisited = false;
|
private boolean isVisited = false;
|
||||||
|
@ -778,7 +778,7 @@ public class TestImportExport {
|
|||||||
* This listens to the {@link #visitLogEntryBeforeWrite(RegionInfo, WALKey, WALEdit)} to
|
* 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.
|
* 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 RegionInfo regionInfo;
|
||||||
private boolean isVisited = false;
|
private boolean isVisited = false;
|
||||||
|
@ -69,7 +69,7 @@ public class LogRoller extends HasThread implements Closeable {
|
|||||||
|
|
||||||
public void addWAL(final WAL wal) {
|
public void addWAL(final WAL wal) {
|
||||||
if (null == walNeedsRoll.putIfAbsent(wal, Boolean.FALSE)) {
|
if (null == walNeedsRoll.putIfAbsent(wal, Boolean.FALSE)) {
|
||||||
wal.registerWALActionsListener(new WALActionsListener.Base() {
|
wal.registerWALActionsListener(new WALActionsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void logRollRequested(boolean lowReplicas) {
|
public void logRollRequested(boolean lowReplicas) {
|
||||||
walNeedsRoll.put(wal, Boolean.TRUE);
|
walNeedsRoll.put(wal, Boolean.TRUE);
|
||||||
|
@ -36,7 +36,7 @@ import org.apache.hadoop.util.StringUtils;
|
|||||||
* single function call and turn it into multiple manipulations of the hadoop metrics system.
|
* single function call and turn it into multiple manipulations of the hadoop metrics system.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class MetricsWAL extends WALActionsListener.Base {
|
public class MetricsWAL implements WALActionsListener {
|
||||||
private static final Log LOG = LogFactory.getLog(MetricsWAL.class);
|
private static final Log LOG = LogFactory.getLog(MetricsWAL.class);
|
||||||
|
|
||||||
private final MetricsWALSource source;
|
private final MetricsWALSource source;
|
||||||
|
@ -19,13 +19,11 @@
|
|||||||
package org.apache.hadoop.hbase.regionserver.wal;
|
package org.apache.hadoop.hbase.regionserver.wal;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
|
||||||
import org.apache.hadoop.fs.Path;
|
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.WALEdit;
|
||||||
import org.apache.hadoop.hbase.wal.WALKey;
|
import org.apache.hadoop.hbase.wal.WALKey;
|
||||||
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get notification of WAL events. The invocations are inline
|
* 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 oldPath the path to the old wal
|
||||||
* @param newPath the path to the new 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
|
* 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 oldPath the path to the old wal
|
||||||
* @param newPath the path to the new 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.
|
* The WAL is going to be archived.
|
||||||
* @param oldPath the path to the old wal
|
* @param oldPath the path to the old wal
|
||||||
* @param newPath the path to the new 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.
|
* The WAL has been archived.
|
||||||
* @param oldPath the path to the old wal
|
* @param oldPath the path to the old wal
|
||||||
* @param newPath the path to the new 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.
|
* A request was made that the WAL be rolled.
|
||||||
*/
|
*/
|
||||||
void logRollRequested(boolean tooFewReplicas);
|
default void logRollRequested(boolean tooFewReplicas) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The WAL is about to close.
|
* The WAL is about to close.
|
||||||
*/
|
*/
|
||||||
void logCloseRequested();
|
default void logCloseRequested() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before each write.
|
* Called before each write.
|
||||||
@ -80,19 +78,19 @@ public interface WALActionsListener {
|
|||||||
* @param logKey
|
* @param logKey
|
||||||
* @param logEdit
|
* @param logEdit
|
||||||
*/
|
*/
|
||||||
void visitLogEntryBeforeWrite(
|
default void visitLogEntryBeforeWrite(
|
||||||
HRegionInfo info, WALKey logKey, WALEdit logEdit
|
RegionInfo info, WALKey logKey, WALEdit logEdit
|
||||||
);
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param logKey
|
* @param logKey
|
||||||
* @param logEdit TODO: Retire this in favor of
|
* @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
|
* scope when replicating. Scope should be in the WALKey and not need us passing in a
|
||||||
* <code>htd</code>.
|
* <code>htd</code>.
|
||||||
* @throws IOException If failed to parse the WALEdit
|
* @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.
|
* 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.
|
* @param logEdit A WAL edit containing list of cells.
|
||||||
* @throws IOException if any network or I/O error occurred
|
* @throws IOException if any network or I/O error occurred
|
||||||
*/
|
*/
|
||||||
void postAppend(final long entryLen, final long elapsedTimeMillis, final WALKey logKey,
|
default void postAppend(final long entryLen, final long elapsedTimeMillis, final WALKey logKey,
|
||||||
final WALEdit logEdit) throws IOException;
|
final WALEdit logEdit) throws IOException {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For notification post writer sync. Used by metrics system at least.
|
* 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
|
* @param handlerSyncs How many sync handler calls were released by this call to filesystem
|
||||||
* sync.
|
* sync.
|
||||||
*/
|
*/
|
||||||
void postSync(final long timeInNanos, final int handlerSyncs);
|
default 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) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -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}.
|
* Gateway to Replication. Used by {@link org.apache.hadoop.hbase.regionserver.HRegionServer}.
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class Replication extends WALActionsListener.Base implements
|
public class Replication implements
|
||||||
ReplicationSourceService, ReplicationSinkService {
|
ReplicationSourceService, ReplicationSinkService, WALActionsListener {
|
||||||
private static final Log LOG =
|
private static final Log LOG =
|
||||||
LogFactory.getLog(Replication.class);
|
LogFactory.getLog(Replication.class);
|
||||||
private boolean replicationForBulkLoadData;
|
private boolean replicationForBulkLoadData;
|
||||||
|
@ -295,7 +295,7 @@ public class TestBlockReorder {
|
|||||||
final List<HRegion> regions = targetRs.getRegions(h.getName());
|
final List<HRegion> regions = targetRs.getRegions(h.getName());
|
||||||
final CountDownLatch latch = new CountDownLatch(regions.size());
|
final CountDownLatch latch = new CountDownLatch(regions.size());
|
||||||
// listen for successful log rolls
|
// listen for successful log rolls
|
||||||
final WALActionsListener listener = new WALActionsListener.Base() {
|
final WALActionsListener listener = new WALActionsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
|
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
@ -577,7 +577,7 @@ public class TestWALLockup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class DummyWALActionsListener extends WALActionsListener.Base {
|
static class DummyWALActionsListener implements WALActionsListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit)
|
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit)
|
||||||
|
@ -131,7 +131,7 @@ public abstract class AbstractTestLogRollPeriod {
|
|||||||
private void checkMinLogRolls(final WAL log, final int minRolls)
|
private void checkMinLogRolls(final WAL log, final int minRolls)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final List<Path> paths = new ArrayList<>();
|
final List<Path> paths = new ArrayList<>();
|
||||||
log.registerWALActionsListener(new WALActionsListener.Base() {
|
log.registerWALActionsListener(new WALActionsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void postLogRoll(Path oldFile, Path newFile) {
|
public void postLogRoll(Path oldFile, Path newFile) {
|
||||||
LOG.debug("postLogRoll: oldFile="+oldFile+" newFile="+newFile);
|
LOG.debug("postLogRoll: oldFile="+oldFile+" newFile="+newFile);
|
||||||
|
@ -136,7 +136,7 @@ public class TestFSHLog extends AbstractTestFSWAL {
|
|||||||
new FSHLog(FS, FSUtils.getRootDir(CONF), name, HConstants.HREGION_OLDLOGDIR_NAME, CONF,
|
new FSHLog(FS, FSUtils.getRootDir(CONF), name, HConstants.HREGION_OLDLOGDIR_NAME, CONF,
|
||||||
null, true, null, null)) {
|
null, true, null, null)) {
|
||||||
|
|
||||||
log.registerWALActionsListener(new WALActionsListener.Base() {
|
log.registerWALActionsListener(new WALActionsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit)
|
public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -145,7 +145,7 @@ public class TestLogRolling extends AbstractTestLogRolling {
|
|||||||
final FSHLog log = (FSHLog) server.getWAL(region);
|
final FSHLog log = (FSHLog) server.getWAL(region);
|
||||||
final AtomicBoolean lowReplicationHookCalled = new AtomicBoolean(false);
|
final AtomicBoolean lowReplicationHookCalled = new AtomicBoolean(false);
|
||||||
|
|
||||||
log.registerWALActionsListener(new WALActionsListener.Base() {
|
log.registerWALActionsListener(new WALActionsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void logRollRequested(boolean lowReplication) {
|
public void logRollRequested(boolean lowReplication) {
|
||||||
if (lowReplication) {
|
if (lowReplication) {
|
||||||
@ -255,7 +255,7 @@ public class TestLogRolling extends AbstractTestLogRolling {
|
|||||||
final List<Integer> preLogRolledCalled = new ArrayList<>();
|
final List<Integer> preLogRolledCalled = new ArrayList<>();
|
||||||
|
|
||||||
paths.add(AbstractFSWALProvider.getCurrentFileName(log));
|
paths.add(AbstractFSWALProvider.getCurrentFileName(log));
|
||||||
log.registerWALActionsListener(new WALActionsListener.Base() {
|
log.registerWALActionsListener(new WALActionsListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preLogRoll(Path oldFile, Path newFile) {
|
public void preLogRoll(Path oldFile, Path newFile) {
|
||||||
|
@ -139,7 +139,7 @@ public class TestWALActionsListener {
|
|||||||
/**
|
/**
|
||||||
* Just counts when methods are called
|
* 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 preLogRollCounter = 0;
|
||||||
public int postLogRollCounter = 0;
|
public int postLogRollCounter = 0;
|
||||||
public int closedCount = 0;
|
public int closedCount = 0;
|
||||||
|
@ -692,7 +692,7 @@ public class TestMasterReplication {
|
|||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
// listen for successful log rolls
|
// listen for successful log rolls
|
||||||
final WALActionsListener listener = new WALActionsListener.Base() {
|
final WALActionsListener listener = new WALActionsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
|
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
@ -218,7 +218,7 @@ public class TestMultiSlaveReplication {
|
|||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
// listen for successful log rolls
|
// listen for successful log rolls
|
||||||
final WALActionsListener listener = new WALActionsListener.Base() {
|
final WALActionsListener listener = new WALActionsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
|
public void postLogRoll(final Path oldPath, final Path newPath) throws IOException {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
@ -422,7 +422,7 @@ public class TestWALEntryStream {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class PathWatcher extends WALActionsListener.Base {
|
class PathWatcher implements WALActionsListener {
|
||||||
|
|
||||||
Path currentPath;
|
Path currentPath;
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import java.net.BindException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
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.KeyValue;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
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.CoprocessorHost;
|
||||||
import org.apache.hadoop.hbase.coprocessor.SampleRegionWALCoprocessor;
|
import org.apache.hadoop.hbase.coprocessor.SampleRegionWALCoprocessor;
|
||||||
import org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl;
|
import org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl;
|
||||||
@ -673,11 +673,11 @@ public class TestWALFactory {
|
|||||||
assertNotNull(c);
|
assertNotNull(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class DumbWALActionsListener extends WALActionsListener.Base {
|
static class DumbWALActionsListener implements WALActionsListener {
|
||||||
int increments = 0;
|
int increments = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitLogEntryBeforeWrite(HRegionInfo info, WALKey logKey,
|
public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey,
|
||||||
WALEdit logEdit) {
|
WALEdit logEdit) {
|
||||||
increments++;
|
increments++;
|
||||||
}
|
}
|
||||||
|
@ -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 we haven't already, attach a listener to this wal to handle rolls and metrics.
|
||||||
if (walsListenedTo.add(wal)) {
|
if (walsListenedTo.add(wal)) {
|
||||||
roller.addWAL(wal);
|
roller.addWAL(wal);
|
||||||
wal.registerWALActionsListener(new WALActionsListener.Base() {
|
wal.registerWALActionsListener(new WALActionsListener() {
|
||||||
private int appends = 0;
|
private int appends = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user