当前位置: 首页>>代码示例>>Java>>正文


Java Options.createIfMissing方法代码示例

本文整理汇总了Java中org.iq80.leveldb.Options.createIfMissing方法的典型用法代码示例。如果您正苦于以下问题:Java Options.createIfMissing方法的具体用法?Java Options.createIfMissing怎么用?Java Options.createIfMissing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.iq80.leveldb.Options的用法示例。


在下文中一共展示了Options.createIfMissing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startInternal

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
protected void startInternal() throws Exception {
  Path storeRoot = createStorageDir();
  Options options = new Options();
  options.createIfMissing(false);
  options.logger(new LeveldbLogger());
  LOG.info("Using state database at " + storeRoot + " for recovery");
  File dbfile = new File(storeRoot.toString());
  try {
    db = JniDBFactory.factory.open(dbfile, options);
  } catch (NativeDB.DBException e) {
    if (e.isNotFound() || e.getMessage().contains(" does not exist ")) {
      LOG.info("Creating state database at " + dbfile);
      options.createIfMissing(true);
      try {
        db = JniDBFactory.factory.open(dbfile, options);
        // store version
        storeVersion();
      } catch (DBException dbErr) {
        throw new IOException(dbErr.getMessage(), dbErr);
      }
    } else {
      throw e;
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:LeveldbRMStateStore.java

示例2: 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);
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:18,代码来源:LevelDBCachePooFactory.java

示例3: startStore

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private void startStore(Path recoveryRoot) throws IOException {
  Options options = new Options();
  options.createIfMissing(false);
  options.logger(new LevelDBLogger());
  Path dbPath = new Path(recoveryRoot, STATE_DB_NAME);
  LOG.info("Using state database at " + dbPath + " for recovery");
  File dbfile = new File(dbPath.toString());
  try {
    stateDb = JniDBFactory.factory.open(dbfile, options);
  } catch (NativeDB.DBException e) {
    if (e.isNotFound() || e.getMessage().contains(" does not exist ")) {
      LOG.info("Creating state database at " + dbfile);
      options.createIfMissing(true);
      try {
        stateDb = JniDBFactory.factory.open(dbfile, options);
        storeVersion();
      } catch (DBException dbExc) {
        throw new IOException("Unable to create state store", dbExc);
      }
    } else {
      throw e;
    }
  }
  checkVersion();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:ShuffleHandler.java

示例4: 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);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:20,代码来源:LevelDBCachePooFactory.java

示例5: 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();
}
 
开发者ID:Rabiator1,项目名称:SWG-Station-Chat,代码行数:17,代码来源:ChatApiServer.java

示例6: main

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  String path = args[0];
  
  Options options = new Options();
  options.createIfMissing(true);
  options.verifyChecksums(true);
  options.paranoidChecks(true);

  DB db = null;

  try {
    db = JniDBFactory.factory.open(new File(path), options);
  } catch (UnsatisfiedLinkError ule) {
    db = Iq80DBFactory.factory.open(new File(path), options);
  }      
  
  db.close();
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:19,代码来源:WarpInit.java

示例7: 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);
    }
}
 
开发者ID:avoloshko,项目名称:WebCrawler,代码行数:17,代码来源:LevelDBStore.java

示例8: onOK

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
private void onOK() {
    Options options = new Options();
    options.createIfMissing(this.createBox.isSelected());
    options.compressionType((CompressionType) this.compressType.getSelectedItem());

    try{
        options.maxOpenFiles(Integer.parseInt(this.maxOpenFiles.getValue().toString()));
    }catch (NumberFormatException e){
        options.maxOpenFiles(1000);
    }

    options.verifyChecksums(this.verifyChecksumsCheckBox.isSelected());
    options.paranoidChecks(this.paranoidChecksCheckBox.isSelected());

    this.viewer.setOptions(options);

    dispose();
}
 
开发者ID:SuperMarcus,项目名称:LevelDBViewer,代码行数:19,代码来源:OpenLevelDBDialog.java

