use of org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate in project jackrabbit-oak by apache.
the class AsyncPropertyIndexTest method testAsyncPropertyNoChanges.
@Test
public void testAsyncPropertyNoChanges() throws Exception {
NodeStore store = new MemoryNodeStore();
assertTrue(Iterables.isEmpty(store.checkpoints()));
AsyncIndexUpdate async = new AsyncIndexUpdate(ASYNC_REINDEX_VALUE, store, provider, true);
async.run();
async.run();
async.close();
assertTrue(Iterables.isEmpty(store.checkpoints()));
}
use of org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate in project jackrabbit-oak by apache.
the class OakTest method closeAsyncIndexers.
@Test
public void closeAsyncIndexers() throws Exception {
final AtomicReference<AsyncIndexUpdate> async = new AtomicReference<AsyncIndexUpdate>();
Whiteboard wb = new DefaultWhiteboard() {
@Override
public <T> Registration register(Class<T> type, T service, Map<?, ?> properties) {
if (service instanceof AsyncIndexUpdate) {
async.set((AsyncIndexUpdate) service);
}
return super.register(type, service, properties);
}
};
Oak oak = new Oak().with(new OpenSecurityProvider()).with(wb).withAsyncIndexing("foo-async", 5);
ContentRepository repo = oak.createContentRepository();
((Closeable) repo).close();
assertNotNull(async.get());
assertTrue(async.get().isClosed());
assertNull(WhiteboardUtils.getService(wb, AsyncIndexUpdate.class));
}
use of org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate in project jackrabbit-oak by apache.
the class IndexImporterTest method laneUnlockedInCaseOfFailure.
@Test
public void laneUnlockedInCaseOfFailure() throws Exception {
NodeBuilder builder = store.getRoot().builder();
createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "fooIndex", true, false, ImmutableSet.of("foo"), null).setProperty(ASYNC_PROPERTY_NAME, "async");
builder.child("a").setProperty("foo", "abc");
builder.child("b").setProperty("foo", "abc");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
new AsyncIndexUpdate("async", store, provider).run();
String checkpoint = createIndexDirs("/oak:index/fooIndex");
builder = store.getRoot().builder();
builder.child("c").setProperty("foo", "abc");
builder.child("d").setProperty("foo", "abc");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
new AsyncIndexUpdate("async", store, provider).run();
IndexImporterProvider importerProvider = new IndexImporterProvider() {
@Override
public void importIndex(NodeState root, NodeBuilder defn, File indexDir) {
}
@Override
public String getType() {
return "property";
}
};
final String exceptionMessage = "TEST MESSAGE";
ClusterNodeStoreLock lock = new ClusterNodeStoreLock(store);
provider = new PropertyIndexEditorProvider() {
@Override
public Editor getIndexEditor(@Nonnull String type, @Nonnull NodeBuilder definition, @Nonnull NodeState root, @Nonnull IndexUpdateCallback callback) {
throw new RuntimeException(exceptionMessage);
}
};
IndexImporter importer = new IndexImporter(store, temporaryFolder.getRoot(), provider, lock);
importer.addImporterProvider(importerProvider);
try {
importer.importIndex();
fail();
} catch (RuntimeException ignore) {
}
assertFalse(lock.isLocked("async"));
AsyncIndexerLock lock2 = new AsyncIndexerLock() {
@Override
public LockToken lock(String asyncIndexerLane) throws CommitFailedException {
return mock(LockToken.class);
}
@Override
public void unlock(LockToken token) throws CommitFailedException {
throw new IllegalStateException("Exception in unlock");
}
};
IndexImporter importer2 = new IndexImporter(store, temporaryFolder.getRoot(), provider, lock2);
importer2.addImporterProvider(importerProvider);
try {
importer2.importIndex();
fail();
} catch (RuntimeException ignore) {
assertEquals(exceptionMessage, ignore.getMessage());
}
}
use of org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate in project jackrabbit-oak by apache.
the class ActiveDeletedBlobCollectionIT method createRepository.
@Override
protected ContentRepository createRepository() {
adbc = new ActiveDeletedBlobCollectorImpl(clock, new File(blobCollectionRoot.getRoot(), "deleted-blobs"), executorService);
IndexCopier copier = createIndexCopier();
editorProvider = new LuceneIndexEditorProvider(copier, null, new ExtractedTextCache(10 * FileUtils.ONE_MB, 100), null, Mounts.defaultMountInfoProvider(), adbc);
provider = new LuceneIndexProvider(copier);
mongoConnection = connectionFactory.getConnection();
MongoUtils.dropCollections(mongoConnection.getDatabase());
if (dataStoreType == DataStoreType.WITHOUT_FDS) {
MongoBlobStore blobStore = new MongoBlobStore(mongoConnection.getDatabase());
blobStore.setBlockSize(128);
blobStore.setBlockSizeMin(48);
this.blobStore = new CountingBlobStore(blobStore);
} else {
FileDataStore fds = new FileDataStore();
fds.init(fileDataStoreRoot.getRoot().getAbsolutePath());
DataStoreBlobStore dsbs = new DataStoreBlobStore(fds);
dsbs.setBlockSize(128);
this.blobStore = new CountingBlobStore(dsbs);
}
nodeStore = new DocumentMK.Builder().setMongoDB(mongoConnection.getMongoClient(), mongoConnection.getDBName()).setBlobStore(this.blobStore).getNodeStore();
asyncIndexUpdate = new AsyncIndexUpdate("async", nodeStore, editorProvider);
return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(editorProvider).createContentRepository();
}
use of org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate in project jackrabbit-oak by apache.
the class ActiveDeletedBlobSyncTrackerTest method createRepository.
@Override
protected ContentRepository createRepository() {
try {
File blobCollectorDeleted = new File(blobCollectionRoot.getRoot(), "deleted-blobs");
blobCollectorDeleted.mkdirs();
adbc = new ActiveDeletedBlobCollectorImpl(clock, new File(blobCollectionRoot.getRoot(), "deleted-blobs"), executorService);
IndexCopier copier = createIndexCopier();
editorProvider = new LuceneIndexEditorProvider(copier, null, new ExtractedTextCache(10 * FileUtils.ONE_MB, 100), null, Mounts.defaultMountInfoProvider(), adbc);
provider = new LuceneIndexProvider(copier);
OakFileDataStore ds = new OakFileDataStore();
ds.setMinRecordLength(10);
ds.init(fileDataStoreRoot.getRoot().getAbsolutePath());
DataStoreBlobStore dsbs = new DataStoreBlobStore(ds);
this.blobStore = new AbstractActiveDeletedBlobTest.CountingBlobStore(dsbs);
FileStore store = FileStoreBuilder.fileStoreBuilder(temporaryFolder.getRoot()).withMemoryMapping(false).withBlobStore(blobStore).build();
nodeStore = SegmentNodeStoreBuilders.builder(store).build();
BlobTrackingStore trackingStore = (BlobTrackingStore) blobStore;
trackingStore.addTracker(new BlobIdTracker(blobTrackerRoot.getRoot().getAbsolutePath(), getOrCreateId(nodeStore), 600, dsbs));
// set the blob store to skip writing blobs through the node store
editorProvider.setBlobStore(blobStore);
asyncIndexUpdate = new AsyncIndexUpdate("async", nodeStore, editorProvider);
return new Oak(nodeStore).with(new InitialContent()).with(new OpenSecurityProvider()).with((QueryIndexProvider) provider).with((Observer) provider).with(editorProvider).createContentRepository();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations