Package org.exist.storage

Examples of org.exist.storage.BrokerPool$StatusReporter


    @Test
  public void test_00() throws Exception {
     
      startDB();
     
        BrokerPool db = null;
        DBBroker broker = null;
        try {
            db = BrokerPool.getInstance();
            broker = db.get(db.getSecurityManager().getSystemSubject());
           
          MetaData md = MetaData.get();
         
          assertNotNull(md);
         
          Metas docMD = MetaData.get().getMetas(doc1uri);
         
          assertNotNull(docMD);
         
          String uuid = docMD.getUUID();
          assertNotNull(uuid);
         
          DocumentImpl doc = MetaData.get().getDocument(uuid);
          assertNotNull(doc);
          assertTrue(doc1.equals(doc));
   
          //add first key-value
          docMD.put(KEY1, VALUE1);
         
          Meta meta = docMD.get(KEY1);
          assertNotNull(meta);
   
          assertEquals(VALUE1, meta.getValue());
         
          List<String> dbRoot = new ArrayList<String>();
          dbRoot.add("/db");

//          assertEquals(
//                "in-memory#element {results} {in-memory#element {search} {in-memory#attribute {uri} {/db/test/test_string.xml}  in-memory#attribute {score} {0.30685282} } } ",
//                md.search("value1", dbRoot).toString()
//            );
//
//          assertEquals(
//              "in-memory#element {results} {in-memory#element {search} {in-memory#attribute {uri} {/db/test/test_string.xml}  in-memory#attribute {score} {0.30685282} in-memory#element {field} {in-memory#attribute {name} {key1} in-memory#element {exist:match} {in-memory#text {value1} } } } } ",
//              md.search("key1:value1", dbRoot).toString()
//          );
//
//            assertEquals(
//                "in-memory#element {results} {in-memory#element {search} {in-memory#attribute {uri} {/db/test/test_string.xml}  in-memory#attribute {score} {0.30685282} in-memory#element {field} {in-memory#attribute {name} {key1} in-memory#element {exist:match} {in-memory#text {value1} } } } } ",
//                md.search("key1:value*", dbRoot).toString()
//            );
//
//            assertEquals(
//                "in-memory#element {results} {} ",
//                md.search("key1:value2", dbRoot).toString()
//            );

//      //add second key-value
//      docMD.put(KEY2, VALUE2);
//     
//      meta = docMD.get(KEY2);
//      assertNotNull(meta);
//
//      assertEquals(VALUE2, meta.getValue());
//
//      //replace first key-value
//      docMD.put(KEY1, VALUE2);
//     
//      meta = docMD.get(KEY1);
//      assertNotNull(meta);
//
//      assertEquals(VALUE2, meta.getValue());
//     
//      //second document
//      docMD = MetaData.get().getMetas(doc2uri);
//     
//      assertNotNull(docMD);
//     
//      uuid = docMD.getUUID();
//      assertNotNull(uuid);
//     
//      doc = MetaData.get().getDocument(uuid);
//      assertNotNull(doc);
//      assertTrue(doc2.equals(doc));
//
//      //add first key-value
//      docMD.put(KEY1, VALUE2);
//     
//      meta = docMD.get(KEY1);
//      assertNotNull(meta);
//
//      assertEquals(VALUE2, meta.getValue());
//
//      //add second key-value
//      docMD.put(KEY2, VALUE1);
//     
//      meta = docMD.get(KEY2);
//      assertNotNull(meta);
//
//      assertEquals(VALUE1, meta.getValue());
//
//      //replace first key-value
//      docMD.put(KEY1, VALUE1);
//     
//      meta = docMD.get(KEY1);
//      assertNotNull(meta);
//
//      assertEquals(VALUE1, meta.getValue());

        } finally {
            if (db != null)
                db.release(broker);
        }

      cleanup();
    }
