本文整理汇总了Java中org.fusesource.leveldbjni.internal.NativeDB.DBException方法的典型用法代码示例。如果您正苦于以下问题:Java NativeDB.DBException方法的具体用法?Java NativeDB.DBException怎么用?Java NativeDB.DBException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fusesource.leveldbjni.internal.NativeDB
的用法示例。
在下文中一共展示了NativeDB.DBException方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startInternal
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的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;
}
}
}
示例2: startStore
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的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();
}
示例3: openDatabase
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的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;
}
示例4: hasPrev
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
public boolean hasPrev() {
if( !iterator.isValid() )
return false;
try {
iterator.prev();
try {
return iterator.isValid();
} finally {
if (iterator.isValid()) {
iterator.next();
} else {
iterator.seekToFirst();
}
}
} catch (NativeDB.DBException e) {
throw new RuntimeException(e);
}
}
示例5: peekPrev
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
public Map.Entry<byte[], byte[]> peekPrev() {
try {
iterator.prev();
try {
return peekNext();
} finally {
if (iterator.isValid()) {
iterator.next();
} else {
iterator.seekToFirst();
}
}
} catch (NativeDB.DBException e) {
throw new RuntimeException(e);
}
}
示例6: initStorage
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
@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();
}
示例7: startStorage
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
@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();
}
示例8: openDatabase
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
protected DB openDatabase(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;
}
}
return db;
}
示例9: seek
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
public void seek(byte[] key) {
try {
iterator.seek(key);
} catch (NativeDB.DBException e) {
if( e.isNotFound() ) {
throw new NoSuchElementException();
} else {
throw new RuntimeException(e);
}
}
}
示例10: peekNext
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
public Map.Entry<byte[], byte[]> peekNext() {
if(!iterator.isValid()) {
throw new NoSuchElementException();
}
try {
return new AbstractMap.SimpleImmutableEntry<byte[],byte[]>(iterator.key(), iterator.value());
} catch (NativeDB.DBException e) {
throw new RuntimeException(e);
}
}
示例11: next
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
public Map.Entry<byte[], byte[]> next() {
Map.Entry<byte[], byte[]> rc = peekNext();
try {
iterator.next();
} catch (NativeDB.DBException e) {
throw new RuntimeException(e);
}
return rc;
}
示例12: prev
import org.fusesource.leveldbjni.internal.NativeDB; //导入方法依赖的package包/类
public Map.Entry<byte[], byte[]> prev() {
Map.Entry<byte[], byte[]> rc = peekPrev();
try {
iterator.prev();
} catch (NativeDB.DBException e) {
throw new RuntimeException(e);
}
return rc;
}