Search in sources :

Example 1 with CommandRunner

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

the class TransferProcessManagerImplTest method setup.

@BeforeEach
void setup() {
    var resourceManifest = ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build();
    when(manifestGenerator.generateResourceManifest(any(TransferProcess.class))).thenReturn(resourceManifest);
    manager = TransferProcessManagerImpl.Builder.newInstance().provisionManager(provisionManager).dataFlowManager(mock(DataFlowManager.class)).waitStrategy(mock(ExponentialWaitStrategy.class)).batchSize(TRANSFER_MANAGER_BATCHSIZE).dispatcherRegistry(dispatcherRegistry).manifestGenerator(manifestGenerator).monitor(mock(Monitor.class)).commandQueue(mock(CommandQueue.class)).commandRunner(mock(CommandRunner.class)).typeManager(new TypeManager()).statusCheckerRegistry(statusCheckerRegistry).observable(mock(TransferProcessObservable.class)).store(store).build();
}
Also used : Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) TestResourceDefinition(org.eclipse.dataspaceconnector.transfer.core.TestResourceDefinition) TransferProcess(org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcess) ExponentialWaitStrategy(org.eclipse.dataspaceconnector.spi.retry.ExponentialWaitStrategy) CommandRunner(org.eclipse.dataspaceconnector.spi.command.CommandRunner) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with CommandRunner

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

the class TransferProcessManagerImplIntegrationTest method setup.

@SuppressWarnings("unchecked")
@BeforeEach
void setup() {
    var resourceManifest = ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build();
    when(manifestGenerator.generateConsumerResourceManifest(any(DataRequest.class), any(Policy.class))).thenReturn(resourceManifest);
    var policyArchive = mock(PolicyArchive.class);
    when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
    transferProcessManager = TransferProcessManagerImpl.Builder.newInstance().provisionManager(provisionManager).dataFlowManager(mock(DataFlowManager.class)).waitStrategy(mock(ExponentialWaitStrategy.class)).batchSize(TRANSFER_MANAGER_BATCHSIZE).dispatcherRegistry(mock(RemoteMessageDispatcherRegistry.class)).manifestGenerator(manifestGenerator).monitor(mock(Monitor.class)).commandQueue(mock(CommandQueue.class)).commandRunner(mock(CommandRunner.class)).typeManager(new TypeManager()).statusCheckerRegistry(mock(StatusCheckerRegistry.class)).observable(mock(TransferProcessObservable.class)).transferProcessStore(store).policyArchive(policyArchive).addressResolver(mock(DataAddressResolver.class)).build();
}
Also used : Policy(org.eclipse.dataspaceconnector.policy.model.Policy) DataAddressResolver(org.eclipse.dataspaceconnector.spi.asset.DataAddressResolver) Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) TestResourceDefinition(org.eclipse.dataspaceconnector.transfer.core.TestResourceDefinition) DataRequest(org.eclipse.dataspaceconnector.spi.types.domain.transfer.DataRequest) StatusCheckerRegistry(org.eclipse.dataspaceconnector.spi.types.domain.transfer.StatusCheckerRegistry) ExponentialWaitStrategy(org.eclipse.dataspaceconnector.spi.retry.ExponentialWaitStrategy) RemoteMessageDispatcherRegistry(org.eclipse.dataspaceconnector.spi.message.RemoteMessageDispatcherRegistry) CommandRunner(org.eclipse.dataspaceconnector.spi.command.CommandRunner) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with CommandRunner

use of org.eclipse.dataspaceconnector.spi.command.CommandRunner 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 4 with CommandRunner

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

the class AbstractContractNegotiationIntegrationTest method setUp.

/**
 * Prepares the test setup
 */
@BeforeEach
void setUp() {
    // Create contract validation service mock, method mocking has to be done in test methods
    validationService = mock(ContractValidationService.class);
    // Create a monitor that logs to the console
    Monitor monitor = new ConsoleMonitor();
    // Create CommandQueue mock
    CommandQueue<ContractNegotiationCommand> queue = (CommandQueue<ContractNegotiationCommand>) mock(CommandQueue.class);
    when(queue.dequeue(anyInt())).thenReturn(new ArrayList<>());
    // Create CommandRunner mock
    CommandRunner<ContractNegotiationCommand> runner = (CommandRunner<ContractNegotiationCommand>) mock(CommandRunner.class);
    providerStore = new InMemoryContractNegotiationStore();
    consumerStore = new InMemoryContractNegotiationStore();
    providerManager = ProviderContractNegotiationManagerImpl.Builder.newInstance().dispatcherRegistry(new FakeProviderDispatcherRegistry()).monitor(monitor).validationService(validationService).waitStrategy(() -> 1000).commandQueue(queue).commandRunner(runner).observable(providerObservable).store(providerStore).policyStore(policyStore).build();
    consumerManager = ConsumerContractNegotiationManagerImpl.Builder.newInstance().dispatcherRegistry(new FakeConsumerDispatcherRegistry()).monitor(monitor).validationService(validationService).waitStrategy(() -> 1000).commandQueue(queue).commandRunner(runner).observable(consumerObservable).store(consumerStore).policyStore(policyStore).build();
    countDownLatch = new CountDownLatch(2);
}
Also used : ConsoleMonitor(org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor) CommandQueue(org.eclipse.dataspaceconnector.spi.command.CommandQueue) ContractValidationService(org.eclipse.dataspaceconnector.spi.contract.validation.ContractValidationService) CountDownLatch(java.util.concurrent.CountDownLatch) ConsoleMonitor(org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor) Monitor(org.eclipse.dataspaceconnector.spi.monitor.Monitor) InMemoryContractNegotiationStore(org.eclipse.dataspaceconnector.core.defaults.negotiationstore.InMemoryContractNegotiationStore) ContractNegotiationCommand(org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.command.ContractNegotiationCommand) CommandRunner(org.eclipse.dataspaceconnector.spi.command.CommandRunner) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CommandRunner (org.eclipse.dataspaceconnector.spi.command.CommandRunner)4 Monitor (org.eclipse.dataspaceconnector.spi.monitor.Monitor)3 ExponentialWaitStrategy (org.eclipse.dataspaceconnector.spi.retry.ExponentialWaitStrategy)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)2 ContractNegotiationCommand (org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.command.ContractNegotiationCommand)2 TestResourceDefinition (org.eclipse.dataspaceconnector.transfer.core.TestResourceDefinition)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 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 InMemoryContractNegotiationStore (org.eclipse.dataspaceconnector.core.defaults.negotiationstore.InMemoryContractNegotiationStore)1 Policy (org.eclipse.dataspaceconnector.policy.model.Policy)1 DataAddressResolver (org.eclipse.dataspaceconnector.spi.asset.DataAddressResolver)1 BoundedCommandQueue (org.eclipse.dataspaceconnector.spi.command.BoundedCommandQueue)1 CommandQueue (org.eclipse.dataspaceconnector.spi.command.CommandQueue)1 NegotiationWaitStrategy (org.eclipse.dataspaceconnector.spi.contract.negotiation.NegotiationWaitStrategy)1 ContractValidationService (org.eclipse.dataspaceconnector.spi.contract.validation.ContractValidationService)1