Search in sources :

Example 1 with PersistVersionStore

use of org.projectnessie.versioned.persist.store.PersistVersionStore in project nessie by projectnessie.

the class ConfigurableVersionStoreFactory method getVersionStore.

/**
 * Version store producer.
 */
@Produces
@Singleton
@Startup
public VersionStore<Content, CommitMeta, Content.Type> getVersionStore() {
    VersionStoreType versionStoreType = storeConfig.getVersionStoreType();
    try {
        TableCommitMetaStoreWorker storeWorker = new TableCommitMetaStoreWorker();
        VersionStore<Content, CommitMeta, Content.Type> versionStore = new PersistVersionStore<>(databaseAdapter, storeWorker);
        if (storeConfig.isTracingEnabled()) {
            versionStore = new TracingVersionStore<>(versionStore);
        }
        if (storeConfig.isMetricsEnabled()) {
            versionStore = new MetricsVersionStore<>(versionStore);
        }
        return versionStore;
    } catch (RuntimeException | IOError e) {
        LOGGER.error("Failed to configure/start {} version store", versionStoreType, e);
        throw e;
    }
}
Also used : PersistVersionStore(org.projectnessie.versioned.persist.store.PersistVersionStore) VersionStoreType(org.projectnessie.quarkus.config.VersionStoreConfig.VersionStoreType) VersionStoreType(org.projectnessie.quarkus.config.VersionStoreConfig.VersionStoreType) TableCommitMetaStoreWorker(org.projectnessie.server.store.TableCommitMetaStoreWorker) IOError(java.io.IOError) Content(org.projectnessie.model.Content) CommitMeta(org.projectnessie.model.CommitMeta) Produces(javax.enterprise.inject.Produces) Singleton(javax.inject.Singleton) Startup(io.quarkus.runtime.Startup)

Example 2 with PersistVersionStore

use of org.projectnessie.versioned.persist.store.PersistVersionStore in project nessie by projectnessie.

the class ErrorTestService method unhandledExceptionInTvsStore.

/**
 * Throws an exception depending on the parameter.
 *
 * @return nothing
 * @see TestNessieError#unhandledRuntimeExceptionInStore()
 * @see TestNessieError#backendThrottledExceptionInStore()
 */
@Path("unhandledExceptionInTvsStore/{exception}")
@GET
@Consumes(MediaType.APPLICATION_JSON)
public String unhandledExceptionInTvsStore(@PathParam("exception") String exception) throws ReferenceNotFoundException {
    Exception ex;
    switch(exception) {
        case "runtime":
            ex = new RuntimeException("Store.getValues-throwing");
            break;
        case "throttle":
            ex = new BackendLimitExceededException("Store.getValues-throttled");
            break;
        default:
            throw new IllegalArgumentException("test code error");
    }
    DatabaseAdapter databaseAdapter = Mockito.mock(DatabaseAdapter.class);
    Mockito.when(databaseAdapter.namedRefs(Mockito.any())).thenThrow(ex);
    PersistVersionStore<BaseContent, CommitMessage, BaseContent.Type> tvs = new PersistVersionStore<>(databaseAdapter, SimpleStoreWorker.INSTANCE);
    try (Stream<ReferenceInfo<CommitMessage>> refs = tvs.getNamedRefs(GetNamedRefsParams.DEFAULT)) {
        refs.forEach(ref -> {
        });
    }
    return "we should not get here";
}
Also used : PersistVersionStore(org.projectnessie.versioned.persist.store.PersistVersionStore) MediaType(javax.ws.rs.core.MediaType) CommitMessage(org.projectnessie.versioned.testworker.CommitMessage) BackendLimitExceededException(org.projectnessie.versioned.BackendLimitExceededException) BaseContent(org.projectnessie.versioned.testworker.BaseContent) NessieReferenceNotFoundException(org.projectnessie.error.NessieReferenceNotFoundException) BackendLimitExceededException(org.projectnessie.versioned.BackendLimitExceededException) ConstraintDefinitionException(javax.validation.ConstraintDefinitionException) ReferenceNotFoundException(org.projectnessie.versioned.ReferenceNotFoundException) ConstraintDeclarationException(javax.validation.ConstraintDeclarationException) GroupDefinitionException(javax.validation.GroupDefinitionException) NessieNotFoundException(org.projectnessie.error.NessieNotFoundException) DatabaseAdapter(org.projectnessie.versioned.persist.adapter.DatabaseAdapter) ReferenceInfo(org.projectnessie.versioned.ReferenceInfo) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) GET(javax.ws.rs.GET)

Aggregations

PersistVersionStore (org.projectnessie.versioned.persist.store.PersistVersionStore)2 Startup (io.quarkus.runtime.Startup)1 IOError (java.io.IOError)1 Produces (javax.enterprise.inject.Produces)1 Singleton (javax.inject.Singleton)1 ConstraintDeclarationException (javax.validation.ConstraintDeclarationException)1 ConstraintDefinitionException (javax.validation.ConstraintDefinitionException)1 GroupDefinitionException (javax.validation.GroupDefinitionException)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 MediaType (javax.ws.rs.core.MediaType)1 NessieNotFoundException (org.projectnessie.error.NessieNotFoundException)1 NessieReferenceNotFoundException (org.projectnessie.error.NessieReferenceNotFoundException)1 CommitMeta (org.projectnessie.model.CommitMeta)1 Content (org.projectnessie.model.Content)1 VersionStoreType (org.projectnessie.quarkus.config.VersionStoreConfig.VersionStoreType)1 TableCommitMetaStoreWorker (org.projectnessie.server.store.TableCommitMetaStoreWorker)1 BackendLimitExceededException (org.projectnessie.versioned.BackendLimitExceededException)1 ReferenceInfo (org.projectnessie.versioned.ReferenceInfo)1