From a599d528208d0941eea5b06a06f41675799bb90a Mon Sep 17 00:00:00 2001 From: Yutong Xiao Date: Mon, 27 Dec 2021 23:59:13 +0800 Subject: [PATCH] HBASE-26564 Retire the method visitLogEntryBeforeWrite without RegionInfo in WALActionListner (#3938) Signed-off-by: Duo Zhang --- .../hadoop/hbase/mapreduce/TestImportExport.java | 2 +- .../hadoop/hbase/regionserver/wal/AbstractFSWAL.java | 2 +- .../hbase/regionserver/wal/WALActionsListener.java | 10 ---------- .../ReplicationSourceWALActionListener.java | 3 ++- .../hbase/regionserver/TestHRegionServerBulkLoad.java | 3 ++- .../hbase/regionserver/wal/AbstractTestFSWAL.java | 2 +- .../hadoop/hbase/regionserver/wal/TestFSHLog.java | 3 +-- .../org/apache/hadoop/hbase/wal/TestWALFactory.java | 7 ------- .../hadoop/hbase/wal/WALPerformanceEvaluation.java | 2 +- 9 files changed, 9 insertions(+), 25 deletions(-) diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java index 8a21c56e445..a68ef63bc17 100644 --- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java +++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java @@ -810,7 +810,7 @@ public class TestImportExport { } @Override - public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) { + public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) { if (logKey.getTableName().getNameAsString().equalsIgnoreCase( this.regionInfo.getTable().getNameAsString()) && (!logEdit.isMetaEdit())) { isVisited = true; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java index 5379e291513..6b260cf1082 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java @@ -1129,7 +1129,7 @@ public abstract class AbstractFSWAL implements WAL { coprocessorHost.preWALWrite(entry.getRegionInfo(), entry.getKey(), entry.getEdit()); if (!listeners.isEmpty()) { for (WALActionsListener i : listeners) { - i.visitLogEntryBeforeWrite(entry.getKey(), entry.getEdit()); + i.visitLogEntryBeforeWrite(entry.getRegionInfo(), entry.getKey(), entry.getEdit()); } } doAppend(writer, entry); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALActionsListener.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALActionsListener.java index 7fba7dfd4b5..c109a1b4bdd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALActionsListener.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALActionsListener.java @@ -89,16 +89,6 @@ public interface WALActionsListener { */ default void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) {} - /** - * @param logKey - * @param logEdit TODO: Retire this in favor of - * {@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 - * htd. - * @throws IOException If failed to parse the WALEdit - */ - default void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) throws IOException {} - /** * For notification post append to the writer. Used by metrics system at least. * TODO: Combine this with above. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceWALActionListener.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceWALActionListener.java index a38a96a3816..f3311eedbe0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceWALActionListener.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceWALActionListener.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.replication.regionserver; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.replication.ReplicationUtils; import org.apache.hadoop.hbase.wal.WALEdit; @@ -53,7 +54,7 @@ class ReplicationSourceWALActionListener implements WALActionsListener { } @Override - public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) throws IOException { + public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) { scopeWALEdits(logKey, logEdit, conf); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java index 34d4681023e..a21c1e1c21b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java @@ -49,6 +49,7 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; @@ -407,7 +408,7 @@ public class TestHRegionServerBulkLoad { private boolean found = false; @Override - public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) { + public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) { for (Cell cell : logEdit.getCells()) { KeyValue kv = KeyValueUtil.ensureKeyValue(cell); for (Map.Entry entry : kv.toStringMap().entrySet()) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java index 068489b06b8..07f3625ac89 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java @@ -545,7 +545,7 @@ public abstract class AbstractTestFSWAL { wal.init(); wal.registerWALActionsListener(new WALActionsListener() { @Override - public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) throws IOException { + public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) { if (startHoldingForAppend.get()) { try { holdAppend.await(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java index 49fa1dffd50..c930d1099c1 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java @@ -240,8 +240,7 @@ public class TestFSHLog extends AbstractTestFSWAL { log.init(); log.registerWALActionsListener(new WALActionsListener() { @Override - public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) - throws IOException { + public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) { if (startHoldingForAppend.get()) { try { holdAppend.await(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java index 5e6f6f9d485..62e29c5e0da 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java @@ -675,13 +675,6 @@ public class TestWALFactory { public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) { increments++; } - - @Override - public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) { - // To change body of implemented methods use File | Settings | File - // Templates. - increments++; - } } @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java index 4c34bf0d6b1..84e952abe04 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/WALPerformanceEvaluation.java @@ -471,7 +471,7 @@ public final class WALPerformanceEvaluation extends Configured implements Tool { private int appends = 0; @Override - public void visitLogEntryBeforeWrite(WALKey logKey, WALEdit logEdit) { + public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) { this.appends++; if (this.appends % whenToRoll == 0) { LOG.info("Rolling after " + appends + " edits");