Search in sources :

Example 6 with AclChangeSets

use of org.alfresco.solr.client.AclChangeSets 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 7 with AclChangeSets

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

the class AclTracker method getSomeAclChangeSets.

protected AclChangeSets getSomeAclChangeSets(BoundedDeque<AclChangeSet> changeSetsFound, Long fromCommitTime, long timeStep, int maxResults, long endTime) throws AuthenticationException, IOException, JSONException {
    long actualTimeStep = timeStep;
    AclChangeSets aclChangeSets;
    // step forward in time until we find something or hit the time bound
    // max id unbounded
    Long startTime = fromCommitTime == null ? Long.valueOf(0L) : fromCommitTime;
    do {
        aclChangeSets = client.getAclChangeSets(startTime, null, startTime + actualTimeStep, null, maxResults);
        startTime += actualTimeStep;
        actualTimeStep *= 2;
        if (actualTimeStep > TIME_STEP_32_DAYS_IN_MS) {
            actualTimeStep = TIME_STEP_32_DAYS_IN_MS;
        }
    } while (((aclChangeSets.getAclChangeSets().size() == 0) && (startTime < endTime)) || ((aclChangeSets.getAclChangeSets().size() > 0) && alreadyFoundChangeSets(changeSetsFound, aclChangeSets)));
    return aclChangeSets;
}
Also used : AclChangeSets(org.alfresco.solr.client.AclChangeSets)

Example 8 with AclChangeSets

use of org.alfresco.solr.client.AclChangeSets 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

AclChangeSets (org.alfresco.solr.client.AclChangeSets)8 AclChangeSet (org.alfresco.solr.client.AclChangeSet)6 Acl (org.alfresco.solr.client.Acl)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 BoundedDeque (org.alfresco.solr.BoundedDeque)2 AclReaders (org.alfresco.solr.client.AclReaders)2 LinkedHashSet (java.util.LinkedHashSet)1 AuthenticationException (org.alfresco.httpclient.AuthenticationException)1 IOpenBitSet (org.alfresco.solr.adapters.IOpenBitSet)1 JSONException (org.json.JSONException)1