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


Java SecondaryDatabase.close方法代码示例

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


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

示例1: testReadOnly

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testReadOnly()
    throws DatabaseException {

    SecondaryDatabase secDb = initDb();
    Database priDb = secDb.getPrimaryDatabase();
    OperationStatus status;
    Transaction txn = txnBegin();

    for (int i = 0; i < NUM_RECS; i += 1) {
        status = priDb.put(txn, entry(i), entry(i));
        assertSame(OperationStatus.SUCCESS, status);
    }

    /*
     * Secondaries can be opened without a key creator if the primary is
     * read only.  openSecondary will specify a null key creator if the
     * readOnly param is false.
     */
    Database readOnlyPriDb = openDatabase(false, "testDB", true);
    SecondaryDatabase readOnlySecDb = openSecondary(readOnlyPriDb,
                                                    true, "testSecDB",
                                                    false, true);
    assertNull(readOnlySecDb.getSecondaryConfig().getKeyCreator());
    verifyRecords(txn, readOnlySecDb, NUM_RECS, true);

    txnCommit(txn);
    readOnlySecDb.close();
    readOnlyPriDb.close();
    secDb.close();
    priDb.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:32,代码来源:SecondaryTest.java

示例2: testTruncate

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testTruncate()
    throws DatabaseException {

    SecondaryDatabase secDb = initDb();
    Database priDb = secDb.getPrimaryDatabase();
    Transaction txn = txnBegin();

    for (int i = 0; i < NUM_RECS; i += 1) {
        priDb.put(txn, entry(i), entry(i));
    }
    verifyRecords(txn, priDb, NUM_RECS, false);
    verifyRecords(txn, secDb, NUM_RECS, true);
    txnCommit(txn);
    secDb.close();
    priDb.close();

    txn = txnBegin();
    assertEquals(NUM_RECS, env.truncateDatabase(txn, "testDB", true));
    assertEquals(NUM_RECS, env.truncateDatabase(txn, "testSecDB", true));
    txnCommit(txn);

    secDb = initDb();
    priDb = secDb.getPrimaryDatabase();

    txn = txnBegin();
    verifyRecords(txn, priDb, 0, false);
    verifyRecords(txn, secDb, 0, true);
    txnCommit(txn);

    secDb.close();
    priDb.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:33,代码来源:SecondaryTest.java

示例3: testReadOnly

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testReadOnly()
    throws DatabaseException {

    SecondaryDatabase secDb = initDb();
    Database priDb = secDb.getPrimaryDatabase();
    OperationStatus status;
    Transaction txn = txnBegin();

    for (int i = 0; i < NUM_RECS; i += 1) {
        status = priDb.put(txn, entry(i), entry(i));
        assertSame(OperationStatus.SUCCESS, status);
    }

    /*
     * Secondaries can be opened without a key creator if the primary is
     * read only.  openSecondary will specify a null key creator if the 
     * readOnly param is false.
     */
    Database readOnlyPriDb = openDatabase(false, "testDB", true);
    SecondaryDatabase readOnlySecDb = openSecondary(readOnlyPriDb,
                                                    true, "testSecDB",
                                                    false, true);
    assertNull(readOnlySecDb.getSecondaryConfig().getKeyCreator());
    verifyRecords(txn, readOnlySecDb, NUM_RECS, true);

    txnCommit(txn);
    readOnlySecDb.close();
    readOnlyPriDb.close();
    secDb.close();
    priDb.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:32,代码来源:SecondaryTest.java

示例4: testTruncate

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testTruncate()
    throws DatabaseException {

    SecondaryDatabase secDb = initDb();
    Database priDb = secDb.getPrimaryDatabase();
    Transaction txn = txnBegin();
    
    for (int i = 0; i < NUM_RECS; i += 1) {
        priDb.put(txn, entry(i), entry(i));
    }
    verifyRecords(txn, priDb, NUM_RECS, false);
    verifyRecords(txn, secDb, NUM_RECS, true);
    txnCommit(txn);
    secDb.close();
    priDb.close();

    txn = txnBegin();
    assertEquals(NUM_RECS, env.truncateDatabase(txn, "testDB", true));
    assertEquals(NUM_RECS, env.truncateDatabase(txn, "testSecDB", true));
    txnCommit(txn);

    secDb = initDb();
    priDb = secDb.getPrimaryDatabase();

    txn = txnBegin();
    verifyRecords(txn, priDb, 0, false);
    verifyRecords(txn, secDb, 0, true);
    txnCommit(txn);

    secDb.close();
    priDb.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:33,代码来源:SecondaryTest.java

示例5: close

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
void close() {
	if (myEnv != null) {
		try {
			db.close();
			for (final SecondaryDatabase index : indexMap.values()) {
				index.close();
			}
			// Finally, close the environment.
			myEnv.close();
		} catch (final DatabaseException dbe) {
			System.err.println("Error closing MyDbEnv: " + dbe.toString());
			System.exit(-1);
		}
	}
}
 
开发者ID:KleeGroup,项目名称:vertigo-labs,代码行数:16,代码来源:BerkeleyDatabase.java

示例6: testOpenAndClose

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testOpenAndClose()
    throws DatabaseException {

    Database priDb = openDatabase(false, "testDB", false);

    /* Open two secondaries as regular databases and as secondaries. */
    Database secDbDetached = openDatabase(true, "testSecDB", false);
    SecondaryDatabase secDb = openSecondary(priDb, true, "testSecDB",
                                            false, false);
    Database secDb2Detached = openDatabase(true, "testSecDB2", false);
    SecondaryDatabase secDb2 = openSecondary(priDb, true, "testSecDB2",
                                             false, false);
    assertEquals(priDb.getSecondaryDatabases(),
                 Arrays.asList(new SecondaryDatabase[] {secDb, secDb2}));

    Transaction txn = txnBegin();

    /* Check that primary writes to both secondaries. */
    checkSecondaryUpdate(txn, priDb, 1, secDbDetached, true,
                                        secDb2Detached, true);

    /* New txn before closing database. */
    txnCommit(txn);
    txn = txnBegin();

    /* Close 2nd secondary. */
    secDb2.close();
    assertEquals(priDb.getSecondaryDatabases(),
                 Arrays.asList(new SecondaryDatabase[] {secDb }));

    /* Check that primary writes to 1st secondary only. */
    checkSecondaryUpdate(txn, priDb, 2, secDbDetached, true,
                                         secDb2Detached, false);

    /* New txn before closing database. */
    txnCommit(txn);
    txn = txnBegin();

    /* Close 1st secondary. */
    secDb.close();
    assertEquals(0, priDb.getSecondaryDatabases().size());

    /* Check that primary writes to no secondaries. */
    checkSecondaryUpdate(txn, priDb, 3, secDbDetached, false,
                                        secDb2Detached, false);

    /* Open the two secondaries again. */
    secDb = openSecondary(priDb, true, "testSecDB", false, false);
    secDb2 = openSecondary(priDb, true, "testSecDB2", false, false);
    assertEquals(priDb.getSecondaryDatabases(),
                 Arrays.asList(new SecondaryDatabase[] {secDb, secDb2}));

    /* Check that primary writes to both secondaries. */
    checkSecondaryUpdate(txn, priDb, 4, secDbDetached, true,
                                        secDb2Detached, true);

    /* Close the primary first to disassociate secondaries. */
    txnCommit(txn);
    priDb.close();
    assertNull(secDb.getPrimaryDatabase());
    assertNull(secDb2.getPrimaryDatabase());
    secDb2.close();
    secDb.close();

    secDb2Detached.close();
    secDbDetached.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:68,代码来源:SecondaryTest.java

示例7: testPopulate

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testPopulate()
    throws DatabaseException {

    Database priDb = openDatabase(false, "testDB", false);
    Transaction txn = txnBegin();

    /* Test population of newly created secondary database. */

    for (int i = 0; i < NUM_RECS; i += 1) {
        assertSame(OperationStatus.SUCCESS,
                   priDb.put(txn, entry(i), entry(i)));
    }
    txnCommit(txn);

    SecondaryDatabase secDb = openSecondary(priDb, true, "testSecDB",
                                            true, false);
    txn = txnBegin();
    verifyRecords(txn, secDb, NUM_RECS, true);
    txnCommit(txn);

    /*
     * Clear secondary and perform populate again, to test the case where
     * an existing database is opened, and therefore a write txn will only
     * be created in order to populate it
     */
    Database secDbDetached = openDatabase(true, "testSecDB", false);
    secDb.close();
    txn = txnBegin();
    for (int i = 0; i < NUM_RECS; i += 1) {
        assertSame(OperationStatus.SUCCESS,
                   secDbDetached.delete(txn, entry(i + KEY_OFFSET)));
    }
    verifyRecords(txn, secDbDetached, 0, true);
    txnCommit(txn);
    secDb = openSecondary(priDb, true, "testSecDB", true, false);
    txn = txnBegin();
    verifyRecords(txn, secDb, NUM_RECS, true);
    verifyRecords(txn, secDbDetached, NUM_RECS, true);

    txnCommit(txn);
    secDbDetached.close();
    secDb.close();
    priDb.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:45,代码来源:SecondaryTest.java

示例8: testDirtyReadPartialGet

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
/**
 * [#14966]
 */
public void testDirtyReadPartialGet()
    throws DatabaseException {

    SecondaryDatabase secDb = initDb();
    Database priDb = secDb.getPrimaryDatabase();

    DatabaseEntry data = new DatabaseEntry();
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry secKey = new DatabaseEntry();
    OperationStatus status;

    /* Put a record */
    Transaction txn = txnBegin();
    status = priDb.put(txn, entry(0), entry(0));
    assertSame(OperationStatus.SUCCESS, status);
    txnCommit(txn);

    /* Regular get */
    status = secDb.get(null, entry(0 + KEY_OFFSET), key,
                       data, LockMode.DEFAULT);
    assertSame(OperationStatus.SUCCESS, status);
    assertDataEquals(entry(0), key);
    assertDataEquals(entry(0), data);

    /* Dirty read returning no data */
    data.setPartial(0, 0, true);
    status = secDb.get(null, entry(0 + KEY_OFFSET), key,
                       data, LockMode.READ_UNCOMMITTED);
    assertSame(OperationStatus.SUCCESS, status);
    assertDataEquals(entry(0), key);
    assertEquals(0, data.getData().length);
    assertEquals(0, data.getSize());

    /* Dirty read returning partial data */
    data.setPartial(0, 1, true);
    status = secDb.get(null, entry(0 + KEY_OFFSET), key,
                       data, LockMode.READ_UNCOMMITTED);
    assertSame(OperationStatus.SUCCESS, status);
    assertDataEquals(entry(0), key);
    assertEquals(1, data.getData().length);
    assertEquals(1, data.getSize());

    secDb.close();
    priDb.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:49,代码来源:SecondaryTest.java

示例9: testOpenAndClose

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testOpenAndClose()
    throws DatabaseException {

    Database priDb = openDatabase(false, "testDB", false);

    /* Open two secondaries as regular databases and as secondaries. */
    Database secDbDetached = openDatabase(true, "testSecDB", false);
    SecondaryDatabase secDb = openSecondary(priDb, true, "testSecDB",
                                            false, false);
    Database secDb2Detached = openDatabase(true, "testSecDB2", false);
    SecondaryDatabase secDb2 = openSecondary(priDb, true, "testSecDB2",
                                             false, false);
    assertEquals(priDb.getSecondaryDatabases(),
                 Arrays.asList(new SecondaryDatabase[] {secDb, secDb2}));

    Transaction txn = txnBegin();

    /* Check that primary writes to both secondaries. */
    checkSecondaryUpdate(txn, priDb, 1, secDbDetached, true,
                                        secDb2Detached, true);
    
    /* New txn before closing database. */
    txnCommit(txn);
    txn = txnBegin();

    /* Close 2nd secondary. */
    secDb2.close();
    assertEquals(priDb.getSecondaryDatabases(),
                 Arrays.asList(new SecondaryDatabase[] {secDb }));

    /* Check that primary writes to 1st secondary only. */
    checkSecondaryUpdate(txn, priDb, 2, secDbDetached, true,
                                         secDb2Detached, false);
    
    /* New txn before closing database. */
    txnCommit(txn);
    txn = txnBegin();

    /* Close 1st secondary. */
    secDb.close();
    assertEquals(0, priDb.getSecondaryDatabases().size());

    /* Check that primary writes to no secondaries. */
    checkSecondaryUpdate(txn, priDb, 3, secDbDetached, false,
                                        secDb2Detached, false);

    /* Open the two secondaries again. */
    secDb = openSecondary(priDb, true, "testSecDB", false, false);
    secDb2 = openSecondary(priDb, true, "testSecDB2", false, false);
    assertEquals(priDb.getSecondaryDatabases(),
                 Arrays.asList(new SecondaryDatabase[] {secDb, secDb2}));

    /* Check that primary writes to both secondaries. */
    checkSecondaryUpdate(txn, priDb, 4, secDbDetached, true,
                                        secDb2Detached, true);

    /* Close the primary first to disassociate secondaries. */
    txnCommit(txn);
    priDb.close();
    assertNull(secDb.getPrimaryDatabase());
    assertNull(secDb2.getPrimaryDatabase());
    secDb2.close();
    secDb.close();

    secDb2Detached.close();
    secDbDetached.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:68,代码来源:SecondaryTest.java

示例10: testPopulate

import com.sleepycat.je.SecondaryDatabase; //导入方法依赖的package包/类
public void testPopulate()
    throws DatabaseException {

    Database priDb = openDatabase(false, "testDB", false);
    Transaction txn = txnBegin();

    /* Test population of newly created secondary database. */
    
    for (int i = 0; i < NUM_RECS; i += 1) {
        assertSame(OperationStatus.SUCCESS, 
                   priDb.put(txn, entry(i), entry(i)));
    }
    txnCommit(txn);

    SecondaryDatabase secDb = openSecondary(priDb, true, "testSecDB",
                                            true, false);
    txn = txnBegin();
    verifyRecords(txn, secDb, NUM_RECS, true);
    txnCommit(txn);

    /*
     * Clear secondary and perform populate again, to test the case where
     * an existing database is opened, and therefore a write txn will only
     * be created in order to populate it
     */
    Database secDbDetached = openDatabase(true, "testSecDB", false);
    secDb.close();
    txn = txnBegin();
    for (int i = 0; i < NUM_RECS; i += 1) {
        assertSame(OperationStatus.SUCCESS, 
                   secDbDetached.delete(txn, entry(i + KEY_OFFSET)));
    }
    verifyRecords(txn, secDbDetached, 0, true);
    txnCommit(txn);
    secDb = openSecondary(priDb, true, "testSecDB", true, false);
    txn = txnBegin();
    verifyRecords(txn, secDb, NUM_RECS, true);
    verifyRecords(txn, secDbDetached, NUM_RECS, true);

    txnCommit(txn);
    secDbDetached.close();
    secDb.close();
    priDb.close();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:45,代码来源:SecondaryTest.java


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