Package org.exist.storage

Examples of org.exist.storage.ProcessMonitor$FixedSizeLinkedHashMap


            final CompiledXQuery compiled = xquery.compile(context, source);

//            Sequence result = xquery.execute(compiled, subject.getName());

        final ProcessMonitor pm = db.getProcessMonitor();

            //execute the XQuery
            try {
            final UserDefinedFunction function = context.resolveFunction(functionName, 0);
            if (function != null) {
                  context.getProfiler().traceQueryStart();
                  pm.queryStarted(context.getWatchDog());
                 
                  final FunctionCall call = new FunctionCall(context, function);
                  if (args != null)
                    {call.setArguments(args);}
                  call.analyze(new AnalyzeContextInfo());
              call.eval(NodeSet.EMPTY_SET);
            }
            } catch(final XPathException e) {
              //XXX: log
              e.printStackTrace();
            } finally {
              if (pm != null) {
                context.getProfiler().traceQueryEnd(context);
                pm.queryCompleted(context.getWatchDog());
              }
              compiled.reset();
            context.reset();
            }
           
View Full Code Here


       
        final RestXqServiceCompiledXQueryCache cache = RestXqServiceCompiledXQueryCacheImpl.getInstance();
       
        DBBroker broker = null;
        CompiledXQuery xquery = null;
        ProcessMonitor processMonitor = null;
       
        try {
           
            broker = getBrokerPool().get(getBrokerPool().getSubject());
           
            //ensure we can execute the function before going any further
            checkSecurity(broker, resourceFunction.getXQueryLocation());
           
            //get a compiled query service from the cache
            xquery = cache.getCompiledQuery(broker, resourceFunction.getXQueryLocation());
           
            //find the function that we will execute
            final UserDefinedFunction fn = findFunction(xquery, resourceFunction.getFunctionSignature());
           
            final XQueryContext xqueryContext = xquery.getContext();
           
            //set the request object - can later be used by the EXQuery Request Module
            xqueryContext.setAttribute(EXQ_REQUEST_ATTR, request);
           
            //TODO this is a workaround?
            declareVariables(xqueryContext);
           
            //START workaround: evaluate global variables in modules, as they are reset by XQueryContext.reset()
            final Expression rootExpr = xqueryContext.getRootExpression();
            for(int i = 0; i < rootExpr.getSubExpressionCount(); i++) {
                final Expression subExpr = rootExpr.getSubExpression(i);
                if(subExpr instanceof VariableDeclaration) {
                    subExpr.eval(null);
                }
            }
            //END workaround
           
            //setup monitoring
            processMonitor = broker.getBrokerPool().getProcessMonitor();
            xqueryContext.getProfiler().traceQueryStart();
            processMonitor.queryStarted(xqueryContext.getWatchDog());
           
            //create a function call
            final FunctionReference fnRef = new FunctionReference(new FunctionCall(xqueryContext, fn));
           
            //convert the arguments
            final org.exist.xquery.value.Sequence[] fnArgs = convertToExistFunctionArguments(xqueryContext, fn, arguments);
           
            //execute the function call
            fnRef.analyze(new AnalyzeContextInfo());
            final org.exist.xquery.value.Sequence result = fnRef.evalFunction(null, null, fnArgs);
           
            return new SequenceAdapter(result);
        } catch(final URISyntaxException use) {
            throw new RestXqServiceException(use.getMessage(), use);
        } catch(final PermissionDeniedException pde) {
            throw new RestXqServiceException(pde.getMessage(), pde);
        } catch(final XPathException xpe) {
            throw new RestXqServiceException(xpe.getMessage(), xpe);
        } catch(final EXistException ee) {
            throw new RestXqServiceException(ee.getMessage(), ee);
        } finally {
           
            //clear down monitoring
            if(processMonitor != null) {
                xquery.getContext().getProfiler().traceQueryEnd(xquery.getContext());
                processMonitor.queryCompleted(xquery.getContext().getWatchDog());
            }
           
            //return the broker
            if(broker != null) {
                getBrokerPool().release(broker);
View Full Code Here

        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);
            builder.addAttribute( new QName("id", null, null), process.getName());
View Full Code Here

    final XmldbURI src = urls[0];
    final CompiledXQuery compiledQuery = getScript(isBefore, broker, transaction, src);
   
    if (compiledQuery == null) {return;}
   
    ProcessMonitor pm = null;
   
    final XQueryContext context = compiledQuery.getContext();
        //execute the XQuery
        try {
         
        final UserDefinedFunction function = context.resolveFunction(functionName, urls.length);
        if (function != null) {
          final List<Expression> args = new ArrayList<Expression>(urls.length);
          for (int i = 0; i < urls.length; i++)
            args.add(new LiteralValue(context, new AnyURIValue(urls[i])));
         
          pm = broker.getBrokerPool().getProcessMonitor();
         
              context.getProfiler().traceQueryStart();
              pm.queryStarted(context.getWatchDog());
             
              final FunctionCall call = new FunctionCall(context, function);
              call.setArguments(args);
              call.analyze(new AnalyzeContextInfo());
          call.eval(NodeSet.EMPTY_SET);
        }
        } catch(final XPathException e) {
        TriggerStatePerThread.setTriggerRunningState(TriggerStatePerThread.NO_TRIGGER_RUNNING, this, null);
        TriggerStatePerThread.setTransaction(null);
          throw new TriggerException(PEPARE_EXCEIPTION_MESSAGE, e);
        } finally {
          if (pm != null) {
            context.getProfiler().traceQueryEnd(context);
            pm.queryCompleted(context.getWatchDog());
          }
        compiledQuery.reset();
        context.reset();
        }
View Full Code Here

TOP

Related Classes of org.exist.storage.ProcessMonitor$FixedSizeLinkedHashMap

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.