Search in sources :

Example 1 with NODES

use of org.apache.jackrabbit.oak.plugins.document.Collection.NODES in project jackrabbit-oak by apache.

the class MongoBlobReferenceIterator method getIteratorOverDocsWithBinaries.

@Override
public Iterator<NodeDocument> getIteratorOverDocsWithBinaries() {
    Bson query = Filters.eq(NodeDocument.HAS_BINARY_FLAG, NodeDocument.HAS_BINARY_VAL);
    // TODO It currently prefers secondary. Would that be Ok?
    MongoCursor<BasicDBObject> cursor = documentStore.getDBCollection(NODES).withReadPreference(documentStore.getConfiguredReadPreference(NODES)).find(query).iterator();
    return CloseableIterator.wrap(transform(cursor, input -> documentStore.convertFromDBObject(NODES, input)), cursor);
}
Also used : Bson(org.bson.conversions.Bson) Filters(com.mongodb.client.model.Filters) Iterator(java.util.Iterator) MongoCursor(com.mongodb.client.MongoCursor) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) BasicDBObject(com.mongodb.BasicDBObject) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument) Iterators.transform(com.google.common.collect.Iterators.transform) BlobReferenceIterator(org.apache.jackrabbit.oak.plugins.document.BlobReferenceIterator) NODES(org.apache.jackrabbit.oak.plugins.document.Collection.NODES) CloseableIterator(org.apache.jackrabbit.oak.plugins.document.util.CloseableIterator) BasicDBObject(com.mongodb.BasicDBObject) Bson(org.bson.conversions.Bson)

Example 2 with NODES

use of org.apache.jackrabbit.oak.plugins.document.Collection.NODES in project jackrabbit-oak by apache.

the class MongoMissingLastRevSeeker method getCandidates.

@Override
@Nonnull
public CloseableIterable<NodeDocument> getCandidates(final long startTime) {
    Bson query = Filters.gte(NodeDocument.MODIFIED_IN_SECS, NodeDocument.getModifiedInSecs(startTime));
    Bson sortFields = new BasicDBObject(NodeDocument.MODIFIED_IN_SECS, 1);
    FindIterable<BasicDBObject> cursor = getNodeCollection().withReadPreference(ReadPreference.primary()).find(query).sort(sortFields);
    return CloseableIterable.wrap(transform(cursor, input -> store.convertFromDBObject(NODES, input)));
}
Also used : ReadPreference(com.mongodb.ReadPreference) Iterables.transform(com.google.common.collect.Iterables.transform) MongoCollection(com.mongodb.client.MongoCollection) BasicDBObject(com.mongodb.BasicDBObject) Filters(com.mongodb.client.model.Filters) Bson(org.bson.conversions.Bson) CloseableIterable(org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable) Clock(org.apache.jackrabbit.oak.stats.Clock) MissingLastRevSeeker(org.apache.jackrabbit.oak.plugins.document.MissingLastRevSeeker) FindIterable(com.mongodb.client.FindIterable) ClusterNodeInfo(org.apache.jackrabbit.oak.plugins.document.ClusterNodeInfo) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument) Nonnull(javax.annotation.Nonnull) CLUSTER_NODES(org.apache.jackrabbit.oak.plugins.document.Collection.CLUSTER_NODES) NODES(org.apache.jackrabbit.oak.plugins.document.Collection.NODES) BasicDBObject(com.mongodb.BasicDBObject) Bson(org.bson.conversions.Bson) Nonnull(javax.annotation.Nonnull)

Example 3 with NODES

use of org.apache.jackrabbit.oak.plugins.document.Collection.NODES in project jackrabbit-oak by apache.

the class MongoVersionGCSupport method logSplitDocIdsTobeDeleted.

