"type": "object",
"properties": {
"observedTimestamp": {
- "description": "The timestamp when the data has been observed. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'. Ex: '2024-02-12T09:35:46.143+0530' ",
+ "description": "The timestamp when the data has been observed in ISO format",
"type": "string"
},
"dataspaceName": {
"type": "string"
},
"eventTime": {
- "description": "The time of the event. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'.",
+ "description": "The time of the event in ISO format.",
"type": "string"
},
"eventTarget": {
"type": "string"
},
"eventTime": {
- "description": "The time of the event. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'.",
+ "description": "The time of the event in ISO format.",
"type": "string"
},
"eventTarget": {
"type": "string"
},
"eventTime": {
- "description": "The time of the event. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'.",
+ "description": "The time of the event in ISO format.",
"type": "string"
},
"eventTarget": {
"type": "string"
},
"eventTime": {
- "description": "The time of the event. The expected format is 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'.",
+ "description": "The time of the event in ISO format.",
"type": "string"
},
"eventTarget": {
}
}
}
-}
\ No newline at end of file
+}
}
/**
- * Get Cm Handle State by Cm Handle Id.
+ * Get Cm Handle State by Cm Handle id.
*
* @param cmHandleReference cm-handle or alternate identifier
* @return cm handle state
@JsonProperty("datastores")
private DataStores dataStores;
-
/**
* Composite State copy constructor.
*
}
private void performInventoryDataMigration() {
- // TODO further implementation is pending
//1. Load all the cm handles (in batch)
//2. Copy the state and known properties
log.info("Inventory module data migration is completed successfully.");
</excludes>
<environmentVariables>
<!--
- disable privileged container usage to cleanup the test containers;
+ disable privileged container usage to clean up the test containers;
these will be removed automatically on jvm termination;
see https://www.testcontainers.org/features/configuration/#disabling-ryuk
-->
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
SchemaSetDetails:
type: object
- title: Schema set details by dataspace and schemasetName
+ title: Schema set details by dataspace and schema set name
required:
- "moduleReferences"
properties:
xpath: "/bookstore/categories/[@code=3]"
target-data:
code: 3,
- name: "kidz"
+ name: "kids"
- action: "remove"
xpath: "/bookstore/categories/[@code=1]"
source-data:
* Create a {@link SchemaSet}.
*
* @param dataspaceName dataspace name
- * @param schemaSetName schemaset name
+ * @param schemaSetName schema set name
* @param multipartFile multipart file
* @return a { {@code @Link} ResponseEntity } of created schemaset name & {@link HttpStatus} CREATED
*/
* Create a {@link SchemaSet}.
*
* @param dataspaceName dataspace name
- * @param schemaSetName schemaset name
+ * @param schemaSetName schema set name
* @param multipartFile multipart file
* @return a { {@code @Link} ResponseEntity } of created schema set
* without any response body & {@link HttpStatus} CREATED
*/
@Override
- @Timed(value = "cps.rest.admin.controller.schemaset.create",
- description = "Time taken to create schemaset from controller")
+ @Timed(value = "cps.rest.admin.controller.schema.create",
+ description = "Time taken to create schema set from controller")
public ResponseEntity<Void> createSchemaSetV2(final String dataspaceName,
@NotNull @Valid final String schemaSetName,
final MultipartFile multipartFile) {
*
* @param apiVersion api version
* @param dataspaceName dataspace name
- * @param schemaSetName schemaset name
+ * @param schemaSetName schema set name
* @return a { {@code @Link} ResponseEntity } of { {@code @Link} SchemaSetDetails } & {@link HttpStatus} OK
*/
@Override
}
/**
- * Delete a {@link SchemaSet} based on given dataspace name & schemaset name.
+ * Delete a {@link SchemaSet} based on given dataspace name & schema set name.
*
* @param apiVersion api version
* @param dataspaceName dataspace name
public class DataRestController implements CpsDataApi {
private static final String ROOT_XPATH = "/";
- private static final String ISO_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
- private static final DateTimeFormatter ISO_TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern(ISO_TIMESTAMP_FORMAT);
+ private static final DateTimeFormatter ISO_TIMESTAMP_FORMATTER =
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
private final CpsFacade cpsFacade;
private final CpsDataService cpsDataService;
return ROOT_XPATH.equals(xpath);
}
- private static OffsetDateTime toOffsetDateTime(final String datetTimestamp) {
+ private static OffsetDateTime toOffsetDateTime(final String dateTimestamp) {
try {
- return StringUtils.isEmpty(datetTimestamp)
- ? null : OffsetDateTime.parse(datetTimestamp, ISO_TIMESTAMP_FORMATTER);
+ return StringUtils.isEmpty(dateTimestamp)
+ ? null : OffsetDateTime.parse(dateTimestamp, ISO_TIMESTAMP_FORMATTER);
} catch (final Exception exception) {
- throw new ValidationException(
- String.format("observed-timestamp must be in '%s' format", ISO_TIMESTAMP_FORMAT));
+ throw new ValidationException("observed-timestamp must be in ISO format");
}
}
}
@Getter
public class ZipFileSizeValidator {
- private static final int THRESHOLD_ENTRIES = 10000;
- @SuppressWarnings("FieldCanBeLocal")
- private static int THRESHOLD_SIZE = 100000000;
- private static final double THRESHOLD_RATIO = 40;
+ private static final int THRESHOLD_ENTRIES = 10_000;
+ private static final int THRESHOLD_RATIO = 40;
+ private static final int THRESHOLD_SIZE = 100_000_000;
private static final String INVALID_ZIP = "Invalid ZIP archive content.";
private int totalUncompressedSizeOfYangFilesInArchive = 0;
assert result["component.yang"] == "fake component content 1\n"
}
- def 'Yang file limits in zip archive: #scenario for the bug reported in CPS-1477'() {
- given: 'a yang file size (uncompressed) limit of #threshold bytes'
- ZipFileSizeValidator.THRESHOLD_SIZE = threshold
- and: 'an archive with a yang file of 1083 bytes'
- def multipartFile = multipartZipFileFromResource('/yang-files-set-total-1083-bytes.zip')
- when: 'attempt to extract yang files'
- def thrownException = null
- try {
- MultipartFileUtil.extractYangResourcesMap(multipartFile)
- } catch (Exception e) {
- thrownException = e
- }
- then: 'ModelValidationException indicating size limit is only thrown when threshold exceeded'
- if (thresholdExceeded) {
- assert thrownException instanceof ModelValidationException
- assert thrownException.details.contains('limit of ' + threshold + ' bytes')
- } else {
- assert thrownException == null
- }
- where:
- scenario | threshold || thresholdExceeded
- 'exceed limit' | 1082 || true
- 'equals to limit' | 1083 || false
- 'within limit' | 1084 || false
- }
-
def 'Extract resources from zip archive having #caseDescriptor.'() {
when: 'attempt to extract resources from zip file is performed'
MultipartFileUtil.extractYangResourcesMap(multipartFile)
final int numberOfAssociatedSchemaSets = schemaSetRepository.countByDataspace(dataspaceEntity);
if (numberOfAssociatedSchemaSets != 0) {
throw new DataspaceInUseException(dataspaceName,
- String.format("Dataspace contains %d schemaset(s)", numberOfAssociatedSchemaSets));
+ String.format("Dataspace contains %d schema set(s)", numberOfAssociatedSchemaSets));
}
dataspaceRepository.delete(dataspaceEntity);
}
@Override
@Timed(value = "cps.data.persistence.service.datanode.query",
- description = "Time taken to query data nodes")
- public List<DataNode> queryDataNodes(final String dataspaceName, final String anchorName, final String cpsPath,
- final FetchDescendantsOption fetchDescendantsOption) {
- return queryDataNodes(dataspaceName, anchorName, cpsPath, fetchDescendantsOption, NO_LIMIT);
- }
-
- @Override
+ description = "Time taken to query data nodes")
public List<DataNode> queryDataNodes(final String dataspaceName,
final String anchorName,
final String cpsPath,
@Override
public <T> Set<T> queryDataLeaf(final String dataspaceName, final String anchorName, final String cpsPath,
- final int queryResultLimit, final Class<T> targetClass) {
+ final Class<T> targetClass) {
final CpsPathQuery cpsPathQuery = getCpsPathQuery(cpsPath);
if (!cpsPathQuery.hasAttributeAxis()) {
throw new IllegalArgumentException(
}
final AnchorEntity anchorEntity = getAnchorEntity(dataspaceName, anchorName);
return fragmentRepository.findAttributeValuesByAnchorAndCpsPath(anchorEntity, cpsPathQuery,
- queryResultLimit, targetClass);
+ NO_LIMIT, targetClass);
}
@Override
}
}
- private static void logMissingXPaths(final Collection<String> xpaths,
- final Collection<FragmentEntity> existingFragmentEntities) {
- final Set<String> existingXPaths =
- existingFragmentEntities.stream().map(FragmentEntity::getXpath).collect(Collectors.toSet());
- final Set<String> missingXPaths =
- xpaths.stream().filter(xpath -> !existingXPaths.contains(xpath)).collect(Collectors.toSet());
- if (!missingXPaths.isEmpty()) {
- log.warn("Cannot update data nodes: Target XPaths {} not found in DB.", missingXPaths);
- }
- }
-
}
@Override
@Transactional
- @Timed(value = "cps.module.persistence.schemaset.create",
- description = "Time taken to store a schemaset (list of module references)")
+ @Timed(value = "cps.module.persistence.schema.create",
+ description = "Time taken to store a schema set (list of module references)")
public void createSchemaSet(final String dataspaceName, final String schemaSetName,
final Map<String, String> yangResourceContentPerName) {
final Set<YangResourceEntity> yangResourceEntities = synchronizeYangResources(yangResourceContentPerName);
@Override
@Transactional
- @Timed(value = "cps.module.persistence.schemaset.createFromNewAndExistingModules",
- description = "Time taken to store a schemaset (from new and existing)")
+ @Timed(value = "cps.module.persistence.schema.createFromNewAndExistingModules",
+ description = "Time taken to store a schema set (from new and existing)")
public void createSchemaSetFromNewAndExistingModules(final String dataspaceName, final String schemaSetName,
final Map<String, String> newYangResourceContentPerName,
final Collection<ModuleReference> allModuleReferences) {
return fragmentEntities;
}
+ @SuppressWarnings("unchecked")
@Override
@Transactional
public List<Long> findAnchorIdsForPagination(final DataspaceEntity dataspaceEntity,
/**
* Intercept methods to measure and log execution details when debug level logging enabled.
*
- * @param proceedingJoinPoint exposes the proceed(..) method in order to support around advice.
+ * @param proceedingJoinPoint exposes the proceeding method in order to support around advice.
* @return empty in case of void otherwise an object of return type
*/
@Around(ALL_CPS_METHODS)
OffsetDateTime observedTimestamp, ContentType contentType);
/**
- * Retrieves all the datanodes by XPath for given dataspace and anchor.
+ * Retrieves all the data nodes by XPath for given dataspace and anchor.
*
* @param dataspaceName dataspace name
* @param anchorName anchor name
FetchDescendantsOption fetchDescendantsOption);
/**
- * Retrieves all the datanodes for multiple XPaths for given dataspace and anchor.
+ * Retrieves all the data nodes for multiple XPaths for given dataspace and anchor.
*
* @param dataspaceName dataspace name
* @param anchorName anchor name
* Replaces list content by removing all existing elements and inserting the given new elements as data nodes
* under given parent, anchor and dataspace.
*
- * @param dataspaceName dataspace-name
+ * @param dataspaceName dataspace name
* @param anchorName anchor name
* @param parentNodeXpath parent node xpath
- * @param dataNodes datanodes representing the updated data
+ * @param dataNodes data nodes representing the updated data
* @param observedTimestamp observedTimestamp
*/
void replaceListContent(String dataspaceName, String anchorName, String parentNodeXpath,
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2025 Nordix Foundation
+ * Copyright (C) 2020-2025 OpenInfra Foundation Europe. All rights reserved.
* Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
*/
<T> Set<T> queryDataLeaf(String dataspaceName, String anchorName, String cpsPath, Class<T> targetClass);
- /**
- * Get data leaf for the given dataspace and anchor by cps path.
- *
- * @param dataspaceName dataspace name
- * @param anchorName anchor name
- * @param cpsPath cps path
- * @param queryResultLimit the maximum number of data nodes to return; if less than 1, returns all matching nodes
- * @param targetClass class of the expected data type
- * @return a collection of data objects of expected type
- */
- <T> Set<T> queryDataLeaf(String dataspaceName, String anchorName, String cpsPath, int queryResultLimit,
- Class<T> targetClass);
-
/**
* Get data nodes for the given dataspace across all anchors by cps path.
*
/**
* Runtime exception.
- * Thrown when given dataspace name is rejected to be deleted because it has anchor or schemasets associated.
+ * Thrown when given dataspace name is rejected to be deleted because it has anchor or schema sets associated.
*/
@SuppressWarnings("squid:S110") // Team agreed to accept 6 levels of inheritance for CPS Exceptions
public class DataspaceInUseException extends DataInUseException {
* @param operation operation performed on the data
* @param observedTimestamp timestamp when data was updated.
*/
- @Timed(value = "cps.dataupdate.events.send", description = "Time taken to send Data Update event")
+ @Timed(value = "cps.data.update.events.send", description = "Time taken to send Data Update event")
public void sendCpsDataUpdateEvent(final Anchor anchor, final String xpath,
final Operation operation, final OffsetDateTime observedTimestamp) {
if (notificationsEnabled && cpsChangeEventNotificationsEnabled && isNotificationEnabledForAnchor(anchor)) {
}
@Override
- @Timed(value = "cps.data.service.datanode.batch.delete", description = "Time taken to delete a batch of datanodes")
+ @Timed(value = "cps.data.service.datanode.batch.delete", description = "Time taken to delete a batch of data nodes")
public void deleteDataNodes(final String dataspaceName, final String anchorName,
final Collection<String> dataNodeXpaths, final OffsetDateTime observedTimestamp) {
cpsValidator.validateNameCharacters(dataspaceName, anchorName);
@Override
@Timed(value = "cps.data.service.datanode.delete.anchor",
- description = "Time taken to delete all datanodes for an anchor")
+ description = "Time taken to delete all data nodes for an anchor")
public void deleteDataNodes(final String dataspaceName, final String anchorName,
final OffsetDateTime observedTimestamp) {
cpsValidator.validateNameCharacters(dataspaceName, anchorName);
@Override
@Timed(value = "cps.data.service.datanode.delete.anchor.batch",
- description = "Time taken to delete all datanodes for multiple anchors")
+ description = "Time taken to delete all data nodes for multiple anchors")
public void deleteDataNodes(final String dataspaceName, final Collection<String> anchorNames,
final OffsetDateTime observedTimestamp) {
cpsValidator.validateNameCharacters(dataspaceName);
private final YangParser yangParser;
@Override
- @Timed(value = "cps.module.service.schemaset.create",
- description = "Time taken to create (and store) a schemaset")
+ @Timed(value = "cps.module.service.schema.create",
+ description = "Time taken to create (and store) a schema set")
public void createSchemaSet(final String dataspaceName, final String schemaSetName,
final Map<String, String> yangResourceContentPerName) {
cpsValidator.validateNameCharacters(dataspaceName);
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2025 Nordix Foundation
+ * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
* Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@Override
public <T> Set<T> queryDataLeaf(final String dataspaceName, final String anchorName, final String cpsPath,
final Class<T> targetClass) {
- return queryDataLeaf(dataspaceName, anchorName, cpsPath, NO_LIMIT, targetClass);
- }
-
- @Override
- public <T> Set<T> queryDataLeaf(final String dataspaceName, final String anchorName, final String cpsPath,
- final int queryResultLimit, final Class<T> targetClass) {
cpsValidator.validateNameCharacters(dataspaceName, anchorName);
- return cpsDataPersistenceService.queryDataLeaf(dataspaceName, anchorName, cpsPath,
- queryResultLimit, targetClass);
+ return cpsDataPersistenceService.queryDataLeaf(dataspaceName, anchorName, cpsPath, targetClass);
}
@Override
private final CpsModulePersistenceService cpsModulePersistenceService;
private final CpsValidator cpsValidator;
- private final AtomicInteger yangSchemaCacheCounter = Metrics.gauge("cps.yangschema.cache.gauge",
+ private final AtomicInteger yangSchemaCacheCounter = Metrics.gauge("cps.yang.schema.cache.gauge",
new AtomicInteger(0));
/**
/**
* Create initial schema set.
* @param dataspaceName dataspace name
- * @param schemaSetName schemaset name
+ * @param schemaSetName schema set name
* @param resourceNames resource names
*/
public void createSchemaSet(final String dataspaceName, final String schemaSetName, final String... resourceNames) {
/**
* Create initial anchor.
* @param dataspaceName dataspace name
- * @param schemaSetName schemaset name
+ * @param schemaSetName schemas et name
* @param anchorName anchor name
*/
public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
* Update anchor schema set.
* @param dataspaceName dataspace name
* @param anchorName anchor name
- * @param schemaSetName schemaset name
+ * @param schemaSetName schema set name
*/
public void updateAnchorSchemaSet(final String dataspaceName, final String anchorName, final String schemaSetName) {
try {
public class CpsNotificationSubscriptionModelLoader extends AbstractModelLoader {
private static final String MODEL_FILENAME = "cps-notification-subscriptions@2024-07-03.yang";
- private static final String SCHEMASET_NAME = "cps-notification-subscriptions";
+ private static final String SCHEMA_SET_NAME = "cps-notification-subscriptions";
private static final String ANCHOR_NAME = "cps-notification-subscriptions";
private static final String CPS_DATASPACE_NAME = "CPS-Admin";
private static final String REGISTRY_DATANODE_NAME = "dataspaces";
private void onboardSubscriptionModels() {
createDataspace(CPS_DATASPACE_NAME);
- createSchemaSet(CPS_DATASPACE_NAME, SCHEMASET_NAME, MODEL_FILENAME);
- createAnchor(CPS_DATASPACE_NAME, SCHEMASET_NAME, ANCHOR_NAME);
+ createSchemaSet(CPS_DATASPACE_NAME, SCHEMA_SET_NAME, MODEL_FILENAME);
+ createAnchor(CPS_DATASPACE_NAME, SCHEMA_SET_NAME, ANCHOR_NAME);
createTopLevelDataNode(CPS_DATASPACE_NAME, ANCHOR_NAME, REGISTRY_DATANODE_NAME);
}
/**
* Query anchor names for the given module names in the provided dataspace.
- * If dataspace or one of the given module names does not exists, return with an empty collection.
+ * If dataspace or one of the given module names does not exist, return with an empty collection.
*
* @param dataspaceName dataspace name
* @param moduleNames a collection of module names
public interface CpsDataPersistenceService {
/**
- * Store multiple datanodes at once.
+ * Store multiple data nodes at once.
* @param dataspaceName dataspace name
* @param anchorName anchor name
* @param dataNodes data nodes
Collection<DataNode> listElementsCollection);
/**
- * Retrieves multiple datanodes for a single XPath for given dataspace and anchor.
+ * Retrieves multiple data nodes for a single XPath for given dataspace and anchor.
* Multiple data nodes are returned when xPath is set to root '/', otherwise single data node
* is returned when a specific xpath is used (Example: /bookstore).
*
FetchDescendantsOption fetchDescendantsOption);
/**
- * Retrieves multiple datanodes for multiple XPaths, given a dataspace and anchor.
+ * Retrieves multiple data nodes for multiple XPaths, given a dataspace and anchor.
*
* @param dataspaceName dataspace name
* @param anchorName anchor name
*/
void deleteListDataNode(String dataspaceName, String anchorName, String targetXpath);
- /**
- * Get a datanode by cps path.
- *
- * @param dataspaceName dataspace name
- * @param anchorName anchor name
- * @param cpsPath cps path
- * @param fetchDescendantsOption defines whether the descendants of the node(s) found by the query should be
- * included in the output
- * @return the data nodes found i.e. 0 or more data nodes
- */
- List<DataNode> queryDataNodes(String dataspaceName, String anchorName,
- String cpsPath, FetchDescendantsOption fetchDescendantsOption);
/**
* Get a datanode by cps path.
* @param dataspaceName dataspace name
* @param anchorName anchor name
* @param cpsPath cps path
- * @param queryResultLimit limits the number of returned entities (if less than 1 returns all)
* @param targetClass class of the expected data type
* @return a collection of data objects of expected type
*/
- <T> Set<T> queryDataLeaf(String dataspaceName, String anchorName, String cpsPath, int queryResultLimit,
- Class<T> targetClass);
+ <T> Set<T> queryDataLeaf(String dataspaceName, String anchorName, String cpsPath, Class<T> targetClass);
/**
* Get a datanode by dataspace name and cps path across all anchors.
/**
* Query total anchors for dataspace name and cps path.
- * @param dataspaceName datasoace name
+ * @param dataspaceName dataspace name
* @param cpsPath cps path
* @return total anchors for dataspace name and cps path
*/
public interface DateTimeUtility {
- String ISO_TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
- DateTimeFormatter ISO_TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern(ISO_TIMESTAMP_PATTERN);
+ DateTimeFormatter ISO_TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
static String toString(OffsetDateTime offsetDateTime) {
return offsetDateTime != null ? ISO_TIMESTAMP_FORMATTER.format(offsetDateTime) : null;
private static final String NO_KEY_VALUE_IN_PATH_SEGMENT = null;
/**
- * Convert RESTCONF style path to CpsPath.
+ * Convert RestConf style path to CpsPath.
*
- * @param restConfStylePath restconf style path
+ * @param restConfStylePath restConf style path
* @param schemaContext schema context
* @return CpsPath
*/
* @param anchor the anchor for the node data
* @return the NormalizedNode object
*/
- @Timed(value = "cps.utils.yangparser.nodedata.with.parent.parse",
+ @Timed(value = "cps.utils.yang.parser.node.data.with.parent.parse",
description = "Time taken to parse node data with a parent")
public ContainerNode parseData(final ContentType contentType, final String nodeData, final Anchor anchor,
final String parentNodeXpath) {
* @param yangResourceContentPerName yang resource content per name
* @return the NormalizedNode object
*/
- @Timed(value = "cps.utils.yangparser.nodedata.with.parent.with.yangResourceMap.parse",
+ @Timed(value = "cps.utils.yang.parser.node.data.with.parent.with.yangResourceMap.parse",
description = "Time taken to parse node data with a parent")
public ContainerNode parseData(final ContentType contentType, final String nodeData,
final Map<String, String> yangResourceContentPerName, final String parentNodeXpath) {
}
/**
- * Get Cps path from Restconf path.
+ * Get Cps path from RestConf path.
*
* @param anchor anchor
- * @param restConfStylePath restconf path
+ * @param restConfStylePath restConf path
* @return CpsPath
*/
public String getCpsPathFromRestConfStylePath(final Anchor anchor, final String restConfStylePath) {
* Get the collection of concatenated module-name:root-node of the provided anchor.
*
* @param anchor Anchor
- * @return Concatentated module and root node
+ * @return Concatenated module and root node
*/
public Set<String> getRootNodeReferences(final Anchor anchor) {
final SchemaContext schemaContext = getSchemaContext(anchor);
public class YangUtils {
/**
- * Create an xpath form a Yang Tools NodeIdentifier (i.e. PathArgument).
+ * Create a xpath form a Yang Tools NodeIdentifier (i.e. PathArgument).
*
* @param nodeIdentifier the NodeIdentifier
* @return a xpath
@Service
public class TimedYangTextSchemaSourceSetBuilder {
- @Timed(value = "cps.yangtextschemasourceset.build",
+ @Timed(value = "cps.yang.text.schema.source.set.build",
description = "Time taken to build a yang text schema source set")
public YangTextSchemaSourceSet getYangTextSchemaSourceSet(
final Map<String, String> yangResourceContentPerName) {
* @return the YangTextSchemaSourceSet
*/
- @Timed(value = "cps.yang.schemasourceset.build", description = "Time taken to build a ODL yang Model")
+ @Timed(value = "cps.yang.schema.source.set.build", description = "Time taken to build a ODL yang Model")
public static YangTextSchemaSourceSet of(final Map<String, String> yangResourceNameToContent) {
return new YangTextSchemaSourceSetBuilder().putAll(yangResourceNameToContent).build();
}
when: 'a query for a specific leaf is executed'
objectUnderTest.queryDataLeaf('some-dataspace', 'some-anchor', '/cps-path/@id', Object.class)
then: 'the persistence service is called once with the correct parameters'
- 1 * mockCpsDataPersistenceService.queryDataLeaf('some-dataspace', 'some-anchor', '/cps-path/@id', 0, Object.class)
+ 1 * mockCpsDataPersistenceService.queryDataLeaf('some-dataspace', 'some-anchor', '/cps-path/@id', Object.class)
}
}
xpath: "/bookstore/categories/[@code=3]"
target-data:
code: "3,"
- name: kidz
+ name: kids
- action: remove
xpath: "/bookstore/categories/[@code=1]"
source-data:
type: string
required:
- moduleReferences
- title: Schema set details by dataspace and schemasetName
+ title: Schema set details by dataspace and schema set name
type: object
ModuleReferences:
example:
cpsModuleService.createSchemaSet('targetDataspace','someSchemaSet',[:])
when: 'attempt to delete dataspace'
objectUnderTest.deleteDataspace('targetDataspace')
- then: 'an in-use exception is thrown mentioning schemasets'
+ then: 'an in-use exception is thrown mentioning schema sets'
def thrownException = thrown(DataspaceInUseException)
- assert thrownException.details.contains('contains 1 schemaset(s)')
+ assert thrownException.details.contains('contains 1 schema set(s)')
cleanup:
cpsModuleService.deleteSchemaSetsWithCascade('targetDataspace',['someSchemaSet'])
objectUnderTest.deleteDataspace('targetDataspace')
-1 || 5
}
- def 'Query data leaf with a limit of #limit.' () {
- when: 'a query for data leaf is executed with a result limit'
- def result = objectUnderTest.queryDataLeaf(FUNCTIONAL_TEST_DATASPACE_1, BOOKSTORE_ANCHOR_1, '/bookstore/categories/@name', limit, String)
- then: 'the expected number of leaf values is returned'
- assert result.size() == expectedNumberOfResults
- where: 'the following parameters are used'
- limit || expectedNumberOfResults
- 1 || 1
- 2 || 2
- 0 || 5
- -1 || 5
- }
}
})
and: 'log the relevant instrumentation'
def dmiModuleRetrievalTimer = meterRegistry.get('cps.ncmp.inventory.module.references.from.dmi').timer()
- def dbSchemaSetStorageTimer = meterRegistry.get('cps.module.persistence.schemaset.createFromNewAndExistingModules').timer()
+ def dbSchemaSetStorageTimer = meterRegistry.get('cps.module.persistence.schema.createFromNewAndExistingModules').timer()
def dbStateUpdateTimer = meterRegistry.get('cps.ncmp.cmhandle.state.update.batch').timer()
logInstrumentation(dmiModuleRetrievalTimer, 'get modules from DMI ')
logInstrumentation(dbSchemaSetStorageTimer, 'store schema sets ')
#!/usr/bin/env python3
#
-# Copyright 2023 Nordix Foundation.
+# Copyright 2023-2025 OpenInfra Foundation Europe. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
def load_metrics_table(filename):
with open(filename) as tsvFile:
- csvreader = csv.DictReader(tsvFile, dialect="excel-tab")
+ csvReader = csv.DictReader(tsvFile, dialect="excel-tab")
table = {}
- for source_row in csvreader:
+ for source_row in csvReader:
method, count, sum_time = source_row['Method'], source_row['Count'], source_row['Sum']
table[method] = { 'Count': int(float(count)), 'Sum': float(sum_time) }
return table
def save_metrics_table(table, filename):
with open(filename, 'w', newline='') as outfile:
- csvwriter = csv.writer(outfile, dialect="excel-tab")
- csvwriter.writerow(["Method", "Count", "Sum"])
+ csvWriter = csv.Writer(outfile, dialect="excel-tab")
+ csvWriter.writerow(["Method", "Count", "Sum"])
for method in table:
count, sum_time = table[method]['Count'], table[method]['Sum']
- csvwriter.writerow([method, count, sum_time])
+ csvWriter.writerow([method, count, sum_time])
def subtract_metrics_tables(table, table_to_subtract):