View Full Code Here


      File existHome = null;
     
      // If eXist was already configured, then return
      // the existHome of this instance.
      try {
        final BrokerPool broker = BrokerPool.getInstance();
        if(broker != null) {
          existHome = broker.getConfiguration().getExistHome();
      if(existHome!=null) {
                          LOG.debug("Got eXist home from broker: " + existHome);
            return existHome;
      }
        }
View Full Code Here

    };

    @Test
    public void test() throws EXistException {

        BrokerPool db = BrokerPool.getInstance();

        db.registerDocumentTrigger(AnotherTrigger.class);

        DBBroker broker = null;

        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());

            Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", "");

            Resource resource = root.createResource("data.xml", "XMLResource");
            resource.setContent(DOCUMENT1_CONTENT);
View Full Code Here

    }

    @Test
    public void saxEventModifications() throws EXistException {

        BrokerPool db = BrokerPool.getInstance();

        db.registerDocumentTrigger(StoreTrigger.class);

        DBBroker broker = null;

        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());

            Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", "");

            Resource resource = root.createResource("data.xml", "XMLResource");
            resource.setContent(DOCUMENT2_CONTENT);
View Full Code Here

    }

    @Test
    public void saxEventModificationsAtXConf() throws EXistException {

        BrokerPool db = BrokerPool.getInstance();

        DBBroker broker = null;

        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());

            Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", "");

            IndexQueryService idxConf = (IndexQueryService) root.getService("IndexQueryService", "1.0");
            idxConf.configureCollection(COLLECTION_CONFIG);
View Full Code Here

            if ( !BrokerPool.isConfigured() )
                {output.println( "<p>Server is not running ...</p>" );}
            else {
                output.println( "<p>The database server is running ...</p>" );

                final BrokerPool pool = BrokerPool.getInstance();
                final Configuration conf = pool.getConfiguration();
                output.println( "<table  width=\"80%\"><tr>" +
                    "<th colspan=\"2\" align=\"left\" bgcolor=\"#0086b2\"><b>Status</b></th></tr>" );
                output.println( "<tr><td>Address:</td><td>" + request.getRequestURI() +
                    "</td></tr>" );
                output.println( "<tr><td>Configuration:</td><td>" + conf.getConfigFilePath() + "</td></tr>" );
                output.println( "<tr><td>Data directory:</td><td>" +
                    (String) conf.getProperty(BrokerPool.PROPERTY_DATA_DIR) +
                    "</td></tr>" );
                output.println( "<tr><td>Active instances:</td><td>" +
                    pool.countActiveBrokers() + "</td></tr>" );
                output.println( "<tr><td>Available instances:</td><td>" +
                    pool.available() + "</td></tr>" );
                output.println( "</table>" );
            }
            output.print( "<p><form action=\"" );
            output.print( response.encodeURL( request.getRequestURI() ) );
            output.println( "\" method=\"GET\">" );
View Full Code Here

        LOG.info("Usable space on partition containing DATA_DIR: " + dataDir.getAbsolutePath() + ": " + (space / 1024 / 1024) + "mb");
    }

    @Override
    public void execute(DBBroker broker) throws EXistException {
        final BrokerPool pool = broker.getBrokerPool();
        if (!checkDiskSpace(pool)) {
            LOG.fatal("Partition containing DATA_DIR: " + dataDir.getAbsolutePath() + " is running out of disk space. " +
                "Switching eXist-db to read only to prevent data loss!");
            pool.setReadOnly();
        }
        if(System.currentTimeMillis() - pool.getLastMajorSync() >
                pool.getMajorSyncPeriod()) {
            pool.sync(broker, Sync.MAJOR_SYNC);
        } else {
            pool.sync(broker, Sync.MINOR_SYNC);
        }
    }
View Full Code Here

        }
    }

    @After
    public void cleanup() {
        BrokerPool pool = null;
        DBBroker broker = null;
        TransactionManager transact = null;
        Txn transaction = null;
        try {
            pool = BrokerPool.getInstance();
            assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            transact = pool.getTransactionManager();
            assertNotNull(transact);
            transaction = transact.beginTransaction();
            assertNotNull(transaction);

            Collection collConfig = broker.getOrCreateCollection(transaction,
                XmldbURI.create(XmldbURI.CONFIG_COLLECTION + "/db"));
            assertNotNull(collConfig);
            broker.removeCollection(transaction, collConfig);

            if (root != null) {
                assertNotNull(root);
                broker.removeCollection(transaction, root);
            }
            transact.commit(transaction);

            Configuration config = BrokerPool.getInstance().getConfiguration();
            config.setProperty(Indexer.PROPERTY_PRESERVE_WS_MIXED_CONTENT, savedConfig);
        } catch (Exception e) {
            if (transact != null)
                transact.abort(transaction);
            e.printStackTrace();
            fail(e.getMessage());
        } finally {
            if (pool != null) pool.release(broker);
        }
    }
