Skip to content

Commit

Permalink
feat: restructure core by component (eclipse-edc#1842)
Browse files Browse the repository at this point in the history
* Move contract and transfer core modules into control-plane

* PR remarks

* Fix CI

* Extract instance store provision to a specific extension

* Rename federated-catalog-cache to federated-catalog-core
  • Loading branch information
ndr-brt authored and Meyer committed Aug 23, 2022
1 parent d15ea23 commit 44830e2
Show file tree
Hide file tree
Showing 365 changed files with 591 additions and 747 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ jobs:
uses: ./.github/actions/run-tests
with:
command: |
./gradlew -p core/micrometer test -DincludeTags="OpenTelemetryIntegrationTest"
./gradlew -p extensions/micrometer test -DincludeTags="OpenTelemetryIntegrationTest"
./gradlew -p system-tests/tests test -DincludeTags="OpenTelemetryIntegrationTest"
Check-Cloud-Environments:
Expand Down
35 changes: 0 additions & 35 deletions core/build.gradle.kts

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ dependencies {
api(project(":spi:common:core-spi"))
api(project(":spi:common:transaction-spi"))
implementation(project(":common:util"))
implementation(project(":core:defaults"))
implementation(project(":core:policy:policy-engine"))
implementation(project(":core:common:policy-engine"))
implementation(project(":extensions:dataloading"))

api("com.squareup.okhttp3:okhttp:${okHttpVersion}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,19 @@
import dev.failsafe.RetryPolicy;
import okhttp3.EventListener;
import okhttp3.OkHttpClient;
import org.eclipse.dataspaceconnector.common.concurrency.LockManager;
import org.eclipse.dataspaceconnector.core.base.OkHttpClientFactory;
import org.eclipse.dataspaceconnector.core.defaults.assetindex.InMemoryAssetIndex;
import org.eclipse.dataspaceconnector.core.defaults.contractdefinition.InMemoryContractDefinitionStore;
import org.eclipse.dataspaceconnector.core.defaults.negotiationstore.InMemoryContractNegotiationStore;
import org.eclipse.dataspaceconnector.core.defaults.policystore.InMemoryPolicyDefinitionStore;
import org.eclipse.dataspaceconnector.core.defaults.transferprocessstore.InMemoryTransferProcessStore;
import org.eclipse.dataspaceconnector.dataloading.AssetLoader;
import org.eclipse.dataspaceconnector.dataloading.ContractDefinitionLoader;
import org.eclipse.dataspaceconnector.spi.EdcSetting;
import org.eclipse.dataspaceconnector.spi.asset.AssetIndex;
import org.eclipse.dataspaceconnector.spi.asset.DataAddressResolver;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.store.ContractNegotiationStore;
import org.eclipse.dataspaceconnector.spi.contract.offer.store.ContractDefinitionStore;
import org.eclipse.dataspaceconnector.spi.policy.store.PolicyDefinitionStore;
import org.eclipse.dataspaceconnector.spi.system.Inject;
import org.eclipse.dataspaceconnector.spi.system.Provider;
import org.eclipse.dataspaceconnector.spi.system.ServiceExtension;
import org.eclipse.dataspaceconnector.spi.system.ServiceExtensionContext;
import org.eclipse.dataspaceconnector.spi.transaction.NoopTransactionContext;
import org.eclipse.dataspaceconnector.spi.transaction.TransactionContext;
import org.eclipse.dataspaceconnector.spi.transfer.store.TransferProcessStore;

import java.time.temporal.ChronoUnit;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
* Provides (in-mem & no-op) defaults for various stores, registries etc.
* Provides defaults for various services.
* Provider methods are only invoked if no other implementation was found on the classpath.
*/
public class DefaultServicesExtension implements ServiceExtension {
Expand All @@ -55,8 +40,6 @@ public class DefaultServicesExtension implements ServiceExtension {
@EdcSetting(value = "Maximum number of milliseconds for exponential backoff. ")
public static final String BACKOFF_MAX_MILLIS = "edc.core.retry.backoff.max";

private InMemoryAssetIndex assetIndex;
private InMemoryContractDefinitionStore contractDefinitionStore;
/**
* An optional OkHttp {@link EventListener} that can be used to instrument OkHttp client for collecting metrics.
* Used by the optional {@code micrometer} module.
Expand All @@ -79,46 +62,6 @@ public RetryPolicy<?> retryPolicy(ServiceExtensionContext context) {
.build();
}

@Provider(isDefault = true)
public AssetIndex defaultAssetIndex() {
return getAssetIndex();
}

@Provider(isDefault = true)
public DataAddressResolver defaultDataAddressResolver() {
return getAssetIndex();
}

@Provider(isDefault = true)
public AssetLoader defaultAssetLoader() {
return getAssetIndex();
}

@Provider(isDefault = true)
public ContractDefinitionStore defaultContractDefinitionStore() {
return getContractDefinitionStore();
}

@Provider(isDefault = true)
public ContractDefinitionLoader defaultContractDefinitionLoader() {
return getContractDefinitionStore()::save;
}

@Provider(isDefault = true)
public ContractNegotiationStore defaultContractNegotiationStore() {
return new InMemoryContractNegotiationStore();
}

@Provider(isDefault = true)
public TransferProcessStore defaultTransferProcessStore() {
return new InMemoryTransferProcessStore();
}

@Provider(isDefault = true)
public PolicyDefinitionStore defaultPolicyStore() {
return new InMemoryPolicyDefinitionStore(new LockManager(new ReentrantReadWriteLock(true)));
}

@Provider(isDefault = true)
public TransactionContext defaultTransactionContext(ServiceExtensionContext context) {
context.getMonitor().warning("No TransactionContext registered, a no-op implementation will be used, not suitable for production environments");
Expand All @@ -130,18 +73,4 @@ public TransactionContext defaultTransactionContext(ServiceExtensionContext cont
public OkHttpClient okHttpClient(ServiceExtensionContext context) {
return OkHttpClientFactory.create(context, okHttpEventListener);
}

private ContractDefinitionStore getContractDefinitionStore() {
if (contractDefinitionStore == null) {
contractDefinitionStore = new InMemoryContractDefinitionStore();
}
return contractDefinitionStore;
}

private InMemoryAssetIndex getAssetIndex() {
if (assetIndex == null) {
assetIndex = new InMemoryAssetIndex();
}
return assetIndex;
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}

dependencies {
api(project(":core:policy:policy-evaluator"))
api(project(":core:common:policy-evaluator"))
}

publishing {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
implementation(project(":common:state-machine-lib"))
implementation("io.opentelemetry:opentelemetry-extension-annotations:${openTelemetryVersion}")

testImplementation(project(":core:defaults"))
testImplementation(project(":core:control-plane:control-plane-core"))
testImplementation(project(":extensions:junit"))
testImplementation(testFixtures(project(":common:util")))
testImplementation("org.awaitility:awaitility:${awaitility}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import io.opentelemetry.extension.annotations.WithSpan;
import org.eclipse.dataspaceconnector.common.statemachine.StateMachineManager;
import org.eclipse.dataspaceconnector.common.statemachine.StateProcessorImpl;
import org.eclipse.dataspaceconnector.contract.common.ContractId;
import org.eclipse.dataspaceconnector.policy.model.Policy;
import org.eclipse.dataspaceconnector.spi.contract.ContractId;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.ConsumerContractNegotiationManager;
import org.eclipse.dataspaceconnector.spi.iam.ClaimToken;
import org.eclipse.dataspaceconnector.spi.response.StatusResult;
Expand All @@ -44,8 +44,8 @@
import java.util.function.Function;

import static java.lang.String.format;
import static org.eclipse.dataspaceconnector.contract.common.ContractId.DEFINITION_PART;
import static org.eclipse.dataspaceconnector.contract.common.ContractId.parseContractId;
import static org.eclipse.dataspaceconnector.spi.contract.ContractId.DEFINITION_PART;
import static org.eclipse.dataspaceconnector.spi.contract.ContractId.parseContractId;
import static org.eclipse.dataspaceconnector.spi.response.ResponseStatus.FATAL_ERROR;
import static org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiation.Type.CONSUMER;
import static org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiationStates.CONFIRMED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import io.opentelemetry.extension.annotations.WithSpan;
import org.eclipse.dataspaceconnector.common.statemachine.StateMachineManager;
import org.eclipse.dataspaceconnector.common.statemachine.StateProcessorImpl;
import org.eclipse.dataspaceconnector.contract.common.ContractId;
import org.eclipse.dataspaceconnector.policy.model.Policy;
import org.eclipse.dataspaceconnector.spi.contract.ContractId;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.ProviderContractNegotiationManager;
import org.eclipse.dataspaceconnector.spi.iam.ClaimToken;
import org.eclipse.dataspaceconnector.spi.response.StatusResult;
Expand All @@ -41,8 +41,8 @@
import java.util.function.BiConsumer;
import java.util.function.Function;

import static org.eclipse.dataspaceconnector.contract.common.ContractId.DEFINITION_PART;
import static org.eclipse.dataspaceconnector.contract.common.ContractId.parseContractId;
import static org.eclipse.dataspaceconnector.spi.contract.ContractId.DEFINITION_PART;
import static org.eclipse.dataspaceconnector.spi.contract.ContractId.parseContractId;
import static org.eclipse.dataspaceconnector.spi.response.ResponseStatus.FATAL_ERROR;
import static org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiation.Type.PROVIDER;
import static org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiationStates.CONFIRMING;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

package org.eclipse.dataspaceconnector.contract.negotiation.command.handlers;

import org.eclipse.dataspaceconnector.contract.negotiation.command.commands.CancelNegotiationCommand;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.store.ContractNegotiationStore;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.command.CancelNegotiationCommand;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiation;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

package org.eclipse.dataspaceconnector.contract.negotiation.command.handlers;

import org.eclipse.dataspaceconnector.contract.negotiation.command.commands.SingleContractNegotiationCommand;
import org.eclipse.dataspaceconnector.spi.EdcException;
import org.eclipse.dataspaceconnector.spi.command.CommandHandler;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.store.ContractNegotiationStore;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.command.SingleContractNegotiationCommand;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiation;

import static java.lang.String.format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.eclipse.dataspaceconnector.contract.offer;

import org.eclipse.dataspaceconnector.contract.common.ContractId;
import org.eclipse.dataspaceconnector.policy.model.Policy;
import org.eclipse.dataspaceconnector.spi.agent.ParticipantAgentService;
import org.eclipse.dataspaceconnector.spi.asset.AssetIndex;
import org.eclipse.dataspaceconnector.spi.contract.ContractId;
import org.eclipse.dataspaceconnector.spi.contract.offer.ContractDefinitionService;
import org.eclipse.dataspaceconnector.spi.contract.offer.ContractOfferQuery;
import org.eclipse.dataspaceconnector.spi.contract.offer.ContractOfferService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import java.time.Clock;

import static java.lang.String.format;
import static org.eclipse.dataspaceconnector.contract.common.ContractId.DEFINITION_PART;
import static org.eclipse.dataspaceconnector.contract.common.ContractId.parseContractId;
import static org.eclipse.dataspaceconnector.spi.contract.ContractId.DEFINITION_PART;
import static org.eclipse.dataspaceconnector.spi.contract.ContractId.parseContractId;

/**
* Implementation of the {@link ContractValidationService}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
package org.eclipse.dataspaceconnector.contract.negotiation;

import org.eclipse.dataspaceconnector.common.statemachine.retry.SendRetryManager;
import org.eclipse.dataspaceconnector.contract.common.ContractId;
import org.eclipse.dataspaceconnector.contract.observe.ContractNegotiationObservableImpl;
import org.eclipse.dataspaceconnector.core.defaults.negotiationstore.InMemoryContractNegotiationStore;
import org.eclipse.dataspaceconnector.core.controlplane.defaults.negotiationstore.InMemoryContractNegotiationStore;
import org.eclipse.dataspaceconnector.policy.model.Action;
import org.eclipse.dataspaceconnector.policy.model.Duty;
import org.eclipse.dataspaceconnector.policy.model.Policy;
import org.eclipse.dataspaceconnector.policy.model.PolicyType;
import org.eclipse.dataspaceconnector.spi.command.CommandQueue;
import org.eclipse.dataspaceconnector.spi.command.CommandRunner;
import org.eclipse.dataspaceconnector.spi.contract.ContractId;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.observe.ContractNegotiationObservable;
import org.eclipse.dataspaceconnector.spi.contract.validation.ContractValidationService;
import org.eclipse.dataspaceconnector.spi.entity.StatefulEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
package org.eclipse.dataspaceconnector.contract.negotiation;

import org.eclipse.dataspaceconnector.common.statemachine.retry.SendRetryManager;
import org.eclipse.dataspaceconnector.contract.common.ContractId;
import org.eclipse.dataspaceconnector.contract.observe.ContractNegotiationObservableImpl;
import org.eclipse.dataspaceconnector.policy.model.Policy;
import org.eclipse.dataspaceconnector.spi.EdcException;
import org.eclipse.dataspaceconnector.spi.command.CommandQueue;
import org.eclipse.dataspaceconnector.spi.command.CommandRunner;
import org.eclipse.dataspaceconnector.spi.contract.ContractId;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.observe.ContractNegotiationListener;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.store.ContractNegotiationStore;
import org.eclipse.dataspaceconnector.spi.contract.validation.ContractValidationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.eclipse.dataspaceconnector.common.statemachine.retry.SendRetryManager;
import org.eclipse.dataspaceconnector.contract.negotiation.ConsumerContractNegotiationManagerImpl;
import org.eclipse.dataspaceconnector.contract.negotiation.ProviderContractNegotiationManagerImpl;
import org.eclipse.dataspaceconnector.contract.negotiation.command.commands.SingleContractNegotiationCommand;
import org.eclipse.dataspaceconnector.contract.negotiation.command.handlers.SingleContractNegotiationCommandHandler;
import org.eclipse.dataspaceconnector.spi.command.BoundedCommandQueue;
import org.eclipse.dataspaceconnector.spi.command.CommandHandlerRegistry;
Expand All @@ -30,6 +29,7 @@
import org.eclipse.dataspaceconnector.spi.message.RemoteMessageDispatcherRegistry;
import org.eclipse.dataspaceconnector.spi.monitor.Monitor;
import org.eclipse.dataspaceconnector.spi.policy.store.PolicyDefinitionStore;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.command.SingleContractNegotiationCommand;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiation;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiationStates;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.command.ContractNegotiationCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

package org.eclipse.dataspaceconnector.contract.negotiation.command.handlers;

import org.eclipse.dataspaceconnector.contract.negotiation.command.commands.CancelNegotiationCommand;
import org.eclipse.dataspaceconnector.spi.EdcException;
import org.eclipse.dataspaceconnector.spi.contract.negotiation.store.ContractNegotiationStore;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.command.CancelNegotiationCommand;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiation;
import org.eclipse.dataspaceconnector.spi.types.domain.contract.negotiation.ContractNegotiationStates;
import org.junit.jupiter.api.BeforeEach;
Expand Down
37 changes: 37 additions & 0 deletions core/control-plane/control-plane-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/

plugins {
`java-library`
}


dependencies {
api(project(":core:common:base"))
api(project(":core:common:boot"))
api(project(":core:common:policy-engine"))
api(project(":core:control-plane:contract"))
api(project(":core:control-plane:transfer"))
implementation(project(":common:util"))
implementation(project(":extensions:dataloading"))
}

publishing {
publications {
create<MavenPublication>("control-plane-core") {
artifactId = "control-plane-core"
from(components["java"])
}
}
}
Loading

0 comments on commit 44830e2

Please sign in to comment.