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

The following examples show how to use org.iq80.leveldb.Options#logger() . 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: LeveldbRMStateStore.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@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;
    }
  }
}
 
Example 2
Source File: ShuffleHandler.java    From hadoop with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: LeveldbRMStateStore.java    From big-c with Apache License 2.0 6 votes vote down vote up
@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;
    }
  }
}
 
Example 4
Source File: ShuffleHandler.java    From big-c with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 5
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 6
Source File: ShuffleHandler.java    From tez with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 7
Source File: NMLeveldbStateStoreService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void initStorage(Configuration conf)
    throws IOException {
  Path storeRoot = createStorageDir(conf);
  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);
      isNewlyCreated = true;
      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;
    }
  }
  checkVersion();
}
 
Example 8
Source File: HistoryServerLeveldbStateStoreService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
protected void startStorage() throws IOException {
  Path storeRoot = createStorageDir(getConfig());
  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;
    }
  }
  checkVersion();
}
 
Example 9
Source File: NMLeveldbStateStoreService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void initStorage(Configuration conf)
    throws IOException {
  Path storeRoot = createStorageDir(conf);
  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);
      isNewlyCreated = true;
      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;
    }
  }
  checkVersion();
}
 
Example 10
Source File: HistoryServerLeveldbStateStoreService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
protected void startStorage() throws IOException {
  Path storeRoot = createStorageDir(getConfig());
  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;
    }
  }
  checkVersion();
}
 
Example 11
Source File: LevelDbStore.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
		Kryo kryo = new Kryo();
		kryo.setReferences(false);
		kryo.setRegistrationRequired(false);
		kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
//		kryo.register(Transaction.class);
//		kryo.register(Xid.class);
//		kryo.register(TransactionType.class);
//		kryo.register(TransactionStatus.class);
//		kryo.register(Participant.class);
		
//		Output output = new Output(new ByteArrayOutputStream());//new Output(new FileOutputStream("file.bin"));
//		
//		DefaultTransaction defaultTransaction = new DefaultTransaction();
//		defaultTransaction.setXid(new DefaultXid("1", "2", "3"));
//		
//		kryo.writeObject(output, defaultTransaction);
//		output.flush();
//		output.close();
		
		Options options = new Options();
		options.createIfMissing(true);
		options.cacheSize(100 * 1048576); // 100MB cache
		options.logger(new org.iq80.leveldb.Logger() {
			public void log(String message) {
				TransactionLog.REPOSITORY.info(message);
			}
		});
		DB db = Iq80DBFactory.factory.open(new File("txtreedb"), options);
		
//		String stats = db.getProperty("leveldb.stats");
//		System.out.println(stats);
		
		DBIterator iterator = null;
		try {
			iterator = db.iterator();
			for(iterator.seekToFirst(); iterator.hasNext(); iterator.next()) {
				String key = Iq80DBFactory.asString(iterator.peekNext().getKey());
				Transaction value = (Transaction) SerializationUtil.deserialize(iterator.peekNext().getValue());
				
				System.out.println(key+" = "+value);
			}
		} finally {
			if (iterator != null) {
				iterator.close();
			}
		}

//		String transactionId = "f282205a-e794-4bda-83a2-bb28b8839cad";
//		Input input = new Input(db.get(Iq80DBFactory.bytes(transactionId)));
//		Transaction transaction = (Transaction) kryo.readClassAndObject(input);
//		System.out.println(transaction);
	}