View Full Code Here

* To change this template use File | Settings | File Templates.
*/
public class TestUtils {
 
    public static void cleanupDB() {
        BrokerPool pool = null;
        DBBroker broker = null;
        TransactionManager transact = null;
        Txn transaction = null;
        try {
            pool = BrokerPool.getInstance();
            assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            transact = pool.getTransactionManager();
            assertNotNull(transact);
            transaction = transact.beginTransaction();
            assertNotNull(transaction);

            // Remove all collections below the /db root, except /db/system
            Collection root = broker.getOrCreateCollection(transaction, XmldbURI.ROOT_COLLECTION_URI);
            assertNotNull(root);
            for (Iterator<DocumentImpl> i = root.iterator(broker); i.hasNext(); ) {
                DocumentImpl doc = i.next();
                root.removeXMLResource(transaction, broker, doc.getURI().lastSegment());
            }
            broker.saveCollection(transaction, root);
            for (Iterator<XmldbURI> i = root.collectionIterator(broker); i.hasNext(); ) {
                XmldbURI childName = i.next();
                if (childName.equals("system"))
                    continue;
                Collection childColl = broker.getOrCreateCollection(transaction, XmldbURI.ROOT_COLLECTION_URI.append(childName));
                assertNotNull(childColl);
                broker.removeCollection(transaction, childColl);
            }

            // Remove /db/system/config/db and all collection configurations with it
            Collection config = broker.getOrCreateCollection(transaction,
                XmldbURI.create(XmldbURI.CONFIG_COLLECTION + "/db"));
            assertNotNull(config);
            broker.removeCollection(transaction, config);

            transact.commit(transaction);
        } catch (Exception e) {
          transact.abort(transaction);
            e.printStackTrace();
            fail(e.getMessage());
        } finally {
            if (pool != null) pool.release(broker);
        }
    }
View Full Code Here

        BrokerPool.stopAll(true);
    }

    private static void createTestCollections() throws Exception {

        BrokerPool pool = BrokerPool.getInstance();
        DBBroker broker = null;
        TransactionManager transact = null;
        Txn txn = null;
        try {
            Subject admin = pool.getSecurityManager().authenticate(ADMIN_UID, ADMIN_PWD);

            broker = pool.get(admin);

            transact = pool.getTransactionManager();
            txn = transact.beginTransaction();

            /** create nessecary collections if they dont exist */
            Collection testCollection = broker.getOrCreateCollection(txn, XmldbURI.create(VALIDATION_HOME_COLLECTION_URI));
            testCollection.getPermissions().setOwner(GUEST_UID);
            broker.saveCollection(txn, testCollection);

            Collection col = broker.getOrCreateCollection(txn, XmldbURI.create(VALIDATION_HOME_COLLECTION_URI + "/" + TestTools.VALIDATION_DTD_COLLECTION));
            col.getPermissions().setOwner(GUEST_UID);
            broker.saveCollection(txn, col);

            col = broker.getOrCreateCollection(txn, XmldbURI.create(VALIDATION_HOME_COLLECTION_URI + "/" + TestTools.VALIDATION_XSD_COLLECTION));
            col.getPermissions().setOwner(GUEST_UID);
            broker.saveCollection(txn, col);

            col = broker.getOrCreateCollection(txn, XmldbURI.create(VALIDATION_HOME_COLLECTION_URI + "/" + TestTools.VALIDATION_TMP_COLLECTION));
            col.getPermissions().setOwner(GUEST_UID);
            broker.saveCollection(txn, col);

            transact.commit(txn);

        } catch (Exception e) {
            if(transact != null && txn != null) {
                transact.abort(txn);
            }
            throw e;
        } finally {
            if(broker != null) {
                pool.release(broker);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.exist.storage.BrokerPool$StatusReporter

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.