Package com.sleepycat.je

Examples of com.sleepycat.je.Transaction


        if (triggers == null) {
            return;
        }

        Transaction triggerTransaction =
            (locker instanceof Txn) ? ((Txn)locker).getTransaction() : null;

        try {
            for (Trigger trigger : triggers) {
                Trigger dbt = trigger;
View Full Code Here


            protected String fun(Trigger e) {
                return e.getName();
            }
        }.run(new HashSet<String>());

        Transaction txn = (locker instanceof Txn) ?
                ((Txn)locker).getTransaction() : null;

        /* First invoke removeTrigger */
        if (oldTriggers != null) {
            for (Trigger trigger : oldTriggers) {
View Full Code Here

                rndKeys.add(i);
            }
            Collections.shuffle(rndKeys, new Random(123));
        }

        final Transaction txn = env.beginTransaction(null, null);
        final Cursor cursor = db.openCursor(txn, null);
        boolean success = false;
        try {
            cursor.setCacheMode(CacheMode.EVICT_LN);
            for (int i = 0; i <= lastKey; i += 1) {
                final int keyVal = orderedInsertion ? i : rndKeys.get(i);
                byte[] keyBytes = padLeft
                    (BigInteger.valueOf(keyVal).toByteArray(), maxKeyBytes);
                setKeyData(keyBytes, keyOffset, keyEntry, dataEntry);

                final OperationStatus status;
                if (duplicates) {
                    status = cursor.putNoDupData(keyEntry, dataEntry);
                } else {
                    status = cursor.putNoOverwrite(keyEntry, dataEntry);
                }
                if (status == OperationStatus.KEYEXIST && !orderedInsertion) {
                    i -= 1;
                    continue;
                }
                if (status != OperationStatus.SUCCESS) {
                    throw new IllegalStateException("Could not insert: " +
                                                    status);
                }

                if (i % 10000 == 0) {
                    final EnvironmentStats stats = env.getStats(null);
                    if (stats.getNNodesScanned() > 0) {
                        throw new IllegalStateException
                            ("*** Ran out of cache memory at record " + i +
                             " -- try increasing Java heap size ***");
                    }
                    if (out != null) {
                        out.print(".");
                        out.flush();
                    }
                }
            }
            success = true;
        } finally {
            cursor.close();
            if (success) {
                txn.commit();
            } else {
                txn.abort();
            }
        }

        /* Checkpoint to reset the memory budget. */
        env.checkpoint(new CheckpointConfig().setForce(true));
View Full Code Here

      if (!transactional)
      {
         throw new UnsupportedOperationException(
               "prepare() not allowed with a non-transactional cache loader");
      }
      Transaction txn = performTransaction(modifications);
      if (onePhase)
      {
         txn.commit();
      }
      else
      {
         txnMap.put(tx, txn);
      }
View Full Code Here

   private void commitModifications(List<Modification> mods)
         throws Exception
   {

      if (!transactional) throw new IllegalStateException();
      Transaction txn = performTransaction(mods);
      txn.commit();
   }
View Full Code Here

       */

      int retries = MAX_TXN_RETRIES;
      while (true)
      {
         Transaction txn = env.beginTransaction(null, null);
         try
         {
            doPut(txn, modifications);
            return txn;
         }
         catch (Exception e)
         {
            txn.abort();
            if (e instanceof DeadlockException && retries > 0)
            {
               retries -= 1;
            }
            else
View Full Code Here

   {

      checkOpen();
      checkNonNull(tx, "tx");

      Transaction txn = txnMap.remove(tx);
      if (txn != null)
      {
         txn.commit();
      }
      else if (transactional)
      {
         throw new IllegalArgumentException("Unknown txn key: " + tx);
      }
View Full Code Here

   {

      checkOpen();
      checkNonNull(tx, "tx");

      Transaction txn = txnMap.remove(tx);
      if (txn != null)
      {
         try
         {
            txn.abort();
         }
         catch (Exception ignored)
         {
         }
      }
View Full Code Here

        Environment env = new Environment(envDir, envConfig);
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setReadOnly(true);
        dbConfig.setTransactional(true);
        dbConfig.setAllowCreate(false);
        Transaction txn = env.beginTransaction(null, null);
        Database db = env.openDatabase(txn, DbType.REP_GROUP.getInternalName(),
                                       dbConfig);

        DatabaseEntry groupEntry = new DatabaseEntry();
        OperationStatus status =
            db.get(txn, groupKeyEntry, groupEntry, LockMode.READ_COMMITTED);
        if (status != OperationStatus.SUCCESS) {
            throw new IllegalStateException
                ("Group entry not found " + status);
        }
        GroupBinding groupBinding = new GroupBinding();
        RepGroupImpl group = groupBinding.entryToObject(groupEntry);

        group = fetchGroup(group.getName(),
                           DbInternal.getDatabaseImpl(db),
                           DbInternal.getTxn(txn));
        txn.commit();
        db.close();
        env.close();
        return group;
    }
View Full Code Here

            /*
             * If master, start a transaction as a way of ascertaining whether
             * all nodes are up. Since the ReplicaAckPolicy is ALL, the
             * transaction will only begin when all the nodes are available.
             */
            Transaction txn = repEnv.beginTransaction(null, null);
            txn.abort();

            /* Invoke the group shutdown API. */
            repEnv.shutdownGroup(timeout, TimeUnit.SECONDS);
        } else if (repEnv.getState().isReplica()) {
            for (long i = 0; i < timeout; i++) {
View Full Code Here

TOP

Related Classes of com.sleepycat.je.Transaction

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.