Skip to content

Commit

Permalink
Merge remote-tracking branch 'eclipse/main' into fix/57-code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
drcgjung committed Oct 19, 2023
2 parents 511c01b + d358674 commit 9f5cf4f
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 40 deletions.
65 changes: 33 additions & 32 deletions agent-plane/agent-plane-protocol/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ cx.agent.controlplane.management=http://consuming-control-plane:8181/management/
cx.agent.controlplane.management.provider=http://providing-control-plane:8181/management/v2
cx.agent.callback=http://agent-plane:8187/callback/endpoint-data-reference
cx.agent.skill.contract.default=Contract?partner=Skill
cx.agent.edc.version=0.5.1

cx.agent.service.allow=(edcs?://.*)|(https://query\\.wikidata\\.org/sparql)|(http://[^\\.]+:\\d+.*)
cx.agent.service.asset.allow=(edcs?://.*)|(https://query\\.wikidata\\.org/sparql)|(http://[^\\.]+:\\d+.*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class AgentConfig {
public static final String SERVICE_DENY_ASSET_PROPERTY = "cx.agent.service.asset.deny";
public static final String DEFAULT_SERVICE_DENY_ASSET_PATTERN = "^$";

public static final String TX_EDC_VERSION_PROPERTY = "cx.agent.edc.version";

/**
* precompiled stuff
*/
Expand Down Expand Up @@ -359,5 +361,18 @@ public Pattern getServiceAssetDenyPattern() {
return serviceAssetDenyPattern;
}

/**
* @return tx edc version as a string
*/
public String getEdcVersion() {
return config.getString(TX_EDC_VERSION_PROPERTY, "0.5.0");
}

/**
* @return whether the edc version is less than 23.09
*/
public boolean isPrerelease() {
return getEdcVersion().compareTo("0.5.0") <= 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,11 @@ public EndpointDataReference createAgreement(String remoteUrl, String asset) thr

startTime = System.currentTimeMillis();

// EDC 0.5.1 has a problem with the checker configuration and wont process to COMPLETED
String expectedTransferState = config.isPrerelease() ? "COMPLETED" : "STARTED";

try {
while ((System.currentTimeMillis() - startTime < config.getNegotiationTimeout()) && (process == null || !process.getState().equals("COMPLETED"))) {
while ((System.currentTimeMillis() - startTime < config.getNegotiationTimeout()) && (process == null || !process.getState().equals(expectedTransferState))) {
Thread.sleep(config.getNegotiationPollInterval());
process = dataManagement.getTransfer(
transferId
Expand All @@ -397,7 +400,7 @@ public EndpointDataReference createAgreement(String remoteUrl, String asset) thr
monitor.warning(String.format("Process thread for asset %s transfer %s run into problem. Giving up.", asset, transferId), e);
}

if (process == null || !process.getState().equals("COMPLETED")) {
if (process == null || !process.getState().equals(expectedTransferState)) {
deactivate(asset);
throw new InternalServerErrorException(String.format("Transfer process %s for agreement %s and asset %s could not be provisioned.", transferId, agreement.getId(), asset));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ public class DataManagement {
*/
public static final String DSP_PATH = "%s/api/v1/dsp";
public static final String CATALOG_CALL = "%s/catalog/request";
// catalog request 0.5.>=1
public static final String CATALOG_REQUEST_BODY = "{" +
"\"@context\": {}," +
"\"protocol\": \"dataspace-protocol-http\"," +
"\"counterPartyAddress\": \"%s\", " +
"\"querySpec\": %s }";
// catalog request 0.5.0
public static final String CATALOG_REQUEST_BODY_PRERELEASE = "{" +
"\"@context\": {}," +
"\"protocol\": \"dataspace-protocol-http\"," +
"\"providerUrl\": \"%s\", " +
Expand Down Expand Up @@ -103,7 +110,23 @@ public class DataManagement {
"}\n";
public static final String ASSET_CALL = "%s/assets/request";

public static final String NEGOTIATION_REQUEST_BODY = "{\n" +
// negotiation request 0.5.>=1
public static final String NEGOTIATION_REQUEST_BODY="{\n" +
"\"@context\": { \"odrl\": \"http://www.w3.org/ns/odrl/2/\"},\n" +
"\"@type\": \"NegotiationInitiateRequestDto\",\n" +
"\"connectorAddress\": \"%1$s\",\n" +
"\"protocol\": \"dataspace-protocol-http\",\n" +
"\"providerId\": \"%3$s\",\n" +
"\"connectorId\": \"%2$s\",\n" +
"\"offer\": {\n" +
" \"offerId\": \"%4$s\",\n" +
" \"assetId\": \"%5$s\",\n" +
" \"policy\": %6$s\n" +
"}\n" +
"}";

// negotiation request 0.5.0 - roles of provider and connector are wrong
public static final String NEGOTIATION_REQUEST_BODY_PRERELEASE="{\n" +
"\"@context\": { \"odrl\": \"http://www.w3.org/ns/odrl/2/\"},\n" +
"\"@type\": \"NegotiationInitiateRequestDto\",\n" +
"\"connectorAddress\": \"%1$s\",\n" +
Expand Down Expand Up @@ -194,9 +217,13 @@ public DcatCatalog findContractOffers(String remoteControlPlaneIdsUrl, String as
* @throws IOException in case something went wrong
*/
public DcatCatalog getCatalog(String remoteControlPlaneIdsUrl, QuerySpec spec) throws IOException {

var url = String.format(CATALOG_CALL, config.getControlPlaneManagementUrl());
var catalogSpec = String.format(CATALOG_REQUEST_BODY, String.format(DSP_PATH, remoteControlPlaneIdsUrl), objectMapper.writeValueAsString(spec));

// use a version specific call
String template = config.isPrerelease() ? CATALOG_REQUEST_BODY_PRERELEASE : CATALOG_REQUEST_BODY;

var catalogSpec =String.format(template,
String.format(DSP_PATH, remoteControlPlaneIdsUrl), objectMapper.writeValueAsString(spec));

var request = new Request.Builder().url(url).post(RequestBody.create(catalogSpec, MediaType.parse("application/json")));
config.getControlPlaneManagementHeaders().forEach(request::addHeader);
Expand Down Expand Up @@ -311,7 +338,10 @@ public IdResponse createOrUpdateSkill(String assetId, String name, String descri
public String initiateNegotiation(ContractNegotiationRequest negotiationRequest) throws IOException {
var url = String.format(NEGOTIATION_INITIATE_CALL, config.getControlPlaneManagementUrl());

var negotiateSpec = String.format(NEGOTIATION_REQUEST_BODY,
// use a version specific call
String template = config.isPrerelease() ? NEGOTIATION_REQUEST_BODY_PRERELEASE : NEGOTIATION_REQUEST_BODY;

var negotiateSpec =String.format(template,
negotiationRequest.getConnectorAddress(),
negotiationRequest.getLocalBusinessPartnerNumber(),
negotiationRequest.getRemoteBusinessPartnerNumber(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-in

HEALTHCHECK NONE

RUN apk update && apk add curl=8.3.0-r0 --no-cache
RUN apk update && apk add curl=8.4.0-r0 --no-cache
RUN curl -L --proto "=https" -sSf ${OTEL_AGENT_LOCATION} --output /tmp/opentelemetry-javaagent.jar

FROM eclipse-temurin:17-jre-alpine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ENV OTEL_AGENT_LOCATION "https://github.com/open-telemetry/opentelemetry-java-in

HEALTHCHECK NONE

RUN apk update && apk add curl=8.3.0-r0 --no-cache
RUN apk update && apk add curl=8.4.0-r0 --no-cache
RUN curl -L --proto "=https" -sSf ${OTEL_AGENT_LOCATION} --output /tmp/opentelemetry-javaagent.jar

FROM eclipse-temurin:17-jre-alpine
Expand Down

0 comments on commit 9f5cf4f

Please sign in to comment.