|
|
|
@ -1,3 +1,7 @@ |
|
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
|
package org.rocksdb; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
@ -5,15 +9,13 @@ import static org.junit.Assert.*; |
|
|
|
|
|
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
import java.nio.file.Paths; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Random; |
|
|
|
|
import java.util.UUID; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
import org.junit.ClassRule; |
|
|
|
|
import org.junit.Rule; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
import org.junit.rules.TemporaryFolder; |
|
|
|
|
import org.rocksdb.AbstractEventListener.EnabledEventCallback; |
|
|
|
|
import org.rocksdb.test.TestableEventListener; |
|
|
|
|
|
|
|
|
|
public class EventListenerTest { |
|
|
|
@ -41,10 +43,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onFlushCompleted() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onFlushCompletedListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onFlushCompletedListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onFlushCompleted(final RocksDB rocksDb, final FlushJobInfo flushJobInfo) { |
|
|
|
|
assertNotNull(flushJobInfo.getColumnFamilyName()); |
|
|
|
@ -57,10 +57,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onFlushBegin() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onFlushBeginListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onFlushBeginListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onFlushBegin(final RocksDB rocksDb, final FlushJobInfo flushJobInfo) { |
|
|
|
|
assertNotNull(flushJobInfo.getColumnFamilyName()); |
|
|
|
@ -72,7 +70,7 @@ public class EventListenerTest { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void deleteTableFile(final AbstractEventListener el, final AtomicBoolean wasCbCalled) |
|
|
|
|
throws RocksDBException, InterruptedException { |
|
|
|
|
throws RocksDBException { |
|
|
|
|
try (final Options opt = |
|
|
|
|
new Options().setCreateIfMissing(true).setListeners(Collections.singletonList(el)); |
|
|
|
|
final RocksDB db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath())) { |
|
|
|
@ -80,7 +78,7 @@ public class EventListenerTest { |
|
|
|
|
final byte[] value = new byte[24]; |
|
|
|
|
rand.nextBytes(value); |
|
|
|
|
db.put("testKey".getBytes(), value); |
|
|
|
|
RocksDB.LiveFiles liveFiles = db.getLiveFiles(); |
|
|
|
|
final RocksDB.LiveFiles liveFiles = db.getLiveFiles(); |
|
|
|
|
assertNotNull(liveFiles); |
|
|
|
|
assertNotNull(liveFiles.files); |
|
|
|
|
assertFalse(liveFiles.files.isEmpty()); |
|
|
|
@ -91,10 +89,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onTableFileDeleted() throws RocksDBException, InterruptedException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onTableFileDeletedListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onTableFileDeletedListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onTableFileDeleted(final TableFileDeletionInfo tableFileDeletionInfo) { |
|
|
|
|
assertNotNull(tableFileDeletionInfo.getDbName()); |
|
|
|
@ -120,10 +116,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onCompactionBegin() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onCompactionBeginListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onCompactionBeginListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onCompactionBegin(final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
|
assertEquals(CompactionReason.kManualCompaction, compactionJobInfo.compactionReason()); |
|
|
|
@ -135,10 +129,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onCompactionCompleted() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onCompactionCompletedListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onCompactionCompletedListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onCompactionCompleted( |
|
|
|
|
final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
@ -151,10 +143,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onTableFileCreated() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onTableFileCreatedListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onTableFileCreatedListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreated(final TableFileCreationInfo tableFileCreationInfo) { |
|
|
|
|
assertEquals(TableFileCreationReason.FLUSH, tableFileCreationInfo.getReason()); |
|
|
|
@ -166,10 +156,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onTableFileCreationStarted() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onTableFileCreationStartedListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onTableFileCreationStartedListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreationStarted( |
|
|
|
|
final TableFileCreationBriefInfo tableFileCreationBriefInfo) { |
|
|
|
@ -197,10 +185,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onColumnFamilyHandleDeletionStarted() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onColumnFamilyHandleDeletionStartedListener = |
|
|
|
|
final AbstractEventListener onColumnFamilyHandleDeletionStartedListener = |
|
|
|
|
new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onColumnFamilyHandleDeletionStarted( |
|
|
|
@ -218,9 +204,9 @@ public class EventListenerTest { |
|
|
|
|
new Options().setCreateIfMissing(true).setListeners(Collections.singletonList(el)); |
|
|
|
|
final RocksDB db = RocksDB.open(opt, dbFolder.getRoot().getAbsolutePath())) { |
|
|
|
|
assertThat(db).isNotNull(); |
|
|
|
|
String uuid = UUID.randomUUID().toString(); |
|
|
|
|
SstFileWriter sstFileWriter = new SstFileWriter(new EnvOptions(), opt); |
|
|
|
|
Path externalFilePath = Paths.get(db.getName(), uuid); |
|
|
|
|
final String uuid = UUID.randomUUID().toString(); |
|
|
|
|
final SstFileWriter sstFileWriter = new SstFileWriter(new EnvOptions(), opt); |
|
|
|
|
final Path externalFilePath = Paths.get(db.getName(), uuid); |
|
|
|
|
sstFileWriter.open(externalFilePath.toString()); |
|
|
|
|
sstFileWriter.put("testKey".getBytes(), uuid.getBytes()); |
|
|
|
|
sstFileWriter.finish(); |
|
|
|
@ -232,10 +218,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void onExternalFileIngested() throws RocksDBException { |
|
|
|
|
// Callback is synchronous, but we need mutable container to update boolean value in other
|
|
|
|
|
// method
|
|
|
|
|
final AtomicBoolean wasCbCalled = new AtomicBoolean(); |
|
|
|
|
AbstractEventListener onExternalFileIngestedListener = new AbstractEventListener() { |
|
|
|
|
final AbstractEventListener onExternalFileIngestedListener = new AbstractEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onExternalFileIngested( |
|
|
|
|
final RocksDB db, final ExternalFileIngestionInfo externalFileIngestionInfo) { |
|
|
|
@ -248,8 +232,8 @@ public class EventListenerTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testAllCallbacksInvocation() { |
|
|
|
|
final int TEST_INT_VAL = Integer.MAX_VALUE; |
|
|
|
|
final long TEST_LONG_VAL = Long.MAX_VALUE; |
|
|
|
|
final int TEST_INT_VAL = -1; |
|
|
|
|
final long TEST_LONG_VAL = -1; |
|
|
|
|
// Expected test data objects
|
|
|
|
|
final Map<String, String> userCollectedPropertiesTestData = |
|
|
|
|
Collections.singletonMap("key", "value"); |
|
|
|
@ -263,18 +247,18 @@ public class EventListenerTest { |
|
|
|
|
"columnFamilyName".getBytes(), "filterPolicyName", "comparatorName", "mergeOperatorName", |
|
|
|
|
"prefixExtractorName", "propertyCollectorsNames", "compressionName", |
|
|
|
|
userCollectedPropertiesTestData, readablePropertiesTestData, propertiesOffsetsTestData); |
|
|
|
|
final FlushJobInfo flushJobInfoTestData = new FlushJobInfo(TEST_INT_VAL, "testColumnFamily", |
|
|
|
|
"/file/path", TEST_LONG_VAL, TEST_INT_VAL, true, true, TEST_LONG_VAL, TEST_LONG_VAL, |
|
|
|
|
tablePropertiesTestData, (byte) 0x0a); |
|
|
|
|
final FlushJobInfo flushJobInfoTestData = new FlushJobInfo(Integer.MAX_VALUE, |
|
|
|
|
"testColumnFamily", "/file/path", TEST_LONG_VAL, Integer.MAX_VALUE, true, true, |
|
|
|
|
TEST_LONG_VAL, TEST_LONG_VAL, tablePropertiesTestData, (byte) 0x0a); |
|
|
|
|
final Status statusTestData = new Status(Status.Code.Incomplete, Status.SubCode.NoSpace, null); |
|
|
|
|
final TableFileDeletionInfo tableFileDeletionInfoTestData = |
|
|
|
|
new TableFileDeletionInfo("dbName", "/file/path", TEST_INT_VAL, statusTestData); |
|
|
|
|
new TableFileDeletionInfo("dbName", "/file/path", Integer.MAX_VALUE, statusTestData); |
|
|
|
|
final TableFileCreationInfo tableFileCreationInfoTestData = |
|
|
|
|
new TableFileCreationInfo(TEST_LONG_VAL, tablePropertiesTestData, statusTestData, "dbName", |
|
|
|
|
"columnFamilyName", "/file/path", TEST_INT_VAL, (byte) 0x03); |
|
|
|
|
"columnFamilyName", "/file/path", Integer.MAX_VALUE, (byte) 0x03); |
|
|
|
|
final TableFileCreationBriefInfo tableFileCreationBriefInfoTestData = |
|
|
|
|
new TableFileCreationBriefInfo( |
|
|
|
|
"dbName", "columnFamilyName", "/file/path", TEST_INT_VAL, (byte) 0x03); |
|
|
|
|
"dbName", "columnFamilyName", "/file/path", Integer.MAX_VALUE, (byte) 0x03); |
|
|
|
|
final MemTableInfo memTableInfoTestData = new MemTableInfo( |
|
|
|
|
"columnFamilyName", TEST_LONG_VAL, TEST_LONG_VAL, TEST_LONG_VAL, TEST_LONG_VAL); |
|
|
|
|
final FileOperationInfo fileOperationInfoTestData = new FileOperationInfo("/file/path", |
|
|
|
@ -285,305 +269,496 @@ public class EventListenerTest { |
|
|
|
|
new ExternalFileIngestionInfo("columnFamilyName", "/external/file/path", |
|
|
|
|
"/internal/file/path", TEST_LONG_VAL, tablePropertiesTestData); |
|
|
|
|
|
|
|
|
|
final int CALLBACKS_COUNT = 22; |
|
|
|
|
final AtomicBoolean[] wasCalled = new AtomicBoolean[CALLBACKS_COUNT]; |
|
|
|
|
for (int i = 0; i < CALLBACKS_COUNT; ++i) { |
|
|
|
|
wasCalled[i] = new AtomicBoolean(); |
|
|
|
|
} |
|
|
|
|
TestableEventListener listener = new TestableEventListener() { |
|
|
|
|
final CapturingTestableEventListener listener = new CapturingTestableEventListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onFlushCompleted(final RocksDB db, final FlushJobInfo flushJobInfo) { |
|
|
|
|
super.onFlushCompleted(db, flushJobInfo); |
|
|
|
|
assertEquals(flushJobInfoTestData, flushJobInfo); |
|
|
|
|
wasCalled[0].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFlushBegin(final RocksDB db, final FlushJobInfo flushJobInfo) { |
|
|
|
|
super.onFlushBegin(db, flushJobInfo); |
|
|
|
|
assertEquals(flushJobInfoTestData, flushJobInfo); |
|
|
|
|
wasCalled[1].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileDeleted(final TableFileDeletionInfo tableFileDeletionInfo) { |
|
|
|
|
super.onTableFileDeleted(tableFileDeletionInfo); |
|
|
|
|
assertEquals(tableFileDeletionInfoTestData, tableFileDeletionInfo); |
|
|
|
|
wasCalled[2].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCompactionBegin(final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
|
super.onCompactionBegin(db, compactionJobInfo); |
|
|
|
|
assertArrayEquals( |
|
|
|
|
"compactionColumnFamily".getBytes(), compactionJobInfo.columnFamilyName()); |
|
|
|
|
assertEquals(statusTestData, compactionJobInfo.status()); |
|
|
|
|
assertEquals(TEST_LONG_VAL, compactionJobInfo.threadId()); |
|
|
|
|
assertEquals(TEST_INT_VAL, compactionJobInfo.jobId()); |
|
|
|
|
assertEquals(TEST_INT_VAL, compactionJobInfo.baseInputLevel()); |
|
|
|
|
assertEquals(TEST_INT_VAL, compactionJobInfo.outputLevel()); |
|
|
|
|
assertEquals(Integer.MAX_VALUE, compactionJobInfo.jobId()); |
|
|
|
|
assertEquals(Integer.MAX_VALUE, compactionJobInfo.baseInputLevel()); |
|
|
|
|
assertEquals(Integer.MAX_VALUE, compactionJobInfo.outputLevel()); |
|
|
|
|
assertEquals(Collections.singletonList("inputFile.sst"), compactionJobInfo.inputFiles()); |
|
|
|
|
assertEquals(Collections.singletonList("outputFile.sst"), compactionJobInfo.outputFiles()); |
|
|
|
|
assertEquals(Collections.singletonMap("tableProperties", tablePropertiesTestData), |
|
|
|
|
compactionJobInfo.tableProperties()); |
|
|
|
|
assertEquals(CompactionReason.kFlush, compactionJobInfo.compactionReason()); |
|
|
|
|
assertEquals(CompressionType.SNAPPY_COMPRESSION, compactionJobInfo.compression()); |
|
|
|
|
wasCalled[3].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCompactionCompleted( |
|
|
|
|
final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
|
super.onCompactionCompleted(db, compactionJobInfo); |
|
|
|
|
assertArrayEquals( |
|
|
|
|
"compactionColumnFamily".getBytes(), compactionJobInfo.columnFamilyName()); |
|
|
|
|
assertEquals(statusTestData, compactionJobInfo.status()); |
|
|
|
|
assertEquals(TEST_LONG_VAL, compactionJobInfo.threadId()); |
|
|
|
|
assertEquals(TEST_INT_VAL, compactionJobInfo.jobId()); |
|
|
|
|
assertEquals(TEST_INT_VAL, compactionJobInfo.baseInputLevel()); |
|
|
|
|
assertEquals(TEST_INT_VAL, compactionJobInfo.outputLevel()); |
|
|
|
|
assertEquals(Integer.MAX_VALUE, compactionJobInfo.jobId()); |
|
|
|
|
assertEquals(Integer.MAX_VALUE, compactionJobInfo.baseInputLevel()); |
|
|
|
|
assertEquals(Integer.MAX_VALUE, compactionJobInfo.outputLevel()); |
|
|
|
|
assertEquals(Collections.singletonList("inputFile.sst"), compactionJobInfo.inputFiles()); |
|
|
|
|
assertEquals(Collections.singletonList("outputFile.sst"), compactionJobInfo.outputFiles()); |
|
|
|
|
assertEquals(Collections.singletonMap("tableProperties", tablePropertiesTestData), |
|
|
|
|
compactionJobInfo.tableProperties()); |
|
|
|
|
assertEquals(CompactionReason.kFlush, compactionJobInfo.compactionReason()); |
|
|
|
|
assertEquals(CompressionType.SNAPPY_COMPRESSION, compactionJobInfo.compression()); |
|
|
|
|
wasCalled[4].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreated(final TableFileCreationInfo tableFileCreationInfo) { |
|
|
|
|
super.onTableFileCreated(tableFileCreationInfo); |
|
|
|
|
assertEquals(tableFileCreationInfoTestData, tableFileCreationInfo); |
|
|
|
|
wasCalled[5].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreationStarted( |
|
|
|
|
final TableFileCreationBriefInfo tableFileCreationBriefInfo) { |
|
|
|
|
super.onTableFileCreationStarted(tableFileCreationBriefInfo); |
|
|
|
|
assertEquals(tableFileCreationBriefInfoTestData, tableFileCreationBriefInfo); |
|
|
|
|
wasCalled[6].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onMemTableSealed(final MemTableInfo memTableInfo) { |
|
|
|
|
super.onMemTableSealed(memTableInfo); |
|
|
|
|
assertEquals(memTableInfoTestData, memTableInfo); |
|
|
|
|
wasCalled[7].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onColumnFamilyHandleDeletionStarted(final ColumnFamilyHandle columnFamilyHandle) { |
|
|
|
|
wasCalled[8].set(true); |
|
|
|
|
super.onColumnFamilyHandleDeletionStarted(columnFamilyHandle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onExternalFileIngested( |
|
|
|
|
final RocksDB db, final ExternalFileIngestionInfo externalFileIngestionInfo) { |
|
|
|
|
super.onExternalFileIngested(db, externalFileIngestionInfo); |
|
|
|
|
assertEquals(externalFileIngestionInfoTestData, externalFileIngestionInfo); |
|
|
|
|
wasCalled[9].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onBackgroundError( |
|
|
|
|
final BackgroundErrorReason backgroundErrorReason, final Status backgroundError) { |
|
|
|
|
wasCalled[10].set(true); |
|
|
|
|
super.onBackgroundError(backgroundErrorReason, backgroundError); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onStallConditionsChanged(final WriteStallInfo writeStallInfo) { |
|
|
|
|
super.onStallConditionsChanged(writeStallInfo); |
|
|
|
|
assertEquals(writeStallInfoTestData, writeStallInfo); |
|
|
|
|
wasCalled[11].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileReadFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
super.onFileReadFinish(fileOperationInfo); |
|
|
|
|
assertEquals(fileOperationInfoTestData, fileOperationInfo); |
|
|
|
|
wasCalled[12].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileWriteFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
super.onFileWriteFinish(fileOperationInfo); |
|
|
|
|
assertEquals(fileOperationInfoTestData, fileOperationInfo); |
|
|
|
|
wasCalled[13].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileFlushFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
public void onFileFlushFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
super.onFileFlushFinish(fileOperationInfo); |
|
|
|
|
assertEquals(fileOperationInfoTestData, fileOperationInfo); |
|
|
|
|
wasCalled[14].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
public void onFileSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
super.onFileSyncFinish(fileOperationInfo); |
|
|
|
|
assertEquals(fileOperationInfoTestData, fileOperationInfo); |
|
|
|
|
wasCalled[15].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileRangeSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
public void onFileRangeSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
super.onFileRangeSyncFinish(fileOperationInfo); |
|
|
|
|
assertEquals(fileOperationInfoTestData, fileOperationInfo); |
|
|
|
|
wasCalled[16].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileTruncateFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
public void onFileTruncateFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
assertEquals(fileOperationInfoTestData, fileOperationInfo); |
|
|
|
|
wasCalled[17].set(true); |
|
|
|
|
super.onFileTruncateFinish(fileOperationInfo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileCloseFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
public void onFileCloseFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
super.onFileCloseFinish(fileOperationInfo); |
|
|
|
|
assertEquals(fileOperationInfoTestData, fileOperationInfo); |
|
|
|
|
wasCalled[18].set(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean shouldBeNotifiedOnFileIO() { |
|
|
|
|
wasCalled[19].set(true); |
|
|
|
|
super.shouldBeNotifiedOnFileIO(); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean onErrorRecoveryBegin( |
|
|
|
|
final BackgroundErrorReason backgroundErrorReason, final Status backgroundError) { |
|
|
|
|
super.onErrorRecoveryBegin(backgroundErrorReason, backgroundError); |
|
|
|
|
assertEquals(BackgroundErrorReason.FLUSH, backgroundErrorReason); |
|
|
|
|
assertEquals(statusTestData, backgroundError); |
|
|
|
|
wasCalled[20].set(true); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onErrorRecoveryCompleted(final Status oldBackgroundError) { |
|
|
|
|
super.onErrorRecoveryCompleted(oldBackgroundError); |
|
|
|
|
assertEquals(statusTestData, oldBackgroundError); |
|
|
|
|
wasCalled[21].set(true); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// test action
|
|
|
|
|
listener.invokeAllCallbacks(); |
|
|
|
|
for (int i = 0; i < CALLBACKS_COUNT; ++i) { |
|
|
|
|
assertTrue("Callback method " + i + " was not called", wasCalled[i].get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// assert
|
|
|
|
|
assertAllEventsCalled(listener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testEnabledCallbacks() { |
|
|
|
|
final AtomicBoolean wasOnMemTableSealedCalled = new AtomicBoolean(); |
|
|
|
|
final AtomicBoolean wasOnErrorRecoveryCompletedCalled = new AtomicBoolean(); |
|
|
|
|
final TestableEventListener listener = new TestableEventListener( |
|
|
|
|
AbstractEventListener.EnabledEventCallback.ON_MEMTABLE_SEALED, |
|
|
|
|
AbstractEventListener.EnabledEventCallback.ON_ERROR_RECOVERY_COMPLETED) { |
|
|
|
|
@Override |
|
|
|
|
public void onFlushCompleted(final RocksDB db, final FlushJobInfo flushJobInfo) { |
|
|
|
|
fail("onFlushCompleted was not enabled"); |
|
|
|
|
} |
|
|
|
|
final EnabledEventCallback enabledEvents[] = { |
|
|
|
|
EnabledEventCallback.ON_MEMTABLE_SEALED, EnabledEventCallback.ON_ERROR_RECOVERY_COMPLETED}; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFlushBegin(final RocksDB db, final FlushJobInfo flushJobInfo) { |
|
|
|
|
fail("onFlushBegin was not enabled"); |
|
|
|
|
} |
|
|
|
|
final CapturingTestableEventListener listener = |
|
|
|
|
new CapturingTestableEventListener(enabledEvents); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileDeleted(final TableFileDeletionInfo tableFileDeletionInfo) { |
|
|
|
|
fail("onTableFileDeleted was not enabled"); |
|
|
|
|
} |
|
|
|
|
// test action
|
|
|
|
|
listener.invokeAllCallbacks(); |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCompactionBegin(final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
|
fail("onCompactionBegin was not enabled"); |
|
|
|
|
} |
|
|
|
|
// assert
|
|
|
|
|
assertEventsCalled(listener, enabledEvents); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCompactionCompleted( |
|
|
|
|
final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
|
fail("onCompactionCompleted was not enabled"); |
|
|
|
|
} |
|
|
|
|
private static void assertAllEventsCalled( |
|
|
|
|
final CapturingTestableEventListener capturingTestableEventListener) { |
|
|
|
|
assertEventsCalled(capturingTestableEventListener, EnumSet.allOf(EnabledEventCallback.class)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreated(final TableFileCreationInfo tableFileCreationInfo) { |
|
|
|
|
fail("onTableFileCreated was not enabled"); |
|
|
|
|
} |
|
|
|
|
private static void assertEventsCalled( |
|
|
|
|
final CapturingTestableEventListener capturingTestableEventListener, |
|
|
|
|
final EnabledEventCallback[] expected) { |
|
|
|
|
assertEventsCalled(capturingTestableEventListener, EnumSet.copyOf(Arrays.asList(expected))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreationStarted( |
|
|
|
|
final TableFileCreationBriefInfo tableFileCreationBriefInfo) { |
|
|
|
|
fail("onTableFileCreationStarted was not enabled"); |
|
|
|
|
} |
|
|
|
|
private static void assertEventsCalled( |
|
|
|
|
final CapturingTestableEventListener capturingTestableEventListener, |
|
|
|
|
final EnumSet<EnabledEventCallback> expected) { |
|
|
|
|
final ListenerEvents capturedEvents = capturingTestableEventListener.capturedListenerEvents; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onMemTableSealed(final MemTableInfo memTableInfo) { |
|
|
|
|
wasOnMemTableSealedCalled.set(true); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FLUSH_COMPLETED)) { |
|
|
|
|
assertTrue("onFlushCompleted was not called", capturedEvents.flushCompleted); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFlushCompleted was not called", capturedEvents.flushCompleted); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onColumnFamilyHandleDeletionStarted(final ColumnFamilyHandle columnFamilyHandle) { |
|
|
|
|
fail("onColumnFamilyHandleDeletionStarted was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FLUSH_BEGIN)) { |
|
|
|
|
assertTrue("onFlushBegin was not called", capturedEvents.flushBegin); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFlushBegin was called", capturedEvents.flushBegin); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onExternalFileIngested( |
|
|
|
|
final RocksDB db, final ExternalFileIngestionInfo externalFileIngestionInfo) { |
|
|
|
|
fail("onExternalFileIngested was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_TABLE_FILE_DELETED)) { |
|
|
|
|
assertTrue("onTableFileDeleted was not called", capturedEvents.tableFileDeleted); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onTableFileDeleted was called", capturedEvents.tableFileDeleted); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onBackgroundError( |
|
|
|
|
final BackgroundErrorReason backgroundErrorReason, final Status backgroundError) { |
|
|
|
|
fail("onBackgroundError was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_COMPACTION_BEGIN)) { |
|
|
|
|
assertTrue("onCompactionBegin was not called", capturedEvents.compactionBegin); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onCompactionBegin was called", capturedEvents.compactionBegin); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onStallConditionsChanged(final WriteStallInfo writeStallInfo) { |
|
|
|
|
fail("onStallConditionsChanged was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_COMPACTION_COMPLETED)) { |
|
|
|
|
assertTrue("onCompactionCompleted was not called", capturedEvents.compactionCompleted); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onCompactionCompleted was called", capturedEvents.compactionCompleted); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileReadFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
fail("onFileReadFinish was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_TABLE_FILE_CREATED)) { |
|
|
|
|
assertTrue("onTableFileCreated was not called", capturedEvents.tableFileCreated); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onTableFileCreated was called", capturedEvents.tableFileCreated); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileWriteFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
fail("onFileWriteFinish was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_TABLE_FILE_CREATION_STARTED)) { |
|
|
|
|
assertTrue( |
|
|
|
|
"onTableFileCreationStarted was not called", capturedEvents.tableFileCreationStarted); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onTableFileCreationStarted was called", capturedEvents.tableFileCreationStarted); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileFlushFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
fail("OnFileFlushFinish was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_MEMTABLE_SEALED)) { |
|
|
|
|
assertTrue("onMemTableSealed was not called", capturedEvents.memTableSealed); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onMemTableSealed was called", capturedEvents.memTableSealed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
fail("OnFileSyncFinish was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_COLUMN_FAMILY_HANDLE_DELETION_STARTED)) { |
|
|
|
|
assertTrue("onColumnFamilyHandleDeletionStarted was not called", |
|
|
|
|
capturedEvents.columnFamilyHandleDeletionStarted); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onColumnFamilyHandleDeletionStarted was called", |
|
|
|
|
capturedEvents.columnFamilyHandleDeletionStarted); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileRangeSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
fail("OnFileRangeSyncFinish was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_EXTERNAL_FILE_INGESTED)) { |
|
|
|
|
assertTrue("onExternalFileIngested was not called", capturedEvents.externalFileIngested); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onExternalFileIngested was called", capturedEvents.externalFileIngested); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileTruncateFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
fail("OnFileTruncateFinish was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_BACKGROUND_ERROR)) { |
|
|
|
|
assertTrue("onBackgroundError was not called", capturedEvents.backgroundError); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onBackgroundError was called", capturedEvents.backgroundError); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void OnFileCloseFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
fail("OnFileCloseFinish was not enabled"); |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_STALL_CONDITIONS_CHANGED)) { |
|
|
|
|
assertTrue("onStallConditionsChanged was not called", capturedEvents.stallConditionsChanged); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onStallConditionsChanged was called", capturedEvents.stallConditionsChanged); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean shouldBeNotifiedOnFileIO() { |
|
|
|
|
fail("shouldBeNotifiedOnFileIO was not enabled"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FILE_READ_FINISH)) { |
|
|
|
|
assertTrue("onFileReadFinish was not called", capturedEvents.fileReadFinish); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFileReadFinish was called", capturedEvents.fileReadFinish); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean onErrorRecoveryBegin( |
|
|
|
|
final BackgroundErrorReason backgroundErrorReason, final Status backgroundError) { |
|
|
|
|
fail("onErrorRecoveryBegin was not enabled"); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FILE_WRITE_FINISH)) { |
|
|
|
|
assertTrue("onFileWriteFinish was not called", capturedEvents.fileWriteFinish); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFileWriteFinish was called", capturedEvents.fileWriteFinish); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onErrorRecoveryCompleted(final Status oldBackgroundError) { |
|
|
|
|
wasOnErrorRecoveryCompletedCalled.set(true); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
listener.invokeAllCallbacks(); |
|
|
|
|
assertTrue(wasOnMemTableSealedCalled.get()); |
|
|
|
|
assertTrue(wasOnErrorRecoveryCompletedCalled.get()); |
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FILE_FLUSH_FINISH)) { |
|
|
|
|
assertTrue("onFileFlushFinish was not called", capturedEvents.fileFlushFinish); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFileFlushFinish was called", capturedEvents.fileFlushFinish); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FILE_SYNC_FINISH)) { |
|
|
|
|
assertTrue("onFileSyncFinish was not called", capturedEvents.fileSyncFinish); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFileSyncFinish was called", capturedEvents.fileSyncFinish); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FILE_RANGE_SYNC_FINISH)) { |
|
|
|
|
assertTrue("onFileRangeSyncFinish was not called", capturedEvents.fileRangeSyncFinish); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFileRangeSyncFinish was called", capturedEvents.fileRangeSyncFinish); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FILE_TRUNCATE_FINISH)) { |
|
|
|
|
assertTrue("onFileTruncateFinish was not called", capturedEvents.fileTruncateFinish); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFileTruncateFinish was called", capturedEvents.fileTruncateFinish); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_FILE_CLOSE_FINISH)) { |
|
|
|
|
assertTrue("onFileCloseFinish was not called", capturedEvents.fileCloseFinish); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onFileCloseFinish was called", capturedEvents.fileCloseFinish); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expected.contains(EnabledEventCallback.SHOULD_BE_NOTIFIED_ON_FILE_IO)) { |
|
|
|
|
assertTrue( |
|
|
|
|
"shouldBeNotifiedOnFileIO was not called", capturedEvents.shouldBeNotifiedOnFileIO); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("shouldBeNotifiedOnFileIO was called", capturedEvents.shouldBeNotifiedOnFileIO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_ERROR_RECOVERY_BEGIN)) { |
|
|
|
|
assertTrue("onErrorRecoveryBegin was not called", capturedEvents.errorRecoveryBegin); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onErrorRecoveryBegin was called", capturedEvents.errorRecoveryBegin); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (expected.contains(EnabledEventCallback.ON_ERROR_RECOVERY_COMPLETED)) { |
|
|
|
|
assertTrue("onErrorRecoveryCompleted was not called", capturedEvents.errorRecoveryCompleted); |
|
|
|
|
} else { |
|
|
|
|
assertFalse("onErrorRecoveryCompleted was called", capturedEvents.errorRecoveryCompleted); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Members are volatile as they may be written |
|
|
|
|
* and read by different threads. |
|
|
|
|
*/ |
|
|
|
|
private static class ListenerEvents { |
|
|
|
|
volatile boolean flushCompleted; |
|
|
|
|
volatile boolean flushBegin; |
|
|
|
|
volatile boolean tableFileDeleted; |
|
|
|
|
volatile boolean compactionBegin; |
|
|
|
|
volatile boolean compactionCompleted; |
|
|
|
|
volatile boolean tableFileCreated; |
|
|
|
|
volatile boolean tableFileCreationStarted; |
|
|
|
|
volatile boolean memTableSealed; |
|
|
|
|
volatile boolean columnFamilyHandleDeletionStarted; |
|
|
|
|
volatile boolean externalFileIngested; |
|
|
|
|
volatile boolean backgroundError; |
|
|
|
|
volatile boolean stallConditionsChanged; |
|
|
|
|
volatile boolean fileReadFinish; |
|
|
|
|
volatile boolean fileWriteFinish; |
|
|
|
|
volatile boolean fileFlushFinish; |
|
|
|
|
volatile boolean fileSyncFinish; |
|
|
|
|
volatile boolean fileRangeSyncFinish; |
|
|
|
|
volatile boolean fileTruncateFinish; |
|
|
|
|
volatile boolean fileCloseFinish; |
|
|
|
|
volatile boolean shouldBeNotifiedOnFileIO; |
|
|
|
|
volatile boolean errorRecoveryBegin; |
|
|
|
|
volatile boolean errorRecoveryCompleted; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static class CapturingTestableEventListener extends TestableEventListener { |
|
|
|
|
final ListenerEvents capturedListenerEvents = new ListenerEvents(); |
|
|
|
|
|
|
|
|
|
public CapturingTestableEventListener() {} |
|
|
|
|
|
|
|
|
|
public CapturingTestableEventListener(final EnabledEventCallback... enabledEventCallbacks) { |
|
|
|
|
super(enabledEventCallbacks); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFlushCompleted(final RocksDB db, final FlushJobInfo flushJobInfo) { |
|
|
|
|
capturedListenerEvents.flushCompleted = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFlushBegin(final RocksDB db, final FlushJobInfo flushJobInfo) { |
|
|
|
|
capturedListenerEvents.flushBegin = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileDeleted(final TableFileDeletionInfo tableFileDeletionInfo) { |
|
|
|
|
capturedListenerEvents.tableFileDeleted = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCompactionBegin(final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
|
capturedListenerEvents.compactionBegin = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCompactionCompleted(final RocksDB db, final CompactionJobInfo compactionJobInfo) { |
|
|
|
|
capturedListenerEvents.compactionCompleted = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreated(final TableFileCreationInfo tableFileCreationInfo) { |
|
|
|
|
capturedListenerEvents.tableFileCreated = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onTableFileCreationStarted( |
|
|
|
|
final TableFileCreationBriefInfo tableFileCreationBriefInfo) { |
|
|
|
|
capturedListenerEvents.tableFileCreationStarted = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onMemTableSealed(final MemTableInfo memTableInfo) { |
|
|
|
|
capturedListenerEvents.memTableSealed = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onColumnFamilyHandleDeletionStarted(final ColumnFamilyHandle columnFamilyHandle) { |
|
|
|
|
capturedListenerEvents.columnFamilyHandleDeletionStarted = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onExternalFileIngested( |
|
|
|
|
final RocksDB db, final ExternalFileIngestionInfo externalFileIngestionInfo) { |
|
|
|
|
capturedListenerEvents.externalFileIngested = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onBackgroundError( |
|
|
|
|
final BackgroundErrorReason backgroundErrorReason, final Status backgroundError) { |
|
|
|
|
capturedListenerEvents.backgroundError = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onStallConditionsChanged(final WriteStallInfo writeStallInfo) { |
|
|
|
|
capturedListenerEvents.stallConditionsChanged = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileReadFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
capturedListenerEvents.fileReadFinish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileWriteFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
capturedListenerEvents.fileWriteFinish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileFlushFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
capturedListenerEvents.fileFlushFinish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
capturedListenerEvents.fileSyncFinish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileRangeSyncFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
capturedListenerEvents.fileRangeSyncFinish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileTruncateFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
capturedListenerEvents.fileTruncateFinish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onFileCloseFinish(final FileOperationInfo fileOperationInfo) { |
|
|
|
|
capturedListenerEvents.fileCloseFinish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean shouldBeNotifiedOnFileIO() { |
|
|
|
|
capturedListenerEvents.shouldBeNotifiedOnFileIO = true; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean onErrorRecoveryBegin( |
|
|
|
|
final BackgroundErrorReason backgroundErrorReason, final Status backgroundError) { |
|
|
|
|
capturedListenerEvents.errorRecoveryBegin = true; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onErrorRecoveryCompleted(final Status oldBackgroundError) { |
|
|
|
|
capturedListenerEvents.errorRecoveryCompleted = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|