private void logSplitDocIdsTobeDeleted(Bson query) {
    // Fetch only the id
    final BasicDBObject keys = new BasicDBObject(Document.ID, 1);
    List<String> ids = new ArrayList<>();
    getNodeCollection().withReadPreference(store.getConfiguredReadPreference(NODES)).find(query).projection(keys).forEach((Block<BasicDBObject>) doc -> ids.add(getID(doc)));
    StringBuilder sb = new StringBuilder("Split documents with following ids were deleted as part of GC \n");
    Joiner.on(StandardSystemProperty.LINE_SEPARATOR.value()).appendTo(sb, ids);
    LOG.debug(sb.toString());
}
Also used : ReadPreference(com.mongodb.ReadPreference) MongoCollection(com.mongodb.client.MongoCollection) Iterables.transform(com.google.common.collect.Iterables.transform) LoggerFactory(org.slf4j.LoggerFactory) SD_MAX_REV_TIME_IN_SECS(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SD_MAX_REV_TIME_IN_SECS) MODIFIED_IN_SECS(org.apache.jackrabbit.oak.plugins.document.NodeDocument.MODIFIED_IN_SECS) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Filters(com.mongodb.client.model.Filters) Bson(org.bson.conversions.Bson) Utils(org.apache.jackrabbit.oak.plugins.document.util.Utils) Lists(com.google.common.collect.Lists) CloseableIterable(org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable) StandardSystemProperty(com.google.common.base.StandardSystemProperty) SD_TYPE(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SD_TYPE) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument) SplitDocType(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType) RevisionVector(org.apache.jackrabbit.oak.plugins.document.RevisionVector) Nonnull(javax.annotation.Nonnull) PATH(org.apache.jackrabbit.oak.plugins.document.NodeDocument.PATH) Revision(org.apache.jackrabbit.oak.plugins.document.Revision) NODES(org.apache.jackrabbit.oak.plugins.document.Collection.NODES) DELETED_ONCE(org.apache.jackrabbit.oak.plugins.document.NodeDocument.DELETED_ONCE) Function(com.google.common.base.Function) SplitDocumentCleanUp(org.apache.jackrabbit.oak.plugins.document.SplitDocumentCleanUp) Logger(org.slf4j.Logger) NodeDocument.getModifiedInSecs(org.apache.jackrabbit.oak.plugins.document.NodeDocument.getModifiedInSecs) BasicDBObject(com.mongodb.BasicDBObject) Set(java.util.Set) VersionGCSupport(org.apache.jackrabbit.oak.plugins.document.VersionGCSupport) VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Block(com.mongodb.Block) Clock(org.apache.jackrabbit.oak.stats.Clock) Predicate(com.google.common.base.Predicate) FindIterable(com.mongodb.client.FindIterable) Document(org.apache.jackrabbit.oak.plugins.document.Document) ID(org.apache.jackrabbit.oak.plugins.document.Document.ID) Pattern(java.util.regex.Pattern) Iterables.filter(com.google.common.collect.Iterables.filter) Joiner(com.google.common.base.Joiner) DEFAULT_NO_BRANCH(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.DEFAULT_NO_BRANCH) BasicDBObject(com.mongodb.BasicDBObject) ArrayList(java.util.ArrayList)

Example 4 with NODES

use of org.apache.jackrabbit.oak.plugins.document.Collection.NODES in project jackrabbit-oak by apache.

the class MongoVersionGCSupport method getPossiblyDeletedDocs.

