diff --git a/src/main/java/org/etsi/osl/metrico/services/MetricoService.java b/src/main/java/org/etsi/osl/metrico/services/MetricoService.java index 897495312f13f017fa193d776b9aa07711ecaaab..04b4d92680da9801fa81695483600080861d51a0 100644 --- a/src/main/java/org/etsi/osl/metrico/services/MetricoService.java +++ b/src/main/java/org/etsi/osl/metrico/services/MetricoService.java @@ -15,6 +15,7 @@ import org.etsi.osl.tmf.common.model.ELifecycle; import org.etsi.osl.tmf.common.model.EValueType; import org.etsi.osl.tmf.common.model.service.ResourceRef; import org.etsi.osl.tmf.pm628.model.*; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; import org.etsi.osl.tmf.ri639.model.LogicalResource; import org.etsi.osl.tmf.ri639.model.Resource; @@ -43,12 +44,12 @@ public class MetricoService extends RouteBuilder { private static final Logger logger = LoggerFactory.getLogger(JobService.class); - public static final String OSL_METRICO_RSPEC_NAME = "metrico.osl.etsi.org"; + public static final String OSL_METRICO_RSPEC_NAME = "METRICO_Resource_Specification"; public static final String OSL_METRICO_RSPEC_VERSION = "0.0.1"; public static final String OSL_METRICO_RSPEC_CATEGORY = "metrico.osl.etsi.org/v1"; public static final String OSL_METRICO_RESOURCE_CATEGORY = "metrico.osl.etsi.org/v1"; public static final String OSL_METRICO_RSPEC_TYPE = "LogicalResourceSpecification"; - public static final String OSL_METRICO_RSPEC_DESCRIPTION = "This Specification is used to describe a generic KubernetesCRD"; + public static final String OSL_METRICO_RSPEC_DESCRIPTION = "This Specification is used to describe a generic METRICO job resource"; @Value("${PM_MEASUREMENT_COLLECTION_JOB_UPDATE}") private String PM_MEASUREMENT_COLLECTION_JOB_UPDATE = ""; @@ -107,25 +108,33 @@ public class MetricoService extends RouteBuilder { ResourceSpecificationCreate rsc = new ResourceSpecificationCreate(); - rsc.setName( "METRICO_RESOURCE_SPECIFICATION" ); + rsc.setName( OSL_METRICO_RSPEC_NAME ); rsc.setCategory( OSL_METRICO_RSPEC_CATEGORY ); rsc.setVersion( OSL_METRICO_RSPEC_VERSION ); rsc.setDescription( OSL_METRICO_RSPEC_DESCRIPTION ); rsc.setType( OSL_METRICO_RSPEC_TYPE ); rsc.setLifecycleStatus( ELifecycle.ACTIVE.getValue() ); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_CHARACTERISTIC_NAME", "", EValueType.TEXT.getValue(), "Used for providing the characteristic of service _MT_SERVICEUUID to update", false); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_SERVICEUUID", "", EValueType.TEXT.getValue(), "Used for providing the id of the service to update", false); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_END_TIME", "", EValueType.TEXT.getValue(), "Used for providing the end time", false); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_START_TIME", "", EValueType.TEXT.getValue(), "Used for providing start time", false); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_RECURRING_INTERVAL", "G_1MN", EValueType.TEXT.getValue(), "Used for providing the polling interval of prometheus", false); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_TYPE", "PROMETHEUS", EValueType.TEXT.getValue(), "Used for providing ", false); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_QUERY", "", EValueType.TEXT.getValue(), "Used for providing the query towards prometheus", false); - rsc.addResourceSpecificationCharacteristicItemShort( "_MT_URL", "", EValueType.TEXT.getValue(), "Used for providing the prometheus URL", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_CHARACTERISTIC_NAME", "", EValueType.TEXT.getValue(), "The characteristic of the service with id _MT_SERVICEUUID that will be updated with monitoring metrics", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_SERVICEUUID", "", EValueType.TEXT.getValue(), "The id of the service to update", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_END_TIME", "", EValueType.TEXT.getValue(), "The ending time of the monitoring job", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_START_TIME", "", EValueType.TEXT.getValue(), "The starting time of the monitoring job", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_RECURRING_INTERVAL", "G_1MN", EValueType.TEXT.getValue(), "The polling interval of the monitoring source", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_TYPE", "PROMETHEUS", EValueType.TEXT.getValue(), "The monitoring source type", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_QUERY", "", EValueType.TEXT.getValue(), "The query towards the monitoring source (e.g. query=gnb_service_state)", false); + rsc.addResourceSpecificationCharacteristicItemShort( "_MT_URL", "", EValueType.TEXT.getValue(), "The monitoring source URL (e.g. https://prom.osl.etsi.org:9090)", false); - prometheusQueries.createOrUpdateResourceSpecByNameCategoryVersion(rsc); - + LogicalResourceSpecification result = prometheusQueries.createOrUpdateResourceSpecByNameCategoryVersion(rsc); + while ( result == null ) { + try { + logger.info("Cannot get resource for registerMetricoResourceSpec. Retrying in 10 seconds" ); + Thread.sleep( 10000 ); + } catch (InterruptedException e) { + e.printStackTrace(); + } + result = prometheusQueries.createOrUpdateResourceSpecByNameCategoryVersion(rsc); + } } diff --git a/src/test/java/org/etsi/osl/metrico/services/MetricoServiceTest.java b/src/test/java/org/etsi/osl/metrico/services/MetricoServiceTest.java index 240ca26892c83ec949a093bbd6ec64c69c8ec84c..23940b6c1256d01c0580dd8c6ec8ad2a35fb4e11 100644 --- a/src/test/java/org/etsi/osl/metrico/services/MetricoServiceTest.java +++ b/src/test/java/org/etsi/osl/metrico/services/MetricoServiceTest.java @@ -34,13 +34,13 @@ public class MetricoServiceTest { DataAccessEndpoint dae = new DataAccessEndpoint(); dae.setApiType("PROMETHEUS"); - dae.setUri(new URI("http://150.140.195.195:9090/api/v1/query?query=netdata_app_disk_physical_io_KiB_persec_average")); + dae.setUri(new URI("http://")); dae.setUuid("123e4567-e89b-12d3-a456-426614174011"); List<DataAccessEndpoint> daeList = new ArrayList<>(); daeList.add(dae); mcj.setDataAccessEndpoint(daeList); - //job.setDataAccessEndPointUri(new URI("http://150.140.195.195:9090/api/v1/query?query=up")); + //job.setDataAccessEndPointUri(new URI("http://")); }