diff --git a/extensions/seed/nats/build.gradle.kts b/extensions/seed/nats/build.gradle.kts deleted file mode 100644 index 5dc4f89..0000000 --- a/extensions/seed/nats/build.gradle.kts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -plugins { - `java-library` -} - -dependencies { - implementation(libs.nats.client) - implementation(libs.edc.spi.controlplane) - implementation(libs.edc.sql.bootstrapper) -} diff --git a/extensions/seed/nats/src/main/java/org/eclipse/edc/virtualized/seed/NatsSeedExtension.java b/extensions/seed/nats/src/main/java/org/eclipse/edc/virtualized/seed/NatsSeedExtension.java deleted file mode 100644 index cdcb0cd..0000000 --- a/extensions/seed/nats/src/main/java/org/eclipse/edc/virtualized/seed/NatsSeedExtension.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - -package org.eclipse.edc.virtualized.seed; - -import io.nats.client.JetStreamManagement; -import io.nats.client.Nats; -import io.nats.client.api.StorageType; -import io.nats.client.api.StreamConfiguration; -import org.eclipse.edc.runtime.metamodel.annotation.Inject; -import org.eclipse.edc.runtime.metamodel.annotation.Setting; -import org.eclipse.edc.spi.EdcException; -import org.eclipse.edc.spi.system.ServiceExtension; -import org.eclipse.edc.spi.system.ServiceExtensionContext; -import org.eclipse.edc.sql.bootstrapper.SqlSchemaBootstrapper; - -/** - * This extension creates NATS streams and consumers. If the streams already exist, they will be deleted and recreated. - */ -public class NatsSeedExtension implements ServiceExtension { - public static final String NAME = "NATS Stream Seed Extension"; - private JetStreamManagement jsm; - - @Setting(key = "edc.nats.cn.subscriber.url") - private String natsUrl; - @Setting(description = "The datasource to be used", defaultValue = "default", key = "edc.sql.store.asset.datasource") - private String dataSourceName; - @Inject - private SqlSchemaBootstrapper sqlSchemaBootstrapper; - - @Override - public String name() { - return NAME; - } - - - @Override - public void initialize(ServiceExtensionContext context) { - - sqlSchemaBootstrapper.addStatementFromResource(dataSourceName, "enable_replication.sql"); - - try (var conn = Nats.connect(natsUrl)) { - jsm = conn.jetStreamManagement(); - conn.jetStream(); - - try { - var si = jsm.getStreamInfo("state_machine"); - if (si != null) { - jsm.deleteConsumer("state_machine", "cn-subscriber"); - jsm.deleteConsumer("state_machine", "tp-subscriber"); - deleteStream("state_machine"); - } - } catch (Exception e) { - context.getMonitor().warning("Could not delete stream 'state_machine': %s", e); - } - - createStream("state_machine", "negotiations.>", "transfers.>"); - createConsumer("state_machine", "cn-subscriber", "negotiations.>"); - createConsumer("state_machine", "tp-subscriber", "transfers.>"); - } catch (Exception e) { - throw new EdcException("Could not connect to NATS", e); - } - } - - public void createStream(String streamName, String... subject) { - var streamConfig = StreamConfiguration.builder() - .name(streamName) - .subjects(subject) - .storageType(StorageType.Memory) - .build(); - try { - jsm.addStream(streamConfig); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public void deleteStream(String streamName) { - try { - jsm.deleteStream(streamName); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public void createConsumer(String streamName, String consumerName, String filterSubject) { - try { - jsm.addOrUpdateConsumer(streamName, io.nats.client.api.ConsumerConfiguration.builder() - .durable(consumerName) - .name(consumerName) - .filterSubject(filterSubject) - .build()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/extensions/seed/nats/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension b/extensions/seed/nats/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension deleted file mode 100644 index edcd68c..0000000 --- a/extensions/seed/nats/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (c) 2025 Metaform Systems, Inc. -# -# 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: -# Metaform Systems, Inc. - initial API and implementation -# -# - -org.eclipse.edc.virtualized.seed.NatsSeedExtension \ No newline at end of file diff --git a/extensions/seed/nats/src/main/resources/enable_replication.sql b/extensions/seed/nats/src/main/resources/enable_replication.sql deleted file mode 100644 index 2e209eb..0000000 --- a/extensions/seed/nats/src/main/resources/enable_replication.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2025 Metaform Systems, Inc. - * - * 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: - * Metaform Systems, Inc. - initial API and implementation - * - */ - --- enable full replication, otherwise -ALTER TABLE edc_contract_negotiation REPLICA IDENTITY FULL; -ALTER TABLE edc_transfer_process REPLICA IDENTITY FULL; \ No newline at end of file diff --git a/k8s/apps/controlplane-config.yaml b/k8s/apps/controlplane-config.yaml index 3441955..34fa088 100644 --- a/k8s/apps/controlplane-config.yaml +++ b/k8s/apps/controlplane-config.yaml @@ -38,8 +38,10 @@ data: # NATS config edc.nats.cn.subscriber.url: "nats://nats.edc-v.svc.cluster.local:4222" + edc.nats.cn.subscriber.autocreate: "true" edc.nats.cn.publisher.url: "nats://nats.edc-v.svc.cluster.local:4222" edc.nats.tp.subscriber.url: "nats://nats.edc-v.svc.cluster.local:4222" + edc.nats.tp.subscriber.autocreate: "true" edc.nats.tp.publisher.url: "nats://nats.edc-v.svc.cluster.local:4222" edc.postgres.cdc.url: "jdbc:postgresql://postgres.edc-v.svc.cluster.local:5432/controlplane" edc.postgres.cdc.user: "cp" diff --git a/launchers/controlplane/build.gradle.kts b/launchers/controlplane/build.gradle.kts index c1fe5ad..a12170c 100644 --- a/launchers/controlplane/build.gradle.kts +++ b/launchers/controlplane/build.gradle.kts @@ -60,7 +60,6 @@ dependencies { runtimeOnly(project(":extensions:api:mgmt")) runtimeOnly(project(":extensions:dcp-impl")) - runtimeOnly(project(":extensions:seed:nats")) } tasks.withType { diff --git a/settings.gradle.kts b/settings.gradle.kts index 2030b77..f0a91d0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,7 +25,6 @@ pluginManagement { } rootProject.name = "jad" -include(":extensions:seed:nats") include(":extensions:api:mgmt") include(":extensions:dcp-impl") include(":extensions:data-plane-public-api-v2")