Example usage for org.apache.solr.common SolrException log

List of usage examples for org.apache.solr.common SolrException log

Introduction

In this page you can find the example usage for org.apache.solr.common SolrException log.

Prototype

public static void log(Logger log, String msg) 

Source Link

Usage

From source file:org.alfresco.solr.AlfrescoUpdateHandler.java

License:Open Source License

public void commit(CommitUpdateCommand cmd) throws IOException {

    if (cmd.optimize) {
        optimizeCommands.incrementAndGet();
    } else {/*  w ww .  ja  va2  s .c  o m*/
        commitCommands.incrementAndGet();
        if (cmd.expungeDeletes)
            expungeDeleteCommands.incrementAndGet();
    }

    Future[] waitSearcher = null;
    if (cmd.waitSearcher) {
        waitSearcher = new Future[1];
    }

    boolean error = true;
    iwCommit.lock();
    try {
        log.info("start " + cmd);

        if (cmd.optimize) {
            openWriter();
            writer.optimize(cmd.maxOptimizeSegments);
        } else if (cmd.expungeDeletes) {
            openWriter();
            writer.expungeDeletes();
        }

        closeWriter();

        callPostCommitCallbacks();
        if (cmd.optimize) {
            callPostOptimizeCallbacks();
        }

        // Add tracking data to the old searcher
        RefCounted<SolrIndexSearcher> refCounted = core.getSearcher(false, true, null);
        SolrIndexSearcher oldSearcher = refCounted.get();
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_ADDED_LEAVES, addedLeaves);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_ADDED_AUX, addedAux);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_ADDED_ACL, addedAcl);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_UPDATED_LEAVES, updatedLeaves);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_UPDATED_AUX, updatedAux);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_UPDATED_ACL, updatedAcl);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_DELETED_LEAVES, deletedLeaves);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_DELETED_AUX, deletedAux);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_DELETED_ACL, deletedAcl);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_DELETE_ALL, deleteAll);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_CHECK_CACHE, checkCache);

        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_ADDED_TX, addedTx);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_DELETED_TX, deletedTx);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_UPDATED_TX, updatedTx);

        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_ADDED_ACL_TX, addedAclTx);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_DELETED_ACL_TX, deletedAclTx);
        oldSearcher.cacheInsert(AlfrescoSolrEventListener.ALFRESCO_CACHE,
                AlfrescoSolrEventListener.KEY_UPDATED_ACL_TX, updatedAclTx);
        refCounted.decref();

        // open a new searcher in the sync block to avoid opening it
        // after a deleteByQuery changed the index, or in between deletes
        // and adds of another commit being done.
        core.getSearcher(true, false, waitSearcher);

        // reset commit tracking
        tracker.didCommit();

        log.info("end_commit_flush");

        addedLeaves = new ConcurrentHashMap<Long, Long>();
        addedAux = new ConcurrentHashMap<Long, Long>();
        addedAcl = new ConcurrentHashMap<Long, Long>();
        updatedLeaves = new ConcurrentHashMap<Long, Long>();
        updatedAux = new ConcurrentHashMap<Long, Long>();
        updatedAcl = new ConcurrentHashMap<Long, Long>();
        deletedLeaves = new ConcurrentHashMap<Long, Long>();
        deletedAux = new ConcurrentHashMap<Long, Long>();
        deletedAcl = new ConcurrentHashMap<Long, Long>();

        deleteAll = new AtomicBoolean(false);
        checkCache = new AtomicBoolean(false);

        addedTx = new ConcurrentHashMap<Long, Long>();
        deletedTx = new ConcurrentHashMap<Long, Long>();
        updatedTx = new ConcurrentHashMap<Long, Long>();

        addedAclTx = new ConcurrentHashMap<Long, Long>();
        deletedAclTx = new ConcurrentHashMap<Long, Long>();
        updatedAclTx = new ConcurrentHashMap<Long, Long>();

        error = false;
    } finally {
        iwCommit.unlock();
        addCommands.set(0);
        deleteByIdCommands.set(0);
        deleteByQueryCommands.set(0);
        numErrors.set(error ? 1 : 0);

    }

    // if we are supposed to wait for the searcher to be registered, then we should do it
    // outside of the synchronized block so that other update operations can proceed.
    if (waitSearcher != null && waitSearcher[0] != null) {
        try {
            waitSearcher[0].get();
        } catch (InterruptedException e) {
            SolrException.log(log, e);
        } catch (ExecutionException e) {
            SolrException.log(log, e);
        }
    }
}