示例9: openDatabase

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
protected DB openDatabase() throws Exception {
  Path storeRoot = createStorageDir();
  Options options = new Options();
  options.createIfMissing(false);
  options.logger(new LeveldbLogger());
  LOG.info("Using state database at " + storeRoot + " for recovery");
  File dbfile = new File(storeRoot.toString());
  try {
    db = JniDBFactory.factory.open(dbfile, options);
  } catch (NativeDB.DBException e) {
    if (e.isNotFound() || e.getMessage().contains(" does not exist ")) {
      LOG.info("Creating state database at " + dbfile);
      options.createIfMissing(true);
      try {
        db = JniDBFactory.factory.open(dbfile, options);
        // store version
        storeVersion();
      } catch (DBException dbErr) {
        throw new IOException(dbErr.getMessage(), dbErr);
      }
    } else {
      throw e;
    }
  }
  return db;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:27,代码来源:LeveldbRMStateStore.java

示例10: submitScore

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
public static boolean submitScore(String username, String score) throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    DB db = factory.open(new File("database"), options);

    String value = asString(db.get(bytes("scores")));

    org.json.JSONObject scoreJSON;
    if (!value.isEmpty()) { //user score
        scoreJSON = new org.json.JSONObject(value);
    } else {
        scoreJSON = new org.json.JSONObject();
    }

    scoreJSON.put(username, score);

    System.out.println("All Scores: \n" + scoreJSON.toString());

    db.put(bytes("scores"), bytes(scoreJSON.toString()));
    db.close();
    return true;
}
 
开发者ID:kaloni,项目名称:TheJavaProject,代码行数:23,代码来源:DatabaseHelper.java

示例11: getAllScoreAsJsonString

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
public static String getAllScoreAsJsonString() throws IOException {
    Options options = new Options();
    options.createIfMissing(true);
    DB db = factory.open(new File("database"), options);

    String value = asString(db.get(bytes("scores")));
    db.close();
    org.json.JSONObject scoreJSON;
    if (!value.isEmpty()) { //user score
        scoreJSON = new org.json.JSONObject(value);
    } else {
        scoreJSON = new org.json.JSONObject();
    }

    System.out.println("All Scores: \n" + scoreJSON.toString());

    return scoreJSON.toString();
}
 
开发者ID:kaloni,项目名称:TheJavaProject,代码行数:19,代码来源:DatabaseHelper.java

示例12: 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);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:20,代码来源:DainLevelDBStorageSystem.java

示例13: 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);
}
 
开发者ID:CaracalDB,项目名称:CaracalDB,代码行数:23,代码来源:LevelDBJNI.java

示例14: EzLevelDbTable

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
public EzLevelDbTable(File path, EzLevelDbFactory factory,
		Serde<H> hashKeySerde, Serde<R> rangeKeySerde, Serde<V> valueSerde,
		Comparator<byte[]> hashKeyComparator,
		Comparator<byte[]> rangeKeyComparator) {
	this.hashKeySerde = hashKeySerde;
	this.rangeKeySerde = rangeKeySerde;
	this.valueSerde = valueSerde;
	this.hashKeyComparator = hashKeyComparator;
	this.rangeKeyComparator = rangeKeyComparator;

	Options options = new Options();
	options.createIfMissing(true);
	options.comparator(new EzLevelDbComparator(hashKeyComparator,
			rangeKeyComparator));

	try {
		this.db = factory.open(path, options);
	} catch (IOException e) {
		throw new DbException(e);
	}
}
 
开发者ID:criccomini,项目名称:ezdb,代码行数:22,代码来源:EzLevelDbTable.java

示例15: makeEmptyMap

import org.iq80.leveldb.Options; //导入方法依赖的package包/类
@Override
protected Map<String, String> makeEmptyMap() throws UnsupportedOperationException
{
	FileUtils.deleteRecursively(empty);

	Options options = new Options();
	options.createIfMissing(true);
	EntryBinding<String> stringBinding = new StringBinding();
	DB db = null;
	try
	{
		db = factory.open(empty, options);
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}

	return new LevelDBStoredMap<String, String>(db, stringBinding, stringBinding);
}
 
开发者ID:GridLine,项目名称:leveldb-mapapi,代码行数:21,代码来源:MapTest.java


注:本文中的org.iq80.leveldb.Options.createIfMissing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。