use of org.alfresco.solr.adapters.IOpenBitSet in project SearchServices by Alfresco.
the class SolrInformationServer method reportTransactionInfo.
private void reportTransactionInfo(TransactionInfoReporter reporter, Long minId, long maxId, IOpenBitSet idsInDb, SolrQueryRequest request, String field) {
if (minId != null) {
IOpenBitSet idsInIndex = this.getOpenBitSetInstance();
long batchStartId = minId;
long batchEndId = Math.min(batchStartId + BATCH_FACET_TXS, maxId);
// Continues as long as the batch does not pass the maximum
while (batchStartId <= maxId) {
long iterationStart = batchStartId;
NamedList<Integer> idCounts = this.getFacets(request, field + ":[" + batchStartId + " TO " + batchEndId + "]", field, // Min count of 1 ensures that the id returned is in the index
1);
for (Map.Entry<String, Integer> idCount : idCounts) {
long idInIndex = Long.valueOf(idCount.getKey());
// Only looks at facet values that fit the query
if (batchStartId <= idInIndex && idInIndex <= batchEndId) {
idsInIndex.set(idInIndex);
// The sequence of ids in the index could look like this: 1, 2, 5, 7...
for (long id = iterationStart; id <= idInIndex; id++) {
if (id == idInIndex) {
iterationStart = idInIndex + 1;
if (!idsInDb.get(id)) {
reporter.reportIdInIndexButNotInDb(id);
}
} else if (idsInDb.get(id)) {
reporter.reportIdInDbButNotInIndex(id);
}
}
if (idCount.getValue().intValue() > 1) {
reporter.reportDuplicatedIdInIndex(idInIndex);
}
} else {
break;
}
}
batchStartId = batchEndId + 1;
batchEndId = Math.min(batchStartId + BATCH_FACET_TXS, maxId);
}
reporter.reportUniqueIdsInIndex(idsInIndex.cardinality());
}
}
use of org.alfresco.solr.adapters.IOpenBitSet in project SearchServices by Alfresco.
the class AlfrescoCoreAdminHandler method actionFIX.
private void actionFIX(String coreName) throws AuthenticationException, IOException, JSONException, EncoderException {
// Gets Metadata health and fixes any problems
MetadataTracker metadataTracker = trackerRegistry.getTrackerForCore(coreName, MetadataTracker.class);
IndexHealthReport indexHealthReport = metadataTracker.checkIndex(null, null, null, null);
IOpenBitSet toReindex = indexHealthReport.getTxInIndexButNotInDb();
toReindex.or(indexHealthReport.getDuplicatedTxInIndex());
toReindex.or(indexHealthReport.getMissingTxFromIndex());
long current = -1;
// Goes through problems in the index
while ((current = toReindex.nextSetBit(current + 1)) != -1) {
metadataTracker.addTransactionToReindex(current);
}
// Gets the Acl health and fixes any problems
AclTracker aclTracker = trackerRegistry.getTrackerForCore(coreName, AclTracker.class);
indexHealthReport = aclTracker.checkIndex(null, null, null, null);
toReindex = indexHealthReport.getAclTxInIndexButNotInDb();
toReindex.or(indexHealthReport.getDuplicatedAclTxInIndex());
toReindex.or(indexHealthReport.getMissingAclTxFromIndex());
current = -1;
// Goes through the problems in the index
while ((current = toReindex.nextSetBit(current + 1)) != -1) {
aclTracker.addAclChangeSetToReindex(current);
}
}
use of org.alfresco.solr.adapters.IOpenBitSet in project SearchServices by Alfresco.
the class MetadataTracker method checkIndex.
public IndexHealthReport checkIndex(Long toTx, Long toAclTx, Long fromTime, Long toTime) throws IOException, AuthenticationException, JSONException, EncoderException {
// DB TX Count
long firstTransactionCommitTime = 0;
Transactions firstTransactions = client.getTransactions(null, 0L, null, 2000L, 1);
if (firstTransactions.getTransactions().size() > 0) {
Transaction firstTransaction = firstTransactions.getTransactions().get(0);
firstTransactionCommitTime = firstTransaction.getCommitTimeMs();
}
IOpenBitSet txIdsInDb = infoSrv.getOpenBitSetInstance();
Long lastTxCommitTime = Long.valueOf(firstTransactionCommitTime);
if (fromTime != null) {
lastTxCommitTime = fromTime;
}
long maxTxId = 0;
Long minTxId = null;
Transactions transactions;
BoundedDeque<Transaction> txnsFound = new BoundedDeque<Transaction>(100);
long endTime = System.currentTimeMillis() + infoSrv.getHoleRetention();
DO: do {
transactions = getSomeTransactions(txnsFound, lastTxCommitTime, TIME_STEP_1_HR_IN_MS, 2000, endTime);
for (Transaction info : transactions.getTransactions()) {
// include
if (toTime != null) {
if (info.getCommitTimeMs() > toTime.longValue()) {
break DO;
}
}
if (toTx != null) {
if (info.getId() > toTx.longValue()) {
break DO;
}
}
// bounds for later loops
if (minTxId == null) {
minTxId = info.getId();
}
if (maxTxId < info.getId()) {
maxTxId = info.getId();
}
lastTxCommitTime = info.getCommitTimeMs();
txIdsInDb.set(info.getId());
txnsFound.add(info);
}
} while (transactions.getTransactions().size() > 0);
return this.infoSrv.reportIndexTransactions(minTxId, txIdsInDb, maxTxId);
}
use of org.alfresco.solr.adapters.IOpenBitSet 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);
}
Aggregations