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


Java DB.commit方法代码示例

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


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

示例1: setConnectionToDB

import org.mapdb.DB; //导入方法依赖的package包/类
public void setConnectionToDB(DockerConnection dc, File configFile, File certFile) throws IOException {
    File database = new File("./connections.db");
    DB db = DBMaker
            .fileDB(database)
            .transactionEnable()
            .closeOnJvmShutdown()
            .fileChannelEnable()
            .make();
    ConcurrentMap mapa = db.hashMap("map").createOrOpen();
    dc.getWithTls().setDockerCertPath(Paths.get("server/certs/").relativize(certFile.toPath()).toString());
    dc.getWithTls().setDockerConfig(Paths.get("server/certs/").relativize(configFile.toPath()).toString());
    mapa.put(dc.getName(), dc);
    db.commit();
    db.close();

}
 
开发者ID:petrleocompel,项目名称:docker-dash,代码行数:17,代码来源:DockerConnectionService.java

示例2: createUser

import org.mapdb.DB; //导入方法依赖的package包/类
@Override
public void createUser(String username, String password, UserProfile profile) throws UserExists, TException {
	final UserStorage storage = UsersPlugin.getInstance().getStorage();
	final DB db = storage.getTxMaker().makeTx();
	try {
		BTreeMap<String, User> userMap = storage.getUserMap(db);
		if (userMap.containsKey(username)) {
			throw new UserExists();
		}

		final String hashed = UserStorage.getPasswordService().encryptPassword(password);
		final User user = User.builder()
				.username(username)
				.hashedPassword(hashed)
				.realName(profile.realName)
				.isAdmin(profile.admin)
				.build();
		userMap.put(username, user);
		db.commit();
	} finally {
		db.close();
	}
}
 
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:24,代码来源:UserServlet.java

示例3: updateProfile

import org.mapdb.DB; //导入方法依赖的package包/类
@Override
public void updateProfile(String username, UserProfile profile) throws UserNotFound, TException {
	final UserStorage storage = UsersPlugin.getInstance().getStorage();
	final DB db = storage.getTxMaker().makeTx();
	try {
		final BTreeMap<String, User> userMap = storage.getUserMap(db);
		final User oldUser = userMap.get(username);
		if (oldUser == null) {
			throw new UserNotFound();
		}

		final User newUser = User.builder(oldUser)
				.realName(profile.realName)
				.isAdmin(profile.admin)
				.build();
		userMap.put(username, newUser);
		db.commit();
	} finally {
		db.close();
	}
}
 
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:22,代码来源:UserServlet.java

示例4: updatePassword

import org.mapdb.DB; //导入方法依赖的package包/类
@Override
public void updatePassword(String username, String password) throws UserNotFound, TException {
	final UserStorage storage = UsersPlugin.getInstance().getStorage();
	final DB db = storage.getTxMaker().makeTx();
	try {
		final BTreeMap<String, User> userMap = storage.getUserMap(db);
		final User oldUser = userMap.get(username);
		if (oldUser == null) {
			throw new UserNotFound();
		}

		final String hashed = UserStorage.getPasswordService().encryptPassword(password);
		final User newUser = User.builder(oldUser).hashedPassword(hashed).build();
		userMap.put(username, newUser);
		db.commit();
	} finally {
		db.close();
	}
}
 
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:20,代码来源:UserServlet.java

示例5: testUseExistingRootIfPossible

import org.mapdb.DB; //导入方法依赖的package包/类
@Test
public void testUseExistingRootIfPossible() throws Exception {
    // Given a non-empty root in the manifest
    File dbFile = createTempFile();
    DB db = MapDbUtils.createFileDb(dbFile);
    manifest = new MapDbManifest(db);
    TreeItem item = new TreeItem(Entry.Type.BLOB, "foo", "foo.txt", 0);
    Tree root = new Tree(MapDbManifest.ROOT_KEY, Collections.singletonList(item));
    manifest.put(root);

    // When you reopen the db
    db.commit();
    db.close();
    db = MapDbUtils.createFileDb(dbFile);
    manifest = new MapDbManifest(db);

    // Then the root contains the saved items
    List<TreeItem> items = manifest.getRoot().getItems();
    assertEquals(1, items.size());
    assertEquals(item, items.get(0));
}
 
