Package org.exist.storage.txn

Examples of org.exist.storage.txn.Txn


            stopDB();
        }
    }

    private Collection storeDocs(DBBroker broker, TransactionManager transact) throws Exception {
        Txn transaction = transact.beginTransaction();
        assertNotNull(transaction);
        System.out.println("Transaction started ...");

        Collection test = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
        assertNotNull(test);
View Full Code Here


            MutableDocumentSet docs = new DefaultDocumentSet();
            docs.add(info.getDocument());
            XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
            assertNotNull(proc);
           
            Txn transaction = mgr.beginTransaction();
            assertNotNull(transaction);
            System.out.println("Transaction started ...");
           
            String xupdate;
            Modification modifications[];
View Full Code Here

    private void store() {
        BrokerPool.FORCE_CORRUPTION = true;
        BrokerPool pool = startDB();
        DBBroker broker = null;
        Txn transaction = null;
        TransactionManager transact = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());           
            transact = pool.getTransactionManager();
           
View Full Code Here

      assertNotNull(broker);
      //TODO : is this necessary ?
            broker.flush();
      TransactionManager mgr = pool.getTransactionManager();
      assertNotNull(mgr);
      Txn txn = mgr.beginTransaction();
      assertNotNull(txn);
      System.out.println("Transaction started ...");
           
            DOMFile domDb = ((NativeBroker) broker).getDOMFile();
            assertNotNull(domDb);
View Full Code Here

          assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);           
            TransactionManager transact = pool.getTransactionManager();
            assertNotNull(transact);
            Txn transaction = transact.beginTransaction();
            assertNotNull(transaction);           
            System.out.println("Transaction started ...");
           
            Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
            assertNotNull(root);
