Search in sources :

Example 1 with BoundedCommandQueue

use of org.eclipse.dataspaceconnector.spi.command.BoundedCommandQueue in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ContractServiceExtension method registerServices.

private void registerServices(ServiceExtensionContext context) {
    var definitionService = new ContractDefinitionServiceImpl(monitor, contractDefinitionStore, policyEngine, policyStore);
    context.registerService(ContractDefinitionService.class, definitionService);
    var contractOfferService = new ContractOfferServiceImpl(agentService, definitionService, assetIndex, policyStore);
    context.registerService(ContractOfferService.class, contractOfferService);
    var validationService = new ContractValidationServiceImpl(agentService, definitionService, assetIndex, policyStore);
    context.registerService(ContractValidationService.class, validationService);
    var waitStrategy = context.hasService(NegotiationWaitStrategy.class) ? context.getService(NegotiationWaitStrategy.class) : new ExponentialWaitStrategy(DEFAULT_ITERATION_WAIT);
    CommandQueue<ContractNegotiationCommand> commandQueue = new BoundedCommandQueue<>(10);
    CommandRunner<ContractNegotiationCommand> commandRunner = new CommandRunner<>(commandHandlerRegistry, monitor);
    var telemetry = context.getTelemetry();
    var observable = new ContractNegotiationObservableImpl();
    context.registerService(ContractNegotiationObservable.class, observable);
    context.registerService(PolicyArchive.class, new PolicyArchiveImpl(store, policyStore));
    consumerNegotiationManager = ConsumerContractNegotiationManagerImpl.Builder.newInstance().waitStrategy(waitStrategy).dispatcherRegistry(dispatcherRegistry).monitor(monitor).validationService(validationService).commandQueue(commandQueue).commandRunner(commandRunner).observable(observable).telemetry(telemetry).executorInstrumentation(context.getService(ExecutorInstrumentation.class)).store(store).policyStore(policyStore).batchSize(context.getSetting(NEGOTIATION_CONSUMER_STATE_MACHINE_BATCH_SIZE, 5)).build();
    providerNegotiationManager = ProviderContractNegotiationManagerImpl.Builder.newInstance().waitStrategy(waitStrategy).dispatcherRegistry(dispatcherRegistry).monitor(monitor).validationService(validationService).commandQueue(commandQueue).commandRunner(commandRunner).observable(observable).telemetry(telemetry).executorInstrumentation(context.getService(ExecutorInstrumentation.class)).store(store).policyStore(policyStore).batchSize(context.getSetting(NEGOTIATION_PROVIDER_STATE_MACHINE_BATCH_SIZE, 5)).build();
    context.registerService(ConsumerContractNegotiationManager.class, consumerNegotiationManager);
    context.registerService(ProviderContractNegotiationManager.class, providerNegotiationManager);
}
Also used : BoundedCommandQueue(org.eclipse.dataspaceconnector.spi.command.BoundedCommandQueue) PolicyArchiveImpl(org.eclipse.dataspaceconnector.contract.policy.PolicyArchiveImpl) ContractValidationServiceImpl(org.eclipse.dataspaceconnector.contract.validation.ContractValidationServiceImpl) ContractOfferServiceImpl(org.eclipse.dataspaceconnector.contract.offer.ContractOfferServiceImpl) ContractDefinitionServiceImpl(org.eclipse.dataspaceconnector.contract.offer.ContractDefinitionServiceImpl) ExponentialWaitStrategy(org.eclipse.dataspaceconnector.spi.retry.ExponentialWaitStrategy) NegotiationWaitStrategy(org.eclipse.dataspaceconnector.spi.contract.negotiation.NegotiationWaitStrategy) ContractNegotiationObservableImpl(org.eclipse.dataspaceconnector.contract.observe.ContractNegotiationObservableImpl) ContractNegotiationCommand(org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.command.ContractNegotiationCommand) CommandRunner(org.eclipse.dataspaceconnector.spi.command.CommandRunner)

Example 2 with BoundedCommandQueue

use of org.eclipse.dataspaceconnector.spi.command.BoundedCommandQueue in project DataSpaceConnector by eclipse-dataspaceconnector.

