@Override protected void init() throws FailStoreException { try { String dbName = dbPath.getPath() + "/lts.db"; db = DBMaker.fileDB(new File(dbName)) .closeOnJvmShutdown() .encryptionEnable("lts") .make(); } catch (Exception e) { throw new FailStoreException(e); } }
@Override protected void init() throws FailStoreException { try { String dbName = dbPath.getPath() + "/lts.db"; db = DBMaker.fileDB(new File(dbName)) .closeOnJvmShutdown() .encryptionEnable("lts") .make(); } catch (Exception e) { throw new FailStoreException(e); } }
/** * This DB returned by this method does not trigger deletion on JVM shutdown. * * @param name name of the DB file * @return an online instance of {@link MapDBContext} */ public static DBContext onlineInstance(String name) { DB db = DBMaker .fileDB(name) .fileMmapEnableIfSupported() .closeOnJvmShutdown() .transactionEnable() .make(); return new MapDBContext(db); }
/** * This DB returned by this method gets deleted on JVM shutdown. * * @param name name of the DB file * @return an offline instance of {@link MapDBContext} */ public static DBContext offlineInstance(String name) { DB db = DBMaker .fileDB(name) .fileMmapEnableIfSupported() .closeOnJvmShutdown() .cleanerHackEnable() .transactionEnable() .fileDeleteAfterClose() .make(); return new MapDBContext(db); }
public MapDBSortedMap(File f) { this.db = DBMaker.fileDB(f).closeOnJvmShutdown().transactionEnable().make(); this.treeMap = db.treeMap(f.getName()) .keySerializer(Serializer.LONG) .valueSerializer(Serializer.BYTE_ARRAY) .createOrOpen(); }
public MapDBHashMap(File f) { this.db = DBMaker.fileDB(f).closeOnJvmShutdown().transactionEnable().make(); this.hashMap = db.hashMap(f.getName()) .keySerializer(Serializer.STRING) .valueSerializer(Serializer.STRING) .createOrOpen(); }
/** * Constructor which uses the specified directory. * * @param dir * where the database should be stored */ public MapDBDataStore(String dir) { super(new CachedHTMLMapConverter()); this.db = this.configure(DBMaker.fileDB(new File(dir + "/parker.mapdb"))); this.dir = dir; }
@Override protected void init() throws FailStoreException { try { String dbName = dbPath.getPath() + "/lts.db"; db = DBMaker.fileDB(new File(dbName)) .closeOnJvmShutdown() .encryptionEnable("lts") .make(); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public DB get() { return Optional.ofNullable(storeFilePath).map(filePath -> DBMaker.fileDB(filePath).closeOnJvmShutdown().make()) .orElseGet(() -> DBMaker.memoryDB().closeOnJvmShutdown().make()); } }
public void useCaching(String dbFile) { // with transaction enabled, the cache won't get corrupt if the program crashes (at the cost of losing a little speed) this.db = DBMaker.fileDB(dbFile).closeOnJvmShutdown().transactionEnable().make(); }
public void useCaching(String dbFile) { // with transaction enabled, the cache won't get corrupt if the program crashes (at the cost of losing a little speed) this.db = DBMaker.fileDB(dbFile).closeOnJvmShutdown().transactionEnable().make(); }
public TextAnnotationMapDBHandler(String dbFile) { try { // enabling transactions avoids cache corruption if service fails. this.db = DBMaker.fileDB(dbFile).closeOnJvmShutdown().transactionEnable().make(); } catch (DBException e) { // logger.warn("mapdb couldn't instantiate db using file '{}': check error and either remove lock, " + // "repair file, or delete file.", dbFile); e.printStackTrace(); System.err.println("mapdb couldn't instantiate db using file '" + dbFile + "': check error and either remove lock, repair file, or delete file."); throw e; } } /**
private DB getDB(String path, boolean safeMode, boolean autoCleanup){ Maker dbConnection = DBMaker.fileDB(path).fileMmapEnable(); if(safeMode){ dbConnection = dbConnection.transactionEnable(); } if (autoCleanup){ dbConnection.closeOnJvmShutdown(); } return dbConnection.make(); } }
public static MapDbAppStorage createMmapFile(String fileSystemName, File dbFile) { return new MapDbAppStorage(fileSystemName, () -> { DBMaker.Maker maker = DBMaker.fileDB(dbFile) .transactionEnable(); // it is not recommanded to use mmap on Windows (crash) // http://www.mapdb.org/blog/mmap_files_alloc_and_jvm_crash/ if (!SystemUtils.IS_OS_WINDOWS) { maker.fileMmapEnableIfSupported() .fileMmapPreclearDisable(); } return maker.make(); }); }
public static ConcurrentMap setup() { DB db = DBMaker.fileDB("test.db").fileMmapEnable().fileMmapPreclearDisable() .allocateStartSize(124 * 1024 * 1024).allocateIncrement(5 * 1024 * 1024).make(); ConcurrentMap<?, ?> dictionaryUpdates = db.hashMap("test").createOrOpen(); return dictionaryUpdates; }
@Override public void setup(final BenchmarkParams b) throws IOException { super.setup(b); wkb = new UnsafeBuffer(new byte[keySize]); wvb = new UnsafeBuffer(new byte[valSize]); db = fileDB(new File(tmp, "map.db")) .fileMmapEnable() .concurrencyDisable() .allocateStartSize(num * valSize) .make(); map = db.treeMap("ba2ba") .keySerializer(BYTE_ARRAY) .valueSerializer(BYTE_ARRAY) .createOrOpen(); }
@Override public Map<Integer, SubscriberState> createMap() { if (storageFile == null) { //In-Memory Stats Storage db = DBMaker.memoryDB().make(); } else { db = DBMaker.fileDB(storageFile).closeOnJvmShutdown().transactionEnable() //Default to Write Ahead Log - lower performance, but has crash protection .make(); } statusStorageMap = db.hashMap("statusStorageMap").keySerializer(Serializer.INTEGER) .valueSerializer(new StatusStorageSerializer()).createOrOpen(); return statusStorageMap; }
@Override public Map<Integer, SubscriberState> createMap() { if (storageFile == null) { //In-Memory Stats Storage db = DBMaker.memoryDB().make(); } else { db = DBMaker.fileDB(storageFile).closeOnJvmShutdown().transactionEnable() //Default to Write Ahead Log - lower performance, but has crash protection .make(); } statusStorageMap = db.hashMap("statusStorageMap").keySerializer(Serializer.INTEGER) .valueSerializer(new StatusStorageSerializer()).createOrOpen(); return statusStorageMap; }
@Override public Map<Integer, SubscriberState> createMap() { if (storageFile == null) { //In-Memory Stats Storage db = DBMaker.memoryDB().make(); } else { db = DBMaker.fileDB(storageFile).closeOnJvmShutdown().transactionEnable() //Default to Write Ahead Log - lower performance, but has crash protection .make(); } statusStorageMap = db.hashMap("statusStorageMap").keySerializer(Serializer.INTEGER) .valueSerializer(new StatusStorageSerializer()).createOrOpen(); return statusStorageMap; }