Arc lint fixes

main
Ankit Gupta 10 years ago
parent e0ebea6cc2
commit 718029fc38
  1. 4
      java/org/rocksdb/BackupableDBOptions.java
  2. 22
      java/org/rocksdb/StatisticsCollector.java
  3. 2
      java/org/rocksdb/StatisticsCollectorCallback.java
  4. 18
      java/org/rocksdb/test/StatisticsCollectorTest.java
  5. 4
      java/org/rocksdb/test/StatsCallbackMock.java

@ -38,10 +38,10 @@ public class BackupableDBOptions extends RocksObject {
boolean destroyOldData, boolean backupLogFiles, long backupRateLimit, boolean destroyOldData, boolean backupLogFiles, long backupRateLimit,
long restoreRateLimit) { long restoreRateLimit) {
super(); super();
backupRateLimit = (backupRateLimit <= 0) ? 0 : backupRateLimit; backupRateLimit = (backupRateLimit <= 0) ? 0 : backupRateLimit;
restoreRateLimit = (restoreRateLimit <= 0) ? 0 : restoreRateLimit; restoreRateLimit = (restoreRateLimit <= 0) ? 0 : restoreRateLimit;
newBackupableDBOptions(path, shareTableFiles, sync, destroyOldData, newBackupableDBOptions(path, shareTableFiles, sync, destroyOldData,
backupLogFiles, backupRateLimit, restoreRateLimit); 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 * Helper class to collect DB statistics periodically at a period specified in
* constructor. Callback function (provided in constructor) is called with * constructor. Callback function (provided in constructor) is called with
* every statistics collection. * every statistics collection.
* *
* Caller should call start() to start statistics collection. Shutdown() should * Caller should call start() to start statistics collection. Shutdown() should
* be called to stop stats collection and should be called before statistics ( * be called to stop stats collection and should be called before statistics (
* provided in constructor) reference has been disposed. * provided in constructor) reference has been disposed.
@ -25,31 +25,31 @@ public class StatisticsCollector {
private final int _statsCollectionInterval; private final int _statsCollectionInterval;
private final StatisticsCollectorCallback _statsCallback; private final StatisticsCollectorCallback _statsCallback;
private volatile boolean _isRunning = true; private volatile boolean _isRunning = true;
public StatisticsCollector(Statistics statistics, public StatisticsCollector(Statistics statistics,
int statsCollectionIntervalInMilliSeconds, int statsCollectionIntervalInMilliSeconds,
StatisticsCollectorCallback statsCallback) { StatisticsCollectorCallback statsCallback) {
_statistics = statistics; _statistics = statistics;
_statsCollectionInterval = statsCollectionIntervalInMilliSeconds; _statsCollectionInterval = statsCollectionIntervalInMilliSeconds;
_statsCallback = statsCallback; _statsCallback = statsCallback;
_threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, _threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(1)); new ArrayBlockingQueue<Runnable>(1));
} }
public void start() { public void start() {
_threadPoolExecutor.submit(collectStatistics()); _threadPoolExecutor.submit(collectStatistics());
} }
public void shutDown() throws InterruptedException { public void shutDown() throws InterruptedException {
_isRunning = false; _isRunning = false;
_threadPoolExecutor.shutdown(); _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. // statistics does not cause any exceptions to be thrown.
_threadPoolExecutor.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS); _threadPoolExecutor.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS);
} }
private Runnable collectStatistics() { private Runnable collectStatistics() {
return new Runnable() { return new Runnable() {
@ -65,11 +65,11 @@ public class StatisticsCollector {
// Collect histogram data // Collect histogram data
for(HistogramType histogramType : HistogramType.values()) { for(HistogramType histogramType : HistogramType.values()) {
HistogramData histogramData = HistogramData histogramData =
_statistics.geHistogramData(histogramType); _statistics.geHistogramData(histogramType);
_statsCallback.histogramCallback(histogramType, histogramData); _statsCallback.histogramCallback(histogramType, histogramData);
} }
Thread.sleep(_statsCollectionInterval); Thread.sleep(_statsCollectionInterval);
} }
catch (InterruptedException e) { catch (InterruptedException e) {

@ -17,7 +17,7 @@ public interface StatisticsCollectorCallback {
* @param tickerCount Value of ticker type. * @param tickerCount Value of ticker type.
*/ */
void tickerCallback(TickerType tickerType, long tickerCount); void tickerCallback(TickerType tickerType, long tickerCount);
/** /**
* Callback function to get histogram values. * Callback function to get histogram values.
* @param histType Histogram type. * @param histType Histogram type.

@ -12,28 +12,28 @@ public class StatisticsCollectorTest {
static { static {
RocksDB.loadLibrary(); RocksDB.loadLibrary();
} }
public static void main(String[] args) throws InterruptedException, RocksDBException { public static void main(String[] args) throws InterruptedException, RocksDBException {
Options opt = new Options().createStatistics().setCreateIfMissing(true); Options opt = new Options().createStatistics().setCreateIfMissing(true);
Statistics stats = opt.statisticsPtr(); Statistics stats = opt.statisticsPtr();
RocksDB db = RocksDB.open(db_path); RocksDB db = RocksDB.open(db_path);
StatsCallbackMock callback = new StatsCallbackMock(); StatsCallbackMock callback = new StatsCallbackMock();
StatisticsCollector statsCollector = new StatisticsCollector(stats, 100, StatisticsCollector statsCollector = new StatisticsCollector(stats, 100,
callback); callback);
statsCollector.start(); statsCollector.start();
Thread.sleep(1000); Thread.sleep(1000);
assert(callback.tickerCallbackCount > 0); assert(callback.tickerCallbackCount > 0);
assert(callback.histCallbackCount > 0); assert(callback.histCallbackCount > 0);
statsCollector.shutDown(); statsCollector.shutDown();
db.close(); db.close();
opt.dispose(); opt.dispose();
System.out.println("Stats collector test passed.!"); System.out.println("Stats collector test passed.!");
} }
} }

@ -10,11 +10,11 @@ import org.rocksdb.*;
public class StatsCallbackMock implements StatisticsCollectorCallback { public class StatsCallbackMock implements StatisticsCollectorCallback {
public int tickerCallbackCount = 0; public int tickerCallbackCount = 0;
public int histCallbackCount = 0; public int histCallbackCount = 0;
public void tickerCallback(TickerType tickerType, long tickerCount) { public void tickerCallback(TickerType tickerType, long tickerCount) {
tickerCallbackCount++; tickerCallbackCount++;
} }
public void histogramCallback(HistogramType histType, public void histogramCallback(HistogramType histType,
HistogramData histData) { HistogramData histData) {
histCallbackCount++; histCallbackCount++;

Loading…
Cancel
Save