the class CoreTransferExtension method initialize.

@Override
public void initialize(ServiceExtensionContext context) {
    var monitor = context.getMonitor();
    var telemetry = context.getTelemetry();
    var typeManager = context.getTypeManager();
    registerTypes(typeManager);
    var dataFlowManager = new DataFlowManagerImpl();
    context.registerService(DataFlowManager.class, dataFlowManager);
    var manifestGenerator = new ResourceManifestGeneratorImpl();
    context.registerService(ResourceManifestGenerator.class, manifestGenerator);
    var statusCheckerRegistry = new StatusCheckerRegistryImpl();
    context.registerService(StatusCheckerRegistry.class, statusCheckerRegistry);
    var dataOperatorRegistry = new DataOperatorRegistryImpl();
    context.registerService(DataOperatorRegistry.class, dataOperatorRegistry);
    var provisionManager = new ProvisionManagerImpl(monitor);
    context.registerService(ProvisionManager.class, provisionManager);
    var waitStrategy = context.hasService(TransferWaitStrategy.class) ? context.getService(TransferWaitStrategy.class) : new ExponentialWaitStrategy(DEFAULT_ITERATION_WAIT);
    var endpointDataReferenceReceiverRegistry = new EndpointDataReferenceReceiverRegistryImpl();
    context.registerService(EndpointDataReferenceReceiverRegistry.class, endpointDataReferenceReceiverRegistry);
    // Register a default EndpointDataReferenceTransformer that can be overridden in extensions.
    var endpointDataReferenceTransformerRegistry = new EndpointDataReferenceTransformerRegistryImpl();
    context.registerService(EndpointDataReferenceTransformerRegistry.class, endpointDataReferenceTransformerRegistry);
    var commandQueue = new BoundedCommandQueue<TransferProcessCommand>(10);
    var observable = new TransferProcessObservableImpl();
    context.registerService(TransferProcessObservable.class, observable);
    var retryLimit = context.getSetting(TRANSFER_SEND_RETRY_LIMIT, 7);
    var retryBaseDelay = context.getSetting(TRANSFER_SEND_RETRY_BASE_DELAY_MS, 100L);
    var sendRetryManager = new TransferProcessSendRetryManager(monitor, () -> new ExponentialWaitStrategy(retryBaseDelay), retryLimit);
    processManager = TransferProcessManagerImpl.Builder.newInstance().waitStrategy(waitStrategy).manifestGenerator(manifestGenerator).dataFlowManager(dataFlowManager).provisionManager(provisionManager).dispatcherRegistry(dispatcherRegistry).statusCheckerRegistry(statusCheckerRegistry).monitor(monitor).telemetry(telemetry).executorInstrumentation(context.getService(ExecutorInstrumentation.class)).vault(vault).typeManager(typeManager).commandQueue(commandQueue).commandRunner(new CommandRunner<>(registry, monitor)).observable(observable).transferProcessStore(transferProcessStore).policyArchive(policyArchive).batchSize(context.getSetting(TRANSFER_STATE_MACHINE_BATCH_SIZE, 5)).sendRetryManager(sendRetryManager).addressResolver(addressResolver).build();
    context.registerService(TransferProcessManager.class, processManager);
    registry.register(new AddProvisionedResourceCommandHandler(processManager));
    registry.register(new DeprovisionCompleteCommandHandler(processManager));
}
Also used : BoundedCommandQueue(org.eclipse.dataspaceconnector.spi.command.BoundedCommandQueue) StatusCheckerRegistryImpl(org.eclipse.dataspaceconnector.transfer.core.transfer.StatusCheckerRegistryImpl) ExecutorInstrumentation(org.eclipse.dataspaceconnector.spi.system.ExecutorInstrumentation) DataFlowManagerImpl(org.eclipse.dataspaceconnector.transfer.core.flow.DataFlowManagerImpl) EndpointDataReferenceReceiverRegistryImpl(org.eclipse.dataspaceconnector.transfer.core.edr.EndpointDataReferenceReceiverRegistryImpl) ResourceManifestGeneratorImpl(org.eclipse.dataspaceconnector.transfer.core.provision.ResourceManifestGeneratorImpl) ProvisionManagerImpl(org.eclipse.dataspaceconnector.transfer.core.provision.ProvisionManagerImpl) TransferProcessObservableImpl(org.eclipse.dataspaceconnector.transfer.core.observe.TransferProcessObservableImpl) ExponentialWaitStrategy(org.eclipse.dataspaceconnector.spi.retry.ExponentialWaitStrategy) TransferWaitStrategy(org.eclipse.dataspaceconnector.spi.transfer.retry.TransferWaitStrategy) AddProvisionedResourceCommandHandler(org.eclipse.dataspaceconnector.transfer.core.command.handlers.AddProvisionedResourceCommandHandler) EndpointDataReferenceTransformerRegistryImpl(org.eclipse.dataspaceconnector.transfer.core.edr.EndpointDataReferenceTransformerRegistryImpl) DeprovisionCompleteCommandHandler(org.eclipse.dataspaceconnector.transfer.core.command.handlers.DeprovisionCompleteCommandHandler) TransferProcessSendRetryManager(org.eclipse.dataspaceconnector.transfer.core.transfer.TransferProcessSendRetryManager) DataOperatorRegistryImpl(org.eclipse.dataspaceconnector.transfer.core.inline.DataOperatorRegistryImpl)

