Package org.jboss.dna.common.statistic

Examples of org.jboss.dna.common.statistic.Stopwatch


                                     testName,
                                     depths[j],
                                     breadths[i],
                                     properties[k],
                                     false,
                                     new Stopwatch(),
                                     System.out,
                                     null);
                }
            }
        }
View Full Code Here


                                   testName,
                                   depths[j],
                                   breadths[i],
                                   properties[k],
                                   false,
                                   new Stopwatch(),
                                   System.out,
                                   null);
                }
            }
        }
View Full Code Here

    @Test
    public void shouldFindInfoForAllNodesInGraph() throws Exception {
        for (int i = 0; i != 3; ++i) {
            super.numberOfConnections = 0;
            Stopwatch sw = new Stopwatch();

            // Get the root ...
            sw.start();
            Node<JcrNodePayload, JcrPropertyPayload> root = cache.findNode(null, path("/"));
            root.getPath();
            root.getPayload(); // forces a load
            sw.stop();

            // Walk the infos for nodes under the root (this is recursive) ...
            walkInfosForNodesUnder(root, sw);
            System.out.println("Statistics for walking nodes using SessionCache: " + sw.getSimpleStatistics() + "  -> "
                               + super.numberOfConnections);
        }
    }
View Full Code Here

    @Test
    public void shouldFindInfoForAllNodesInGraphWithLoadingDepthOf2() throws Exception {
        cache.graphSession().setDepthForLoadingNodes(2);
        for (int i = 0; i != 3; ++i) {
            super.numberOfConnections = 0;
            Stopwatch sw = new Stopwatch();

            // Get the root ...
            sw.start();
            Node<JcrNodePayload, JcrPropertyPayload> root = cache.findNode(null, path("/"));
            root.getPath();
            root.getPayload(); // forces a load
            sw.stop();

            // Walk the infos for nodes under the root (this is recursive) ...
            walkInfosForNodesUnder(root, sw);
            System.out.println("Statistics for walking nodes using SessionCache: " + sw.getSimpleStatistics() + "  -> "
                               + super.numberOfConnections);
        }
    }
View Full Code Here

    @Test
    public void shouldFindInfoForAllNodesInGraphWithLoadingDepthOf4() throws Exception {
        cache.graphSession().setDepthForLoadingNodes(6);
        for (int i = 0; i != 3; ++i) {
            Stopwatch sw = new Stopwatch();
            super.numberOfConnections = 0;

            // Get the root ...
            sw.start();
            Node<JcrNodePayload, JcrPropertyPayload> root = cache.findNode(null, path("/"));
            root.getPath();
            root.getPayload(); // forces a load
            sw.stop();

            // Walk the infos for nodes under the root (this is recursive) ...
            walkInfosForNodesUnder(root, sw);
            System.out.println("Statistics for walking nodes using SessionCache: " + sw.getSimpleStatistics() + "  -> "
                               + super.numberOfConnections);
        }
    }
View Full Code Here

    FederatedRepositoryConnection( FederatedRepository repository,
                                   Observer observer ) {
        this.repository = repository;
        this.logger = Logger.getLogger(getClass());
        this.stopwatch = logger.isTraceEnabled() ? new Stopwatch() : null;
        this.observer = observer;
    }
View Full Code Here

     *      org.jboss.dna.graph.request.Request)
     */
    public void execute( ExecutionContext context,
                         Request request ) throws RepositorySourceException {
        Logger logger = context.getLogger(getClass());
        Stopwatch sw = null;
        if (logger.isTraceEnabled()) {
            sw = new Stopwatch();
            sw.start();
        }

        // Do any commands update/write?
        PathRequestProcessor processor = repository.createRequestProcessor(context, source);
        PathRepositoryTransaction txn = processor.getTransaction();

        boolean commit = true;
        try {
            // Obtain the lock and execute the commands ...
            processor.process(request);
            if (request.hasError() && !request.isReadOnly()) {
                // The changes failed, so we need to rollback so we have 'all-or-nothing' behavior
                commit = false;
            }
        } catch (Throwable error) {
            commit = false;
        } finally {
            try {
                processor.close();
            } finally {
                // Now commit or rollback ...
                try {
                    if (commit) {
                        txn.commit();
                    } else {
                        // Need to rollback the changes made to the repository ...
                        txn.rollback();
                    }
                } catch (Throwable commitOrRollbackError) {
                    if (commit && !request.hasError() && !request.isFrozen()) {
                        // Record the error on the request ...
                        request.setError(commitOrRollbackError);
                    }
                    commit = false; // couldn't do it
                }
                if (commit) {
                    // Now that we've closed our transaction, we can notify the observer of the committed changes ...
                    processor.notifyObserverOfChanges();
                }
            }
        }

        if (logger.isTraceEnabled()) {
            assert sw != null;
            sw.stop();
            logger.trace(getClass().getSimpleName() + ".execute(...) took " + sw.getTotalDuration());
        }
    }
View Full Code Here

     *      org.jboss.dna.graph.request.Request)
     */
    public void execute( ExecutionContext context,
                         Request request ) throws RepositorySourceException {
        Logger logger = context.getLogger(getClass());
        Stopwatch sw = null;
        if (logger.isTraceEnabled()) {
            sw = new Stopwatch();
            sw.start();
        }
        // Do any commands update/write?
        RepositoryContext repositoryContext = this.source.getRepositoryContext();
        Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
        RequestProcessor processor = new MapRequestProcessor(context, this.repository, observer, source.areUpdatesAllowed());

        boolean commit = true;
        MapRepositoryTransaction txn = repository.startTransaction(request.isReadOnly());
        try {
            // Obtain the lock and execute the commands ...
            processor.process(request);
            if (request.hasError() && !request.isReadOnly()) {
                // The changes failed, so we need to rollback so we have 'all-or-nothing' behavior
                commit = false;
            }
        } catch (Throwable error) {
            commit = false;
        } finally {
            try {
                processor.close();
            } finally {
                // Now commit or rollback ...
                try {
                    if (commit) {
                        txn.commit();
                    } else {
                        // Need to rollback the changes made to the repository ...
                        txn.rollback();
                    }
                } catch (Throwable commitOrRollbackError) {
                    if (commit && !request.hasError() && !request.isFrozen()) {
                        // Record the error on the request ...
                        request.setError(commitOrRollbackError);
                    }
                    commit = false; // couldn't do it
                }
                if (commit) {
                    // Now that we've closed our transaction, we can notify the observer of the committed changes ...
                    processor.notifyObserverOfChanges();
                }
            }
        }
        if (logger.isTraceEnabled()) {
            assert sw != null;
            sw.stop();
            logger.trace("MapRepositoryConnection.execute(...) took " + sw.getTotalDuration());
        }
    }
View Full Code Here

    private Stopwatch stopwatch;
    private long totalPauseTimeInMillis;

    @Before
    public void beforeEach() {
        this.stopwatch = new Stopwatch();
    }
View Full Code Here

    FederatedRepositoryConnection( FederatedRepository repository,
                                   Observer observer ) {
        this.repository = repository;
        this.logger = Logger.getLogger(getClass());
        this.stopwatch = logger.isTraceEnabled() ? new Stopwatch() : null;
        this.observer = observer;
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.common.statistic.Stopwatch

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.