Package com.sleepycat.je

Examples of com.sleepycat.je.XAEnvironment


             Integer.toString(N_ENTRIES));

        CheckpointConfig forceCheckpoint = new CheckpointConfig();
        forceCheckpoint.setForce(true);

        XAEnvironment env = new XAEnvironment(homeDir, envConfig);

        for (int i = 0; i < 2; i += 1) {
            boolean transactional = (i == 0);
            String dbName = transactional ? Utils.DB1_NAME : Utils.DB2_NAME;
           
            DatabaseConfig dbConfig = new DatabaseConfig();
            dbConfig.setAllowCreate(true);
            dbConfig.setTransactional(transactional);
            dbConfig.setSortedDuplicates(true);
            Database db = env.openDatabase(null, dbName, dbConfig);

            Transaction txn = null;
            if (transactional) {
                txn = env.beginTransaction(null, null);
            }

            /* Write: {0, 0}, {0, 1}, {1, 0}, {2, 0}, {3, 0} */
            for (int j = 0; j < N_ENTRIES; j += 1) {
                db.put(txn, Utils.entry(j), Utils.entry(0));
            }
            db.put(txn, Utils.entry(0), Utils.entry(1));

            /* Must checkpoint to generate BINDeltas. */
            env.checkpoint(forceCheckpoint);

            /* Delete everything but the last LN to cause IN deletion. */
            for (int j = 0; j < N_ENTRIES - 1; j += 1) {
                db.delete(txn, Utils.entry(j));
            }

            if (transactional) {
                txn.abort();
            }

            db.close();
        }

        /* Compress to delete DBIN, DIN, BIN, IN. */
        env.compress();

        /* DB2 was not aborted and will contain: {3, 0} */
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(false);
        dbConfig.setReadOnly(true);
        dbConfig.setSortedDuplicates(true);
        Database db = env.openDatabase(null, Utils.DB2_NAME, dbConfig);
        Cursor cursor = db.openCursor(null, null);
        try {
            DatabaseEntry key = new DatabaseEntry();
            DatabaseEntry data = new DatabaseEntry();
            OperationStatus status = cursor.getFirst(key, data, null);
            if (status != OperationStatus.SUCCESS) {
                throw new Exception("Expected SUCCESS but got: " + status);
            }
            if (Utils.value(key) != 3 || Utils.value(data) != 0) {
                throw new Exception("Expected {3,0} but got: {" +
                                    Utils.value(key) + ',' +
                                    Utils.value(data) + '}');
            }
        } finally {
            cursor.close();
        }
        db.close();

  XidImpl xid =
      new XidImpl(1, "MakeLogEntryVersionData".getBytes(), null);
  env.start(xid, XAResource.TMNOFLAGS);
  env.prepare(xid);
  env.rollback(xid);

        env.close();

        /*
         * Get the set of all log entry types we expect to output.  We punt on
         * one type -- MapLN -- because it is only a slight variant of the
         * transactional version and because cleaning would be necessary to
View Full Code Here


    JEManagedConnection(Subject subject, JERequestInfo jeInfo)
        throws ResourceException {

        try {
            savedTransConfig = jeInfo.getTransactionConfig();
            this.env = new XAEnvironment(jeInfo.getJERootDir(),
                                         jeInfo.getEnvConfig());
        } catch (DatabaseException DE) {
            throw new ResourceException(DE.toString());
        }
          listeners = new ArrayList<ConnectionEventListener>();
View Full Code Here

    JEManagedConnection(Subject subject, JERequestInfo jeInfo)
  throws ResourceException {

  try {
      savedTransConfig = jeInfo.getTransactionConfig();
      this.env = new XAEnvironment(jeInfo.getJERootDir(),
           jeInfo.getEnvConfig());
  } catch (DatabaseException DE) {
      throw new ResourceException(DE.toString());
  }
    listeners = new ArrayList();
View Full Code Here

      propertiesWithDefaults.getProperty(property));
    }
      }
  }
  try {
      env = new XAEnvironment(new File(directory), config);
  } catch (DatabaseException e) {
      throw convertException(e, false);
  } catch (Error e) {
      logger.logThrow(
    Level.SEVERE, e, "JeEnvironment initialization failed");
View Full Code Here

TOP

Related Classes of com.sleepycat.je.XAEnvironment

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.