From 116031ee55870cc5a3c90a18716fbd0fc26bb399 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonas=20M=C3=A5rtensson?= Date: Mon, 28 Nov 2022 12:09:35 +0000 Subject: [PATCH] Fix persistence when karaf is restarted MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit OpenDaylight supports datastore persistence but this does not currently work for TransportPCE since the service list and all openroadm network layers are initialised as empty when karaf is started. This changes the transaction from put to merge in order to not overwrite existing services and network layers. This also sets config datastore persistence to false before running tests since they are implemented with the assumption that datastore is not persistent. JIRA: TRNSPRTPCE-706 Signed-off-by: Jonas MÃ¥rtensson Change-Id: Icec7a1ae47d7001eb408b3b573a837daa8645bc8 --- karaf/src/main/assembly/ressources/post_install_for_tests.sh | 2 ++ .../transportpce/networkmodel/util/TpceNetwork.java | 2 +- .../service/ServiceDataStoreOperationsImpl.java | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/karaf/src/main/assembly/ressources/post_install_for_tests.sh b/karaf/src/main/assembly/ressources/post_install_for_tests.sh index 86e32826d..40f3545d0 100755 --- a/karaf/src/main/assembly/ressources/post_install_for_tests.sh +++ b/karaf/src/main/assembly/ressources/post_install_for_tests.sh @@ -8,6 +8,8 @@ sed 's/8181/ODL_RESTCONF_PORT/' ../etc/jetty.xml > jetty_template.xml sed 's/8101/ODL_SHELL_PORT/' ../etc/org.apache.karaf.shell.cfg > org.apache.karaf.shell._template.cfg sed -e 's/1099/ODL_RMI_REGISTRY_PORT/' -e 's/44444/ODL_RMI_SERVER_PORT/' ../etc/org.apache.karaf.management.cfg > org.apache.karaf.management._template.cfg +sed 's/^#persistent=true/persistent=false/' ../system/org/opendaylight/controller/sal-clustering-config/*/sal-clustering-config-*-datastore.cfg > ../etc/org.opendaylight.controller.cluster.datastore.cfg + sed -i'_' -e '1 a\ \ . \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\ diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/TpceNetwork.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/TpceNetwork.java index a8818bcb4..a19a8636f 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/TpceNetwork.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/TpceNetwork.java @@ -49,7 +49,7 @@ public class TpceNetwork { Network network = createNetwork(networkId); InstanceIdentifier.Builder nwIID = InstanceIdentifier.builder(Networks.class).child(Network.class, new NetworkKey(new NetworkId(networkId))); - networkTransactionService.put(LogicalDatastoreType.CONFIGURATION, nwIID.build(), network); + networkTransactionService.merge(LogicalDatastoreType.CONFIGURATION, nwIID.build(), network); this.networkTransactionService.commit().get(1, TimeUnit.SECONDS); LOG.info("{} network layer created successfully.", networkId); } catch (ExecutionException | TimeoutException | InterruptedException e) { diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImpl.java index 5a7386ffa..9c9c8de52 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImpl.java @@ -90,7 +90,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation try { LOG.info("initializing service registry"); WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction(); - transaction.put( + transaction.merge( LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(ServiceList.class), new ServiceListBuilder().build()); @@ -105,7 +105,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation try { LOG.info("initializing temp service registry"); WriteTransaction transaction = this.dataBroker.newWriteOnlyTransaction(); - transaction.put( + transaction.merge( LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(TempServiceList.class), new TempServiceListBuilder().build()); -- 2.36.6