本文整理汇总了Java中org.iq80.leveldb.Options.cacheSize方法的典型用法代码示例。如果您正苦于以下问题:Java Options.cacheSize方法的具体用法?Java Options.cacheSize怎么用?Java Options.cacheSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.iq80.leveldb.Options
的用法示例。
在下文中一共展示了Options.cacheSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCachePool
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
public CachePool createCachePool(String poolName, int cacheSize,
int expireSeconds) {
Options options = new Options();
options.cacheSize(cacheSize * 1048576);//cacheSize M 大小
options.createIfMissing(true);
DB db =null;
try {
db=factory.open(new File("leveldb\\"+poolName), options);
// Use the db in here....
} catch (Exception e) {
// Make sure you close the db to shutdown the
// database and avoid resource leaks.
// db.close();
}
return new LevelDBPool(poolName,db,cacheSize);
}
示例2: createCachePool
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
public CachePool createCachePool(String poolName, int cacheSize,
int expireSeconds) {
Options options = new Options();
options.cacheSize(1048576L * cacheSize); //cacheSize M
options.createIfMissing(true);
DB db = null;
String filePath = "leveldb\\" + poolName;
try {
db = factory.open(new File(filePath), options);
// Use the db in here....
} catch (IOException e) {
LOGGER.info("factory try to open file " + filePath + " failed ");
// Make sure you close the db to shutdown the
// database and avoid resource leaks.
// db.close();
}
return new LevelDBPool(poolName, db, cacheSize);
}
示例3: start
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private void start() throws IOException {
persister = Executors.newFixedThreadPool(config.getInt("persisterThreads"));
Options levelDbOptions = new Options();
levelDbOptions.createIfMissing(true);
levelDbOptions.cacheSize(config.getInt("levelDbCache"));
avatarDb = factory.open(new File("./db/chatAvatars"), levelDbOptions);
chatRoomDb = factory.open(new File("./db/chatRooms"), levelDbOptions);
if(config.getBoolean("compressMails"))
levelDbOptions.compressionType(CompressionType.SNAPPY);
mailDb = factory.open(new File("./db/mails"), levelDbOptions);
getHighestAvatarIdFromDatabase();
registrar = new ChatApiTcpListener(config.getInt("registrarPort"));
gateway = new ChatApiTcpListener(config.getInt("gatewayPort"));
registrar.start();
gateway.start();
}
示例4: open
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
public void open() {
Options options = new Options();
options.createIfMissing(true);
options.cacheSize(cacheSize);
options.compressionType(CompressionType.SNAPPY);
try {
File file = new File(database);
logger.info("Opening LevelDB: " + file.getAbsolutePath());
db = JniDBFactory.factory.open(new File(database), options);
logger.debug(db.getProperty("leveldb.stats"));
} catch (IOException e) {
logger.error("Error opening LevelDB ", e);
}
}
示例5: DainLevelDBStorageSystem
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
/** Constructor. */
public DainLevelDBStorageSystem(File dir, int cacheSizeMB)
throws StorageException {
ensureStorageDirectory(dir);
Options options = new Options();
options.createIfMissing(true);
// we disable compression, as the storage framework has own support for
// selective compression of sub-stores
options.compressionType(CompressionType.NONE);
options.cacheSize(cacheSizeMB * 1024 * 1024);
try {
database = Iq80DBFactory.factory.open(dir, options);
} catch (IOException e) {
throw new StorageException(e);
}
}
示例6: LevelDBJNI
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
/**
* @param config
* @throws IOException
*/
public LevelDBJNI(Config config) throws IOException {
super(config);
this.dbPath = config.getString("leveldb.path");
this.cacheSize = config.getBytes("leveldb.cache");
File dbDir = new File(dbPath);
if (!dbDir.exists()) {
if (!dbDir.mkdirs()) {
throw new IOException("Unable to create DB directory");
}
}
Options options = new Options();
options.createIfMissing(true);
options.cacheSize(cacheSize);
options.compressionType(CompressionType.NONE); // No compression
db = JniDBFactory.factory.open(dbDir, options);
}
示例7: initRollingLevelDB
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private void initRollingLevelDB(Long dbStartTime,
Path rollingInstanceDBPath) {
if (rollingdbs.containsKey(dbStartTime)) {
return;
}
Options options = new Options();
options.createIfMissing(true);
options.cacheSize(conf.getLong(
YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
options.maxOpenFiles(conf.getInt(
YarnConfiguration.TIMELINE_SERVICE_LEVELDB_MAX_OPEN_FILES,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_MAX_OPEN_FILES));
options.writeBufferSize(conf.getInt(
YarnConfiguration.TIMELINE_SERVICE_LEVELDB_WRITE_BUFFER_SIZE,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_WRITE_BUFFER_SIZE));
LOG.info("Initializing rolling leveldb instance :" + rollingInstanceDBPath
+ " for start time: " + dbStartTime);
DB db = null;
try {
db = factory.open(
new File(rollingInstanceDBPath.toUri().getPath()), options);
rollingdbs.put(dbStartTime, db);
String dbName = fdf.format(dbStartTime);
LOG.info("Added rolling leveldb instance " + dbName + " to " + getName());
} catch (IOException ioe) {
LOG.warn("Failed to open rolling leveldb instance :"
+ new File(rollingInstanceDBPath.toUri().getPath()), ioe);
}
}
示例8: serviceInit
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
protected synchronized void serviceInit(Configuration conf) throws Exception {
configuration = conf;
Options options = new Options();
options.createIfMissing(true);
options.cacheSize(conf.getLong(
YarnConfiguration.TIMELINE_SERVICE_LEVELDB_CACHE_READ_CACHE_SIZE,
YarnConfiguration.
DEFAULT_TIMELINE_SERVICE_LEVELDB_CACHE_READ_CACHE_SIZE));
JniDBFactory factory = new JniDBFactory();
Path dbPath = new Path(
conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH),
dbId + CACHED_LDB_FILE_PREFIX);
FileSystem localFS = null;
try {
localFS = FileSystem.getLocal(conf);
if (!localFS.exists(dbPath)) {
if (!localFS.mkdirs(dbPath)) {
throw new IOException("Couldn't create directory for leveldb " +
"timeline store " + dbPath);
}
localFS.setPermission(dbPath, LeveldbUtils.LEVELDB_DIR_UMASK);
}
} finally {
IOUtils.cleanup(LOG, localFS);
}
LOG.info("Using leveldb path " + dbPath);
entityDb = factory.open(new File(dbPath.toString()), options);
entities = new LevelDBMapAdapter<>(entityDb);
super.serviceInit(conf);
}
示例9: serviceInit
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
Options options = new Options();
options.createIfMissing(true);
options.cacheSize(conf.getLong(
YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
JniDBFactory factory = new JniDBFactory();
String path = conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH);
File p = new File(path);
if (!p.exists()) {
if (!p.mkdirs()) {
throw new IOException("Couldn't create directory for leveldb " +
"timeline store " + path);
}
}
LOG.info("Using leveldb path " + path);
db = factory.open(new File(path, FILENAME), options);
startTimeWriteCache =
Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
conf)));
startTimeReadCache =
Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
conf)));
if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
deletionThread = new EntityDeletionThread(conf);
deletionThread.start();
}
super.serviceInit(conf);
}
示例10: dataDbOptions
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private Options dataDbOptions() {
Options options = new Options().createIfMissing(true);
options.compressionType(CompressionType.valueOf(configuration.compressionType().name()));
if (configuration.blockSize() != null) {
options.blockSize(configuration.blockSize());
}
if (configuration.cacheSize() != null) {
options.cacheSize(configuration.cacheSize());
}
return options;
}
示例11: serviceInit
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void serviceInit(Configuration conf) throws Exception {
Options options = new Options();
options.createIfMissing(true);
options.cacheSize(conf.getLong(
YarnConfiguration.TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE));
JniDBFactory factory = new JniDBFactory();
Path dbPath = new Path(
conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH), FILENAME);
FileSystem localFS = null;
try {
localFS = FileSystem.getLocal(conf);
if (!localFS.exists(dbPath)) {
if (!localFS.mkdirs(dbPath)) {
throw new IOException("Couldn't create directory for leveldb " +
"timeline store " + dbPath);
}
localFS.setPermission(dbPath, LEVELDB_DIR_UMASK);
}
} finally {
IOUtils.cleanup(LOG, localFS);
}
LOG.info("Using leveldb path " + dbPath);
db = factory.open(new File(dbPath.toString()), options);
checkVersion();
startTimeWriteCache =
Collections.synchronizedMap(new LRUMap(getStartTimeWriteCacheSize(
conf)));
startTimeReadCache =
Collections.synchronizedMap(new LRUMap(getStartTimeReadCacheSize(
conf)));
if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, true)) {
deletionThread = new EntityDeletionThread(conf);
deletionThread.start();
}
super.serviceInit(conf);
}
示例12: activateService
import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@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 );
}