Package org.exist.storage

Examples of org.exist.storage.BrokerPool


        final MemTreeBuilder builder = context.getDocumentBuilder();

        builder.startDocument();
        builder.startElement( new QName( "jobs", NAMESPACE_URI, PREFIX ), null );

        final BrokerPool brokerPool = context.getBroker().getBrokerPool();
    final ProcessMonitor monitor = brokerPool.getProcessMonitor();
        final ProcessMonitor.JobInfo[] jobs = monitor.runningJobs();
        for (int i = 0; i < jobs.length; i++) {
            final Thread process = jobs[i].getThread();
      final Date startDate = new Date(jobs[i].getStartTime());
            builder.startElement( new QName( "job", NAMESPACE_URI, PREFIX ), null);
View Full Code Here


          delay = ((NumericValue)args[0].itemAt(0)).getLong();
        }
      }
     
      //get the broker pool and shutdown
      final BrokerPool pool = context.getBroker().getBrokerPool();
       
      if(delay > 0)
      {
        logger.info("Shuttting down in " + delay + " milliseconds.");
        final TimerTask task = new DelayedShutdownTask(pool);
        final Timer timer = new Timer();
        timer.schedule(task, delay);
      }
      else
      {
        logger.info("Shutting down now.");
        pool.shutdown();
      }
    }
    else
    {
      final XPathException xPathException = new XPathException(this, "Permission denied, calling user '" + context.getSubject().getName() + "' must be a DBA to shutdown the database");
View Full Code Here

    final String node1NodeId = storedNode1.getNodeId().toString();
    String node2NodeId = "-1";
    if (! (node2 == null))
      {node2NodeId = storedNode2.getNodeId().toString();}
    final DocumentImpl docImpl = (DocumentImpl) node1.getOwnerDocument();
    BrokerPool brokerPool = null;
    DBBroker dbBroker = null;
    final StringBuilder resultFragment = new StringBuilder("");
    String actualNodeId = "-2";
    boolean getFragmentMode = false;
    try {
      brokerPool = docImpl.getBrokerPool();
      dbBroker = brokerPool.get(null);
      EmbeddedXMLStreamReader reader = null;
      final NodeList children = docImpl.getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        final StoredNode docChildStoredNode = (StoredNode) children.item(i);
        final int docChildStoredNodeType = docChildStoredNode.getNodeType();
        reader = dbBroker.getXMLStreamReader(docChildStoredNode, false);
        while (reader.hasNext() && ! node2NodeId.equals(actualNodeId) && docChildStoredNodeType != Node.PROCESSING_INSTRUCTION_NODE && docChildStoredNodeType != Node.COMMENT_NODE) {
          final int status = reader.next();
          switch (status) {
            case XMLStreamReader.START_DOCUMENT:
            case XMLStreamReader.END_DOCUMENT:
              break;
            case XMLStreamReader.START_ELEMENT :
              actualNodeId = reader.getNode().getNodeId().toString();
              if (actualNodeId.equals(node1NodeId))
                {getFragmentMode = true;}
              if (actualNodeId.equals(node2NodeId))
                {getFragmentMode = false;}
              if (getFragmentMode) {
                final String startElementTag = getStartElementTag(reader);
                resultFragment.append(startElementTag);
              }
              break;
            case XMLStreamReader.END_ELEMENT :
              if (getFragmentMode) {
                final String endElementTag = getEndElementTag(reader);
                resultFragment.append(endElementTag);
              }
              break;
            case XMLStreamReader.CHARACTERS :
              if (getFragmentMode) {
                final String characters = getCharacters(reader);
                resultFragment.append(characters);
              }
              break;
            case XMLStreamReader.CDATA :
              if (getFragmentMode) {
                final String cdata = getCDataTag(reader);
                resultFragment.append(cdata);
              }
              break;
            case XMLStreamReader.COMMENT :
              if (getFragmentMode) {
                final String comment = getCommentTag(reader);
                resultFragment.append(comment);
              }
              break;
            case XMLStreamReader.PROCESSING_INSTRUCTION :
              if (getFragmentMode) {
                final String piTag = getPITag(reader);
                resultFragment.append(piTag);
              }
              break;
          }
        }
      }
    } catch (final EXistException e) {
      throw new XPathException(this, "An error occurred while getFragmentBetween: " + e.getMessage(), e);
    } catch (final XMLStreamException e) {
      throw new XPathException(this, "An error occurred while getFragmentBetween: " + e.getMessage(), e);
    } catch (final IOException e) {
      throw new XPathException(this, "An error occurred while getFragmentBetween: " + e.getMessage(), e);
    } finally {
      if (brokerPool != null)
        {brokerPool.release(dbBroker);
    }
    return resultFragment;
  }
