MongoDocumentStore implements DocumentStore { <T extends Document> MongoCollection<BasicDBObject> getDBCollection(Collection<T> collection) { if (collection == Collection.NODES) { return nodes; } else if (collection == Collection.CLUSTER_NODES) { return clusterNodes; } else if (collection == Collection.SETTINGS) { return settings; } else if (collection == Collection.JOURNAL) { return journal; } else { throw new IllegalArgumentException( "Unknown collection: " + collection.toString()); } } MongoDocumentStore(MongoClient client, MongoDatabase db,
                              MongoDocumentNodeStoreBuilderBase<?> builder); boolean isReadOnly(); @Override void finalize(); @Override CacheInvalidationStats invalidateCache(); @Override CacheInvalidationStats invalidateCache(Iterable<String> keys); @Override void invalidateCache(Collection<T> collection, String key); @Override T find(Collection<T> collection, String key); @Override T find(final Collection<T> collection,
                                       final String key,
                                       int maxCacheAge); @NotNull @Override List<T> query(Collection<T> collection,
                                String fromKey,
                                String toKey,
                                int limit); @NotNull @Override List<T> query(Collection<T> collection,
                                              String fromKey,
                                              String toKey,
                                              String indexedProperty,
                                              long startValue,
                                              int limit); @Override void remove(Collection<T> collection, String key); @Override void remove(Collection<T> collection, List<String> keys); @Override int remove(Collection<T> collection, Map<String, Long> toRemove); @Override int remove(Collection<T> collection,
                                    String indexedProperty, long startValue, long endValue); @Nullable @Override T createOrUpdate(Collection<T> collection, UpdateOp update); @SuppressWarnings("unchecked") @Nullable @Override List<T> createOrUpdate(Collection<T> collection,
                                                       List<UpdateOp> updateOps); @Override T findAndUpdate(Collection<T> collection, UpdateOp update); @Override boolean create(Collection<T> collection, List<UpdateOp> updateOps); @Override void dispose(); @Override Iterable<CacheStats> getCacheStats(); @Override Map<String, String> getMetadata(); @NotNull @Override Map<String, String> getStats(); @Override T getIfCached(Collection<T> collection, String key); @Override void setReadWriteMode(String readWriteMode); void setStatsCollector(DocumentStoreStatsCollector stats); @Override long determineServerTimeDifferenceMillis(); static final int IN_CLAUSE_BATCH_SIZE; }
@Test public void defaultIndexes() { assertTrue(hasIndex(store.getDBCollection(Collection.NODES), Document.ID)); assertFalse(hasIndex(store.getDBCollection(Collection.NODES), NodeDocument.SD_TYPE)); assertTrue(hasIndex(store.getDBCollection(Collection.NODES), NodeDocument.SD_TYPE, NodeDocument.SD_MAX_REV_TIME_IN_SECS)); if (new MongoStatus(mongoConnection.getMongoClient(), mongoConnection.getDBName()).isVersion(3, 2)) { assertTrue(hasIndex(store.getDBCollection(Collection.NODES), NodeDocument.DELETED_ONCE, NodeDocument.MODIFIED_IN_SECS)); } else { assertTrue(hasIndex(store.getDBCollection(Collection.NODES), NodeDocument.DELETED_ONCE)); } assertTrue(hasIndex(store.getDBCollection(Collection.NODES), NodeDocument.HAS_BINARY_FLAG)); assertTrue(hasIndex(store.getDBCollection(Collection.NODES), NodeDocument.MODIFIED_IN_SECS, Document.ID)); assertFalse(hasIndex(store.getDBCollection(Collection.NODES), NodeDocument.MODIFIED_IN_SECS)); assertTrue(hasIndex(store.getDBCollection(Collection.JOURNAL), JournalEntry.MODIFIED)); }
@Test public void oak6423() throws Exception { MongoConnection c = connectionFactory.getConnection(); assertNotNull(c); DocumentMK.Builder builder = new DocumentMK.Builder(); TestStore s = new TestStore(c, builder); if (new MongoStatus(mongoConnection.getMongoClient(), mongoConnection.getDBName()).isVersion(3, 2)) { assertFalse(hasIndex(s.getDBCollection(Collection.NODES), NodeDocument.DELETED_ONCE)); } else { assertFalse(hasIndex(s.getDBCollection(Collection.NODES), NodeDocument.DELETED_ONCE, NodeDocument.MODIFIED_IN_SECS)); } }