Aggregations

BoundedCommandQueue (org.eclipse.dataspaceconnector.spi.command.BoundedCommandQueue)2 ExponentialWaitStrategy (org.eclipse.dataspaceconnector.spi.retry.ExponentialWaitStrategy)2 ContractNegotiationObservableImpl (org.eclipse.dataspaceconnector.contract.observe.ContractNegotiationObservableImpl)1 ContractDefinitionServiceImpl (org.eclipse.dataspaceconnector.contract.offer.ContractDefinitionServiceImpl)1 ContractOfferServiceImpl (org.eclipse.dataspaceconnector.contract.offer.ContractOfferServiceImpl)1 PolicyArchiveImpl (org.eclipse.dataspaceconnector.contract.policy.PolicyArchiveImpl)1 ContractValidationServiceImpl (org.eclipse.dataspaceconnector.contract.validation.ContractValidationServiceImpl)1 CommandRunner (org.eclipse.dataspaceconnector.spi.command.CommandRunner)1 NegotiationWaitStrategy (org.eclipse.dataspaceconnector.spi.contract.negotiation.NegotiationWaitStrategy)1 ExecutorInstrumentation (org.eclipse.dataspaceconnector.spi.system.ExecutorInstrumentation)1 TransferWaitStrategy (org.eclipse.dataspaceconnector.spi.transfer.retry.TransferWaitStrategy)1 ContractNegotiationCommand (org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.command.ContractNegotiationCommand)1 AddProvisionedResourceCommandHandler (org.eclipse.dataspaceconnector.transfer.core.command.handlers.AddProvisionedResourceCommandHandler)1 DeprovisionCompleteCommandHandler (org.eclipse.dataspaceconnector.transfer.core.command.handlers.DeprovisionCompleteCommandHandler)1 EndpointDataReferenceReceiverRegistryImpl (org.eclipse.dataspaceconnector.transfer.core.edr.EndpointDataReferenceReceiverRegistryImpl)1 EndpointDataReferenceTransformerRegistryImpl (org.eclipse.dataspaceconnector.transfer.core.edr.EndpointDataReferenceTransformerRegistryImpl)1 DataFlowManagerImpl (org.eclipse.dataspaceconnector.transfer.core.flow.DataFlowManagerImpl)1 DataOperatorRegistryImpl (org.eclipse.dataspaceconnector.transfer.core.inline.DataOperatorRegistryImpl)1 TransferProcessObservableImpl (org.eclipse.dataspaceconnector.transfer.core.observe.TransferProcessObservableImpl)1 ProvisionManagerImpl (org.eclipse.dataspaceconnector.transfer.core.provision.ProvisionManagerImpl)1