diff options
17 files changed, 107 insertions, 25 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java index 032745b5ee..7a864a9216 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech - * Modifications Copyright (C) 2021 Nordix Foundation + * Modifications Copyright (C) 2021-2022 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public class YangResourceEntity implements Serializable { @NotNull @Column - private String name; + private String fileName; @NotNull @Column diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java index 117cb43b4f..9443355981 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java @@ -263,7 +263,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService final SchemaSetEntity schemaSetEntity = fragmentEntity.getAnchor().getSchemaSet(); final Map<String, String> yangResourceNameToContent = schemaSetEntity.getYangResources().stream().collect( - Collectors.toMap(YangResourceEntity::getName, YangResourceEntity::getContent)); + Collectors.toMap(YangResourceEntity::getFileName, YangResourceEntity::getContent)); final SchemaContext schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent) .getSchemaContext(); return schemaContext.getModules().iterator().next().getName(); diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java index 806e7ccaba..647d6cdefb 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java @@ -96,7 +96,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ final var schemaSetEntity = schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName); return schemaSetEntity.getYangResources().stream().collect( - Collectors.toMap(YangResourceEntity::getName, YangResourceEntity::getContent)); + Collectors.toMap(YangResourceEntity::getFileName, YangResourceEntity::getContent)); } @Override @@ -203,7 +203,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ final Map<String, String> moduleNameAndRevisionMap = createModuleNameAndRevisionMap(entry.getKey(), entry.getValue()); final var yangResourceEntity = new YangResourceEntity(); - yangResourceEntity.setName(entry.getKey()); + yangResourceEntity.setFileName(entry.getKey()); yangResourceEntity.setContent(entry.getValue()); yangResourceEntity.setModuleName(moduleNameAndRevisionMap.get("moduleName")); yangResourceEntity.setRevision(moduleNameAndRevisionMap.get("revision")); @@ -328,7 +328,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ yangResourceEntities.stream() .filter(entity -> StringUtils.equals(checksum, (entity.getChecksum()))) .findFirst() - .map(YangResourceEntity::getName) + .map(YangResourceEntity::getFileName) .orElse(null); } diff --git a/cps-ri/src/main/resources/changelog/changelog-master.yaml b/cps-ri/src/main/resources/changelog/changelog-master.yaml index aa1b49d8b8..218e78b85c 100644 --- a/cps-ri/src/main/resources/changelog/changelog-master.yaml +++ b/cps-ri/src/main/resources/changelog/changelog-master.yaml @@ -44,3 +44,5 @@ databaseChangeLog: file: changelog/db/changes/13-insert-dmi-registry-2022-02-10-schema-set.yaml - include: file: changelog/db/changes/14-loadData-dmi-registry-2022-05-10-schema-set.yaml + - include: + file: changelog/db/changes/15-rename-column-yang-resource-table.yaml
\ No newline at end of file diff --git a/cps-ri/src/main/resources/changelog/db/changes/15-rename-column-yang-resource-table.yaml b/cps-ri/src/main/resources/changelog/db/changes/15-rename-column-yang-resource-table.yaml new file mode 100644 index 0000000000..71f11a5382 --- /dev/null +++ b/cps-ri/src/main/resources/changelog/db/changes/15-rename-column-yang-resource-table.yaml @@ -0,0 +1,14 @@ +databaseChangeLog: + - changeSet: + author: cps + label: yang-resource-rename-column + id: 15 + changes: + - renameColumn: + tableName: yang_resource + columnDataType: TEXT + oldColumnName: name + newColumnName: file_name + rollback: + - sql: + sql: alter table yang_resource rename column file_name to name
\ No newline at end of file diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy index bb80199d09..bde2f3de9f 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsDataPersistenceServiceSpec.groovy @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.hibernate.StaleStateException import org.onap.cps.spi.FetchDescendantsOption import org.onap.cps.spi.entities.AnchorEntity -import org.onap.cps.spi.entities.DataspaceEntity import org.onap.cps.spi.entities.FragmentEntity import org.onap.cps.spi.entities.SchemaSetEntity import org.onap.cps.spi.entities.YangResourceEntity @@ -35,9 +34,6 @@ import org.onap.cps.spi.repository.DataspaceRepository import org.onap.cps.spi.repository.FragmentRepository import org.onap.cps.spi.utils.SessionManager import org.onap.cps.utils.JsonObjectMapper -import org.onap.cps.yang.YangTextSchemaSourceSet -import org.onap.cps.yang.YangTextSchemaSourceSetBuilder -import org.opendaylight.yangtools.yang.model.api.SchemaContext import spock.lang.Shared import spock.lang.Specification @@ -67,7 +63,7 @@ class CpsDataPersistenceServiceSpec extends Specification { @Shared def yangResourceSet = [new YangResourceEntity(moduleName: 'moduleName', content: NEW_RESOURCE_CONTENT, - name: 'sampleYangResource' + fileName: 'sampleYangResource' )] as Set diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy index 8a43e5125d..3249d51ad1 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy @@ -30,7 +30,6 @@ import org.onap.cps.spi.model.ModuleDefinition import org.onap.cps.spi.model.ModuleReference import org.onap.cps.spi.repository.AnchorRepository import org.onap.cps.spi.repository.SchemaSetRepository -import org.onap.cps.spi.repository.YangResourceRepository import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.jdbc.Sql @@ -244,7 +243,7 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase // assert the attached yang resource content YangResourceEntity yangResourceEntity = yangResourceEntities.iterator().next() assert yangResourceEntity.id != null - yangResourceEntity.name == expectedYangResourceName + yangResourceEntity.fileName == expectedYangResourceName yangResourceEntity.content == expectedYangResourceContent yangResourceEntity.checksum == expectedYangResourceChecksum yangResourceEntity.moduleName == expectedYangResourceModuleName diff --git a/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java b/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java index 10f8de422d..2d2df2e629 100755 --- a/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java +++ b/cps-ri/src/test/java/org/onap/cps/DatabaseTestContainer.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2020 Pantheon.tech + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +30,7 @@ import org.testcontainers.containers.PostgreSQLContainer; * psql -d test -U test */ public class DatabaseTestContainer extends PostgreSQLContainer<DatabaseTestContainer> { - private static final String IMAGE_VERSION = "postgres:13.2"; + private static final String IMAGE_VERSION = "postgres:14.1"; private static DatabaseTestContainer databaseTestContainer; private DatabaseTestContainer() { diff --git a/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql b/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql index 45119dec0f..65b3a48ca5 100644 --- a/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql +++ b/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql @@ -1,6 +1,6 @@ /* ============LICENSE_START======================================================= - Copyright (C) 2021 Nordix Foundation. + Copyright (C) 2021-2022 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ INSERT INTO SCHEMA_SET (ID, NAME, DATASPACE_ID) VALUES (2003, 'schema-set-3', 1001), (2004, 'schema-set-4', 1002); -INSERT INTO YANG_RESOURCE (ID, NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES +INSERT INTO YANG_RESOURCE (ID, FILE_NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES (3001, 'module1@revA.yang', 'some-content', 'checksum1','module-name-1','revA'), (3002, 'module2@revA.yang', 'some-content', 'checksum2','module-name-2','revA'), (3003, 'module2@revB.yang', 'some-content', 'checksum3','module-name-2','revB'), diff --git a/cps-ri/src/test/resources/data/cps-path-query.sql b/cps-ri/src/test/resources/data/cps-path-query.sql index c406203c8c..b6000cffb4 100644 --- a/cps-ri/src/test/resources/data/cps-path-query.sql +++ b/cps-ri/src/test/resources/data/cps-path-query.sql @@ -25,7 +25,7 @@ INSERT INTO DATASPACE (ID, NAME) VALUES INSERT INTO SCHEMA_SET (ID, NAME, DATASPACE_ID) VALUES (2001, 'SCHEMA-SET-001', 1001); -INSERT INTO YANG_RESOURCE (ID, NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES +INSERT INTO YANG_RESOURCE (ID, FILE_NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES (4001, 'TEST','', 'SAMPLECHECKSUM','TESTMODULENAME', 'SAMPLEREVISION'); UPDATE YANG_RESOURCE SET diff --git a/cps-ri/src/test/resources/data/fragment.sql b/cps-ri/src/test/resources/data/fragment.sql index fd05900e28..bc6e4e7c65 100755 --- a/cps-ri/src/test/resources/data/fragment.sql +++ b/cps-ri/src/test/resources/data/fragment.sql @@ -27,7 +27,7 @@ INSERT INTO DATASPACE (ID, NAME) VALUES INSERT INTO SCHEMA_SET (ID, NAME, DATASPACE_ID) VALUES (2001, 'SCHEMA-SET-001', 1001); -INSERT INTO YANG_RESOURCE (ID, NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES +INSERT INTO YANG_RESOURCE (ID, FILE_NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES (4001, 'TEST','', 'SAMPLECHECKSUM','TESTMODULENAME', 'SAMPLEREVISION'); UPDATE YANG_RESOURCE SET diff --git a/cps-ri/src/test/resources/data/schemaset.sql b/cps-ri/src/test/resources/data/schemaset.sql index 2b0a8961b6..ad611664b8 100644 --- a/cps-ri/src/test/resources/data/schemaset.sql +++ b/cps-ri/src/test/resources/data/schemaset.sql @@ -1,7 +1,7 @@ /* ============LICENSE_START======================================================= Copyright (C) 2020-2021 Pantheon.tech - Modifications Copyright (C) 2020 Nordix Foundation. + Modifications Copyright (C) 2020-2022 Nordix Foundation. Modifications Copyright (C) 2020-2021 Bell Canada. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,7 @@ INSERT INTO SCHEMA_SET (ID, NAME, DATASPACE_ID) VALUES (2004, 'SCHEMA-SET-004', 1002), (2005, 'SCHEMA-SET-005', 1001); -INSERT INTO YANG_RESOURCE (ID, NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES +INSERT INTO YANG_RESOURCE (ID, FILE_NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES (3001, 'module1@2020-02-02.yang', 'CONTENT-001', 'e8bdda931099310de66532e08c3fafec391db29f55c81927b168f6aa8f81b73b',null,null), (3002, 'module2@2020-02-02.yang', 'CONTENT-002', '7e7d48afbe066ed0a890a09081859046d3dde52300dfcdb13be5b20780353a11','MODULE-NAME-002','REVISION-002'), (3003, 'module3@2020-02-02.yang', 'CONTENT-003', 'ca20c45fec8547633f05ff8905c48ffa7b02b94ec3ad4ed79922e6ba40779df3','MODULE-NAME-003','REVISION-002'), diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index ed37f58245..8d3a0a3579 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -23,7 +23,7 @@ services: dbpostgresql: container_name: dbpostgresql - image: postgres:13.2-alpine + image: postgres:14.1-alpine ports: - ${DB_PORT:-5432}:5432 environment: diff --git a/docs/cps-scheduled-processes.rst b/docs/cps-scheduled-processes.rst new file mode 100644 index 0000000000..01fe66aae4 --- /dev/null +++ b/docs/cps-scheduled-processes.rst @@ -0,0 +1,44 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2022 Nordix Foundation + +.. DO NOT CHANGE THIS LABEL FOR RELEASE NOTES - EVEN THOUGH IT GIVES A WARNING +.. cpsScheduledProcesses: + + +CPS Scheduled Processes +####################### + +.. toctree:: + :maxdepth: 1 + +Introduction +============ + +The following section is a list of the current scheduled processes running within the CPS system. + +Module Sync +----------- +The module sync is a user :ref:`configurable timed process<additional-cps-ncmp-customizations>`, +which is set to search for CM-Handles within CPS with an *'ADVISED'* state. +Once the CM-Handle(s) is processed by the module sync, the CM-Handle state is then set to *'READY'*, if the process completes successfully. +If for any reason the module sync fails, the CM-Handle state will then be set to *'LOCKED'*, +and the reason for the lock will also be stored within CPS. + +Data Sync +--------- +The data sync is a user :ref:`configurable timed process<additional-cps-ncmp-customizations>`, +which is set to search for CM-Handles with a sync state of *'UNSYNCHRONIZED'*. +Once the CM-Handle(s) with a sync state of *'UNSYNCHRONIZED'* is processed by the data sync, +the CM-Handle sync state is then set to *'SYNCHRONIZED'*, if the process completes successfully. +If the data sync fails, the CM-Handle sync state will remain as *'UNSYNCHRONIZED'*, and will be re-attempted. + +Retry Mechanism +--------------- +The retry mechanism is a user :ref:`configurable timed process<additional-cps-ncmp-customizations>`, +which is used to search for CM-Handles which are currently in a *'LOCKED'* state. +If the CM-Handle is ready to be retried then, the CM-Handle(s) in a *'LOCKED'* state is processed by the retry mechanism, +the CM-Handle state is then set to *'ADVISED'*. +Whether the CM-Handle is ready to be retried is dependent on both the number of attempts to sync the CM-Handle, +and the last update time of the CM-Handle state. +With each new attempt to unlock the CM-Handle, the time until the CM-Handle can next be retried is doubled. diff --git a/docs/deployment.rst b/docs/deployment.rst index c0d8b60294..11cf77f870 100644 --- a/docs/deployment.rst +++ b/docs/deployment.rst @@ -1,6 +1,6 @@ .. This work is licensed under a Creative Commons Attribution 4.0 International License. .. http://creativecommons.org/licenses/by/4.0 -.. Copyright (C) 2021 Nordix Foundation +.. Copyright (C) 2021-2022 Nordix Foundation .. Modifications Copyright (C) 2021 Bell Canada. .. DO NOT CHANGE THIS LABEL FOR RELEASE NOTES - EVEN THOUGH IT GIVES A WARNING @@ -278,6 +278,8 @@ Any spring supported property can be configured by providing in ``config.additio | maximumPoolSize | including both idle and in-use connections. | | +---------------------------------------+---------------------------------------------------------------------------------------------------------+-------------------------------+ +.. _additional-cps-ncmp-customizations: + Additional CPS-NCMP Customizations ================================== +---------------------------------------+---------------------------------------------------------------------------------------------------------+-------------------------------+ @@ -293,6 +295,15 @@ Additional CPS-NCMP Customizations | .sleep-time-ms | | | | | | | +---------------------------------------+---------------------------------------------------------------------------------------------------------+-------------------------------+ +| config.timers.locked-modules-sync | Specifies the delay in milliseconds in which the retry mechanism watch dog | | +| | will wake again after finishing. | ``300000`` | +| .sleep-time-ms | | | +| | | | ++---------------------------------------+---------------------------------------------------------------------------------------------------------+-------------------------------+ +| config.timers.cm-handle-data-sync | Specifies the delay in milliseconds in which the data sync watch dog will wake again after finishing. | ``30000`` | +| .sleep-time-ms | | | +| | | | ++---------------------------------------+---------------------------------------------------------------------------------------------------------+-------------------------------+ CPS-Core Docker Installation ============================ diff --git a/docs/index.rst b/docs/index.rst index df4ea95185..c1427ad381 100755 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,8 +11,8 @@ CPS Documentation ################# -CPS Core -======== +CPS +=== .. toctree:: :maxdepth: 1 diff --git a/docs/modeling.rst b/docs/modeling.rst index 80cfdeaaf6..bc1019abe7 100644 --- a/docs/modeling.rst +++ b/docs/modeling.rst @@ -83,6 +83,20 @@ Basic Concepts These are stored as Anchors within CPS-Core. + - **CM-Handle States** are used to represent the potential states in which a CM-Handle can transition between. + + The 5 possible CM-Handle states are: ADVISED, READY, LOCKED, DELETING, DELETED + + **ADVISED** indicates that a CM-Handle has been registered successfully, and is waiting for the module synchronization process to sync the CM-Handle. + + **READY** indicates that the CM-Handle has been synced successfully. + + **LOCKED** indicates that the CM-Handle has not synced successfully. A retry mechanism within CPS will set the state back to ADVISED after a set time. + + **DELETING** indicates that the CM-Handle is currently being deleted. + + **DELETED** indicates that the CM-Handle has been deleted successfully. + - **Data-sync state** is the state of the data synchronization process of the CM-Handle There are 3 possibles states: NONE_REQUESTED, UNSYNCHRONIZED, SYNCHRONIZED @@ -111,4 +125,5 @@ Querying CM Handles .. toctree:: :maxdepth: 1 - ncmp-cmhandle-querying.rst
\ No newline at end of file + ncmp-cmhandle-querying.rst + cps-processes.rst
\ No newline at end of file |