Skip to content

Commit c949da8

Browse files
committed
HBASE-28588 Remove deprecated methods in WAL
1 parent ca34010 commit c949da8

File tree

8 files changed

+57
-55
lines changed

8 files changed

+57
-55
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AbstractFSWAL.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import static org.apache.hbase.thirdparty.com.google.common.base.Preconditions.checkArgument;
2828
import static org.apache.hbase.thirdparty.com.google.common.base.Preconditions.checkNotNull;
2929

30+
import com.google.errorprone.annotations.RestrictedApi;
3031
import com.lmax.disruptor.RingBuffer;
3132
import com.lmax.disruptor.Sequence;
3233
import com.lmax.disruptor.Sequencer;
@@ -686,12 +687,6 @@ public void abortCacheFlush(byte[] encodedRegionName) {
686687
this.sequenceIdAccounting.abortCacheFlush(encodedRegionName);
687688
}
688689

689-
@Override
690-
public long getEarliestMemStoreSeqNum(byte[] encodedRegionName) {
691-
// Used by tests. Deprecated as too subtle for general usage.
692-
return this.sequenceIdAccounting.getLowestSequenceId(encodedRegionName);
693-
}
694-
695690
@Override
696691
public long getEarliestMemStoreSeqNum(byte[] encodedRegionName, byte[] familyName) {
697692
// This method is used by tests and for figuring if we should flush or not because our
@@ -730,6 +725,12 @@ public final void sync(long txid, boolean forceSync) throws IOException {
730725
TraceUtil.trace(() -> doSync(txid, forceSync), () -> createSpan("WAL.sync"));
731726
}
732727

728+
@RestrictedApi(explanation = "Should only be called in tests", link = "",
729+
allowedOnPath = ".*/src/test/.*")
730+
public SequenceIdAccounting getSequenceIdAccounting() {
731+
return sequenceIdAccounting;
732+
}
733+
733734
/**
734735
* This is a convenience method that computes a new filename with a given file-number.
735736
* @param filenum to use

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SequenceIdAccounting.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import static org.apache.hadoop.hbase.util.ConcurrentMapUtils.computeIfAbsent;
2121

22+
import com.google.errorprone.annotations.RestrictedApi;
2223
import java.util.ArrayList;
2324
import java.util.Collection;
2425
import java.util.Collections;
@@ -50,7 +51,7 @@
5051
* </p>
5152
*/
5253
@InterfaceAudience.Private
53-
class SequenceIdAccounting {
54+
public class SequenceIdAccounting {
5455
private static final Logger LOG = LoggerFactory.getLogger(SequenceIdAccounting.class);
5556

5657
/**
@@ -112,7 +113,9 @@ class SequenceIdAccounting {
112113
* @return Lowest outstanding unflushed sequenceid for <code>encodedRegionName</code>. Will return
113114
* {@link HConstants#NO_SEQNUM} when none.
114115
*/
115-
long getLowestSequenceId(final byte[] encodedRegionName) {
116+
@RestrictedApi(explanation = "Should only be called in tests", link = "",
117+
allowedOnPath = ".*/src/test/.*")
118+
public long getLowestSequenceId(final byte[] encodedRegionName) {
116119
synchronized (this.tieLock) {
117120
Map<?, Long> m = this.flushingSequenceIds.get(encodedRegionName);
118121
long flushingLowest = m != null ? getLowestSequenceId(m) : Long.MAX_VALUE;

hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,6 @@ public WALCoprocessorHost getCoprocessorHost() {
237237
return coprocessorHost;
238238
}
239239

240-
@Override
241-
public long getEarliestMemStoreSeqNum(byte[] encodedRegionName) {
242-
return HConstants.NO_SEQNUM;
243-
}
244-
245240
@Override
246241
public long getEarliestMemStoreSeqNum(byte[] encodedRegionName, byte[] familyName) {
247242
return HConstants.NO_SEQNUM;

hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WAL.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,6 @@ default void sync(long txid, boolean forceSync) throws IOException {
212212
/** Returns Coprocessor host. */
213213
WALCoprocessorHost getCoprocessorHost();
214214

215-
/**
216-
* Gets the earliest unflushed sequence id in the memstore for the region.
217-
* @param encodedRegionName The region to get the number for.
218-
* @return The earliest/lowest/oldest sequence id if present, HConstants.NO_SEQNUM if absent.
219-
* @deprecated Since version 1.2.0. Removing because not used and exposes subtle internal
220-
* workings. Use {@link #getEarliestMemStoreSeqNum(byte[], byte[])}
221-
*/
222-
@Deprecated
223-
long getEarliestMemStoreSeqNum(byte[] encodedRegionName);
224-
225215
/**
226216
* Gets the earliest unflushed sequence id in the memstore for the store.
227217
* @param encodedRegionName The region to get the number for.

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPerColumnFamilyFlush.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.apache.hadoop.hbase.client.Table;
4848
import org.apache.hadoop.hbase.client.TableDescriptor;
4949
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
50+
import org.apache.hadoop.hbase.regionserver.wal.AbstractTestFSWAL;
5051
import org.apache.hadoop.hbase.testclassification.LargeTests;
5152
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
5253
import org.apache.hadoop.hbase.util.Bytes;
@@ -162,8 +163,8 @@ public void testSelectiveFlushWhenEnabled() throws IOException {
162163
MemStoreSize cf3MemstoreSize = region.getStore(FAMILY3).getMemStoreSize();
163164

164165
// Get the overall smallest LSN in the region's memstores.
165-
long smallestSeqInRegionCurrentMemstore =
166-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
166+
long smallestSeqInRegionCurrentMemstore = AbstractTestFSWAL
167+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
167168

168169
// The overall smallest LSN in the region's memstores should be the same as
169170
// the LSN of the smallest edit in CF1
@@ -193,8 +194,8 @@ public void testSelectiveFlushWhenEnabled() throws IOException {
193194
cf2MemstoreSize = region.getStore(FAMILY2).getMemStoreSize();
194195
cf3MemstoreSize = region.getStore(FAMILY3).getMemStoreSize();
195196
totalMemstoreSize = region.getMemStoreDataSize();
196-
smallestSeqInRegionCurrentMemstore =
197-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
197+
smallestSeqInRegionCurrentMemstore = AbstractTestFSWAL.getEarliestMemStoreSeqNum(getWAL(region),
198+
region.getRegionInfo().getEncodedNameAsBytes());
198199

199200
// We should have cleared out only CF1, since we chose the flush thresholds
200201
// and number of puts accordingly.
@@ -231,8 +232,8 @@ public void testSelectiveFlushWhenEnabled() throws IOException {
231232
cf2MemstoreSize = region.getStore(FAMILY2).getMemStoreSize();
232233
cf3MemstoreSize = region.getStore(FAMILY3).getMemStoreSize();
233234
totalMemstoreSize = region.getMemStoreDataSize();
234-
smallestSeqInRegionCurrentMemstore =
235-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
235+
smallestSeqInRegionCurrentMemstore = AbstractTestFSWAL.getEarliestMemStoreSeqNum(getWAL(region),
236+
region.getRegionInfo().getEncodedNameAsBytes());
236237

237238
// CF1 and CF2, both should be absent.
238239
assertEquals(0, cf1MemstoreSize.getDataSize());
@@ -242,6 +243,7 @@ public void testSelectiveFlushWhenEnabled() throws IOException {
242243
// CF3 shouldn't have been touched.
243244
assertEquals(cf3MemstoreSize, oldCF3MemstoreSize);
244245
assertEquals(totalMemstoreSize, cf3MemstoreSize.getDataSize());
246+
assertEquals(smallestSeqInRegionCurrentMemstore, smallestSeqCF3);
245247

246248
// What happens when we hit the memstore limit, but we are not able to find
247249
// any Column Family above the threshold?
@@ -313,8 +315,8 @@ public void testSelectiveFlushWhenNotEnabled() throws IOException {
313315
cf2MemstoreSize = region.getStore(FAMILY2).getMemStoreSize();
314316
cf3MemstoreSize = region.getStore(FAMILY3).getMemStoreSize();
315317
totalMemstoreSize = region.getMemStoreDataSize();
316-
long smallestSeqInRegionCurrentMemstore =
317-
region.getWAL().getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
318+
long smallestSeqInRegionCurrentMemstore = AbstractTestFSWAL
319+
.getEarliestMemStoreSeqNum(region.getWAL(), region.getRegionInfo().getEncodedNameAsBytes());
318320

319321
// Everything should have been cleared
320322
assertEquals(0, cf1MemstoreSize.getDataSize());

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestWalAndCompactingMemStoreFlush.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.apache.hadoop.hbase.client.RegionInfo;
3737
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
3838
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
39+
import org.apache.hadoop.hbase.regionserver.wal.AbstractTestFSWAL;
3940
import org.apache.hadoop.hbase.testclassification.LargeTests;
4041
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
4142
import org.apache.hadoop.hbase.util.Bytes;
@@ -177,8 +178,8 @@ public void testSelectiveFlushWithEager() throws IOException {
177178
MemStoreSize cf3MemstoreSizePhaseI = region.getStore(FAMILY3).getMemStoreSize();
178179

179180
// Get the overall smallest LSN in the region's memstores.
180-
long smallestSeqInRegionCurrentMemstorePhaseI =
181-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
181+
long smallestSeqInRegionCurrentMemstorePhaseI = AbstractTestFSWAL
182+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
182183

183184
String s = "\n\n----------------------------------\n"
184185
+ "Upon initial insert and before any flush, size of CF1 is:" + cf1MemstoreSizePhaseI
@@ -224,8 +225,8 @@ public void testSelectiveFlushWithEager() throws IOException {
224225
MemStoreSize cf2MemstoreSizePhaseII = region.getStore(FAMILY2).getMemStoreSize();
225226
MemStoreSize cf3MemstoreSizePhaseII = region.getStore(FAMILY3).getMemStoreSize();
226227

227-
long smallestSeqInRegionCurrentMemstorePhaseII =
228-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
228+
long smallestSeqInRegionCurrentMemstorePhaseII = AbstractTestFSWAL
229+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
229230
// Find the smallest LSNs for edits wrt to each CF.
230231
long smallestSeqCF1PhaseII = region.getOldestSeqIdOfStore(FAMILY1);
231232
long smallestSeqCF2PhaseII = region.getOldestSeqIdOfStore(FAMILY2);
@@ -280,8 +281,8 @@ public void testSelectiveFlushWithEager() throws IOException {
280281
MemStoreSize cf2MemstoreSizePhaseIV = region.getStore(FAMILY2).getMemStoreSize();
281282
MemStoreSize cf3MemstoreSizePhaseIV = region.getStore(FAMILY3).getMemStoreSize();
282283

283-
long smallestSeqInRegionCurrentMemstorePhaseIV =
284-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
284+
long smallestSeqInRegionCurrentMemstorePhaseIV = AbstractTestFSWAL
285+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
285286
long smallestSeqCF1PhaseIV = region.getOldestSeqIdOfStore(FAMILY1);
286287
long smallestSeqCF2PhaseIV = region.getOldestSeqIdOfStore(FAMILY2);
287288
long smallestSeqCF3PhaseIV = region.getOldestSeqIdOfStore(FAMILY3);
@@ -318,8 +319,8 @@ public void testSelectiveFlushWithEager() throws IOException {
318319
MemStoreSize cf1MemstoreSizePhaseV = region.getStore(FAMILY1).getMemStoreSize();
319320
MemStoreSize cf2MemstoreSizePhaseV = region.getStore(FAMILY2).getMemStoreSize();
320321
MemStoreSize cf3MemstoreSizePhaseV = region.getStore(FAMILY3).getMemStoreSize();
321-
long smallestSeqInRegionCurrentMemstorePhaseV =
322-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
322+
long smallestSeqInRegionCurrentMemstorePhaseV = AbstractTestFSWAL
323+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
323324

324325
assertEquals(0, cf1MemstoreSizePhaseV.getDataSize());
325326
assertEquals(MutableSegment.DEEP_OVERHEAD, cf1MemstoreSizePhaseV.getHeapSize());
@@ -405,8 +406,8 @@ public void testSelectiveFlushWithIndexCompaction() throws IOException {
405406
MemStoreSize cf2MemstoreSizePhaseI = region.getStore(FAMILY2).getMemStoreSize();
406407
MemStoreSize cf3MemstoreSizePhaseI = region.getStore(FAMILY3).getMemStoreSize();
407408
// Get the overall smallest LSN in the region's memstores.
408-
long smallestSeqInRegionCurrentMemstorePhaseI =
409-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
409+
long smallestSeqInRegionCurrentMemstorePhaseI = AbstractTestFSWAL
410+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
410411

411412
/*------------------------------------------------------------------------------*/
412413
/* PHASE I - validation */
@@ -458,8 +459,8 @@ public void testSelectiveFlushWithIndexCompaction() throws IOException {
458459
MemStoreSize cf1MemstoreSizePhaseII = region.getStore(FAMILY1).getMemStoreSize();
459460
MemStoreSize cf2MemstoreSizePhaseII = region.getStore(FAMILY2).getMemStoreSize();
460461
MemStoreSize cf3MemstoreSizePhaseII = region.getStore(FAMILY3).getMemStoreSize();
461-
long smallestSeqInRegionCurrentMemstorePhaseII =
462-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
462+
long smallestSeqInRegionCurrentMemstorePhaseII = AbstractTestFSWAL
463+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
463464
// Find the smallest LSNs for edits wrt to each CF.
464465
long smallestSeqCF3PhaseII = region.getOldestSeqIdOfStore(FAMILY3);
465466
long totalMemstoreSizePhaseII = region.getMemStoreDataSize();
@@ -531,8 +532,8 @@ public void testSelectiveFlushWithIndexCompaction() throws IOException {
531532
MemStoreSize cf1MemstoreSizePhaseIV = region.getStore(FAMILY1).getMemStoreSize();
532533
MemStoreSize cf2MemstoreSizePhaseIV = region.getStore(FAMILY2).getMemStoreSize();
533534
MemStoreSize cf3MemstoreSizePhaseIV = region.getStore(FAMILY3).getMemStoreSize();
534-
long smallestSeqInRegionCurrentMemstorePhaseIV =
535-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
535+
long smallestSeqInRegionCurrentMemstorePhaseIV = AbstractTestFSWAL
536+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
536537
long smallestSeqCF3PhaseIV = region.getOldestSeqIdOfStore(FAMILY3);
537538

538539
/*------------------------------------------------------------------------------*/
@@ -563,8 +564,8 @@ public void testSelectiveFlushWithIndexCompaction() throws IOException {
563564
MemStoreSize cf1MemstoreSizePhaseV = region.getStore(FAMILY1).getMemStoreSize();
564565
MemStoreSize cf2MemstoreSizePhaseV = region.getStore(FAMILY2).getMemStoreSize();
565566
MemStoreSize cf3MemstoreSizePhaseV = region.getStore(FAMILY3).getMemStoreSize();
566-
long smallestSeqInRegionCurrentMemstorePhaseV =
567-
getWAL(region).getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
567+
long smallestSeqInRegionCurrentMemstorePhaseV = AbstractTestFSWAL
568+
.getEarliestMemStoreSeqNum(getWAL(region), region.getRegionInfo().getEncodedNameAsBytes());
568569
long totalMemstoreSizePhaseV = region.getMemStoreDataSize();
569570

570571
/*------------------------------------------------------------------------------*/
@@ -683,8 +684,8 @@ public void testSelectiveFlushAndWALinDataCompaction() throws IOException {
683684

684685
MemStoreSize cf2MemstoreSizePhaseII = region.getStore(FAMILY2).getMemStoreSize();
685686

686-
long smallestSeqInRegionCurrentMemstorePhaseII =
687-
region.getWAL().getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
687+
long smallestSeqInRegionCurrentMemstorePhaseII = AbstractTestFSWAL
688+
.getEarliestMemStoreSeqNum(region.getWAL(), region.getRegionInfo().getEncodedNameAsBytes());
688689
long smallestSeqCF1PhaseII = region.getOldestSeqIdOfStore(FAMILY1);
689690
long smallestSeqCF2PhaseII = region.getOldestSeqIdOfStore(FAMILY2);
690691
long smallestSeqCF3PhaseII = region.getOldestSeqIdOfStore(FAMILY3);
@@ -713,8 +714,8 @@ public void testSelectiveFlushAndWALinDataCompaction() throws IOException {
713714
region.put(createPut(2, i));
714715
}
715716

716-
long smallestSeqInRegionCurrentMemstorePhaseIII =
717-
region.getWAL().getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
717+
long smallestSeqInRegionCurrentMemstorePhaseIII = AbstractTestFSWAL
718+
.getEarliestMemStoreSeqNum(region.getWAL(), region.getRegionInfo().getEncodedNameAsBytes());
718719
long smallestSeqCF1PhaseIII = region.getOldestSeqIdOfStore(FAMILY1);
719720
long smallestSeqCF2PhaseIII = region.getOldestSeqIdOfStore(FAMILY2);
720721
long smallestSeqCF3PhaseIII = region.getOldestSeqIdOfStore(FAMILY3);
@@ -731,8 +732,8 @@ public void testSelectiveFlushAndWALinDataCompaction() throws IOException {
731732
cms3.flushInMemory();
732733
region.flush(false);
733734

734-
long smallestSeqInRegionCurrentMemstorePhaseIV =
735-
region.getWAL().getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
735+
long smallestSeqInRegionCurrentMemstorePhaseIV = AbstractTestFSWAL
736+
.getEarliestMemStoreSeqNum(region.getWAL(), region.getRegionInfo().getEncodedNameAsBytes());
736737
long smallestSeqCF1PhaseIV = region.getOldestSeqIdOfStore(FAMILY1);
737738
long smallestSeqCF2PhaseIV = region.getOldestSeqIdOfStore(FAMILY2);
738739
long smallestSeqCF3PhaseIV = region.getOldestSeqIdOfStore(FAMILY3);

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestFSWAL.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public void testUnflushedSeqIdTrackingWithAsyncWal() throws IOException, Interru
624624
}, startHoldingForAppend, closeFinished, holdAppend);
625625

626626
// now check the region's unflushed seqIds.
627-
long seqId = wal.getEarliestMemStoreSeqNum(region.getRegionInfo().getEncodedNameAsBytes());
627+
long seqId = getEarliestMemStoreSeqNum(wal, region.getRegionInfo().getEncodedNameAsBytes());
628628
assertEquals("Found seqId for the region which is already closed", HConstants.NO_SEQNUM,
629629
seqId);
630630
} finally {
@@ -634,6 +634,16 @@ public void testUnflushedSeqIdTrackingWithAsyncWal() throws IOException, Interru
634634
}
635635
}
636636

637+
public static long getEarliestMemStoreSeqNum(WAL wal, byte[] encodedRegionName) {
638+
if (wal != null) {
639+
if (wal instanceof AbstractFSWAL) {
640+
return ((AbstractFSWAL<?>) wal).getSequenceIdAccounting()
641+
.getLowestSequenceId(encodedRegionName);
642+
}
643+
}
644+
return HConstants.NO_SEQNUM;
645+
}
646+
637647
private static final Set<byte[]> STORES_TO_FLUSH =
638648
Collections.newSetFromMap(new ConcurrentSkipListMap<byte[], Boolean>(Bytes.BYTES_COMPARATOR));
639649

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestFSHLog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public void run() {
212212
assertEquals("Region did not flush?", 1, region.getStoreFileList(new byte[][] { b }).size());
213213

214214
// now check the region's unflushed seqIds.
215-
long seqId = log.getEarliestMemStoreSeqNum(hri.getEncodedNameAsBytes());
215+
long seqId = AbstractTestFSWAL.getEarliestMemStoreSeqNum(log, hri.getEncodedNameAsBytes());
216216
assertEquals("Found seqId for the region which is already flushed", HConstants.NO_SEQNUM,
217217
seqId);
218218

0 commit comments

Comments
 (0)