Package com.sleepycat.je

Examples of com.sleepycat.je.Database


  }
        dbConfig.setTransactional(env.getConfig().getTransactional());
        dbConfig.setSortedDuplicates(true);
        dbConfig.setReadOnly(true);
        for (int d = startDb; d < endDb; d++) {
            Database checkDb = env.openDatabase(null, DB_NAME + d,
            dbConfig);
            Cursor myCursor = checkDb.openCursor(null, null);
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry data = new DatabaseEntry();
            OperationStatus status =
    myCursor.getFirst(key, data, LockMode.DEFAULT);
            DbInternal.envGetEnvironmentImpl(env).verifyCursors();
            int numSeen = 0;

            while (status == OperationStatus.SUCCESS) {

                /* The key should have been in the expected data set. */
                removeExpectedData(useData, d, key, data, true);

                /* The count should be right. */
                int count = myCursor.count();
                assertEquals("Count not right for key " +
                             TestUtils.dumpByteArray(key.getData()),
                             getExpectedCount(countMap, d, key), count);
               
                status = myCursor.getNext(key, data, LockMode.DEFAULT);
                numSeen++;
            }

            myCursor.close();

            /* Should be nothing left in the expected data map. */
            if (DEBUG) {
                System.out.println("Finished db" + d + " numSeen=" +numSeen);
                dumpExpected(useData);
            }
            checkDb.close();
        }

        assertEquals(0, useData.size());
    }
View Full Code Here


                /* Unload any db handles protected by this txn. */
                if (handleToHandleLockMap != null) {
                    Iterator handleIter =
                        handleToHandleLockMap.keySet().iterator();
                    while (handleIter.hasNext()){
                        Database handle = (Database) handleIter.next();
                        DbInternal.dbInvalidate(handle);
                    }
                }

                return abortLsn;
View Full Code Here

      dbConfig.setBtreeComparator(btreeComparisonFunction.getClass());
  }
        dbConfig.setSortedDuplicates(true);
  dbConfig.setTransactional(true);
        for (int d = 0; d < numDbs; d++) {
            Database checkDb = env.openDatabase(null, DB_NAME + d, dbConfig);
            Cursor myCursor = checkDb.openCursor(null, null);
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry data = new DatabaseEntry();

            OperationStatus status =
    myCursor.getFirst(key, data, LockMode.DEFAULT);
View Full Code Here

    public void testCursorDupAndCloseDb()
  throws DatabaseException {
        initEnv(false);
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        Database myDb = exampleEnv.openDatabase(null, "fooDb", dbConfig);

  myDb.put(null, new StringDbt("blah"), new StringDbt("blort"));
  Cursor cursor = myDb.openCursor(null, null);
  OperationStatus status = cursor.getNext(new DatabaseEntry(),
                                                new DatabaseEntry(),
                                                LockMode.DEFAULT);
  Cursor cursorDup = cursor.dup(true);
  cursor.close();
  cursorDup.close();
  myDb.close();
    }
View Full Code Here

        /* Open db. */
        initEnv(false);
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        Database myDb = exampleEnv.openDatabase(null, "fooDb", dbConfig);

        /* Open uninitialized cursor. */
        Cursor c1 = myDb.openCursor(null, null);
        try {
            c1.getCurrent(new DatabaseEntry(), new DatabaseEntry(), null);
            fail();
        } catch (DatabaseException expected) {}

        /* Dup uninitialized cursor with samePosition=false. */
        Cursor c2 = c1.dup(false);
        try {
            c2.getCurrent(new DatabaseEntry(), new DatabaseEntry(), null);
            fail();
        } catch (DatabaseException expected) {}

        /* Dup uninitialized cursor with samePosition=true. */
        Cursor c3 = c1.dup(true);
        try {
            c3.getCurrent(new DatabaseEntry(), new DatabaseEntry(), null);
            fail();
        } catch (DatabaseException expected) {}

        /* Ensure dup'ed cursors are usable. */
        assertEquals(OperationStatus.SUCCESS,
                     c1.put(new DatabaseEntry(new byte[0]),
                            new DatabaseEntry(new byte[0])));
        assertEquals(OperationStatus.SUCCESS,
                     c2.getFirst(new DatabaseEntry(), new DatabaseEntry(),
                                 null));
        assertEquals(OperationStatus.NOTFOUND,
                     c2.getNext(new DatabaseEntry(), new DatabaseEntry(),
                                 null));
        assertEquals(OperationStatus.SUCCESS,
                     c3.getFirst(new DatabaseEntry(), new DatabaseEntry(),
                                 null));
        assertEquals(OperationStatus.NOTFOUND,
                     c3.getNext(new DatabaseEntry(), new DatabaseEntry(),
                                 null));

        /* Close db. */
        c3.close();
        c2.close();
        c1.close();
  myDb.close();
    }
