Search in sources :

Example 1 with TracingDatabaseAdapter

use of org.projectnessie.versioned.persist.adapter.spi.TracingDatabaseAdapter in project nessie by projectnessie.

the class DatabaseAdapterProvider method produceDatabaseAdapter.

@Produces
@Singleton
@Startup
public DatabaseAdapter produceDatabaseAdapter() {
    VersionStoreType versionStoreType = storeConfig.getVersionStoreType();
    LOGGER.info("Using {} Version store", versionStoreType);
    TableCommitMetaStoreWorker storeWorker = new TableCommitMetaStoreWorker();
    DatabaseAdapter databaseAdapter = databaseAdapterBuilder.select(new Literal(versionStoreType)).get().newDatabaseAdapter(new GenericContentVariantSupplier<>(storeWorker));
    databaseAdapter.initializeRepo(serverConfig.getDefaultBranch());
    if (storeConfig.isTracingEnabled()) {
        databaseAdapter = new TracingDatabaseAdapter(databaseAdapter);
    }
    return databaseAdapter;
}
Also used : TracingDatabaseAdapter(org.projectnessie.versioned.persist.adapter.spi.TracingDatabaseAdapter) VersionStoreType(org.projectnessie.quarkus.config.VersionStoreConfig.VersionStoreType) TableCommitMetaStoreWorker(org.projectnessie.server.store.TableCommitMetaStoreWorker) Literal(org.projectnessie.quarkus.providers.StoreType.Literal) TracingDatabaseAdapter(org.projectnessie.versioned.persist.adapter.spi.TracingDatabaseAdapter) DatabaseAdapter(org.projectnessie.versioned.persist.adapter.DatabaseAdapter) Produces(javax.enterprise.inject.Produces) Singleton(javax.inject.Singleton) Startup(io.quarkus.runtime.Startup)

Example 2 with TracingDatabaseAdapter

use of org.projectnessie.versioned.persist.adapter.spi.TracingDatabaseAdapter in project nessie by projectnessie.

the class DatabaseAdapterExtension method resolve.

private Object resolve(NessieDbAdapter nessieDbAdapter, AnnotatedElement annotatedElement, Class<?> type, ExtensionContext context, ParameterContext parameterContext, boolean canReinit, Consumer<DatabaseAdapter> newAdapter) {
    StoreWorker<?, ?, ?> storeWorker = createStoreWorker(nessieDbAdapter);
    DatabaseAdapter databaseAdapter = createAdapterResource(nessieDbAdapter, context, parameterContext, storeWorker);
    if (nessieDbAdapter.withTracing()) {
        databaseAdapter = new TracingDatabaseAdapter(databaseAdapter);
    }
    if (canReinit && nessieDbAdapter.initializeRepo()) {
        reinit(databaseAdapter);
    }
    Object assign;
    if (type.isAssignableFrom(DatabaseAdapter.class)) {
        assign = databaseAdapter;
    } else if (type.isAssignableFrom(VersionStore.class)) {
        VersionStore<?, ?, ?> store = createStore(databaseAdapter, storeWorker);
        if (nessieDbAdapter.withTracing()) {
            store = new TracingVersionStore<>(store);
        }
        assign = store;
    } else {
        throw new IllegalStateException("Cannot assign to " + annotatedElement);
    }
    newAdapter.accept(databaseAdapter);
    return assign;
}
Also used : TracingDatabaseAdapter(org.projectnessie.versioned.persist.adapter.spi.TracingDatabaseAdapter) TracingVersionStore(org.projectnessie.versioned.TracingVersionStore) TracingDatabaseAdapter(org.projectnessie.versioned.persist.adapter.spi.TracingDatabaseAdapter) DatabaseAdapter(org.projectnessie.versioned.persist.adapter.DatabaseAdapter) VersionStore(org.projectnessie.versioned.VersionStore) PersistVersionStore(org.projectnessie.versioned.persist.store.PersistVersionStore) TracingVersionStore(org.projectnessie.versioned.TracingVersionStore)

Aggregations

DatabaseAdapter (org.projectnessie.versioned.persist.adapter.DatabaseAdapter)2 TracingDatabaseAdapter (org.projectnessie.versioned.persist.adapter.spi.TracingDatabaseAdapter)2 Startup (io.quarkus.runtime.Startup)1 Produces (javax.enterprise.inject.Produces)1 Singleton (javax.inject.Singleton)1 VersionStoreType (org.projectnessie.quarkus.config.VersionStoreConfig.VersionStoreType)1 Literal (org.projectnessie.quarkus.providers.StoreType.Literal)1 TableCommitMetaStoreWorker (org.projectnessie.server.store.TableCommitMetaStoreWorker)1 TracingVersionStore (org.projectnessie.versioned.TracingVersionStore)1 VersionStore (org.projectnessie.versioned.VersionStore)1 PersistVersionStore (org.projectnessie.versioned.persist.store.PersistVersionStore)1