开发者ID:omnidrive,项目名称:omnidrive,代码行数:22,代码来源:MapDbManifestTest.java

示例6: compile

import org.mapdb.DB; //导入方法依赖的package包/类
static void compile(String file, String database){
	DB db = DBMaker.newFileDB(new File(database)).compressionEnable().closeOnJvmShutdown().make();
	NavigableSet<Tuple2<String, Tuple2<String,Double>>> multiset = db.getTreeSet("SW");
	multiset.clear();
	try {
		BufferedReader swFile = new BufferedReader(new InputStreamReader(new BZip2InputStream(new FileInputStream(new File(file)), false), "UTF-8"));
		int entry = 0;
		for(String line=swFile.readLine();line != null;line = swFile.readLine()){
			String key = line.trim();
			String[] values = swFile.readLine().trim().split(" ");
			for(int i = 1;i < values.length;i += 2){
				multiset.add(Fun.t2(key, Fun.t2(values[i-1], Double.parseDouble(values[i]))));
			}
			if(entry++ > 100){
				db.commit();
				entry = 0;
			}
		}
		swFile.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	db.commit();
	db.close();
}
 
开发者ID:tticoin,项目名称:JointER,代码行数:26,代码来源:NICTNounSynonymsDB.java

示例7: main

import org.mapdb.DB; //导入方法依赖的package包/类
public static void main(String[] args) {
	if (args.length != 2){
		logger.error(usage);
		System.exit(1);
	}
	
	RecordReader<WikipediaLabelToFreebaseRecord> reader = new RecordReader<WikipediaLabelToFreebaseRecord>(
			args[0], new WikipediaLabelToFreebaseRecord.Parser());
	File f = new File(args[1]);
	if (!f.exists()) {
		f.mkdirs();
	}
	File dbfile = new File(f, "freebase.db");
	DB db = DBMaker.fileDB(dbfile).fileMmapEnable().closeOnJvmShutdown().make();
	ProgressLogger pl = new ProgressLogger("indexed {} records", 100000);
	HTreeMap<String, String> map = db.hashMap("index", Serializer.STRING, Serializer.STRING).createOrOpen();
	HTreeMap<String, String> labels = db.hashMap("label", Serializer.STRING, Serializer.STRING).createOrOpen();
	for (WikipediaLabelToFreebaseRecord record : reader) {
		map.put(record.getCleanWikipediaLabel(), record.getFreebaseId());
		labels.put(record.getFreebaseId(), record.getLabel());
		pl.up();
	}
	db.commit();
	db.close();

	logger.info("file indexed, index in {}", args[1]);

}
 
开发者ID:marcocor,项目名称:smaph,代码行数:29,代码来源:IndexWikipediaFreebase.java

示例8: test

import org.mapdb.DB; //导入方法依赖的package包/类
/**
     * 测试provider注册
     */
    public void test(DB db) {

        
                //create new collection (or open existing)
                ConcurrentNavigableMap map = db.getTreeMap("collectionName");
                map.put(1,"one");
                map.put(new Random().nextInt(25500),"bnt_test" + new Random().nextInt(25005));
                //persist changes into disk, there is also rollback() method
                db.commit();
//                db.close();
                cnt.incrementAndGet();
    }
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:16,代码来源:TestMapDB.java

示例9: setProperty

import org.mapdb.DB; //导入方法依赖的package包/类
public synchronized void setProperty(String property, String value) {
	AssertionUtils.assertNotNull(new IllegalArgumentException("property"), property);
	AssertionUtils.assertNotNull(new IllegalArgumentException("value"), value);
	DB db = getDB(false);
	try {
		getMap(db).put(property, value);
		db.commit();
	} finally  {
		db.close();
	}		
}
 
开发者ID:AKSW,项目名称:KBox,代码行数:12,代码来源:CustomParams.java

示例10: add

import org.mapdb.DB; //导入方法依赖的package包/类
public synchronized void add(String value) {
	AssertionUtils.assertNotNull(new IllegalArgumentException("value"), value);
	DB db = getDB(false);
	try {
		getSet(db).add(value);
		db.commit();
	} finally  {
		db.close();
	}
}
 
开发者ID:AKSW,项目名称:KBox,代码行数:11,代码来源:CustomParams.java

示例11: remove

import org.mapdb.DB; //导入方法依赖的package包/类
public void remove(String value) {
	DB db = getDB(false);
	try {
		getSet(db).remove(value);
		db.commit();
	} finally  {
		db.close();
	}	
}
 
开发者ID:AKSW,项目名称:KBox,代码行数:10,代码来源:CustomParams.java

示例12: markReplayAsParsed

import org.mapdb.DB; //导入方法依赖的package包/类
@Override
public void markReplayAsParsed(Replay replay) {
    DB db = initDatabase(dbFileReplays);
    Set<Replay> replays = getReplays(db);
    if (replays.contains(replay)) {
        MyLogger.getLogger().info("Replay is already contained.");
        replay.setParsedMoreTimes(true);
        replays.remove(replay);
    }
    replays.add(replay);
    db.commit();
    db.close();
}
 
开发者ID:honzaMaly,项目名称:kusanagi,代码行数:14,代码来源:StorageServiceImp.java

示例13: deleteUser

import org.mapdb.DB; //导入方法依赖的package包/类
@Override
public void deleteUser(String username) throws UserNotFound, TException {
	final UserStorage storage = UsersPlugin.getInstance().getStorage();
	final DB db = storage.getTxMaker().makeTx();
	try {
		final BTreeMap<String, User> userMap = storage.getUserMap(db);
		if (!userMap.containsKey(username)) {
			throw new UserNotFound();
		}
		userMap.remove(username);
		db.commit();
	} finally {
		db.close();
	}
}
 
开发者ID:mondo-project,项目名称:mondo-integration,代码行数:16,代码来源:UserServlet.java

示例14: onChunkRemoved

import org.mapdb.DB; //导入方法依赖的package包/类
@Override
public void onChunkRemoved(RDSStore origin, Long start, Long length) {

    TraceRecordStore traceIndexStore = getTraceIndexStore();
    BTreeMap<Long,TraceInfoRecord> infos = getInfos();
    DB db = getDb();

    long end = start + length - 1;
    long t0 = System.currentTimeMillis();

    log.info("Removing old index entries for host " + name);
    long idxOffs = -1;
    int count = 0;
    if (infos != null && db != null) {
        Map.Entry<Long, TraceInfoRecord> nextEntry = infos.ceilingEntry(end);
        idxOffs = nextEntry != null ? nextEntry.getValue().getIndexOffs()-1 : -1;
        ConcurrentNavigableMap<Long, TraceInfoRecord> rmitems = infos.headMap(end);
        count = rmitems.size();
        rmitems.clear();
        db.commit();
    }

    if (idxOffs > 0 && traceIndexStore != null) {
        try {
            log.info("Cleaning up index RDS for host " + name + " (idxOffs=" + idxOffs + ")");
            traceIndexStore.getRds().cleanup(idxOffs);
        } catch (IOException e) {
            log.error("Problem cleaning up index store", e);
        }
    }
    long t = System.currentTimeMillis() - t0;
    log.info("Removing " + count + " entries from " + name + " took " + t + "ms.");
}
 
开发者ID:jitlogic,项目名称:zico,代码行数:34,代码来源:HostStore.java

示例15: execute

import org.mapdb.DB; //导入方法依赖的package包/类
@Override
public void execute(ITransactionCall<IVelvet> transaction) {
    DB db = txMaker.makeTx();
    try {
        transaction.execute(new MapDbVelvet(db, serializerSupplier));
        db.commit();
    } catch (Throwable e) {
        db.rollback();
        throw (e instanceof RuntimeException) ? (RuntimeException)e : new VelvetException(e);
    } finally {
        db.close();
    }
}
 
开发者ID:zakgof,项目名称:velvetdb,代码行数:14,代码来源:MapDbVelvetEnv.java


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