Search in sources :

Example 1 with CosmosDbApiImpl

use of org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosContractNegotiationStoreExtension method initialize.

@Override
public void initialize(ServiceExtensionContext context) {
    var configuration = new CosmosContractNegotiationStoreConfig(context);
    Vault vault = context.getService(Vault.class);
    var cosmosDbApi = new CosmosDbApiImpl(vault, configuration);
    var store = new CosmosContractNegotiationStore(cosmosDbApi, context.getTypeManager(), (RetryPolicy<Object>) context.getService(RetryPolicy.class), configuration.getPartitionKey());
    context.registerService(ContractNegotiationStore.class, store);
    context.getTypeManager().registerTypes(ContractNegotiationDocument.class);
    context.getService(HealthCheckService.class).addReadinessProvider(() -> cosmosDbApi.get().forComponent(name()));
}
Also used : HealthCheckService(org.eclipse.dataspaceconnector.spi.system.health.HealthCheckService) Vault(org.eclipse.dataspaceconnector.spi.security.Vault) CosmosDbApiImpl(org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl)

Example 2 with CosmosDbApiImpl

use of org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosAssetIndexExtension method initialize.

@Override
public void initialize(ServiceExtensionContext context) {
    var configuration = new AssetIndexCosmosConfig(context);
    Vault vault = context.getService(Vault.class);
    var cosmosDbApi = new CosmosDbApiImpl(vault, configuration);
    var assetIndex = new CosmosAssetIndex(cosmosDbApi, configuration.getPartitionKey(), context.getTypeManager(), context.getService(RetryPolicy.class));
    context.registerService(AssetIndex.class, assetIndex);
    context.registerService(AssetLoader.class, assetIndex);
    context.registerService(DataAddressResolver.class, assetIndex);
    context.getService(HealthCheckService.class).addReadinessProvider(() -> cosmosDbApi.get().forComponent(name()));
    context.getTypeManager().registerTypes(AssetDocument.class);
}
Also used : HealthCheckService(org.eclipse.dataspaceconnector.spi.system.health.HealthCheckService) Vault(org.eclipse.dataspaceconnector.spi.security.Vault) RetryPolicy(net.jodah.failsafe.RetryPolicy) CosmosDbApiImpl(org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl)

Example 3 with CosmosDbApiImpl

use of org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosContractDefinitionStoreIntegrationTest method setUp.

@BeforeEach
void setUp() {
    var containerName = CONTAINER_PREFIX + UUID.randomUUID();
    CosmosContainerResponse containerIfNotExists = database.createContainerIfNotExists(containerName, "/partitionKey");
    container = database.getContainer(containerIfNotExists.getProperties().getId());
    assertThat(database).describedAs("CosmosDB database is null - did something go wrong during initialization?").isNotNull();
    var cosmosDbApi = new CosmosDbApiImpl(container, true);
    store = new CosmosContractDefinitionStore(cosmosDbApi, typeManager, new RetryPolicy<>().withMaxRetries(3).withBackoff(1, 5, ChronoUnit.SECONDS), TEST_PARTITION_KEY);
}
Also used : CosmosContainerResponse(com.azure.cosmos.models.CosmosContainerResponse) RetryPolicy(net.jodah.failsafe.RetryPolicy) CosmosDbApiImpl(org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with CosmosDbApiImpl

use of org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosFederatedCacheNodeDirectoryIntegrationTest method setUp.

@BeforeEach
void setUp() {
    var containerIfNotExists = database.createContainerIfNotExists(CONTAINER_NAME, "/partitionKey");
    container = database.getContainer(containerIfNotExists.getProperties().getId());
    assertThat(database).describedAs("CosmosDB database is null - did something go wrong during initialization?").isNotNull();
    typeManager = new TypeManager();
    typeManager.registerTypes(FederatedCacheNode.class, FederatedCacheNodeDocument.class);
    var cosmosDbApi = new CosmosDbApiImpl(container, true);
    store = new CosmosFederatedCacheNodeDirectory(cosmosDbApi, TEST_PARTITION_KEY, typeManager, new RetryPolicy<>());
}
Also used : TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) RetryPolicy(net.jodah.failsafe.RetryPolicy) CosmosDbApiImpl(org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with CosmosDbApiImpl

use of org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CosmosPolicyStoreIntegrationTest method setUp.

@BeforeEach
void setUp() {
    var containerName = CONTAINER_PREFIX + UUID.randomUUID();
    CosmosContainerResponse containerIfNotExists = database.createContainerIfNotExists(containerName, "/partitionKey");
    container = database.getContainer(containerIfNotExists.getProperties().getId());
    assertThat(database).describedAs("CosmosDB database is null - did something go wrong during initialization?").isNotNull();
    var cosmosDbApi = new CosmosDbApiImpl(container, true);
    store = new CosmosPolicyStore(cosmosDbApi, typeManager, new RetryPolicy<>().withMaxRetries(3).withBackoff(1, 5, ChronoUnit.SECONDS), TEST_PARTITION_KEY);
}
Also used : CosmosContainerResponse(com.azure.cosmos.models.CosmosContainerResponse) RetryPolicy(net.jodah.failsafe.RetryPolicy) CosmosDbApiImpl(org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CosmosDbApiImpl (org.eclipse.dataspaceconnector.azure.cosmos.CosmosDbApiImpl)11 RetryPolicy (net.jodah.failsafe.RetryPolicy)8 BeforeEach (org.junit.jupiter.api.BeforeEach)7 HealthCheckService (org.eclipse.dataspaceconnector.spi.system.health.HealthCheckService)4 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)4 CosmosContainerResponse (com.azure.cosmos.models.CosmosContainerResponse)3 Vault (org.eclipse.dataspaceconnector.spi.security.Vault)2 FederatedCacheNodeDirectory (org.eclipse.dataspaceconnector.catalog.spi.FederatedCacheNodeDirectory)1 ContractDefinitionLoader (org.eclipse.dataspaceconnector.dataloading.ContractDefinitionLoader)1