View Full Code Here

            if (obj == null) {
                return null;
            }

            if (obj instanceof LifeCycle) {
                BrokerPool db = null;
               
                try {
                    db = BrokerPool.getInstance();
                } catch (final EXistException e) {
                    //ignore if database is starting-up
                    //TODO: add to BrokerPool static list to activate when ready
                }
               
                if (db != null) {
                    DBBroker broker = null;
                    try {
                        broker = db.get(null);
                        ((LifeCycle) obj).start(broker);
                       
                    } finally {
                        db.release(broker);
                    }
                }
               
            }
            return obj;
View Full Code Here

        hotConfigs.put(key, conf);
        return conf;
    }

    public static DocumentAtExist save(final Configurable instance, final XmldbURI uri) throws IOException {
        BrokerPool database;
        try {
            database = BrokerPool.getInstance();
           
        } catch (final EXistException e) {
            throw new IOException(e);
        }
       
        DBBroker broker = null;
        try {
            broker = database.get(null);

            return save(broker, instance, uri);

        } catch (final EXistException e) {
            throw new IOException(e);
           
        } finally {
            database.release(broker);
        }
    }
View Full Code Here

        if (data == null || data.length() == 0) {
            return null;
        }
       
        FullXmldbURI fullURI = null;
        final BrokerPool pool = broker.getBrokerPool();
        final TransactionManager transact = pool.getTransactionManager();
        Txn txn = null;
        LOG.info("Storing configuration " + collection.getURI() + "/" + uri);
        final Subject currentUser = broker.getSubject();
       
        try {
            broker.setSubject(pool.getSecurityManager().getSystemSubject());
            txn = transact.beginTransaction();
            txn.acquireLock(collection.getLock(), Lock.WRITE_LOCK);
            final IndexInfo info = collection.validateXMLResource(txn, broker, uri, data);
            final DocumentImpl doc = info.getDocument();
            doc.getMetadata().setMimeType(MimeType.XML_TYPE.getName());
View Full Code Here

            } else {
                throw new XMLDBException(ErrorCodes.COLLECTION_CLOSED, "Local database server is not running");
            }
        }
       
        BrokerPool pool;
        try {
            pool = BrokerPool.getInstance(xmldbURI.getInstanceName());
        } catch (final EXistException e) {
            throw new XMLDBException( ErrorCodes.VENDOR_ERROR, "Can not access to local database instance", e);
        }
View Full Code Here

          logger.info("Entering the " + SystemModule.PREFIX + ":trace XQuery function");
            context.getProfiler().reset();
            final MemTreeBuilder builder = context.getDocumentBuilder();

            builder.startDocument();
            final BrokerPool brokerPool = context.getBroker().getBrokerPool();
            brokerPool.getPerformanceStats().toXML(builder);
            builder.endDocument();
          logger.info("Exiting " + SystemModule.PREFIX + ":" + getName().getLocalName());
            return (NodeValue)builder.getDocument().getDocumentElement();
        }
      logger.info("Exiting " + SystemModule.PREFIX + ":" + getName().getLocalName());
View Full Code Here

            throw new XPathException("New mime-type must be a " + currentMimeType.getXMLDBType() + " mime-type");
        }

        // At this moment it is possible to update the mimetype
        final DBBroker broker = context.getBroker();
        final BrokerPool brokerPool = broker.getBrokerPool();

        DocumentImpl doc = null;
        final TransactionManager txnManager = brokerPool.getTransactionManager();
        final Txn txn = txnManager.beginTransaction();

        try {
            // relative collection Path: add the current base URI
            pathUri = context.getBaseURI().toXmldbURI().resolveCollectionPath(pathUri);
View Full Code Here

        final MemTreeBuilder builder = context.getDocumentBuilder();

        builder.startDocument();
        builder.startElement( new QName( "jobs", NAMESPACE_URI, PREFIX ), null );

        final BrokerPool brokerPool = context.getBroker().getBrokerPool();
        logger.trace("brokerPool = " + brokerPool.toString());
       
        if( brokerPool != null ) {
            final org.exist.scheduler.Scheduler existScheduler = brokerPool.getScheduler();
           
            if( existScheduler != null ) {
                final List<ScheduledJobInfo> scheduledJobsInfo = existScheduler.getScheduledJobs();
                final ScheduledJobInfo[] executingJobsInfo = existScheduler.getExecutingJobs();
               
View Full Code Here

TOP

Related Classes of org.exist.storage.BrokerPool

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.