View Full Code Here

    private void read() {
        BrokerPool.FORCE_CORRUPTION = false;
        BrokerPool pool = null;
        DBBroker broker = null;          
        TransactionManager transact = null;
        Txn transaction = null;
       
        try {
          System.out.println("testRead() ...\n");
          pool = startDB();
          assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            Serializer serializer = broker.getSerializer();
            serializer.reset();
           
            DocumentImpl doc = broker.getXMLResource(XmldbURI.ROOT_COLLECTION_URI.append("test/test2/hamlet.xml"), Lock.READ_LOCK);
            assertNotNull("Document '" + XmldbURI.ROOT_COLLECTION + "/test/test2/hamlet.xml' should not be null", doc);
            String data = serializer.serialize(doc);
            assertNotNull(data);
            //System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);
           
            doc = broker.getXMLResource(XmldbURI.ROOT_COLLECTION_URI.append("test/test2/test_string.xml"), Lock.READ_LOCK);
            assertNotNull("Document '" + XmldbURI.ROOT_COLLECTION + "/test/test2/test_string.xml' should not be null", doc);
            data = serializer.serialize(doc);
            assertNotNull(data);
            //System.out.println(data);
            doc.getUpdateLock().release(Lock.READ_LOCK);
           
            File files[] = dir.listFiles();
            assertNotNull(files);
           
            doc = broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append(files[files.length - 1].getName()), Lock.READ_LOCK);
            assertNull("Document '" + XmldbURI.ROOT_COLLECTION + "/test/test2/'" + files[files.length - 1].getName() + " should not exist anymore", doc);
           
            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("//SPEECH[ft:query(LINE, 'king')]", null, AccessContext.TEST);
            assertNotNull(seq);
            System.out.println("Found: " + seq.getItemCount());
            for (SequenceIterator i = seq.iterate(); i.hasNext(); ) {
                Item next = i.nextItem();
                String value = serializer.serialize((NodeValue) next);
                //System.out.println(value);
            }
           
            BinaryDocument binDoc = (BinaryDocument) broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append(TestConstants.TEST_BINARY_URI), Lock.READ_LOCK);
            assertNotNull("Binary document is null", binDoc);
            InputStream is = broker.getBinaryResource(binDoc);
            byte [] bdata = new byte[(int)broker.getBinaryResourceSize(binDoc)];
            is.read(bdata);
            is.close();
            data = new String(bdata);
            assertNotNull(data);
            System.out.println(data);
           
            DOMFile domDb = ((NativeBroker)broker).getDOMFile();
            assertNotNull(domDb);
            Writer writer = new StringWriter();
            domDb.dump(writer);
            //System.out.println(writer.toString());
           
            transact = pool.getTransactionManager();
            assertNotNull(transact);
            transaction = transact.beginTransaction();
            assertNotNull(transaction);
            System.out.println("Transaction started ...");
           
            Collection root = broker.openCollection(TestConstants.TEST_COLLECTION_URI, Lock.WRITE_LOCK);
            assertNotNull(root);
            transaction.registerLock(root.getLock(), Lock.WRITE_LOCK);           
            broker.removeCollection(transaction, root);
           
            transact.commit(transaction);
            System.out.println("Transaction commited ...");
      } catch (Exception e) {        
View Full Code Here

      assertNotNull(pool);
      broker = pool.get(pool.getSecurityManager().getSystemSubject());
      assertNotNull(broker);
      TransactionManager transact = pool.getTransactionManager();
      assertNotNull(transact);
      Txn transaction = transact.beginTransaction();
      assertNotNull(transaction);
      System.out.println("Transaction started ...");

      Collection root = broker.getOrCreateCollection(transaction,  TestConstants.TEST_COLLECTION_URI);
      assertNotNull(root);
View Full Code Here

  private void doRead() {
      BrokerPool.FORCE_CORRUPTION = false;
      BrokerPool pool = null;
      DBBroker broker = null;
        TransactionManager transact = null;
        Txn transaction = null;
      try {
        System.out.println("testRead() ...\n");
        pool = startDB();
        assertNotNull(pool);
          broker = pool.get(pool.getSecurityManager().getSystemSubject());
          assertNotNull(broker);
          Serializer serializer = broker.getSerializer();
          serializer.reset();

          DocumentImpl doc = broker.getXMLResource(XmldbURI.ROOT_COLLECTION_URI.append("test/new_test.xml"), Lock.READ_LOCK);
          assertNotNull("Document should not be null", doc);
          String data = serializer.serialize(doc);
          assertNotNull(data);
//          System.out.println(data);
          doc.getUpdateLock().release(Lock.READ_LOCK);

            transact = pool.getTransactionManager();
            assertNotNull(transact);
            transaction = transact.beginTransaction();
            assertNotNull(transaction);
            System.out.println("Transaction started ...");

            Collection root = broker.openCollection(TestConstants.TEST_COLLECTION_URI, Lock.WRITE_LOCK);
            assertNotNull(root);
            transaction.registerLock(root.getLock(), Lock.WRITE_LOCK);
            broker.removeCollection(transaction, root);

            transact.commit(transaction);
            System.out.println("Transaction commited ...");
      } catch (Exception e) {
View Full Code Here

    DBBroker broker = null;
    try {
      broker = pool.get(pool.getSecurityManager().getSystemSubject());

      TransactionManager transact = pool.getTransactionManager();
      Txn transaction = transact.beginTransaction();

      System.out.println("Transaction started ...");

      Collection root = broker.getOrCreateCollection(transaction,  TestConstants.TEST_COLLECTION_URI);
      assertNotNull(root);
View Full Code Here

    private void readAborted() {
      BrokerPool.FORCE_CORRUPTION = false;
      BrokerPool pool = null;
      DBBroker broker = null;
        TransactionManager transact = null;
        Txn transaction = null;
      try {
        System.out.println("testRead() ...\n");
        pool = startDB();
        assertNotNull(pool);
          broker = pool.get(pool.getSecurityManager().getSystemSubject());
          assertNotNull(broker);
          Serializer serializer = broker.getSerializer();
          serializer.reset();

          DocumentImpl doc = broker.getXMLResource(TestConstants.TEST_COLLECTION_URI2.append("new_test2.xml"), Lock.READ_LOCK);
          assertNotNull("Document should not be null", doc);
          String data = serializer.serialize(doc);
          assertNotNull(data);
//          System.out.println(data);
          doc.getUpdateLock().release(Lock.READ_LOCK);

            transact = pool.getTransactionManager();
            assertNotNull(transact);
            transaction = transact.beginTransaction();
            assertNotNull(transaction);
            System.out.println("Transaction started ...");

            Collection root = broker.openCollection(TestConstants.TEST_COLLECTION_URI, Lock.WRITE_LOCK);
            assertNotNull(root);
            transaction.registerLock(root.getLock(), Lock.WRITE_LOCK);
            broker.removeCollection(transaction, root);

            transact.commit(transaction);
            System.out.println("Transaction commited ...");
      } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.exist.storage.txn.Txn

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.