@Override
public CloseableIterable<NodeDocument> getPossiblyDeletedDocs(final long fromModified, final long toModified) {
    // _deletedOnce == true && _modified >= fromModified && _modified < toModified
    Bson query = Filters.and(Filters.eq(DELETED_ONCE, true), Filters.gte(MODIFIED_IN_SECS, getModifiedInSecs(fromModified)), Filters.lt(MODIFIED_IN_SECS, getModifiedInSecs(toModified)));
    FindIterable<BasicDBObject> cursor = getNodeCollection().withReadPreference(ReadPreference.secondaryPreferred()).find(query).batchSize(batchSize);
    return CloseableIterable.wrap(transform(cursor, input -> store.convertFromDBObject(NODES, input)));
}
Also used : ReadPreference(com.mongodb.ReadPreference) MongoCollection(com.mongodb.client.MongoCollection) Iterables.transform(com.google.common.collect.Iterables.transform) LoggerFactory(org.slf4j.LoggerFactory) SD_MAX_REV_TIME_IN_SECS(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SD_MAX_REV_TIME_IN_SECS) MODIFIED_IN_SECS(org.apache.jackrabbit.oak.plugins.document.NodeDocument.MODIFIED_IN_SECS) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Filters(com.mongodb.client.model.Filters) Bson(org.bson.conversions.Bson) Utils(org.apache.jackrabbit.oak.plugins.document.util.Utils) Lists(com.google.common.collect.Lists) CloseableIterable(org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable) StandardSystemProperty(com.google.common.base.StandardSystemProperty) SD_TYPE(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SD_TYPE) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument) SplitDocType(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType) RevisionVector(org.apache.jackrabbit.oak.plugins.document.RevisionVector) Nonnull(javax.annotation.Nonnull) PATH(org.apache.jackrabbit.oak.plugins.document.NodeDocument.PATH) Revision(org.apache.jackrabbit.oak.plugins.document.Revision) NODES(org.apache.jackrabbit.oak.plugins.document.Collection.NODES) DELETED_ONCE(org.apache.jackrabbit.oak.plugins.document.NodeDocument.DELETED_ONCE) Function(com.google.common.base.Function) SplitDocumentCleanUp(org.apache.jackrabbit.oak.plugins.document.SplitDocumentCleanUp) Logger(org.slf4j.Logger) NodeDocument.getModifiedInSecs(org.apache.jackrabbit.oak.plugins.document.NodeDocument.getModifiedInSecs) BasicDBObject(com.mongodb.BasicDBObject) Set(java.util.Set) VersionGCSupport(org.apache.jackrabbit.oak.plugins.document.VersionGCSupport) VersionGCStats(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Block(com.mongodb.Block) Clock(org.apache.jackrabbit.oak.stats.Clock) Predicate(com.google.common.base.Predicate) FindIterable(com.mongodb.client.FindIterable) Document(org.apache.jackrabbit.oak.plugins.document.Document) ID(org.apache.jackrabbit.oak.plugins.document.Document.ID) Pattern(java.util.regex.Pattern) Iterables.filter(com.google.common.collect.Iterables.filter) Joiner(com.google.common.base.Joiner) DEFAULT_NO_BRANCH(org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.DEFAULT_NO_BRANCH) BasicDBObject(com.mongodb.BasicDBObject) Bson(org.bson.conversions.Bson)

Aggregations

BasicDBObject (com.mongodb.BasicDBObject)4 Filters (com.mongodb.client.model.Filters)4 NODES (org.apache.jackrabbit.oak.plugins.document.Collection.NODES)4 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)4 Bson (org.bson.conversions.Bson)4 Iterables.transform (com.google.common.collect.Iterables.transform)3 ReadPreference (com.mongodb.ReadPreference)3 FindIterable (com.mongodb.client.FindIterable)3 MongoCollection (com.mongodb.client.MongoCollection)3 Nonnull (javax.annotation.Nonnull)3 CloseableIterable (org.apache.jackrabbit.oak.plugins.document.util.CloseableIterable)3 Clock (org.apache.jackrabbit.oak.stats.Clock)3 Function (com.google.common.base.Function)2 Joiner (com.google.common.base.Joiner)2 Predicate (com.google.common.base.Predicate)2 StandardSystemProperty (com.google.common.base.StandardSystemProperty)2 Iterables.filter (com.google.common.collect.Iterables.filter)2 Lists (com.google.common.collect.Lists)2 Block (com.mongodb.Block)2 ArrayList (java.util.ArrayList)2