Search in sources :

Example 1 with DefaultRevisionIndex

use of com.b2international.index.revision.DefaultRevisionIndex in project snow-owl by b2ihealthcare.

the class IndexResource method before.

@Override
protected void before() throws Throwable {
    if (INIT.compareAndSet(false, true)) {
        mapper = new ObjectMapper();
        mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
        client = Indexes.createIndexClient(UUID.randomUUID().toString(), mapper, new Mappings(), indexSettings.get());
        index = new DefaultIndex(client);
        revisionIndex = new DefaultRevisionIndex(index, new TimestampProvider.Default(), mapper);
    }
    // apply mapper changes first
    objectMapperConfigurator.accept(mapper);
    // then mapping changes
    revisionIndex.admin().updateMappings(new Mappings(types));
    // then settings changes
    revisionIndex.admin().updateSettings(indexSettings.get());
    // then make sure we have all indexes ready for tests
    revisionIndex.admin().create();
}
Also used : Mappings(com.b2international.index.mapping.Mappings) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with DefaultRevisionIndex

use of com.b2international.index.revision.DefaultRevisionIndex in project snow-owl by b2ihealthcare.

the class TerminologyRepository method initIndex.

private RevisionIndex initIndex(final ServiceProvider context, Mappings mappings) {
    final ObjectMapper mapper = context.service(ObjectMapper.class);
    IndexConfiguration indexConfiguration = context.service(RepositoryConfiguration.class).getIndexConfiguration();
    final IndexClient indexClient = Indexes.createIndexClient(repositoryId, mapper, mappings, context.service(IndexSettings.class).forIndex(indexConfiguration, repositoryId));
    final Index index = new DefaultIndex(indexClient);
    final RevisionIndex revisionIndex = new DefaultRevisionIndex(index, context.service(TimestampProvider.class), mapper);
    revisionIndex.branching().addBranchChangeListener(path -> {
        new BranchChangedEvent(repositoryId, path).publish(context.service(IEventBus.class));
    });
    // register IndexClient per terminology
    bind(IndexClient.class, indexClient);
    // register index and revision index access, the underlying index is the same
    bind(Index.class, index);
    bind(RevisionIndex.class, revisionIndex);
    // register branching services
    bind(BaseRevisionBranching.class, revisionIndex.branching());
    return revisionIndex;
}
Also used : DefaultIndex(com.b2international.index.DefaultIndex) TimestampProvider(com.b2international.index.revision.TimestampProvider) RevisionIndex(com.b2international.index.revision.RevisionIndex) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) IndexClient(com.b2international.index.IndexClient) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) Index(com.b2international.index.Index) RevisionIndex(com.b2international.index.revision.RevisionIndex) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) DefaultIndex(com.b2international.index.DefaultIndex) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BranchChangedEvent(com.b2international.snowowl.core.branch.BranchChangedEvent) IEventBus(com.b2international.snowowl.eventbus.IEventBus) IndexConfiguration(com.b2international.snowowl.core.config.IndexConfiguration)

Example 3 with DefaultRevisionIndex

use of com.b2international.index.revision.DefaultRevisionIndex in project snow-owl by b2ihealthcare.

the class SnowOwlPlugin method preRun.

@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) throws Exception {
    if (env.isServer()) {
        final ObjectMapper mapper = env.service(ObjectMapper.class);
        final Index resourceIndex = Indexes.createIndex(RESOURCES_INDEX, mapper, new Mappings(ResourceDocument.class, VersionDocument.class), env.service(IndexSettings.class).forIndex(env.service(RepositoryConfiguration.class).getIndexConfiguration(), RESOURCES_INDEX));
        final RevisionIndex revisionIndex = new DefaultRevisionIndex(resourceIndex, env.service(TimestampProvider.class), mapper);
        env.services().registerService(ResourceRepository.class, new ResourceRepository(revisionIndex));
    }
}
Also used : VersionDocument(com.b2international.snowowl.core.version.VersionDocument) TimestampProvider(com.b2international.index.revision.TimestampProvider) Mappings(com.b2international.index.mapping.Mappings) RevisionIndex(com.b2international.index.revision.RevisionIndex) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) Index(com.b2international.index.Index) RevisionIndex(com.b2international.index.revision.RevisionIndex) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

DefaultRevisionIndex (com.b2international.index.revision.DefaultRevisionIndex)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Index (com.b2international.index.Index)2 Mappings (com.b2international.index.mapping.Mappings)2 RevisionIndex (com.b2international.index.revision.RevisionIndex)2 TimestampProvider (com.b2international.index.revision.TimestampProvider)2 RepositoryConfiguration (com.b2international.snowowl.core.config.RepositoryConfiguration)2 DefaultIndex (com.b2international.index.DefaultIndex)1 IndexClient (com.b2international.index.IndexClient)1 BranchChangedEvent (com.b2international.snowowl.core.branch.BranchChangedEvent)1 IndexConfiguration (com.b2international.snowowl.core.config.IndexConfiguration)1 VersionDocument (com.b2international.snowowl.core.version.VersionDocument)1 IEventBus (com.b2international.snowowl.eventbus.IEventBus)1