View Full Code Here

      DatabaseEntry data = new DatabaseEntry(new byte[] { 4, 3, 2, 1 });
      DatabaseConfig dbConfig = new DatabaseConfig();
      dbConfig.setAllowCreate(true);
      dbConfig.setSortedDuplicates(false);
      dbConfig.setTransactional(true);
            Database otherDb = env.openDatabase(txn1, "extradb", dbConfig);
      otherDb.put(txn1, key, data);

            /* Delete all and abort. */
            txn = env.beginTransaction(null, null);
            deleteData(txn, expectedData, false, false, NUM_DBS);
            txn.abort();

            /* Delete all and commit. */
            txn = env.beginTransaction(null, null);
            deleteData(txn, expectedData, false, true, NUM_DBS);
            txn.commit();

      env.sync(); /* env.checkpoint does not seem to be sufficient. */
            txn1.commit();
      otherDb.close();

      closeEnv();

            if (DEBUG) {
                dumpData(NUM_DBS);
View Full Code Here

      DatabaseEntry data = new DatabaseEntry(new byte[] { 4, 3, 2, 1 });
      DatabaseConfig dbConfig = new DatabaseConfig();
      dbConfig.setAllowCreate(true);
      dbConfig.setSortedDuplicates(false);
      dbConfig.setTransactional(true);
            Database otherDb = env.openDatabase(txn1, "extradb", dbConfig);
      otherDb.put(txn1, key, data);

            /* Delete all and abort. */
            txn = env.beginTransaction(null, null);
            deleteData(txn, expectedData, false, false, NUM_DBS);
            txn.abort();

            /* Delete all and commit. */
            txn = env.beginTransaction(null, null);
            deleteData(txn, expectedData, false, true, NUM_DBS);
            txn.commit();

      env.sync(); /* env.checkpoint does not seem to be sufficient. */
            txn1.commit();
      otherDb.close();

      closeEnv();

            if (DEBUG) {
                dumpData(NUM_DBS);
View Full Code Here

            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setTransactional(true);
            dbConfig.setAllowCreate(true);
            for (int i = 0; i < N2; i++) {
                Database db = env.openDatabase(txn, dbName1 + i, dbConfig);
            }
            txn.abort();
           
            /* All dbs should not exist */
            checkForNoDb(dbName1, 0, N2);

            /* Make more dbs, overlapping with some of the aborted set. */
            txn = env.beginTransaction(null, null);
            for (int i = N1; i < N5; i++) {
                Database db = env.openDatabase(txn, dbName1 + i, dbConfig);
                db.close();
            }
            txn.commit();

            /*
             * Dbs 0  - N1-1 shouldn't exist
View Full Code Here

         
        /* Dbs start - end -1  shouldn't exist */
        Properties emptyProps = new Properties();
        for (int i = start; i < end; i++) {
            try {
                Database checkDb = env.openDatabase(null, dbName + i, null);
                fail(DB_NAME + i + " shouldn't exist");
            } catch (DatabaseException e) {
            }
        }
    }
View Full Code Here

        Properties emptyProps = new Properties();

        /* Dbs start - end -1  should exist. */
        for (int i = start; i < end; i++) {
            try {
                Database checkDb = env.openDatabase(null, dbName + i, null);
                checkDb.close();
            } catch (DatabaseException e) {
                fail(e.getMessage());
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.je.Database

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.