Arc lint fixes
This commit is contained in:
parent
e0ebea6cc2
commit
718029fc38
@ -38,10 +38,10 @@ public class BackupableDBOptions extends RocksObject {
|
||||
boolean destroyOldData, boolean backupLogFiles, long backupRateLimit,
|
||||
long restoreRateLimit) {
|
||||
super();
|
||||
|
||||
|
||||
backupRateLimit = (backupRateLimit <= 0) ? 0 : backupRateLimit;
|
||||
restoreRateLimit = (restoreRateLimit <= 0) ? 0 : restoreRateLimit;
|
||||
|
||||
|
||||
newBackupableDBOptions(path, shareTableFiles, sync, destroyOldData,
|
||||
backupLogFiles, backupRateLimit, restoreRateLimit);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* Helper class to collect DB statistics periodically at a period specified in
|
||||
* constructor. Callback function (provided in constructor) is called with
|
||||
* every statistics collection.
|
||||
*
|
||||
*
|
||||
* Caller should call start() to start statistics collection. Shutdown() should
|
||||
* be called to stop stats collection and should be called before statistics (
|
||||
* provided in constructor) reference has been disposed.
|
||||
@ -25,31 +25,31 @@ public class StatisticsCollector {
|
||||
private final int _statsCollectionInterval;
|
||||
private final StatisticsCollectorCallback _statsCallback;
|
||||
private volatile boolean _isRunning = true;
|
||||
|
||||
public StatisticsCollector(Statistics statistics,
|
||||
|
||||
public StatisticsCollector(Statistics statistics,
|
||||
int statsCollectionIntervalInMilliSeconds,
|
||||
StatisticsCollectorCallback statsCallback) {
|
||||
_statistics = statistics;
|
||||
_statsCollectionInterval = statsCollectionIntervalInMilliSeconds;
|
||||
_statsCallback = statsCallback;
|
||||
|
||||
|
||||
_threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
|
||||
new ArrayBlockingQueue<Runnable>(1));
|
||||
}
|
||||
|
||||
|
||||
public void start() {
|
||||
_threadPoolExecutor.submit(collectStatistics());
|
||||
}
|
||||
|
||||
|
||||
public void shutDown() throws InterruptedException {
|
||||
_isRunning = false;
|
||||
|
||||
|
||||
_threadPoolExecutor.shutdown();
|
||||
// Wait for collectStatistics runnable to finish so that disposal of
|
||||
// Wait for collectStatistics runnable to finish so that disposal of
|
||||
// statistics does not cause any exceptions to be thrown.
|
||||
_threadPoolExecutor.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
private Runnable collectStatistics() {
|
||||
return new Runnable() {
|
||||
|
||||
@ -65,11 +65,11 @@ public class StatisticsCollector {
|
||||
|
||||
// Collect histogram data
|
||||
for(HistogramType histogramType : HistogramType.values()) {
|
||||
HistogramData histogramData =
|
||||
HistogramData histogramData =
|
||||
_statistics.geHistogramData(histogramType);
|
||||
_statsCallback.histogramCallback(histogramType, histogramData);
|
||||
}
|
||||
|
||||
|
||||
Thread.sleep(_statsCollectionInterval);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
|
@ -17,7 +17,7 @@ public interface StatisticsCollectorCallback {
|
||||
* @param tickerCount Value of ticker type.
|
||||
*/
|
||||
void tickerCallback(TickerType tickerType, long tickerCount);
|
||||
|
||||
|
||||
/**
|
||||
* Callback function to get histogram values.
|
||||
* @param histType Histogram type.
|
||||
|
@ -12,28 +12,28 @@ public class StatisticsCollectorTest {
|
||||
static {
|
||||
RocksDB.loadLibrary();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, RocksDBException {
|
||||
Options opt = new Options().createStatistics().setCreateIfMissing(true);
|
||||
Statistics stats = opt.statisticsPtr();
|
||||
|
||||
|
||||
RocksDB db = RocksDB.open(db_path);
|
||||
|
||||
|
||||
StatsCallbackMock callback = new StatsCallbackMock();
|
||||
StatisticsCollector statsCollector = new StatisticsCollector(stats, 100,
|
||||
StatisticsCollector statsCollector = new StatisticsCollector(stats, 100,
|
||||
callback);
|
||||
statsCollector.start();
|
||||
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
|
||||
assert(callback.tickerCallbackCount > 0);
|
||||
assert(callback.histCallbackCount > 0);
|
||||
|
||||
|
||||
statsCollector.shutDown();
|
||||
|
||||
|
||||
db.close();
|
||||
opt.dispose();
|
||||
|
||||
|
||||
System.out.println("Stats collector test passed.!");
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ import org.rocksdb.*;
|
||||
public class StatsCallbackMock implements StatisticsCollectorCallback {
|
||||
public int tickerCallbackCount = 0;
|
||||
public int histCallbackCount = 0;
|
||||
|
||||
|
||||
public void tickerCallback(TickerType tickerType, long tickerCount) {
|
||||
tickerCallbackCount++;
|
||||
}
|
||||
|
||||
|
||||
public void histogramCallback(HistogramType histType,
|
||||
HistogramData histData) {
|
||||
histCallbackCount++;
|
||||
|
Loading…
Reference in New Issue
Block a user