Package org.exist.management

Examples of org.exist.management.Agent


    }


    private void registerMBean()
    {
        final Agent agent = AgentFactory.getInstance();

        try {
            agent.addMBean( instanceName, "org.exist.management." + instanceName + ":type=CacheManager", new org.exist.management.CacheManager( this ) );
        }
        catch( final DatabaseConfigurationException e ) {
            LOG.warn( "Exception while registering cache mbean.", e );
        }
    }
View Full Code Here


    }


    private void registerMBean( Cache cache )
    {
        final Agent agent = AgentFactory.getInstance();

        try {
            agent.addMBean( instanceName, "org.exist.management." + instanceName + ":type=CacheManager.Cache,name=" + cache.getFileName() + ",cache-type=" + cache.getType(), new org.exist.management.Cache( cache ) );
        }
        catch( final DatabaseConfigurationException e ) {
            LOG.warn( "Exception while registering cache mbean.", e );
        }
    }
View Full Code Here

        checkDocs = check.equalsIgnoreCase("YES");
    }

    @Override
    public void execute(DBBroker broker) throws EXistException {
        final Agent agentInstance = AgentFactory.getInstance();
        final BrokerPool brokerPool = broker.getBrokerPool();
        final TaskStatus endStatus = new TaskStatus(TaskStatus.Status.STOPPED_OK);

        agentInstance.changeStatus(brokerPool, new TaskStatus(TaskStatus.Status.INIT));

        if (paused) {
            LOG.info("Consistency check is paused.");
            agentInstance.changeStatus(brokerPool, new TaskStatus(TaskStatus.Status.PAUSED));
            return;
        }

        brokerPool.getProcessMonitor().startJob(ProcessMonitor.ACTION_BACKUP, null, monitor);

        PrintWriter report = null;
        try {
            boolean doBackup = createBackup;
            // TODO: don't use the direct access feature for now. needs more testing
            List<ErrorReport> errors = null;
            if (!incremental || incrementalCheck) {
               
                LOG.info("Starting consistency check...");
               
                report = openLog();
                final CheckCallback cb = new CheckCallback(report);

                final ConsistencyCheck check = new ConsistencyCheck(broker, false, checkDocs);
                agentInstance.changeStatus(brokerPool, new TaskStatus(TaskStatus.Status.RUNNING_CHECK));
                errors = check.checkAll(cb);
               
                if (!errors.isEmpty()) {
                    endStatus.setStatus(TaskStatus.Status.STOPPED_ERROR);
                    endStatus.setReason(errors);
                  
                    LOG.error("Errors found: " + errors.size());

                    doBackup = true;

                    if (fatalErrorsFound(errors)) {
                        LOG.error("Fatal errors were found: pausing the consistency check task.");  
                        paused = true;
                    }
                }
               
                LOG.info("Finished consistency check");
            }

            if (doBackup) {
                LOG.info("Starting backup...");

                final SystemExport sysexport = new SystemExport(broker, logCallback, monitor, false);
                lastExportedBackup = sysexport.export(exportDir, incremental, maxInc, createZip, errors);
                agentInstance.changeStatus(brokerPool, new TaskStatus(TaskStatus.Status.RUNNING_BACKUP));

                if (lastExportedBackup != null) {
                    LOG.info("Created backup to file: " + lastExportedBackup.getAbsolutePath());
                }
               
                LOG.info("Finished backup");
            }

        } catch (final TerminatedException e) {
            throw new EXistException(e.getMessage(), e);
           
        } catch (final PermissionDeniedException e) {
            //TODO should maybe throw PermissionDeniedException instead!
            throw new EXistException(e.getMessage(), e);
           
        } finally {
            if (report != null) {
                report.close();
            }
           
            agentInstance.changeStatus(brokerPool, endStatus);
            brokerPool.getProcessMonitor().endJob();
        }
    }
View Full Code Here

    public long getCurrentSize() {
        return collectionCache.getRealSize();
    }

    private void registerMBean(String instanceName) {
        final Agent agent = AgentFactory.getInstance();
        try {
            agent.addMBean(instanceName, "org.exist.management." + instanceName +
                ":type=CollectionCacheManager", new org.exist.management.CacheManager(this));
        } catch (final DatabaseConfigurationException e) {
            LOG.warn("Exception while registering cache mbean.", e);
        }
        }
View Full Code Here

TOP

Related Classes of org.exist.management.Agent

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.