Search in sources :

Example 16 with AclChangeSet

use of org.alfresco.solr.client.AclChangeSet in project SearchServices by Alfresco.

the class AclTracker method checkIndex.

public IndexHealthReport checkIndex(Long toTx, Long toAclTx, Long fromTime, Long toTime) throws AuthenticationException, IOException, JSONException {
    // DB ACL TX Count
    long firstChangeSetCommitTimex = 0;
    AclChangeSets firstChangeSets = client.getAclChangeSets(null, 0L, null, 2000L, 1);
    if (firstChangeSets.getAclChangeSets().size() > 0) {
        AclChangeSet firstChangeSet = firstChangeSets.getAclChangeSets().get(0);
        firstChangeSetCommitTimex = firstChangeSet.getCommitTimeMs();
    }
    IOpenBitSet aclTxIdsInDb = infoSrv.getOpenBitSetInstance();
    Long lastAclTxCommitTime = Long.valueOf(firstChangeSetCommitTimex);
    if (fromTime != null) {
        lastAclTxCommitTime = fromTime;
    }
    long maxAclTxId = 0;
    Long minAclTxId = null;
    long endTime = System.currentTimeMillis() + infoSrv.getHoleRetention();
    AclChangeSets aclTransactions;
    BoundedDeque<AclChangeSet> changeSetsFound = new BoundedDeque<AclChangeSet>(100);
    DO: do {
        aclTransactions = getSomeAclChangeSets(changeSetsFound, lastAclTxCommitTime, TIME_STEP_1_HR_IN_MS, 2000, endTime);
        for (AclChangeSet set : aclTransactions.getAclChangeSets()) {
            // include
            if (toTime != null) {
                if (set.getCommitTimeMs() > toTime.longValue()) {
                    break DO;
                }
            }
            if (toAclTx != null) {
                if (set.getId() > toAclTx.longValue()) {
                    break DO;
                }
            }
            // bounds for later loops
            if (minAclTxId == null) {
                minAclTxId = set.getId();
            }
            if (maxAclTxId < set.getId()) {
                maxAclTxId = set.getId();
            }
            lastAclTxCommitTime = set.getCommitTimeMs();
            aclTxIdsInDb.set(set.getId());
            changeSetsFound.add(set);
        }
    } while (aclTransactions.getAclChangeSets().size() > 0);
    return this.infoSrv.reportAclTransactionsInIndex(minAclTxId, aclTxIdsInDb, maxAclTxId);
}
Also used : BoundedDeque(org.alfresco.solr.BoundedDeque) AclChangeSets(org.alfresco.solr.client.AclChangeSets) IOpenBitSet(org.alfresco.solr.adapters.IOpenBitSet) AclChangeSet(org.alfresco.solr.client.AclChangeSet)

Example 17 with AclChangeSet

use of org.alfresco.solr.client.AclChangeSet in project SearchServices by Alfresco.

the class AclTracker method reindexAclChangeSets.

protected void reindexAclChangeSets() throws AuthenticationException, IOException, JSONException {
    boolean requiresCommit = false;
    while (aclChangeSetsToReindex.peek() != null) {
        Long aclChangeSetId = aclChangeSetsToReindex.poll();
        if (aclChangeSetId != null) {
            this.infoSrv.deleteByAclChangeSetId(aclChangeSetId);
            AclChangeSets aclChangeSets = client.getAclChangeSets(null, aclChangeSetId, null, aclChangeSetId + 1, 1);
            if ((aclChangeSets.getAclChangeSets().size() > 0) && aclChangeSetId.equals(aclChangeSets.getAclChangeSets().get(0).getId())) {
                AclChangeSet changeSet = aclChangeSets.getAclChangeSets().get(0);
                List<Acl> acls = client.getAcls(Collections.singletonList(changeSet), null, Integer.MAX_VALUE);
                for (Acl acl : acls) {
                    List<AclReaders> readers = client.getAclReaders(Collections.singletonList(acl));
                    indexAcl(readers, true);
                }
                this.infoSrv.indexAclTransaction(changeSet, true);
                requiresCommit = true;
            }
        }
        checkShutdown();
    }
    if (requiresCommit) {
        checkShutdown();
    // this.infoSrv.commit();
    }
}
Also used : AclChangeSets(org.alfresco.solr.client.AclChangeSets) Acl(org.alfresco.solr.client.Acl) AclChangeSet(org.alfresco.solr.client.AclChangeSet) AclReaders(org.alfresco.solr.client.AclReaders)

Aggregations

AclChangeSet (org.alfresco.solr.client.AclChangeSet)17 Acl (org.alfresco.solr.client.Acl)11 AclReaders (org.alfresco.solr.client.AclReaders)10 ArrayList (java.util.ArrayList)9 AlfrescoSolrUtils.getAcl (org.alfresco.solr.AlfrescoSolrUtils.getAcl)8 AlfrescoSolrUtils.getAclChangeSet (org.alfresco.solr.AlfrescoSolrUtils.getAclChangeSet)8 AlfrescoSolrUtils.getAclReaders (org.alfresco.solr.AlfrescoSolrUtils.getAclReaders)8 AlfrescoSolrUtils.getNode (org.alfresco.solr.AlfrescoSolrUtils.getNode)8 AlfrescoSolrUtils.getNodeMetaData (org.alfresco.solr.AlfrescoSolrUtils.getNodeMetaData)8 AlfrescoSolrUtils.getTransaction (org.alfresco.solr.AlfrescoSolrUtils.getTransaction)8 AlfrescoSolrUtils.indexAclChangeSet (org.alfresco.solr.AlfrescoSolrUtils.indexAclChangeSet)8 Node (org.alfresco.solr.client.Node)8 NodeMetaData (org.alfresco.solr.client.NodeMetaData)8 Transaction (org.alfresco.solr.client.Transaction)8 Term (org.apache.lucene.index.Term)8 TermQuery (org.apache.lucene.search.TermQuery)8 Test (org.junit.Test)8 AclChangeSets (org.alfresco.solr.client.AclChangeSets)6 AbstractAlfrescoDistributedTest (org.alfresco.solr.AbstractAlfrescoDistributedTest)4 BooleanClause (org.apache.lucene.search.BooleanClause)4