Java Code Examples for org.iq80.leveldb.Options#maxOpenFiles()

The following examples show how to use org.iq80.leveldb.Options#maxOpenFiles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LevelDB.java    From aion with MIT License 6 votes vote down vote up
private Options setupLevelDbOptions() {
    Options options = new Options();

    options.createIfMissing(true);
    options.compressionType(
            enableDbCompression ? CompressionType.SNAPPY : CompressionType.NONE);
    options.blockSize(this.blockSize);
    options.writeBufferSize(this.writeBufferSize); // (levelDb default: 8mb)
    options.cacheSize(enableDbCache ? this.cacheSize : 0);
    options.paranoidChecks(true);
    options.verifyChecksums(true);
    options.maxOpenFiles(this.maxOpenFiles);

    LOG.info("LevelDb Options: EnableCompression:{} MaxOpenFiles:{} BlockSize:{} WriteBuffer:{} EnableCache:{} CacheSize:{}"
        , enableDbCompression, maxOpenFiles, blockSize, writeBufferSize, enableDbCache, cacheSize);

    return options;
}
 
Example 2
Source File: WarpDB.java    From warp10-platform with Apache License 2.0 6 votes vote down vote up
public Options getOptions() {
  //
  // Clone the current options
  //
  
  Options opt = new Options();
  opt.blockRestartInterval(options.blockRestartInterval());
  opt.blockSize(options.blockSize());
  opt.cacheSize(options.cacheSize());
  opt.comparator(options.comparator());
  opt.compressionType(options.compressionType());
  opt.createIfMissing(options.createIfMissing());
  opt.errorIfExists(options.errorIfExists());
  opt.logger(options.logger());
  opt.maxOpenFiles(options.maxOpenFiles());
  opt.paranoidChecks(options.paranoidChecks());
  opt.verifyChecksums(options.verifyChecksums());
  opt.writeBufferSize(options.writeBufferSize());
  
  return opt;
}
 
Example 3
Source File: LevelDbDataSourceImpl.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
private Options createDbOptions() {
    Options dbOptions = new Options();
    dbOptions.createIfMissing(true);
    dbOptions.compressionType(CompressionType.NONE);
    dbOptions.blockSize(10 * 1024 * 1024);
    dbOptions.writeBufferSize(10 * 1024 * 1024);
    dbOptions.cacheSize(0);
    dbOptions.paranoidChecks(true);
    dbOptions.verifyChecksums(true);
    dbOptions.maxOpenFiles(32);
    return dbOptions;
}
 
Example 4
Source File: Storage.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Options createDefaultDbOptions() {
    Options dbOptions = new Options();

    dbOptions.createIfMissing(true);
    dbOptions.paranoidChecks(true);
    dbOptions.verifyChecksums(true);

    dbOptions.compressionType(DEFAULT_COMPRESSION_TYPE);
    dbOptions.blockSize(DEFAULT_BLOCK_SIZE);
    dbOptions.writeBufferSize(DEFAULT_WRITE_BUFFER_SIZE);
    dbOptions.cacheSize(DEFAULT_CACHE_SIZE);
    dbOptions.maxOpenFiles(DEFAULT_MAX_OPEN_FILES);

    return dbOptions;
}
 
Example 5
Source File: LevelDbUtil.java    From mcg-helper with Apache License 2.0 5 votes vote down vote up
public static void init() throws IOException {
	errorRecovery(Constants.DATA_PATH + File.separator + "CURRENT");
	
    File dir = new File(Constants.DATA_PATH);
    Options options = new Options().createIfMissing(true);
    options.maxOpenFiles(100);
    db = factory.open(dir, options);
}
 
Example 6
Source File: WarpRepair.java    From warp10-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
  String path = args[0];

  Options options = new Options();
  options.createIfMissing(false);
  options.maxOpenFiles(200);
  options.verifyChecksums(!("true".equals(System.getProperty(DISABLE_CHECKSUMS))));
  options.paranoidChecks(!("true".equals(System.getProperty(DISABLE_PARANOIDCHECKS))));
  
  boolean nativedisabled = "true".equals(System.getProperty(Configuration.LEVELDB_NATIVE_DISABLE));
  boolean javadisabled = "true".equals(System.getProperty(Configuration.LEVELDB_JAVA_DISABLE));

  repair(path, options, javadisabled, nativedisabled);
}
 
Example 7
Source File: LevelDBEntityStoreMixin.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
@Override
public void activateService()
    throws Exception
{
    charset = Charset.forName( "UTF-8" );
    configuration.refresh();
    LevelDBEntityStoreConfiguration config = configuration.get();

    // Choose flavour
    String flavour = config.flavour().get();
    DBFactory factory;
    if( "jni".equalsIgnoreCase( flavour ) )
    {
        factory = newJniDBFactory();
    }
    else if( "java".equalsIgnoreCase( flavour ) )
    {
        factory = newJavaDBFactory();
    }
    else
    {
        factory = newDBFactory();
    }

    // Apply configuration
    Options options = new Options();
    options.createIfMissing( true );
    if( config.blockRestartInterval().get() != null )
    {
        options.blockRestartInterval( config.blockRestartInterval().get() );
    }
    if( config.blockSize().get() != null )
    {
        options.blockSize( config.blockSize().get() );
    }
    if( config.cacheSize().get() != null )
    {
        options.cacheSize( config.cacheSize().get() );
    }
    if( config.compression().get() != null )
    {
        options.compressionType( config.compression().get()
                                 ? CompressionType.SNAPPY
                                 : CompressionType.NONE );
    }
    if( config.maxOpenFiles().get() != null )
    {
        options.maxOpenFiles( config.maxOpenFiles().get() );
    }
    if( config.paranoidChecks().get() != null )
    {
        options.paranoidChecks( config.paranoidChecks().get() );
    }
    if( config.verifyChecksums().get() != null )
    {
        options.verifyChecksums( config.verifyChecksums().get() );
    }
    if( config.writeBufferSize().get() != null )
    {
        options.writeBufferSize( config.writeBufferSize().get() );
    }
    if( config.errorIfExists().get() != null )
    {
        options.errorIfExists( config.errorIfExists().get() );
    }

    // Open/Create the database
    File dbFile = new File( fileConfig.dataDirectory(), descriptor.identity().toString() );
    db = factory.open( dbFile, options );
}