Fix javadocs to allow build to pass in JDK 17 (#4834)

- Added missing javadocs so that javadoc doclint passes against JDK 17 (invoke by Besu gradle build).
- Exclude following packages from javadoc lint:
org.hyperledger.besu.privacy.contracts.generated
org.hyperledger.besu.tests.acceptance.*
- Temporarily exclude ethereum and evm submodule for doc lint checks.
- Run the javadoc task using GitHub actions (use Java 17) to report any javadoc errors during the PR builds
- Updating plugin-api build.gradle with new hash as javadoc comments caused it to change

Signed-off-by: Usman Saleem <usman@usmans.info>
This commit is contained in:
Usman Saleem
2023-01-18 22:51:00 +10:00
committed by GitHub
parent aef335cfcf
commit 9eb32836b7
763 changed files with 15266 additions and 74 deletions

View File

@@ -44,6 +44,11 @@ public class RocksDBKeyValuePrivacyStorageFactory implements PrivacyKeyValueStor
private final RocksDBKeyValueStorageFactory publicFactory;
private Integer databaseVersion;
/**
* Instantiates a new RocksDb key value privacy storage factory.
*
* @param publicFactory the public factory
*/
public RocksDBKeyValuePrivacyStorageFactory(final RocksDBKeyValueStorageFactory publicFactory) {
this.publicFactory = publicFactory;
}

View File

@@ -41,6 +41,7 @@ import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Rocks db key value storage factory. */
public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory {
private static final Logger LOG = LoggerFactory.getLogger(RocksDBKeyValueStorageFactory.class);
@@ -60,6 +61,15 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory {
private final List<SegmentIdentifier> segments;
private final List<SegmentIdentifier> ignorableSegments;
/**
* Instantiates a new RocksDb key value storage factory.
*
* @param configuration the configuration
* @param segments the segments
* @param ignorableSegments the ignorable segments
* @param defaultVersion the default version
* @param rocksDBMetricsFactory the rocks db metrics factory
*/
public RocksDBKeyValueStorageFactory(
final Supplier<RocksDBFactoryConfiguration> configuration,
final List<SegmentIdentifier> segments,
@@ -73,6 +83,14 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory {
this.rocksDBMetricsFactory = rocksDBMetricsFactory;
}
/**
* Instantiates a new RocksDb key value storage factory.
*
* @param configuration the configuration
* @param segments the segments
* @param defaultVersion the default version
* @param rocksDBMetricsFactory the rocks db metrics factory
*/
public RocksDBKeyValueStorageFactory(
final Supplier<RocksDBFactoryConfiguration> configuration,
final List<SegmentIdentifier> segments,
@@ -81,6 +99,14 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory {
this(configuration, segments, List.of(), defaultVersion, rocksDBMetricsFactory);
}
/**
* Instantiates a new Rocks db key value storage factory.
*
* @param configuration the configuration
* @param segments the segments
* @param ignorableSegments the ignorable segments
* @param rocksDBMetricsFactory the rocks db metrics factory
*/
public RocksDBKeyValueStorageFactory(
final Supplier<RocksDBFactoryConfiguration> configuration,
final List<SegmentIdentifier> segments,
@@ -89,6 +115,13 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory {
this(configuration, segments, ignorableSegments, DEFAULT_VERSION, rocksDBMetricsFactory);
}
/**
* Instantiates a new Rocks db key value storage factory.
*
* @param configuration the configuration
* @param segments the segments
* @param rocksDBMetricsFactory the rocks db metrics factory
*/
public RocksDBKeyValueStorageFactory(
final Supplier<RocksDBFactoryConfiguration> configuration,
final List<SegmentIdentifier> segments,
@@ -96,6 +129,11 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory {
this(configuration, segments, List.of(), DEFAULT_VERSION, rocksDBMetricsFactory);
}
/**
* Gets default version.
*
* @return the default version
*/
int getDefaultVersion() {
return defaultVersion;
}
@@ -163,6 +201,12 @@ public class RocksDBKeyValueStorageFactory implements KeyValueStorageFactory {
}
}
/**
* Storage path.
*
* @param commonConfiguration the common configuration
* @return the path
*/
protected Path storagePath(final BesuConfiguration commonConfiguration) {
return commonConfiguration.getStoragePath();
}

View File

@@ -17,6 +17,7 @@ package org.hyperledger.besu.plugin.services.storage.rocksdb;
import org.hyperledger.besu.plugin.services.metrics.Counter;
import org.hyperledger.besu.plugin.services.metrics.OperationTimer;
/** The Rocks db metrics. */
public class RocksDBMetrics {
private final OperationTimer readLatency;
@@ -25,6 +26,15 @@ public class RocksDBMetrics {
private final OperationTimer commitLatency;
private final Counter rollbackCount;
/**
* Instantiates a new RocksDb metrics.
*
* @param readLatency the read latency
* @param removeLatency the remove latency
* @param writeLatency the write latency
* @param commitLatency the commit latency
* @param rollbackCount the rollback count
*/
public RocksDBMetrics(
final OperationTimer readLatency,
final OperationTimer removeLatency,
@@ -38,22 +48,47 @@ public class RocksDBMetrics {
this.rollbackCount = rollbackCount;
}
/**
* Gets read latency.
*
* @return the read latency
*/
public OperationTimer getReadLatency() {
return readLatency;
}
/**
* Gets remove latency.
*
* @return the remove latency
*/
public OperationTimer getRemoveLatency() {
return removeLatency;
}
/**
* Gets write latency.
*
* @return the write latency
*/
public OperationTimer getWriteLatency() {
return writeLatency;
}
/**
* Gets commit latency.
*
* @return the commit latency
*/
public OperationTimer getCommitLatency() {
return commitLatency;
}
/**
* Gets rollback count.
*
* @return the rollback count
*/
public Counter getRollbackCount() {
return rollbackCount;
}

View File

@@ -29,12 +29,15 @@ import org.rocksdb.Statistics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Rocks db metrics factory. */
public class RocksDBMetricsFactory {
/** The constant PUBLIC_ROCKS_DB_METRICS. */
public static final RocksDBMetricsFactory PUBLIC_ROCKS_DB_METRICS =
new RocksDBMetricsFactory(
BesuMetricCategory.KVSTORE_ROCKSDB, BesuMetricCategory.KVSTORE_ROCKSDB_STATS);
/** The constant PRIVATE_ROCKS_DB_METRICS. */
public static final RocksDBMetricsFactory PRIVATE_ROCKS_DB_METRICS =
new RocksDBMetricsFactory(
BesuMetricCategory.KVSTORE_PRIVATE_ROCKSDB,
@@ -45,12 +48,27 @@ public class RocksDBMetricsFactory {
private final MetricCategory rocksDbMetricCategory;
private final MetricCategory statsDbMetricCategory;
/**
* Instantiates a new RocksDb metrics factory.
*
* @param rocksDbMetricCategory the rocks db metric category
* @param statsDbMetricCategory the stats db metric category
*/
public RocksDBMetricsFactory(
final MetricCategory rocksDbMetricCategory, final MetricCategory statsDbMetricCategory) {
this.rocksDbMetricCategory = rocksDbMetricCategory;
this.statsDbMetricCategory = statsDbMetricCategory;
}
/**
* Create RocksDb metrics.
*
* @param metricsSystem the metrics system
* @param rocksDbConfiguration the rocks db configuration
* @param db the db
* @param stats the stats
* @return the rocks db metrics
*/
public RocksDBMetrics create(
final MetricsSystem metricsSystem,
final RocksDBConfiguration rocksDbConfiguration,

View File

@@ -32,6 +32,7 @@ import com.google.common.base.Suppliers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The RocksDb plugin. */
public class RocksDBPlugin implements BesuPlugin {
private static final Logger LOG = LoggerFactory.getLogger(RocksDBPlugin.class);
@@ -43,10 +44,16 @@ public class RocksDBPlugin implements BesuPlugin {
private RocksDBKeyValueStorageFactory factory;
private RocksDBKeyValuePrivacyStorageFactory privacyFactory;
/** Instantiates a newRocksDb plugin. */
public RocksDBPlugin() {
this.options = RocksDBCLIOptions.create();
}
/**
* Add ignorable segment identifier.
*
* @param ignorable the ignorable
*/
public void addIgnorableSegmentIdentifier(final SegmentIdentifier ignorable) {
ignorableSegments.add(ignorable);
}
@@ -101,6 +108,11 @@ public class RocksDBPlugin implements BesuPlugin {
}
}
/**
* Is high spec enabled.
*
* @return the boolean
*/
public boolean isHighSpecEnabled() {
return options.isHighSpec();
}

View File

@@ -31,6 +31,7 @@ import org.rocksdb.RocksIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Rocks db iterator. */
public class RocksDbIterator implements Iterator<Pair<byte[], byte[]>>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(RocksDbIterator.class);
@@ -41,6 +42,12 @@ public class RocksDbIterator implements Iterator<Pair<byte[], byte[]>>, AutoClos
this.rocksIterator = rocksIterator;
}
/**
* Create RocksDb iterator.
*
* @param rocksIterator the rocks iterator
* @return the rocks db iterator
*/
public static RocksDbIterator create(final RocksIterator rocksIterator) {
return new RocksDbIterator(rocksIterator);
}
@@ -70,6 +77,11 @@ public class RocksDbIterator implements Iterator<Pair<byte[], byte[]>>, AutoClos
return Pair.of(key, value);
}
/**
* Next key.
*
* @return the byte [ ]
*/
public byte[] nextKey() {
assertOpen();
try {
@@ -87,6 +99,11 @@ public class RocksDbIterator implements Iterator<Pair<byte[], byte[]>>, AutoClos
return key;
}
/**
* To stream.
*
* @return the stream
*/
public Stream<Pair<byte[], byte[]>> toStream() {
assertOpen();
final Spliterator<Pair<byte[], byte[]>> spliterator =
@@ -101,6 +118,11 @@ public class RocksDbIterator implements Iterator<Pair<byte[], byte[]>>, AutoClos
return StreamSupport.stream(spliterator, false).onClose(this::close);
}
/**
* To stream keys.
*
* @return the stream
*/
public Stream<byte[]> toStreamKeys() {
assertOpen();
final Spliterator<byte[]> spliterator =

View File

@@ -24,17 +24,25 @@ import org.rocksdb.ColumnFamilyHandle;
import org.rocksdb.OptimisticTransactionDB;
import org.rocksdb.RocksDBException;
/** The RocksDb segment identifier. */
public class RocksDbSegmentIdentifier {
private final OptimisticTransactionDB db;
private final AtomicReference<ColumnFamilyHandle> reference;
/**
* Instantiates a new RocksDb segment identifier.
*
* @param db the db
* @param columnFamilyHandle the column family handle
*/
public RocksDbSegmentIdentifier(
final OptimisticTransactionDB db, final ColumnFamilyHandle columnFamilyHandle) {
this.db = db;
this.reference = new AtomicReference<>(columnFamilyHandle);
}
/** Reset. */
public void reset() {
reference.getAndUpdate(
oldHandle -> {
@@ -52,6 +60,11 @@ public class RocksDbSegmentIdentifier {
});
}
/**
* Get column family handle.
*
* @return the column family handle
*/
public ColumnFamilyHandle get() {
return reference.get();
}

View File

@@ -20,11 +20,13 @@ import org.rocksdb.RocksDB;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The RocksDb util. */
public class RocksDbUtil {
private static final Logger LOG = LoggerFactory.getLogger(RocksDbUtil.class);
private RocksDbUtil() {}
/** Load native library. */
public static void loadNativeLibrary() {
try {
RocksDB.loadLibrary();

View File

@@ -30,6 +30,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Database metadata. */
public class DatabaseMetadata {
private static final Logger LOG = LoggerFactory.getLogger(DatabaseMetadata.class);
@@ -39,44 +40,94 @@ public class DatabaseMetadata {
private Optional<Integer> privacyVersion;
/**
* Instantiates a new Database metadata.
*
* @param version the version
*/
@JsonCreator
public DatabaseMetadata(@JsonProperty("version") final int version) {
this(version, Optional.empty());
}
/**
* Instantiates a new Database metadata.
*
* @param version the version
* @param privacyVersion the privacy version
*/
public DatabaseMetadata(final int version, final Optional<Integer> privacyVersion) {
this.version = version;
this.privacyVersion = privacyVersion;
}
/**
* Instantiates a new Database metadata.
*
* @param version the version
* @param privacyVersion the privacy version
*/
public DatabaseMetadata(final int version, final int privacyVersion) {
this(version, Optional.of(privacyVersion));
}
/**
* Gets version.
*
* @return the version
*/
public int getVersion() {
return version;
}
/**
* Sets privacy version.
*
* @param privacyVersion the privacy version
*/
@JsonSetter("privacyVersion")
public void setPrivacyVersion(final int privacyVersion) {
this.privacyVersion = Optional.of(privacyVersion);
}
/**
* Gets privacy version.
*
* @return the privacy version
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonGetter("privacyVersion")
public Integer getPrivacyVersion() {
return privacyVersion.orElse(null);
}
/**
* Maybe privacy version.
*
* @return the optional
*/
public Optional<Integer> maybePrivacyVersion() {
return privacyVersion;
}
/**
* Look up database metadata.
*
* @param dataDir the data dir
* @return the database metadata
* @throws IOException the io exception
*/
public static DatabaseMetadata lookUpFrom(final Path dataDir) throws IOException {
LOG.info("Lookup database metadata file in data directory: {}", dataDir.toString());
return resolveDatabaseMetadata(getDefaultMetadataFile(dataDir));
}
/**
* Write to directory.
*
* @param dataDir the data dir
* @throws IOException the io exception
*/
public void writeToDirectory(final Path dataDir) throws IOException {
try {
final DatabaseMetadata currentMetadata =

View File

@@ -17,22 +17,34 @@ package org.hyperledger.besu.plugin.services.storage.rocksdb.configuration;
import com.google.common.base.MoreObjects;
import picocli.CommandLine;
/** The RocksDb cli options. */
public class RocksDBCLIOptions {
/** The constant DEFAULT_MAX_OPEN_FILES. */
public static final int DEFAULT_MAX_OPEN_FILES = 1024;
/** The constant DEFAULT_CACHE_CAPACITY. */
public static final long DEFAULT_CACHE_CAPACITY = 134217728;
/** The constant DEFAULT_MAX_BACKGROUND_COMPACTIONS. */
public static final int DEFAULT_MAX_BACKGROUND_COMPACTIONS = 4;
/** The constant DEFAULT_BACKGROUND_THREAD_COUNT. */
public static final int DEFAULT_BACKGROUND_THREAD_COUNT = 4;
/** The constant DEFAULT_IS_HIGH_SPEC. */
public static final boolean DEFAULT_IS_HIGH_SPEC = false;
/** The constant MAX_OPEN_FILES_FLAG. */
public static final String MAX_OPEN_FILES_FLAG = "--Xplugin-rocksdb-max-open-files";
/** The constant CACHE_CAPACITY_FLAG. */
public static final String CACHE_CAPACITY_FLAG = "--Xplugin-rocksdb-cache-capacity";
/** The constant MAX_BACKGROUND_COMPACTIONS_FLAG. */
public static final String MAX_BACKGROUND_COMPACTIONS_FLAG =
"--Xplugin-rocksdb-max-background-compactions";
/** The constant BACKGROUND_THREAD_COUNT_FLAG. */
public static final String BACKGROUND_THREAD_COUNT_FLAG =
"--Xplugin-rocksdb-background-thread-count";
/** The constant IS_HIGH_SPEC. */
public static final String IS_HIGH_SPEC = "--Xplugin-rocksdb-high-spec-enabled";
/** The Max open files. */
@CommandLine.Option(
names = {MAX_OPEN_FILES_FLAG},
hidden = true,
@@ -41,6 +53,7 @@ public class RocksDBCLIOptions {
description = "Max number of files RocksDB will open (default: ${DEFAULT-VALUE})")
int maxOpenFiles;
/** The Cache capacity. */
@CommandLine.Option(
names = {CACHE_CAPACITY_FLAG},
hidden = true,
@@ -49,6 +62,7 @@ public class RocksDBCLIOptions {
description = "Cache capacity of RocksDB (default: ${DEFAULT-VALUE})")
long cacheCapacity;
/** The Max background compactions. */
@CommandLine.Option(
names = {MAX_BACKGROUND_COMPACTIONS_FLAG},
hidden = true,
@@ -57,6 +71,7 @@ public class RocksDBCLIOptions {
description = "Maximum number of RocksDB background compactions (default: ${DEFAULT-VALUE})")
int maxBackgroundCompactions;
/** The Background thread count. */
@CommandLine.Option(
names = {BACKGROUND_THREAD_COUNT_FLAG},
hidden = true,
@@ -65,6 +80,7 @@ public class RocksDBCLIOptions {
description = "Number of RocksDB background threads (default: ${DEFAULT-VALUE})")
int backgroundThreadCount;
/** The Is high spec. */
@CommandLine.Option(
names = {IS_HIGH_SPEC},
hidden = true,
@@ -75,10 +91,21 @@ public class RocksDBCLIOptions {
private RocksDBCLIOptions() {}
/**
* Create RocksDb cli options.
*
* @return the RocksDb cli options
*/
public static RocksDBCLIOptions create() {
return new RocksDBCLIOptions();
}
/**
* RocksDb cli options from config.
*
* @param config the config
* @return the RocksDb cli options
*/
public static RocksDBCLIOptions fromConfig(final RocksDBConfiguration config) {
final RocksDBCLIOptions options = create();
options.maxOpenFiles = config.getMaxOpenFiles();
@@ -89,11 +116,21 @@ public class RocksDBCLIOptions {
return options;
}
/**
* To domain object rocks db factory configuration.
*
* @return the rocks db factory configuration
*/
public RocksDBFactoryConfiguration toDomainObject() {
return new RocksDBFactoryConfiguration(
maxOpenFiles, maxBackgroundCompactions, backgroundThreadCount, cacheCapacity, isHighSpec);
}
/**
* Is high spec.
*
* @return the boolean
*/
public boolean isHighSpec() {
return isHighSpec;
}

View File

@@ -16,6 +16,7 @@ package org.hyperledger.besu.plugin.services.storage.rocksdb.configuration;
import java.nio.file.Path;
/** The Rocks db configuration. */
public class RocksDBConfiguration {
private final Path databaseDir;
@@ -26,6 +27,17 @@ public class RocksDBConfiguration {
private final long cacheCapacity;
private final boolean isHighSpec;
/**
* Instantiates a new RocksDb configuration.
*
* @param databaseDir the database dir
* @param maxOpenFiles the max open files
* @param maxBackgroundCompactions the max background compactions
* @param backgroundThreadCount the background thread count
* @param cacheCapacity the cache capacity
* @param label the label
* @param isHighSpec the is high spec
*/
public RocksDBConfiguration(
final Path databaseDir,
final int maxOpenFiles,
@@ -43,30 +55,65 @@ public class RocksDBConfiguration {
this.isHighSpec = isHighSpec;
}
/**
* Gets database dir.
*
* @return the database dir
*/
public Path getDatabaseDir() {
return databaseDir;
}
/**
* Gets max open files.
*
* @return the max open files
*/
public int getMaxOpenFiles() {
return maxOpenFiles;
}
/**
* Gets max background compactions.
*
* @return the max background compactions
*/
public int getMaxBackgroundCompactions() {
return maxBackgroundCompactions;
}
/**
* Gets background thread count.
*
* @return the background thread count
*/
public int getBackgroundThreadCount() {
return backgroundThreadCount;
}
/**
* Gets cache capacity.
*
* @return the cache capacity
*/
public long getCacheCapacity() {
return cacheCapacity;
}
/**
* Gets label.
*
* @return the label
*/
public String getLabel() {
return label;
}
/**
* Is high spec.
*
* @return the boolean
*/
public boolean isHighSpec() {
return isHighSpec;
}

View File

@@ -22,6 +22,7 @@ import static org.hyperledger.besu.plugin.services.storage.rocksdb.configuration
import java.nio.file.Path;
/** The RocksDb configuration builder. */
public class RocksDBConfigurationBuilder {
private Path databaseDir;
@@ -32,41 +33,89 @@ public class RocksDBConfigurationBuilder {
private int backgroundThreadCount = DEFAULT_BACKGROUND_THREAD_COUNT;
private boolean isHighSpec = DEFAULT_IS_HIGH_SPEC;
/**
* Database dir.
*
* @param databaseDir the database dir
* @return the rocks db configuration builder
*/
public RocksDBConfigurationBuilder databaseDir(final Path databaseDir) {
this.databaseDir = databaseDir;
return this;
}
/**
* Max open files.
*
* @param maxOpenFiles the max open files
* @return the rocks db configuration builder
*/
public RocksDBConfigurationBuilder maxOpenFiles(final int maxOpenFiles) {
this.maxOpenFiles = maxOpenFiles;
return this;
}
/**
* Label.
*
* @param label the label
* @return the rocks db configuration builder
*/
public RocksDBConfigurationBuilder label(final String label) {
this.label = label;
return this;
}
/**
* Cache capacity.
*
* @param cacheCapacity the cache capacity
* @return the rocks db configuration builder
*/
public RocksDBConfigurationBuilder cacheCapacity(final long cacheCapacity) {
this.cacheCapacity = cacheCapacity;
return this;
}
/**
* Max background compactions.
*
* @param maxBackgroundCompactions the max background compactions
* @return the rocks db configuration builder
*/
public RocksDBConfigurationBuilder maxBackgroundCompactions(final int maxBackgroundCompactions) {
this.maxBackgroundCompactions = maxBackgroundCompactions;
return this;
}
/**
* Background thread count.
*
* @param backgroundThreadCount the background thread count
* @return the rocks db configuration builder
*/
public RocksDBConfigurationBuilder backgroundThreadCount(final int backgroundThreadCount) {
this.backgroundThreadCount = backgroundThreadCount;
return this;
}
/**
* Is high spec.
*
* @param isHighSpec the is high spec
* @return the rocks db configuration builder
*/
public RocksDBConfigurationBuilder isHighSpec(final boolean isHighSpec) {
this.isHighSpec = isHighSpec;
return this;
}
/**
* From.
*
* @param configuration the configuration
* @return the rocks db configuration builder
*/
public static RocksDBConfigurationBuilder from(final RocksDBFactoryConfiguration configuration) {
return new RocksDBConfigurationBuilder()
.backgroundThreadCount(configuration.getBackgroundThreadCount())
@@ -76,6 +125,11 @@ public class RocksDBConfigurationBuilder {
.isHighSpec(configuration.isHighSpec());
}
/**
* Build rocks db configuration.
*
* @return the rocks db configuration
*/
public RocksDBConfiguration build() {
return new RocksDBConfiguration(
databaseDir,

View File

@@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.plugin.services.storage.rocksdb.configuration;
/** The RocksDb factory configuration. */
public class RocksDBFactoryConfiguration {
private final int maxOpenFiles;
@@ -22,6 +23,15 @@ public class RocksDBFactoryConfiguration {
private final long cacheCapacity;
private final boolean isHighSpec;
/**
* Instantiates a new RocksDb factory configuration.
*
* @param maxOpenFiles the max open files
* @param maxBackgroundCompactions the max background compactions
* @param backgroundThreadCount the background thread count
* @param cacheCapacity the cache capacity
* @param isHighSpec the is high spec
*/
public RocksDBFactoryConfiguration(
final int maxOpenFiles,
final int maxBackgroundCompactions,
@@ -35,22 +45,47 @@ public class RocksDBFactoryConfiguration {
this.isHighSpec = isHighSpec;
}
/**
* Gets max open files.
*
* @return the max open files
*/
public int getMaxOpenFiles() {
return maxOpenFiles;
}
/**
* Gets max background compactions.
*
* @return the max background compactions
*/
public int getMaxBackgroundCompactions() {
return maxBackgroundCompactions;
}
/**
* Gets background thread count.
*
* @return the background thread count
*/
public int getBackgroundThreadCount() {
return backgroundThreadCount;
}
/**
* Gets cache capacity.
*
* @return the cache capacity
*/
public long getCacheCapacity() {
return cacheCapacity;
}
/**
* Is high spec.
*
* @return the boolean
*/
public boolean isHighSpec() {
return isHighSpec;
}

View File

@@ -32,10 +32,20 @@ import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.Pair;
import org.rocksdb.OptimisticTransactionDB;
/** The RocksDb columnar key value snapshot. */
public class RocksDBColumnarKeyValueSnapshot implements SnappedKeyValueStorage {
/** The Db. */
final OptimisticTransactionDB db;
/** The Snap tx. */
final RocksDBSnapshotTransaction snapTx;
/**
* Instantiates a new RocksDb columnar key value snapshot.
*
* @param db the db
* @param segment the segment
* @param metrics the metrics
*/
RocksDBColumnarKeyValueSnapshot(
final OptimisticTransactionDB db,
final RocksDbSegmentIdentifier segment,

View File

@@ -66,6 +66,7 @@ import org.rocksdb.WriteOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The RocksDb columnar key value storage. */
public class RocksDBColumnarKeyValueStorage
implements SegmentedKeyValueStorage<RocksDbSegmentIdentifier> {
@@ -90,6 +91,15 @@ public class RocksDBColumnarKeyValueStorage
private final WriteOptions tryDeleteOptions =
new WriteOptions().setNoSlowdown(true).setIgnoreMissingColumnFamilies(true);
/**
* Instantiates a new RocksDb columnar key value storage.
*
* @param configuration the configuration
* @param segments the segments
* @param metricsSystem the metrics system
* @param rocksDBMetricsFactory the RocksDb metrics factory
* @throws StorageException the storage exception
*/
public RocksDBColumnarKeyValueStorage(
final RocksDBConfiguration configuration,
final List<SegmentIdentifier> segments,
@@ -99,6 +109,16 @@ public class RocksDBColumnarKeyValueStorage
this(configuration, segments, List.of(), metricsSystem, rocksDBMetricsFactory);
}
/**
* Instantiates a new Rocks db columnar key value storage.
*
* @param configuration the configuration
* @param segments the segments
* @param ignorableSegments the ignorable segments
* @param metricsSystem the metrics system
* @param rocksDBMetricsFactory the rocks db metrics factory
* @throws StorageException the storage exception
*/
public RocksDBColumnarKeyValueStorage(
final RocksDBConfiguration configuration,
final List<SegmentIdentifier> segments,
@@ -235,6 +255,13 @@ public class RocksDBColumnarKeyValueStorage
}
}
/**
* Take snapshot RocksDb columnar key value snapshot.
*
* @param segment the segment
* @return the RocksDb columnar key value snapshot
* @throws StorageException the storage exception
*/
public RocksDBColumnarKeyValueSnapshot takeSnapshot(final RocksDbSegmentIdentifier segment)
throws StorageException {
throwIfClosed();
@@ -330,6 +357,12 @@ public class RocksDBColumnarKeyValueStorage
private final org.rocksdb.Transaction innerTx;
private final WriteOptions options;
/**
* Instantiates a new RocksDb transaction.
*
* @param innerTx the inner tx
* @param options the write options
*/
RocksDbTransaction(final org.rocksdb.Transaction innerTx, final WriteOptions options) {
this.innerTx = innerTx;
this.options = options;

View File

@@ -36,6 +36,7 @@ import org.rocksdb.WriteOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Rocks db snapshot transaction. */
public class RocksDBSnapshotTransaction implements KeyValueStorageTransaction, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(RocksDBSnapshotTransaction.class);
private static final String NO_SPACE_LEFT_ON_DEVICE = "No space left on device";
@@ -49,6 +50,13 @@ public class RocksDBSnapshotTransaction implements KeyValueStorageTransaction, A
private final ReadOptions readOptions;
private final AtomicBoolean isClosed = new AtomicBoolean(false);
/**
* Instantiates a new RocksDb snapshot transaction.
*
* @param db the db
* @param columnFamilyHandle the column family handle
* @param metrics the metrics
*/
RocksDBSnapshotTransaction(
final OptimisticTransactionDB db,
final ColumnFamilyHandle columnFamilyHandle,
@@ -78,6 +86,12 @@ public class RocksDBSnapshotTransaction implements KeyValueStorageTransaction, A
this.snapTx = snapTx;
}
/**
* Get data against given key.
*
* @param key the key
* @return the optional data
*/
public Optional<byte[]> get(final byte[] key) {
if (isClosed.get()) {
LOG.debug("Attempted to access closed snapshot");
@@ -126,12 +140,22 @@ public class RocksDBSnapshotTransaction implements KeyValueStorageTransaction, A
}
}
/**
* Stream.
*
* @return the stream
*/
public Stream<Pair<byte[], byte[]>> stream() {
final RocksIterator rocksIterator = db.newIterator(columnFamilyHandle, readOptions);
rocksIterator.seekToFirst();
return RocksDbIterator.create(rocksIterator).toStream();
}
/**
* Stream keys.
*
* @return the stream
*/
public Stream<byte[]> streamKeys() {
final RocksIterator rocksIterator = db.newIterator(columnFamilyHandle, readOptions);
rocksIterator.seekToFirst();
@@ -160,6 +184,11 @@ public class RocksDBSnapshotTransaction implements KeyValueStorageTransaction, A
}
}
/**
* Copy.
*
* @return the rocks db snapshot transaction
*/
public RocksDBSnapshotTransaction copy() {
if (isClosed.get()) {
throw new StorageException("Snapshot already closed");

View File

@@ -47,6 +47,7 @@ import org.rocksdb.WriteOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The Rocks db key value storage. */
public class RocksDBKeyValueStorage implements KeyValueStorage {
static {
@@ -62,6 +63,13 @@ public class RocksDBKeyValueStorage implements KeyValueStorage {
private final WriteOptions tryDeleteOptions =
new WriteOptions().setNoSlowdown(true).setIgnoreMissingColumnFamilies(true);
/**
* Instantiates a new Rocks db key value storage.
*
* @param configuration the configuration
* @param metricsSystem the metrics system
* @param rocksDBMetricsFactory the rocks db metrics factory
*/
public RocksDBKeyValueStorage(
final RocksDBConfiguration configuration,
final MetricsSystem metricsSystem,

View File

@@ -25,6 +25,7 @@ import org.rocksdb.WriteOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** The RocksDb transaction. */
public class RocksDBTransaction implements KeyValueStorageTransaction {
private static final Logger logger = LoggerFactory.getLogger(RocksDBTransaction.class);
private static final String NO_SPACE_LEFT_ON_DEVICE = "No space left on device";
@@ -33,6 +34,13 @@ public class RocksDBTransaction implements KeyValueStorageTransaction {
private final Transaction innerTx;
private final WriteOptions options;
/**
* Instantiates a new RocksDb transaction.
*
* @param innerTx the inner tx
* @param options the options
* @param metrics the metrics
*/
RocksDBTransaction(
final Transaction innerTx, final WriteOptions options, final RocksDBMetrics metrics) {
this.innerTx = innerTx;