Standalone TCA with EELF Logger 45/60745/2
authorSingla, Rajiv (rs153v) <rs153v@att.com>
Wed, 15 Aug 2018 15:46:10 +0000 (11:46 -0400)
committerSingla, Rajiv (rs153v) <rs153v@att.com>
Thu, 16 Aug 2018 15:09:15 +0000 (11:09 -0400)
Issue-ID: DCAEGEN2-633
Change-Id: I4da76b532021c0d6248455e7bd6e77f4614c35a7
Signed-off-by: Singla, Rajiv (rs153v) <rs153v@att.com>
371 files changed:
.gitignore [new file with mode: 0644]
.gitreview [new file with mode: 0644]
LICENSE.txt [new file with mode: 0644]
dcae-analytics/.gitignore [new file with mode: 0644]
dcae-analytics/.gitreview [new file with mode: 0644]
dcae-analytics/LICENSE.txt [new file with mode: 0644]
dcae-analytics/README.md [new file with mode: 0644]
dcae-analytics/checkstyle-suppressions.xml [new file with mode: 0644]
dcae-analytics/checkstyle.xml [new file with mode: 0644]
dcae-analytics/cpd-exclude.properties [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/pom.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsHttpConstants.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsModelConstants.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsProfile.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/DmaapMrConstants.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/TcaModelConstants.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/AlertAction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/AlertType.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/BaseCEFModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CEFModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CommonEventHeader.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Criticality.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Domain.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Event.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventListener.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventSeverity.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Field.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/InternalHeaderFields.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/MeasurementsForVfScalingFields.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/NamedArrayOfFields.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/PerformanceCounter.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Priority.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/ThresholdCrossingAlertFields.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/VNicPerformance.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/BaseDynamicPropertiesProvider.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/ConfigSource.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/DynamicPropertiesProvider.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/BaseConfigBindingServiceProperties.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConfigBindingServiceConstants.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConfigBindingServiceModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConsulConfigBindingServiceQueryResponse.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/ecomplogger/AnalyticsErrorType.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/ecomplogger/EcompLoggerModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/facade/AnalyticsFacadeModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/policy/AnalyticsPolicyModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/BiFunctionExtension.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/JsonStringToMapFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/JsonToJavaObjectBiFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/StringToURLFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/URLToHttpGetFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/AnalyticsModelJsonConversion.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/BaseObjectMapperSupplier.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/JsonMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertActionMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertTypeMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/BaseCEFModelMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CommonEventHeaderMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CriticalityMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/DomainMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventListenerMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventSeverityMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/FieldMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/InternalHeaderFieldsMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/MeasurementsForVfScalingFieldsMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/NamedArrayOfFieldsMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/PerformanceCounterMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/PriorityMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/ThresholdCrossingAlertFieldsMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/VNicUsageArrayMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/common/BaseDynamicPropertiesProviderMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/configbindingservice/ConsulConfigBindingServiceQueryResponseMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModule.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/ConfigBindingServiceModule.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/DynamicPropertiesModule.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/AnalyticsRequestIdSupplier.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/ConfigBindingServiceJsonSupplier.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/CreationTimestampSupplier.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/RandomIdSupplier.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/UnboundedSupplier.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/BaseAnalyticsModelTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertTypeMixinTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventListenerMixinTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/configbindingservice/ConsulConfigBindingServiceQueryResponseMixinTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/pom.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/exception/TcaProcessingException.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaProcessingContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaResultContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentService.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementEntity.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementRepository.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaProcessingContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaResultContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAaiEnrichmentFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAbatementCalculator.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAlertCreationFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculationFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculator.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaDomainFilter.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventListenerExtractor.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventNameFilter.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaThresholdViolationCalculator.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/BaseTcaCoreTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAaiEnrichmentContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAaiEnrichmentService.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementContext.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementEntity.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementRepository.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculatorTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/pom.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/TcaModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaAlert.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaFacadeModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/BaseTcaPolicyModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ClosedLoopEventStatus.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ControlLoopSchemaType.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Direction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicy.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicyModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Threshold.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionRequest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionResponse.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaRestApiModel.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaObjectMapperSupplier.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/AaiMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/BaseTcaPolicyModelMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ClosedLoopEventStatusMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ControlLoopSchemaTypeMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/DirectionMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/MetricsPerEventNameMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ThresholdMixin.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaFacadeModelModule.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaPolicyModule.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/BaseTcaModelTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixinTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/Dockerfile [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/docker/Dockerfile [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/docker/logback.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/pom.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppMain.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiEnrichmentContextImpl.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiEnrichmentServiceImpl.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiRestClientPreferences.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementContextImpl.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementEntity.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementRepository.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementContextImpl.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementEntity.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementRepository.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/ControllerConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/SwaggerConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaAaiConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMongoAbatementConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaSimpleAbatementConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaWebConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/controller/TcaRestController.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformer.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandler.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingService.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImpl.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/TcaUtils.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToAaiRestClientPrefsFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToMrPublisherPrefsFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToMrSubscriberPrefsFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/ConfigPropertiesAaiValidator.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaAppPropertiesValidator.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidator.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-mongo.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/bootstrap.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/BaseTcaWebSpringBootIT.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/config/TcaWebTestConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/pom.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsIT.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsSpringBootIT.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsUnitTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/config/application-dev.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/config/application-mongo.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/config/application.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/config/bootstrap.yaml [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vnf_enrichment.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vserver_enrichment.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vserver_resource_data.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_meesage_with_inapplicable_event_name.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message_with_abatement.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message_with_violation.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_messages.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_unescaped_messages.txt [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/config/tca_app_config.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/configservice/config_service_bindings.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/dmaap/dmaap_config.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/facade/tca_alert.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/policy/tca_policy.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/json/test/test_message.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy.properties [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy_from_json.properties [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vnf-enrichment.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vserver-enrichment.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vserver-resource-data.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-configservice-binding.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-configservice-tca.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-pubTopic.txt [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-subTopic-cg1-c0.txt [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-subTopic-cg1-c1.txt [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vnf-enrichment.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vserver-enrichment.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vserver-resource-data.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-configservice-binding.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-configservice-tca.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-pubTopic.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-subTopic-cg1-c0.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-subTopic-cg1-c1.json [new file with mode: 0644]
dcae-analytics/dcae-analytics-test/src/main/resources/logback-test.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/pom.xml [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/AnalyticsWebConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrPublisherPreferences.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingPreferences.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPreferences.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsParsingException.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsValidationException.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/BaseHttpClientPreferences.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/EelfAuditLogInterceptor.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/HttpClientPreferences.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/HttpClientPreferencesCustomizer.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/mongo/MongoProfileCondition.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/MongoAutoConfigurationPostProcessor.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/AnalyticsHttpUtils.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/AnalyticsWebUtils.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/ValidationUtils.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/function/MrSubscriberURLFunction.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/AnalyticsValidator.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/GenericValidationResponse.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/ValidationResponse.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/main/resources/META-INF/spring.factories [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/BaseAnalyticsWebSpringBootIT.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/BaseAnalyticsWebTest.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/DmaapMrFlowsIT.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/config/AnalyticsWebTestConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/config/DmaapMrTestConfig.java [new file with mode: 0644]
dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessorIT.java [new file with mode: 0644]
dcae-analytics/dpo/tca/commands [new file with mode: 0644]
dcae-analytics/dpo/tca/dmaap.json [new file with mode: 0644]
dcae-analytics/dpo/tca/tca_output.json [new file with mode: 0644]
dcae-analytics/dpo/tca/tca_spec.json [new file with mode: 0644]
dcae-analytics/findbugs-exclude.xml [new file with mode: 0644]
dcae-analytics/pmd-exclude.properties [new file with mode: 0644]
dcae-analytics/pom.xml [new file with mode: 0644]
dcae-analytics/version.properties [new file with mode: 0644]
eelf-logger/cpd-exclude.properties [new file with mode: 0644]
eelf-logger/eelf-logger-api/pom.xml [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/AppLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CodeLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CustomFieldsLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ErrorLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogLevelCategory.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MessageLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MiscLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/NagiosAlertLevel.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestIdLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestStatusCode.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestTimingLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ResponseLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ServiceLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/TargetServiceLogInfo.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/package-info.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/AuditLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/DebugLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogFactory.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogger.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLoggerContext.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/ErrorLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/MetricLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/package-info.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpAuditLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpDebugLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpEELFLogger.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpErrorLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpMetricLog.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/package-info.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AppLogSpec.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AuditLogSpec.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/DebugLogSpec.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/ErrorLogSpec.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/MetricLogSpec.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/OptionalLogSpec.java [new file with mode: 0644]
eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/package-info.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/pom.xml [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/EELFLoggerDefaults.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/filter/MarkerFilter.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/AuditLogLayout.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/ConsoleLayout.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/DebugLogLayout.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/ErrorLogLayout.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/MetricLogLayout.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/listener/LogbackStartupListener.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/AuditLogImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/DebugLogImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/EELFLoggerContextImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/EELFLoggerImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/ErrorLogImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/MetricLogImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/CompositePropertyResolver.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/EnvironmentPropertyResolver.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/PropertyResolver.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/SystemPropertyResolver.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/utils/LogUtils.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/resources/META-INF/services/org.onap.dcae.utils.eelf.logger.api.log.EELFLogger [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-async-appenders.xml [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-defaults.xml [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-logback.xml [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-optional-appenders.xml [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-required-appenders.xml [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/BaseLogbackUnitTest.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/AuditLogImplTest.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/DebugLogImplTest.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/ErrorLogImplTest.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/MetricLogImplTest.java [new file with mode: 0644]
eelf-logger/eelf-logger-logback-impl/src/test/resources/logback.xml [new file with mode: 0644]
eelf-logger/eelf-logger-model/pom.xml [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/AppLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/CodeLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/CustomFieldsLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ErrorLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/MessageLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/MiscLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/RequestIdLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/RequestTimingLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ResponseLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ServiceLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/TargetServiceLogInfoImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/package-info.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/AppLogSpecImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/AuditLogSpecImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/DebugLogSpecImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/ErrorLogSpecImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/MetricLogSpecImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/OptionalLogSpecImpl.java [new file with mode: 0644]
eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/package-info.java [new file with mode: 0644]
eelf-logger/findbugs-exclude.xml [new file with mode: 0644]
eelf-logger/pmd-exclude.properties [new file with mode: 0644]
eelf-logger/pom.xml [new file with mode: 0644]
eelf-logger/version.properties [new file with mode: 0644]
pom.xml [new file with mode: 0644]
version.properties [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..ff94b20
--- /dev/null
@@ -0,0 +1,51 @@
+*.class
+.*.swp
+.beamer
+# Package Files #
+*.jar
+*.war
+*.ear
+
+# Intellij Files & Dir #
+*.iml
+*.ipr
+*.iws
+atlassian-ide-plugin.xml
+out/
+.DS_Store
+./lib/
+.idea
+
+# Gradle Files & Dir #
+build/
+.gradle/
+.stickyStorage
+.build/
+target/
+
+# Node log
+npm-*.log
+logs/
+.nux_enabled
+.nux_dashboard
+
+# Singlenode and test data files.
+/templates/
+/artifacts/
+/data/
+/data-fabric-tests/data/
+
+# Checkstyle report
+examples/checkstyle_report.xml
+
+# Examples Stuff
+dependency-reduced-pom.xml
+
+# generated by docs build
+*.pyc
+
+#black duck scanner results
+*_bdio.jsonld
+blackDuckHubProjectName.txt
+blackDuckHubProjectVersionName.txt
+/bin/
diff --git a/.gitreview b/.gitreview
new file mode 100644 (file)
index 0000000..06d6626
--- /dev/null
@@ -0,0 +1,4 @@
+[gerrit]
+host=gerrit.onap.org
+port=29418
+project=dcaegen2/analytics/tca-gen2.git
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644 (file)
index 0000000..94444ff
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+* ===================================================================
+* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+* ===================================================================
+*
+* Unless otherwise specified, all software contained herein is licensed
+* under the Apache License, Version 2.0 (the "License");
+* you may not use this software except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*             http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+*
+* Unless otherwise specified, all documentation contained herein is licensed
+* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+* you may not use this documentation except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*             https://creativecommons.org/licenses/by/4.0/
+*
+* Unless required by applicable law or agreed to in writing, documentation
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
diff --git a/dcae-analytics/.gitignore b/dcae-analytics/.gitignore
new file mode 100644 (file)
index 0000000..c48bc19
--- /dev/null
@@ -0,0 +1,58 @@
+*.class
+.*.swp
+.beamer
+# Package Files #
+*.war
+*.ear
+
+# Intellij Files & Dir #
+*.iml
+*.ipr
+*.iws
+atlassian-ide-plugin.xml
+out/
+.DS_Store
+./lib/
+.idea
+
+# Gradle Files & Dir #
+build/
+.gradle/
+.stickyStorage
+.build/
+target/
+
+# Node log
+npm-*.log
+logs/
+.nux_enabled
+.nux_dashboard
+
+# Singlenode and test data files.
+/templates/
+/artifacts/
+/data/
+/data-fabric-tests/data/
+
+# Checkstyle report
+examples/checkstyle_report.xml
+
+# Examples Stuff
+dependency-reduced-pom.xml
+
+# generated by docs build
+*.pyc
+
+#black duck scanner results
+*_bdio.jsonld
+blackDuckHubProjectName.txt
+blackDuckHubProjectVersionName.txt
+
+#maven
+.mvn
+
+#memory dump
+*.hprof
+
+# application uploads
+/uploads/
diff --git a/dcae-analytics/.gitreview b/dcae-analytics/.gitreview
new file mode 100644 (file)
index 0000000..fbc3e1a
--- /dev/null
@@ -0,0 +1,4 @@
+[gerrit]
+host=gerrit.onap.org
+port=29418
+project=dcaegen2/analytics/tca-sa.git
diff --git a/dcae-analytics/LICENSE.txt b/dcae-analytics/LICENSE.txt
new file mode 100644 (file)
index 0000000..69d5fc1
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+* ============LICENSE_START==========================================
+* ===================================================================
+* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* ===================================================================
+*
+* Unless otherwise specified, all software contained herein is licensed
+* under the Apache License, Version 2.0 (the “License”);
+* you may not use this software except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*             http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+*
+* Unless otherwise specified, all documentation contained herein is licensed
+* under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+* you may not use this documentation except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*             https://creativecommons.org/licenses/by/4.0/
+*
+* Unless required by applicable law or agreed to in writing, documentation
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* ============LICENSE_END============================================
+*
+* ECOMP is a trademark and service mark of AT&T Intellectual Property.
+*
+*/
+
diff --git a/dcae-analytics/README.md b/dcae-analytics/README.md
new file mode 100644 (file)
index 0000000..bb91d21
--- /dev/null
@@ -0,0 +1,4 @@
+Repository DCAE Analytics Framework Platform
+---------------------------------------------
+
+Standalone DCAE Analytics without CDAP Dependencies
diff --git a/dcae-analytics/checkstyle-suppressions.xml b/dcae-analytics/checkstyle-suppressions.xml
new file mode 100644 (file)
index 0000000..c2c0006
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<!DOCTYPE suppressions PUBLIC
+        "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+        "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+
+<suppressions>
+
+    <suppress checks="Javadoc.*" files=".*[/\\]src[/\\]test[/\\]java[/\\].*"/>
+    <suppress checks="SummaryJavadoc" files=".*[/\\]src[/\\]test[/\\]java[/\\].*"/>
+    <suppress checks="Header" files=".*[/\\]src[/\\]test[/\\]java[/\\].*"/>
+
+    <suppress checks="JavadocPackage" files=".*[/\\]src[/\\](main|integration)[/\\]java[/\\].*"/>
+    <suppress checks="JavadocPackage" files=".*[/\\]src[/\\].*[/\\]internal[/\\].*"/>
+
+    <suppress checks="JavadocStyle" files=".*[/\\]src[/\\](main|integration)[/\\]java[/\\].*"/>
+    <suppress checks="JavadocStyle" files=".*[/\\]src[/\\].*[/\\]internal[/\\].*"/>
+
+    <suppress checks="RedundantModifier" files=".*[/\\]src[/\\]test[/\\]java[/\\].*"/>
+
+
+    <suppress checks=".*" files=".*[/\\]target[/\\]generated-sources[/\\]delombok[/\\].*"/>
+
+
+</suppressions>
diff --git a/dcae-analytics/checkstyle.xml b/dcae-analytics/checkstyle.xml
new file mode 100644 (file)
index 0000000..89cd940
--- /dev/null
@@ -0,0 +1,416 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<!DOCTYPE module PUBLIC
+        "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+        "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+
+<!-- This is a checkstyle configuration file. For descriptions of
+what the following rules do, please see the checkstyle configuration
+page at http://checkstyle.sourceforge.net/config.html -->
+
+<module name="Checker">
+
+
+    <!--
+
+     COPYRIGHT HEADER CHECKS
+
+    -->
+
+
+    <module name="FileTabCharacter">
+        <property name="severity" value="error"/>
+        <!-- Checks that there are no tab characters in the file. -->
+    </module>
+
+    <!--
+
+    LENGTH CHECKS FOR FILES
+
+    -->
+
+    <module name="FileLength">
+        <property name="max" value="3000"/>
+        <property name="severity" value="warning"/>
+    </module>
+
+
+    <module name="NewlineAtEndOfFile">
+        <property name="lineSeparator" value="lf"/>
+    </module>
+
+    <module name="RegexpSingleline">
+        <!-- Checks that FIXME is not used in comments.  TODO is preferred. -->
+        <property name="format" value="((//.*)|(\*.*))FIXME"/>
+        <property name="message"
+                  value='TODO is preferred to FIXME.  e.g. "TODO: (ENG-123) -  Refactor when v2 is released."'/>
+    </module>
+
+    <module name="RegexpSingleline">
+        <!-- Checks that TODOs are named with some basic formatting. Checks for the following pattern  TODO: (
+        -->
+        <property name="format" value="((//.*)|(\*.*))TODO[^: (]"/>
+        <property name="message"
+                  value='All TODOs should be named.  e.g. "TODO: (ENG-123) - Refactor when v2 is released."'/>
+    </module>
+
+    <module name="JavadocPackage">
+        <!-- Checks that each Java package has a Javadoc file used for commenting.
+          Only allows a package-info.java, not package.html. -->
+        <property name="severity" value="error"/>
+    </module>
+
+    <!-- All Java AST specific tests live under TreeWalker module. -->
+    <module name="TreeWalker">
+
+        <!-- required for SupressionCommentFilter and SuppressWithNearbyCommentFilter -->
+        <module name="FileContentsHolder"/>
+
+        <!--
+
+        IMPORT CHECKS
+
+        -->
+
+        <module name="AvoidStarImport">
+            <property name="allowClassImports" value="false"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="RedundantImport">
+            <!-- Checks for redundant import statements. -->
+            <property name="severity" value="error"/>
+        </module>
+
+        <!--
+        <module name="ImportOrder">
+            <property name="severity" value="error"/>
+            <property name="ordered" value="true"/>
+            <property name="option" value="bottom"/>
+            <property name="tokens" value="STATIC_IMPORT, IMPORT"/>
+        </module>
+        -->
+
+        <module name="IllegalImport">
+            <property name="illegalPkgs" value="junit.framework"/>
+        </module>
+
+        <!--
+
+        METHOD LENGTH CHECKS
+
+        -->
+
+        <module name="MethodLength">
+            <property name="tokens" value="METHOD_DEF"/>
+            <property name="max" value="300"/>
+            <property name="countEmpty" value="false"/>
+            <property name="severity" value="warning"/>
+        </module>
+
+        <!--
+
+        JAVADOC CHECKS
+
+        -->
+
+        <!-- Checks for Javadoc comments.                     -->
+        <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+        <module name="JavadocMethod">
+            <property name="scope" value="protected"/>
+            <property name="severity" value="error"/>
+            <property name="allowMissingJavadoc" value="true"/>
+            <property name="allowMissingParamTags" value="true"/>
+            <property name="allowMissingReturnTag" value="true"/>
+            <property name="allowMissingThrowsTags" value="true"/>
+            <property name="allowThrowsTagsForSubclasses" value="true"/>
+            <property name="allowUndeclaredRTE" value="true"/>
+        </module>
+
+        <module name="JavadocType">
+            <property name="scope" value="protected"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="JavadocStyle">
+            <property name="severity" value="error"/>
+        </module>
+
+        <!--
+
+        NAMING CHECKS
+
+        -->
+
+        <!-- Item 38 - Adhere to generally accepted naming conventions -->
+
+        <module name="PackageName">
+            <!-- Validates identifiers for package names against the
+              supplied expression. -->
+            <!-- Here the default checkstyle rule restricts package name parts to
+              seven characters, this is not in line with common practice at Google.
+            -->
+            <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,})*$"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="TypeNameCheck">
+            <!-- Validates static, final fields against the
+            expression "^[A-Z][a-zA-Z0-9]*$". -->
+            <metadata name="altname" value="TypeName"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="ConstantNameCheck">
+            <!-- Validates non-private, static, final fields against the supplied
+            public/package final fields "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$". -->
+            <metadata name="altname" value="ConstantName"/>
+            <property name="applyToPublic" value="true"/>
+            <property name="applyToProtected" value="true"/>
+            <property name="applyToPackage" value="true"/>
+            <property name="applyToPrivate" value="false"/>
+            <property name="format" value="^log(ger)?|([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|FLAG_.*)$"/>
+            <message key="name.invalidPattern"
+                     value="Variable ''{0}'' should be in ALL_CAPS (if it is a constant) or be private (otherwise)."/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="StaticVariableNameCheck">
+            <!-- Validates static, non-final fields against the supplied
+            expression "^[a-z][a-zA-Z0-9]*_?$". -->
+            <metadata name="altname" value="StaticVariableName"/>
+            <property name="applyToPublic" value="true"/>
+            <property name="applyToProtected" value="true"/>
+            <property name="applyToPackage" value="true"/>
+            <property name="applyToPrivate" value="true"/>
+            <property name="format" value="^[a-z][a-zA-Z0-9]*_?$"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="MemberNameCheck">
+            <!-- Validates non-static members against the supplied expression. -->
+            <metadata name="altname" value="MemberName"/>
+            <property name="applyToPublic" value="true"/>
+            <property name="applyToProtected" value="true"/>
+            <property name="applyToPackage" value="true"/>
+            <property name="applyToPrivate" value="true"/>
+            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="MethodNameCheck">
+            <!-- Validates identifiers for method names. -->
+            <metadata name="altname" value="MethodName"/>
+            <property name="format" value="^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="ParameterName">
+            <!-- Validates identifiers for method parameters against the
+              expression "^[a-z][a-zA-Z0-9]*$". -->
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="LocalFinalVariableName">
+            <!-- Validates identifiers for local final variables against the
+              expression "^[a-z][a-zA-Z0-9]*$". -->
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="LocalVariableName">
+            <!-- Validates identifiers for local variables against the
+              expression "^[a-z][a-zA-Z0-9]*$". -->
+            <property name="severity" value="error"/>
+        </module>
+
+
+        <!--
+
+        LENGTH and CODING CHECKS
+
+        -->
+
+        <module name="LineLength">
+            <!-- Checks if a line is too long. -->
+            <property name="max" value="120" default="120"/>
+            <property name="severity" value="error"/>
+
+            <!--
+              The default ignore pattern exempts the following elements:
+                - import statements
+                - long URLs inside comments
+            -->
+
+            <property name="ignorePattern"
+                      value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
+                      default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
+        </module>
+
+        <module name="LeftCurly">
+            <!-- Checks for placement of the left curly brace ('{'). -->
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="RightCurly">
+            <!-- Checks right curlies on CATCH, ELSE, and TRY blocks are on
+            the same line. e.g., the following example is fine:
+            <pre>
+              if {
+                ...
+              } else
+            </pre>
+            -->
+            <!-- This next example is not fine:
+            <pre>
+              if {
+                ...
+              }
+              else
+            </pre>
+            -->
+            <property name="option" value="same"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <!-- Checks for braces around if and else blocks -->
+        <module name="NeedBraces">
+            <property name="severity" value="error"/>
+            <property name="tokens" value="LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO"/>
+        </module>
+
+        <module name="UpperEll">
+            <!-- Checks that long constants are defined with an upper ell.-->
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="FallThrough">
+            <!-- Warn about falling through to the next case statement.  Similar to
+            javac -Xlint:fallthrough, but the check is suppressed if a single-line comment
+            on the last non-blank line preceding the fallen-into case contains 'fall through' (or
+            some other variants which we don't publicized to promote consistency).
+            -->
+            <property name="reliefPattern"
+                      value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
+            <property name="severity" value="error"/>
+        </module>
+
+
+        <!--
+
+        MODIFIERS CHECKS
+
+        -->
+
+        <module name="ModifierOrder">
+            <!-- Warn if modifier order is inconsistent with JLS3 8.1.1, 8.3.1, and
+                 8.4.3.  The prescribed order is:
+                 public, protected, private, abstract, static, final, transient, volatile,
+                 synchronized, native, strictfp
+              -->
+        </module>
+
+        <module name="RedundantModifier">
+            <!-- Checks for redundant modifiers in:
+                 - interface and annotation definitions,
+                 - the final modifier on methods of final classes, and
+                 - inner interface declarations that are declared as static.
+              -->
+        </module>
+
+
+        <!--
+
+        WHITESPACE CHECKS
+
+        -->
+        <module name="GenericWhitespace"/>
+
+        <module name="WhitespaceAround">
+            <!-- Checks that various tokens are surrounded by whitespace.
+                 This includes most binary operators and keywords followed
+                 by regular or curly braces.
+            -->
+            <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
+        BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN,
+        EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
+        LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
+        LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS,
+        MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION,
+        SL, SLIST, SL_ASSIGN, SR_ASSIGN, STAR, STAR_ASSIGN"/>
+            <property name="allowEmptyConstructors" value="true"/>
+            <property name="allowEmptyMethods" value="true"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="WhitespaceAfter">
+            <!-- Checks that commas, semicolons and typecasts are followed by
+                 whitespace.
+            -->
+            <property name="tokens" value="COMMA, SEMI, TYPECAST"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="NoWhitespaceAfter">
+            <!-- Checks that there is no whitespace after various unary operators.
+                 Linebreaks are allowed.
+            -->
+            <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS,
+        UNARY_PLUS"/>
+            <property name="allowLineBreaks" value="true"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="NoWhitespaceBefore">
+            <!-- Checks that there is no whitespace before various unary operators.
+                 Linebreaks are allowed.
+            -->
+            <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
+            <property name="allowLineBreaks" value="true"/>
+            <property name="severity" value="error"/>
+        </module>
+
+        <module name="ParenPad">
+            <!-- Checks that there is no whitespace before close parens or after
+                 open parens.
+            -->
+            <property name="severity" value="error"/>
+        </module>
+
+    </module>
+
+    <!--
+      Optional suppression filter. It is optional because when running with Maven, it should be the
+       checkstyle plugin who provides it. It is only used when this file is used in IntelliJ.
+      -->
+    <module name="SuppressionFilter">
+        <property name="file" value="suppressions.xml"/>
+        <property name="optional" value="true"/>
+    </module>
+
+    <module name="SuppressionCommentFilter">
+        <property name="offCommentFormat" value="CHECKSTYLE OFF: (.+)"/>
+        <property name="onCommentFormat" value="CHECKSTYLE ON"/>
+        <property name="checkFormat" value="Javadoc.*"/>
+        <property name="messageFormat" value="$1"/>
+    </module>
+
+</module>
diff --git a/dcae-analytics/cpd-exclude.properties b/dcae-analytics/cpd-exclude.properties
new file mode 100644 (file)
index 0000000..88e72e8
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
diff --git a/dcae-analytics/dcae-analytics-model/pom.xml b/dcae-analytics/dcae-analytics-model/pom.xml
new file mode 100644 (file)
index 0000000..4b806ae
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.dcaegen2.analytics</groupId>
+        <artifactId>dcae-analytics</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dcae-analytics-model</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- THIS MODULE CONTAINS MODELS COMMON FOR ALL DCAE ANALYTICS MODULES.
+     NOTE: THIS MODULE MUST NOT DEPEND ON ANY OTHER ANALYTICS MODULE IN COMPILE SCOPE. -->
+    <name>DCAE Analytics Model</name>
+    <description>Contains models (e.g. Common Event Format) which are common to DCAE Analytics</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+    </properties>
+
+    <dependencies>
+
+        <!-- LOGGING API -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <!-- JSON SERIALIZATION/DESERIALIZATION LIBRARY -->
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+
+        <!-- JSON PATH -->
+        <dependency>
+            <groupId>com.jayway.jsonpath</groupId>
+            <artifactId>json-path</artifactId>
+        </dependency>
+
+        <!-- CODE GENERATION -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- TEST DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-test</artifactId>
+        </dependency>
+
+    </dependencies>
+
+</project>
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsHttpConstants.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsHttpConstants.java
new file mode 100644 (file)
index 0000000..421e158
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model;
+
+/**
+ * Captures various standard Analytics HTTP Request Headers
+ *
+ * @author Rajiv Singla
+ */
+public abstract class AnalyticsHttpConstants {
+
+    public static final String REQUEST_ID_HEADER_KEY = "X-ECOMP-RequestID";
+    public static final String REQUEST_TRANSACTION_ID_HEADER_KEY = "X-ECOMP-TransactionID";
+    public static final String REQUEST_APP_NAME_HEADER_KEY = "X-ECOMP-FromAppID";
+    public static final String REQUEST_BEGIN_TS_HEADER_KEY = "X-Begin-Timestamp";
+    public static final String REQUEST_END_TS_HEADER_KEY = "X-End-Timestamp";
+
+    public static final String REQUEST_APP_NAME_HEADER_DEFAULT_VALUE = "DCAE-Analytics";
+
+    // DEFAULT HTTP CLIENT ID
+    public static final String DEFAULT_HTTP_CLIENT_ID_PREFIX = "DCAE-Analytics-Client-";
+
+    public static final String HTTP_STATUS_CODE_HEADER_KEY = "http_statusCode";
+
+    private AnalyticsHttpConstants() {
+        // private constructor
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsModel.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsModel.java
new file mode 100644 (file)
index 0000000..bb13ed6
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model;
+
+import java.io.Serializable;
+
+/**
+ * Marker Interface for all DCAE Analytics Model implementations
+ *
+ * @author Rajiv Singla
+ */
+public interface AnalyticsModel extends Serializable {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsModelConstants.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsModelConstants.java
new file mode 100644 (file)
index 0000000..30fb5f7
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model;
+
+/**
+ * Contains constants for DCAE Analytics Model Module
+ *
+ * @author Rajiv Singla
+ */
+public abstract class AnalyticsModelConstants {
+
+    public static final String JSON_MODULE_GROUP_ID = "org.onap.dcae.analytics.model";
+    public static final String JSON_MODULE_ARTIFACT_ID = "dcae-analytics-model";
+
+    // ========================= UTILITIES =======================================//
+    // DATE CONSTANTS
+    public static final String ANALYTICS_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+    // RANDOM ID
+    public static final Integer DEFAULT_RANDOM_ID_LENGTH = 5;
+    // UTF-8 CHARSET NAME
+    public static final String UTF8_CHARSET_NAME = "UTF-8";
+    // REQUEST ID DELIMITER
+    public static final String ANALYTICS_REQUEST_ID_DELIMITER = ":";
+
+    private AnalyticsModelConstants() {
+        // private constructor
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsProfile.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/AnalyticsProfile.java
new file mode 100644 (file)
index 0000000..c7f2872
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model;
+
+/**
+ * Analytics Profiles
+ *
+ * @author Rajiv Singla
+ */
+public abstract class AnalyticsProfile {
+
+    public static final String NEGATION_PREFIX = "!";
+
+    public static final String DEV_PROFILE_NAME = "dev";
+    public static final String NOT_DEV_PROFILE_NAME = NEGATION_PREFIX + DEV_PROFILE_NAME;
+    public static final String CONFIG_BINDING_SERVICE_PROFILE_NAME = "configBindingService";
+    public static final String NOT_CONFIG_BINDING_SERVICE_PROFILE_NAME =
+            NEGATION_PREFIX + CONFIG_BINDING_SERVICE_PROFILE_NAME;
+    public static final String DMAAP_PROFILE_NAME = "dmaap";
+    public static final String NOT_DMAAP_PROFILE_NAME = NEGATION_PREFIX + DMAAP_PROFILE_NAME;
+    public static final String REDIS_PROFILE_NAME = "redis";
+    public static final String NOT_REDIS_PROFILE_NAME = NEGATION_PREFIX + REDIS_PROFILE_NAME;
+    public static final String MONGO_PROFILE_NAME = "mongo";
+    public static final String NOT_MONGO_PROFILE_NAME = NEGATION_PREFIX + MONGO_PROFILE_NAME;
+
+    private AnalyticsProfile() {
+        // private constructor
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/DmaapMrConstants.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/DmaapMrConstants.java
new file mode 100644 (file)
index 0000000..1171f44
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class DmaapMrConstants {
+
+    // ================== DMaaP MR CONSTANTS ============================== //
+
+    public static final Set<String> DMAAP_MAPPED_HEADERS = Stream.of(
+            AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY,
+            AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY,
+            AnalyticsHttpConstants.REQUEST_BEGIN_TS_HEADER_KEY,
+            AnalyticsHttpConstants.REQUEST_END_TS_HEADER_KEY).collect(Collectors.toSet());
+
+
+    // MR SUBSCRIBER
+    public static final String SUBSCRIBER_EMPTY_MESSAGE_RESPONSE_STRING = "[]";
+    public static final String SUBSCRIBER_RANDOM_CONSUMER_GROUP_PREFIX = "DCAE-SUB-";
+    public static final String SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME = "timeout";
+    public static final Integer SUBSCRIBER_DEFAULT_TIMEOUT = -1;
+    public static final Integer SUBSCRIBER_DEFAULT_FIXED_POLLING_INTERVAL = 30_000;
+    public static final String SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME = "limit";
+    public static final Integer SUBSCRIBER_DEFAULT_MESSAGE_LIMIT = 50_000;
+    public static final Integer SUBSCRIBER_DEFAULT_PROCESSING_BATCH_SIZE = 10_000;
+
+
+    // =================== INTEGRATION DEFAULTS =========================== //
+
+    // RETRY ON FAILURE
+    public static final Integer DEFAULT_NUM_OF_RETRIES_ON_FAILURE = 5;
+    public static final Integer DEFAULT_RETRY_INITIAL_INTERVAL = 1_000;
+    public static final Integer DEFAULT_RETRY_MULTIPLIER = 5;
+    public static final Integer DEFAULT_RETRY_MAX_INTERVAL = 300_000;
+
+    public static final String DMAAP_MR_SUBSCRIBER_OUTPUT_CHANNEL_NAME = "mrSubscriberOutputChannel";
+    public static final String DMAAP_MR_PUBLISHER_INPUT_CHANNEL = "mrPublisherInputChannel";
+    public static final String DMAAP_MR_PUBLISHER_OUTPUT_CHANNEL = "mrPublisherOutputChannel";
+
+    // MESSAGE STORE NAMES
+    public static final String DMAAP_MR_SUBSCRIBER_OUTPUT_MESSAGE_STORE_GROUP_ID = "mrSubscriberMessageStoreGroup";
+    public static final String DMAAP_MR_PUBLISHER_RECOVERY_MESSAGE_STORE_GROUP_ID = "mrPublisherRecoveryStoreGroup";
+
+    public DmaapMrConstants() {
+        // private constructor
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/TcaModelConstants.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/TcaModelConstants.java
new file mode 100644 (file)
index 0000000..dbe0846
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model;
+
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class TcaModelConstants {
+
+    // =================== TCA CONSTANTS =========================== //
+
+    // TCA Alert - VNF Constants
+    public static final String TCA_ALERT_VNF_TARGET_TYPE = "VNF";
+    public static final String AAI_VNF_KEY_PREFIX = "generic-vnf.";
+    public static final String TCA_ALERT_VNF_TARGET = AAI_VNF_KEY_PREFIX + "vnf-name";
+    // TCA Alert - VM Constants
+    public static final String TCA_ALERT_VM_TARGET_TYPE = "VM";
+    public static final String AAI_VSERVER_KEY_PREFIX = "vserver.";
+    public static final String TCA_ALERT_VM_TARGET = AAI_VSERVER_KEY_PREFIX + "vserver-name";
+    // VNF & VM - Common Constants
+    public static final String TCA_VES_RESPONSE_FROM = "DCAE";
+    public static final String TCA_SERVICE_NAME =
+            ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE != null ?
+                    ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE : "DCAE-TCA";
+
+
+    // ================= PERSISTENCE CONSTANTS ================== //
+    public static final String TCA_ROW_KEY_DELIMITER = ":";
+
+
+    // ======================= DEFAULTS ====================== //
+    public static final boolean DEFAULT_AAI_ENRICHMENT_ENABLED = false;
+    public static final boolean DEFAULT_ABATEMENT_ENABLED = true;
+    public static final boolean DEFAULT_ECOMP_LOGGING_ENABLED = true;
+    public static final Integer DEFAULT_TCA_PROCESSING_BATCH_SIZE = 10_000;
+
+    public static final boolean DEFAULT_TCA_AAI_IGNORE_SSL_VALIDATION = false;
+    public static final String DEFAULT_TCA_AAI_GENERIC_VNF_PATH = "aai/v11/network/generic-vnfs/generic-vnf";
+    public static final String DEFAULT_TCA_AAI_NODE_QUERY_PATH = "aai/v11/search/nodes-query";
+
+    public static final int TCA_ABATEMENT_SIMPLE_REPOSITORY_MAX_ENTITY_COUNT = 100_000;
+    public static final int TCA_ABATEMENT_SIMPLE_REPOSITORY_REMOVE_ENTITY_COUNT = 1_000;
+
+
+    //====================== REST API ===================== //
+    public static final String TCA_REST_API_PREFIX = "/api/v1/tca/";
+    public static final String TCA_POLICY_ENDPOINT = "policy";
+    public static final String TCA_EXECUTION_ENDPOINT = "execute";
+    public static final String TCA_POLICY_SOURCE_HEADER_KEY = "X-TCA-POLICY-SOURCE";
+    public static final String TCA_POLICY_CREATION_HEADER_KEY = "X-TCA-POLICY-CREATION-TIME";
+    public static final String TCA_POLICY_VERSION_HEADER_KEY = "X-TCA-POLICY-VERSION";
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/AlertAction.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/AlertAction.java
new file mode 100644 (file)
index 0000000..65483f2
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+/**
+ * Common Event Format Alert Action
+ *
+ * @author Rajiv Singla
+ */
+public enum AlertAction implements CEFModel {
+
+    CLEAR, CONT, SET
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/AlertType.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/AlertType.java
new file mode 100644 (file)
index 0000000..9b34809
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+/**
+ * CEF Alert Type
+ *
+ * @author Rajiv Singla
+ */
+public enum AlertType implements CEFModel {
+
+    CARD_ANOMALY("CARD-ANOMALY"),
+    ELEMENT_ANOMALY("ELEMENT-ANOMALY"),
+    INTERFACE_ANOMALY("INTERFACE-ANOMALY"),
+    SERVICE_ANOMALY("SERVICE-ANOMALY"),
+    UNKNOWN(null);
+
+    private final String name;
+
+    AlertType(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/BaseCEFModel.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/BaseCEFModel.java
new file mode 100644 (file)
index 0000000..da90fd0
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider;
+
+/**
+ * Base CEF Model should be extended by all CEF Model Entities.
+ * By extending CEF Model all the additional dynamic Properties
+ * can be accumulated in a map.
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public abstract class BaseCEFModel extends BaseDynamicPropertiesProvider implements CEFModel {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CEFModel.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CEFModel.java
new file mode 100644 (file)
index 0000000..8f894c7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import org.onap.dcae.analytics.model.AnalyticsModel;
+
+/**
+ * Marker interface for all DCAE Analytics Common Event Format Model implementations
+ *
+ * @author Rajiv Singla
+ */
+public interface CEFModel extends AnalyticsModel {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CommonEventHeader.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CommonEventHeader.java
new file mode 100644 (file)
index 0000000..3398b51
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Fields common to all Events
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class CommonEventHeader extends BaseCEFModel {
+
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * The eventing domain associated with this event
+     */
+    private Domain domain;
+
+    /**
+     * Event key that is unique to the event source
+     */
+    private String eventId;
+
+    /**
+     * Unique event name
+     */
+    private String eventName;
+
+
+    /**
+     * Event type e.g. applicationVnf, guestOS, hostOS, platform
+     */
+    private String eventType;
+
+
+    /**
+     * Enrichment fields for internal VES Event Listener service use only, not supplied by event sources
+     */
+    private InternalHeaderFields internalHeaderFields;
+
+
+    /**
+     * The latest unix time aka epoch time associated with the event from any component--as microseconds elapsed since
+     * 1 Jan 1970 not including leap seconds
+     */
+    private Long lastEpochMicrosec;
+
+
+    /**
+     * Three character network function component type as aligned with vfc naming standards
+     */
+    private String nfcNamingCode;
+
+
+    /**
+     * Four character network function type as aligned with vnf naming standards
+     */
+    private String nfNamingCode;
+
+
+    /**
+     * Processing Priority
+     */
+    private Priority priority;
+
+
+    /**
+     * UUID identifying the entity reporting the event, for example an OAM VM; must be populated by the
+     * enrichment process
+     */
+    private String reportingEntityId;
+
+
+    /**
+     * Name of the entity reporting the event, for example, an EMS name; may be the same as sourceName
+     */
+    private String reportingEntityName;
+
+
+    /**
+     * Ordering of events communicated by an event source instance or 0 if not needed
+     */
+    private Integer sequence;
+
+
+    /**
+     * UUID identifying the entity experiencing the event issue; must be populated by the enrichment process
+     */
+    private String sourceId;
+
+
+    /**
+     * Name of the entity experiencing the event issue
+     */
+    private String sourceName;
+
+
+    /**
+     * the earliest unix time aka epoch time associated with the event from any component--as microseconds elapsed
+     * since 1 Jan 1970 not including leap seconds
+     */
+    private Long startEpochMicrosec;
+
+
+    /**
+     * Version of the event header
+     */
+    private Float version;
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Criticality.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Criticality.java
new file mode 100644 (file)
index 0000000..d8f0875
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+/**
+ * Performance Criticality
+ *
+ * @author Rajiv Singla
+ */
+public enum Criticality implements CEFModel {
+
+    CRIT, MAJ, UNKNOWN
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Domain.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Domain.java
new file mode 100644 (file)
index 0000000..2be00dc
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+/**
+ * Eventing domain associated with the event
+ *
+ * @author Rajiv Singla
+ */
+public enum Domain implements CEFModel {
+
+    fault,
+    heartbeat,
+    measurementsForVfScaling,
+    mobileFlow,
+    other,
+    sipSignaling,
+    stateChange,
+    syslog,
+    thresholdCrossingAlert,
+    voiceQuality;
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Event.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Event.java
new file mode 100644 (file)
index 0000000..aee213c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Generic Event Format
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class Event extends BaseCEFModel {
+
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Fields common to all Events
+     */
+    private CommonEventHeader commonEventHeader;
+
+    /**
+     * Measurements for Vf scaling fields
+     */
+    private MeasurementsForVfScalingFields measurementsForVfScalingFields;
+
+    /**
+     * Threshold crossing alert Fields.
+     */
+    private ThresholdCrossingAlertFields thresholdCrossingAlertFields;
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventListener.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventListener.java
new file mode 100644 (file)
index 0000000..50bf3d1
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Common Event Format - Base Event Listener
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class EventListener extends BaseCEFModel {
+
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Common Event Format - Event
+     */
+    private Event event;
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventSeverity.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventSeverity.java
new file mode 100644 (file)
index 0000000..da699b8
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+/**
+ * CEF Event severity or priority
+ * <p>
+ * <b>NOTE: Event Severity Enum order must not be changed. Events severity is ordered from high to low</b>
+ *
+ * @author Rajiv Singla
+ */
+public enum EventSeverity implements CEFModel {
+
+    CRITICAL,
+    MAJOR,
+    MINOR,
+    WARNING,
+    NORMAL
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Field.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Field.java
new file mode 100644 (file)
index 0000000..070d695
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Name Value Pair
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class Field extends BaseCEFModel {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Name of the Field
+     */
+    private String name;
+
+    /**
+     * Value of the Field
+     */
+    private String value;
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/InternalHeaderFields.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/InternalHeaderFields.java
new file mode 100644 (file)
index 0000000..f886052
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Enrichment fields for internal VES Event Listener service use only, not supplied by event sources
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class InternalHeaderFields extends BaseCEFModel {
+
+    private static final long serialVersionUID = 1L;
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/MeasurementsForVfScalingFields.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/MeasurementsForVfScalingFields.java
new file mode 100644 (file)
index 0000000..ce92132
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * Common Event Format - MeasurementsForVfScaling fields
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class MeasurementsForVfScalingFields extends BaseCEFModel {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Additional name-value-pair fields
+     */
+    private List<Field> additionalFields;
+
+
+    /**
+     * Array of named name-value-pair arrays for additional Measurements
+     */
+    private List<NamedArrayOfFields> additionalMeasurements;
+
+    /**
+     * Interval over which measurements are being reported in seconds
+     */
+    private Long measurementInterval;
+
+    /**
+     * Version of the measurementsForVfScaling block
+     */
+    private Float measurementsForVfScalingVersion;
+
+    /**
+     * Usage of an array of virtual network interface cards
+     */
+    private List<VNicPerformance> vNicPerformanceArray;
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/NamedArrayOfFields.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/NamedArrayOfFields.java
new file mode 100644 (file)
index 0000000..b7a9530
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * An array of name value pairs along with a name for the array
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class NamedArrayOfFields extends BaseCEFModel {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Name of the NamedArrayOfFields
+     */
+    private String name;
+
+    /**
+     * Array of name value pairs
+     */
+    private List<Field> arrayOfFields;
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/PerformanceCounter.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/PerformanceCounter.java
new file mode 100644 (file)
index 0000000..8c5fa8c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Common Event Format - Performance PerformanceCounter
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class PerformanceCounter extends BaseCEFModel {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Performance Counter Criticality.
+     */
+    private Criticality criticality;
+
+    /**
+     * Performance Counter Name
+     */
+    private String name;
+
+    /**
+     * Performance Counter for Threshold Crossed.
+     */
+    private String thresholdCrossed;
+
+    /**
+     * Performance Counter Value.
+     */
+    private String value;
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Priority.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Priority.java
new file mode 100644 (file)
index 0000000..066af2a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+/**
+ * Common Event Format - Event processing priority
+ *
+ * @author Rajiv Singla
+ */
+public enum Priority implements CEFModel {
+
+    High,
+    Medium,
+    Normal,
+    Low
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/ThresholdCrossingAlertFields.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/ThresholdCrossingAlertFields.java
new file mode 100644 (file)
index 0000000..625f5f6
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * Common Event Format - Fields Specific to threshold crossing alert events
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ThresholdCrossingAlertFields extends BaseCEFModel {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Additional Performance counters parameters.
+     */
+    private List<PerformanceCounter> additionalParameters;
+
+    /**
+     * Event alert action
+     */
+    private AlertAction alertAction;
+
+    /**
+     * Unique short alert description such as IF-SHUB-ERRDROP
+     */
+    private String alertDescription;
+
+    /**
+     * Alert type
+     */
+    private AlertType alertType;
+
+    /**
+     * Calculated API value (if applicable)
+     */
+    private String alertValue;
+
+    /**
+     * List of eventIds associated with the event being reported
+     */
+    private List<String> associatedAlertIdList;
+
+    /**
+     * Time when the performance collector picked up the data; with RFC 2822 compliant format:
+     * ‘Sat, 13 Mar 2010 11:29:05 -0800’
+     */
+    private String collectionTimestamp;
+
+    /**
+     * Specific performance collector instance used
+     */
+    private String dataCollector;
+
+    /**
+     * Type of network element
+     */
+    private String elementType;
+
+    /**
+     * Event severity or priority
+     */
+    private EventSeverity eventSeverity;
+
+    /**
+     * Time closest to when the measurement was made; with RFC 2822 compliant format: ‘Sat, 13 Mar 2010 11:29:05 -0800’
+     */
+    private String eventStartTimestamp;
+
+    /**
+     * Physical or logical port or card (if applicable)
+     */
+    private String interfaceName;
+
+    /**
+     * Network name
+     */
+    private String networkService;
+
+    /**
+     * Possible Root Cause (reserved for future use)
+     */
+    private String possibleRootCause;
+
+    /**
+     * Version of the thresholdCrossingAlertFields block
+     */
+    private Integer thresholdCrossingFieldsVersion;
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/VNicPerformance.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/VNicPerformance.java
new file mode 100644 (file)
index 0000000..d2c774b
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.cef;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Describes the performance and errors of an identified virtual network interface card
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class VNicPerformance extends BaseCEFModel {
+
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Cumulative count of broadcast packets received as read at the end of the measurement interval
+     */
+    private Long receivedBroadcastPacketsAccumulated;
+
+    /**
+     * Count of broadcast packets received within the measurement interval
+     */
+    private Long receivedBroadcastPacketsDelta;
+
+    /**
+     * Cumulative count of discarded packets received as read at the end of the measurement interval
+     */
+    private Long receivedDiscardedPacketsAccumulated;
+
+    /**
+     * Count of discarded packets received within the measurement interval
+     */
+    private Long receivedDiscardedPacketsDelta;
+
+    /**
+     * Cumulative count of error packets received as read at the end of the measurement interval
+     */
+    private Long receivedErrorPacketsAccumulated;
+
+    /**
+     * Count of error packets received within the measurement interval
+     */
+    private Long receivedErrorPacketsDelta;
+
+    /**
+     * Cumulative count of multicast packets received as read at the end of the measurement interval
+     */
+    private Long receivedMulticastPacketsAccumulated;
+
+    /**
+     * Count of multicast packets received within the measurement interval
+     */
+    private Long receivedMulticastPacketsDelta;
+
+    /**
+     * Cumulative count of octets received as read at the end of the measurement interval
+     */
+    private Long receivedOctetsAccumulated;
+
+    /**
+     * Count of octets received within the measurement interval
+     */
+    private Long receivedOctetsDelta;
+
+    /**
+     * Cumulative count of all packets received as read at the end of the measurement interval
+     */
+    private Long receivedTotalPacketsAccumulated;
+
+    /**
+     * Count of all packets received within the measurement interval
+     */
+    private Long receivedTotalPacketsDelta;
+
+    /**
+     * Cumulative count of unicast packets received as read at the end of the measurement interval
+     */
+    private Long receivedUnicastPacketsAccumulated;
+
+    /**
+     * Count of unicast packets received within the measurement interval
+     */
+    private Long receivedUnicastPacketsDelta;
+
+    /**
+     * Cumulative count of broadcast packets transmitted as read at the end of the measurement interval
+     */
+    private Long transmittedBroadcastPacketsAccumulated;
+
+    /**
+     * Count of broadcast packets transmitted within the measurement interval
+     */
+    private Long transmittedBroadcastPacketsDelta;
+
+    /**
+     * Cumulative count of discarded packets transmitted as read at the end of the measurement interval
+     */
+    private Long transmittedDiscardedPacketsAccumulated;
+
+    /**
+     * Count of discarded packets transmitted within the measurement interval
+     */
+    private Long transmittedDiscardedPacketsDelta;
+
+    /**
+     * Cumulative count of error packets transmitted as read at the end of the measurement interval
+     */
+    private Long transmittedErrorPacketsAccumulated;
+
+    /**
+     * Count of error packets transmitted within the measurement interval
+     */
+    private Long transmittedErrorPacketsDelta;
+
+    /**
+     * Cumulative count of multicast packets transmitted as read at the end of the measurement interval
+     */
+    private Long transmittedMulticastPacketsAccumulated;
+
+    /**
+     * Count of multicast packets transmitted within the measurement interval
+     */
+    private Long transmittedMulticastPacketsDelta;
+
+    /**
+     * Cumulative count of octets transmitted as read at the end of the measurement interval
+     */
+    private Long transmittedOctetsAccumulated;
+
+    /**
+     * Count of octets transmitted within the measurement interval
+     */
+    private Long transmittedOctetsDelta;
+
+    /**
+     * Cumulative count of all packets transmitted as read at the end of the measurement interval
+     */
+    private Long transmittedTotalPacketsAccumulated;
+
+    /**
+     * Count of all packets transmitted within the measurement interval
+     */
+    private Long transmittedTotalPacketsDelta;
+
+    /**
+     * Cumulative count of unicast packets transmitted as read at the end of the measurement interval
+     */
+    private Long transmittedUnicastPacketsAccumulated;
+
+
+    /**
+     * Count of unicast packets transmitted within the measurement interval
+     */
+    private Long transmittedUnicastPacketsDelta;
+
+
+    /**
+     * Indicates whether vNicPerformance values are likely inaccurate due to counter overflow or other conditions
+     */
+    private Boolean valuesAreSuspect;
+
+
+    /**
+     * Virtual Network Card Identifier
+     */
+    private String vNicIdentifier;
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/BaseDynamicPropertiesProvider.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/BaseDynamicPropertiesProvider.java
new file mode 100644 (file)
index 0000000..8a3f3e4
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.common;
+
+import lombok.Data;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Base Dynamic Provider provide functionality so that all the
+ * additional dynamic Properties can be accumulated in a map.
+ *
+ * @author Rajiv Singla
+ */
+@Data
+public abstract class BaseDynamicPropertiesProvider implements DynamicPropertiesProvider {
+
+    /**
+     * All non-required properties should be captured in additional properties
+     */
+    private Map<String, Object> dynamicProperties = new LinkedHashMap<>();
+
+
+    /**
+     * Add a dynamic property to Common Event Format Entity
+     *
+     * @param propertyName property name
+     * @param propertyValue property value
+     */
+    @Override
+    public void addDynamicProperties(String propertyName, Object propertyValue) {
+        dynamicProperties.put(propertyName, propertyValue);
+    }
+
+    /**
+     * Determines if dynamic properties are present for the CEF Entity
+     *
+     * @return return true if Dynamic Properties are present
+     */
+    public boolean isDynamicPropertiesPresent() {
+        return dynamicProperties.size() == 0;
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/ConfigSource.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/ConfigSource.java
new file mode 100644 (file)
index 0000000..0829f93
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.common;
+
+import org.onap.dcae.analytics.model.AnalyticsModel;
+
+/**
+ * @author Rajiv Singla
+ */
+public enum ConfigSource implements AnalyticsModel {
+
+    CONFIG_BINDING_SERVICE,
+    CLASSPATH,
+    REST_API,
+    REDIS,
+    MONGO;
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/DynamicPropertiesProvider.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/common/DynamicPropertiesProvider.java
new file mode 100644 (file)
index 0000000..ac51656
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.common;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * This contract allows the deserialization mechanism to catch dynamic properties
+ * in a Map so that deserialization mechanism will not loose any information and
+ * can be serialized back everything without any loss in information
+ *
+ * @author Rajiv Singla
+ */
+public interface DynamicPropertiesProvider extends Serializable {
+
+
+    /**
+     * Adds dynamic properties in a Map object
+     *
+     * @param propertyName property name
+     * @param propertyValue property value
+     */
+    void addDynamicProperties(String propertyName, Object propertyValue);
+
+    /**
+     * Provides dynamic properties map
+     *
+     * @return dynamic properties map object
+     */
+    Map<String, Object> getDynamicProperties();
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/BaseConfigBindingServiceProperties.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/BaseConfigBindingServiceProperties.java
new file mode 100644 (file)
index 0000000..7158b2e
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.configbindingservice;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Base call for Controller Config Binding Service Properties. Other analytics components
+ * must extend this base class and add properties specific to their requirements
+ * <p>NOTE: The base class supports all standard config binding service properties and additional custom properties</p>
+ *
+ * @author Rajiv Singla
+ */
+@Data
+public abstract class BaseConfigBindingServiceProperties implements ConfigBindingServiceModel {
+
+    private static final long serialVersionUID = 1L;
+
+    protected Map<String, List<String>> servicesCalls = new LinkedHashMap<>();
+    protected Map<String, PublisherDetails> streamsPublishes = new LinkedHashMap<>();
+    protected Map<String, SubscriberDetails> streamsSubscribes = new LinkedHashMap<>();
+
+    /**
+     * Publisher and Subscriber common properties
+     */
+    @Data
+    @ToString(exclude = "aafPassword")
+    public static class PubSubCommonDetails implements ConfigBindingServiceModel {
+
+        private static final long serialVersionUID = 1L;
+
+        private String type;
+        private String aafUsername;
+        private String aafPassword;
+        private DmaapInfo dmaapInfo;
+
+        // custom additional properties
+        private String proxyUrl;
+        private Boolean ignoreSSLValidation;
+
+    }
+
+    /**
+     * Publisher Details
+     */
+    @Getter
+    @Setter
+    @RequiredArgsConstructor
+    @ToString(callSuper = true)
+    @EqualsAndHashCode(callSuper = true)
+    public static class PublisherDetails extends PubSubCommonDetails {
+
+        private static final long serialVersionUID = 1L;
+
+    }
+
+
+    /**
+     * Subscriber Details
+     */
+    @Getter
+    @Setter
+    @RequiredArgsConstructor
+    @ToString(callSuper = true)
+    @EqualsAndHashCode(callSuper = true)
+    public static class SubscriberDetails extends PubSubCommonDetails {
+
+        private static final long serialVersionUID = 1L;
+
+        // custom subscriber properties
+        private String consumerGroup;
+        private List<String> consumerIds;
+        private Integer messageLimit;
+        private Integer timeout;
+
+        // custom polling configuration
+        private Polling polling;
+    }
+
+    /**
+     * DMaaP Info
+     */
+    @Data
+    public static class DmaapInfo implements ConfigBindingServiceModel {
+
+        private static final long serialVersionUID = 1L;
+
+        private String clientRole;
+        private String clientId;
+        private String location;
+        private String topicUrl;
+
+    }
+
+
+    /**
+     * Polling Details
+     */
+    @Data
+    public static class Polling implements ConfigBindingServiceModel {
+
+        private static final long serialVersionUID = 1L;
+
+        private Integer fixedRate;
+        private AutoAdjusting autoAdjusting;
+
+    }
+
+
+    /**
+     * Auto Adjusting Polling Details
+     */
+    @Data
+    public static class AutoAdjusting implements ConfigBindingServiceModel {
+
+        private static final long serialVersionUID = 1L;
+
+        private Integer min;
+        private Integer stepUp;
+        private Integer max;
+        private Integer stepDown;
+
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConfigBindingServiceConstants.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConfigBindingServiceConstants.java
new file mode 100644 (file)
index 0000000..196b791
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.configbindingservice;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.PubSubCommonDetails;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class ConfigBindingServiceConstants {
+
+    // ================== CONFIG SERVICE CONSTANTS ============================== //
+    public static final String CONSUL_HOST_ENV_VARIABLE_KEY = "CONSUL_HOST";
+    public static final String CONSUL_HOST_ENV_VARIABLE_VALUE = System.getenv(CONSUL_HOST_ENV_VARIABLE_KEY);
+    public static final String CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY = "CONFIG_BINDING_SERVICE";
+    public static final String CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE =
+            System.getenv(CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY);
+    public static final String SERVICE_NAME_ENV_VARIABLE_KEY = "SERVICE_NAME";
+    public static final String SERVICE_NAME_ENV_VARIABLE_VALUE = System.getenv(SERVICE_NAME_ENV_VARIABLE_KEY);
+    public static final String CONSUL_QUERY_URL_STRING = String.format("http://%s:8500/v1/catalog/service/%s",
+            CONSUL_HOST_ENV_VARIABLE_VALUE, CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE);
+    public static final String CONFIG_SERVICE_QUERY_URL_STRING = "http://%s:%s/service_component/%s";
+
+
+    public static final String CONFIG_BINDING_SERVICE_PROPERTIES_KEY = "config-binding-service";
+
+
+    public static final Set<String> SPRING_RESERVED_PROPERTIES_KEY_PREFIXES =
+            Stream.of("spring", "endpoints", "server", "logging", "management").collect(Collectors.toSet());
+    public static final String CONFIG_SERVICE_MESSAGE_ROUTER_VALUE = "message_router";
+    // CONVERT JSON TO MAP
+    public static final String KEY_SEPARATOR = ".";
+
+    // ============== CONFIG BINDING SERVICE UTILS ========================= //
+    /**
+     * Predicate which can be used to filter message router publisher or subscriber details
+     */
+    public static final Predicate<Map.Entry<String, ? extends PubSubCommonDetails>> MESSAGE_ROUTER_PREDICATE =
+            e -> e.getValue().getType() != null &&
+                    e.getValue().getType().equalsIgnoreCase(CONFIG_SERVICE_MESSAGE_ROUTER_VALUE);
+
+    private ConfigBindingServiceConstants() {
+        // private constructor
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConfigBindingServiceModel.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConfigBindingServiceModel.java
new file mode 100644 (file)
index 0000000..902dded
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.configbindingservice;
+
+import org.onap.dcae.analytics.model.AnalyticsModel;
+
+/**
+ * Marker Interface for all Config Binding Service Model Objects
+ *
+ * @author Rajiv Singla
+ */
+public interface ConfigBindingServiceModel extends AnalyticsModel {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConsulConfigBindingServiceQueryResponse.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/configbindingservice/ConsulConfigBindingServiceQueryResponse.java
new file mode 100644 (file)
index 0000000..fed262e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.configbindingservice;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ConsulConfigBindingServiceQueryResponse extends BaseDynamicPropertiesProvider implements
+        ConfigBindingServiceModel {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+    private String node;
+    private String address;
+    private String dataCenter;
+    private Map<String, String> taggedAddresses;
+    private Map<String, String> nodeMeta;
+    private String serviceId;
+    private String serviceName;
+    private List<String> serviceTags;
+    private String serviceAddress;
+    private Integer servicePort;
+    private Boolean serviceEnableTagOverride;
+    private long createIndex;
+    private long modifyIndex;
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/ecomplogger/AnalyticsErrorType.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/ecomplogger/AnalyticsErrorType.java
new file mode 100644 (file)
index 0000000..0cf306c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.ecomplogger;
+
+/**
+ * @author Rajiv Singla
+ */
+public enum AnalyticsErrorType implements EcompLoggerModel {
+
+    SUCCESSFUL(0, ""),
+    PERMISSION_ERROR(100, "Permission Error"),
+    TIMEOUT_ERROR(200, "Timeout Error"),
+    DATA_ERROR(300, "Data Error"),
+    SCHEMA_ERROR(400, "Schema Error"),
+    BUSINESS_PROCESS_ERROR(500, "Business Process Error"),
+    UNKNOWN_ERROR(900, "Unknown Error");
+
+    private final Integer errorCode;
+    private final String errorDescription;
+
+    AnalyticsErrorType(final Integer errorCode, final String errorDescription) {
+        this.errorCode = errorCode;
+        this.errorDescription = errorDescription;
+    }
+
+    public Integer getErrorCode() {
+        return errorCode;
+    }
+
+    public String getErrorDescription() {
+        return errorDescription;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/ecomplogger/EcompLoggerModel.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/ecomplogger/EcompLoggerModel.java
new file mode 100644 (file)
index 0000000..9ff2736
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.ecomplogger;
+
+import org.onap.dcae.analytics.model.AnalyticsModel;
+
+/**
+ * Marker interface for all ECOMP Logger Model classes
+ *
+ * @author Rajiv Singla
+ */
+public interface EcompLoggerModel extends AnalyticsModel {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/facade/AnalyticsFacadeModel.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/facade/AnalyticsFacadeModel.java
new file mode 100644 (file)
index 0000000..75f0321
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.facade;
+
+import org.onap.dcae.analytics.model.AnalyticsModel;
+
+/**
+ * Marker Interface for all Facade (outgoing) DCAE Analytics Facade Models
+ *
+ * @author Rajiv Singla
+ */
+public interface AnalyticsFacadeModel extends AnalyticsModel {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/policy/AnalyticsPolicyModel.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/policy/AnalyticsPolicyModel.java
new file mode 100644 (file)
index 0000000..baebfbc
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.policy;
+
+import org.onap.dcae.analytics.model.AnalyticsModel;
+
+/**
+ * Marker Interface all DCAE Analytics Policy Model implementations
+ *
+ * @author Rajiv Singla
+ */
+public interface AnalyticsPolicyModel extends AnalyticsModel {
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/BiFunctionExtension.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/BiFunctionExtension.java
new file mode 100644 (file)
index 0000000..1a3779a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.function;
+
+import java.util.function.BiFunction;
+import java.util.function.Function;
+
+/**
+ * A BiFunction extension which extends {@link BiFunction} to support additional functional
+ * concepts like currying
+ *
+ * @param <T> the type of the first argument to the function
+ * @param <U> the type of the second argument to the function
+ * @param <R> the type of the result of the function
+ */
+public interface BiFunctionExtension<T, U, R> extends BiFunction<T, U, R> {
+
+    /**
+     * Returns a {@link Function} which takes one argument
+     *
+     * @param t Bi Function first param
+     *
+     * @return Function which takes another argument
+     */
+    default Function<U, R> curry(T t) {
+        return (U u) -> apply(t, u);
+    }
+
+}
+
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/JsonStringToMapFunction.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/JsonStringToMapFunction.java
new file mode 100644 (file)
index 0000000..a68c327
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.function;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.Function;
+
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Converts JSON String to flatten map of key value pair
+ *
+ * @author Rajiv Singla
+ */
+public class JsonStringToMapFunction implements Function<String, Map<String, Object>> {
+
+    private static final Logger logger = LoggerFactory.getLogger(JsonStringToMapFunction.class);
+
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+    private final String keyPrefix;
+    private final String keySeparator;
+
+    public JsonStringToMapFunction(final String keyPrefix, final String keySeparator) {
+        this.keyPrefix = keyPrefix;
+        this.keySeparator = keySeparator;
+    }
+
+    public JsonStringToMapFunction(final String keyPrefix) {
+        this(keyPrefix, ConfigBindingServiceConstants.KEY_SEPARATOR);
+    }
+
+    public JsonStringToMapFunction() {
+        this("", ConfigBindingServiceConstants.KEY_SEPARATOR);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Map<String, Object> apply(final String jsonString) {
+
+        logger.debug("Converting JSON to flattened key value Map: {}", jsonString);
+        if (jsonString == null || jsonString.trim().isEmpty()) {
+            return new HashMap<>();
+        }
+
+        final Map<String, Object> result = flattenJson(jsonString);
+        logger.debug("Flattened Key Value Pairs");
+        result.forEach((key, value) -> logger.debug("{}:{}", key, value));
+        return result;
+    }
+
+    /**
+     * Flattens Json String
+     *
+     * @param jsonString json String
+     *
+     * @return map containing flattened json string key and value
+     */
+    private Map<String, Object> flattenJson(final String jsonString) {
+
+        try {
+            final JsonNode rootNode = OBJECT_MAPPER.readTree(jsonString);
+            final LinkedHashMap<String, Object> result = new LinkedHashMap<>();
+            flattenJsonNode(keyPrefix, rootNode, result);
+            return result;
+        } catch (IOException e) {
+            final String errorMessage = String.format("Unable to flatten JSON String to Map. Invalid JSON String: " +
+                    "%s", jsonString);
+            logger.error(errorMessage, e, jsonString);
+            throw new IllegalArgumentException(jsonString, e);
+        }
+
+    }
+
+    /**
+     * Flattens json array
+     *
+     * @param propertyPrefix property prefix
+     * @param jsonNodesIterator json array node that needs to be flattened
+     * @param resultMap result map containing flattened key value pairs
+     */
+    private void flattenJsonArray(String propertyPrefix, Iterator<JsonNode> jsonNodesIterator,
+                                  Map<String, Object> resultMap) {
+        int counter = 0;
+        while (jsonNodesIterator.hasNext()) {
+            flattenJsonNode(propertyPrefix + "[" + counter + "]", jsonNodesIterator.next(), resultMap);
+            counter++;
+        }
+
+    }
+
+    /**
+     * Flattens json array
+     *
+     * @param propertyPrefix property prefix
+     * @param objectNode json object node that needs to be flattened
+     * @param resultMap result map containing flattened key value pairs
+     */
+    private void flattenJsonMap(String propertyPrefix, JsonNode objectNode,
+                                Map<String, Object> resultMap) {
+        final Iterator<Map.Entry<String, JsonNode>> fieldsIterator = objectNode.fields();
+        while (fieldsIterator.hasNext()) {
+            final Map.Entry<String, JsonNode> fieldEntry = fieldsIterator.next();
+            final JsonNode jsonValue = fieldEntry.getValue();
+            final String jsonKey = fieldEntry.getKey();
+            flattenJsonNode(
+                    (propertyPrefix.isEmpty() ? "" : propertyPrefix + keySeparator) + jsonKey,
+                    jsonValue, resultMap);
+        }
+    }
+
+    /**
+     * Checks various elements types of JSON Types and flattens them based on their type
+     *
+     * @param propertyPrefix property prefix
+     * @param currentJsonNode currentJsonNode that may need to be flattened
+     * @param resultMap result map containing flattened key value pairs
+     */
+    private void flattenJsonNode(final String propertyPrefix, final JsonNode currentJsonNode,
+                                 final Map<String, Object> resultMap) {
+
+
+        if (currentJsonNode.isObject()) {
+            flattenJsonMap(propertyPrefix, currentJsonNode, resultMap);
+        } else if (currentJsonNode.isArray()) {
+            flattenJsonArray(propertyPrefix, currentJsonNode.iterator(), resultMap);
+        } else {
+            resultMap.put(propertyPrefix, getObjectValue(currentJsonNode));
+        }
+    }
+
+    private static Object getObjectValue(final JsonNode jsonNode) {
+        if (jsonNode.isTextual()) {
+            return jsonNode.textValue();
+        } else if (jsonNode.isNumber()) {
+            return jsonNode.asLong();
+        } else if (jsonNode.isBoolean()) {
+            return jsonNode.asBoolean();
+        } else {
+            return jsonNode.asText();
+        }
+    }
+}
+
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/JsonToJavaObjectBiFunction.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/JsonToJavaObjectBiFunction.java
new file mode 100644 (file)
index 0000000..7910435
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.function;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.Optional;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Converts given Json String to Java Object if possible
+ *
+ * @param <T> Target Java Object class Type for JSON String
+ *
+ * @author Rajiv Singla
+ */
+public class JsonToJavaObjectBiFunction<T> implements BiFunctionExtension<TypeReference<T>, String, Optional<T>> {
+
+    private static final Logger logger = LoggerFactory.getLogger(JsonToJavaObjectBiFunction.class);
+
+    private final ObjectMapper objectMapper;
+
+    public JsonToJavaObjectBiFunction(final ObjectMapper objectMapper) {
+        this.objectMapper = objectMapper;
+    }
+
+
+    @Override
+    public Optional<T> apply(final TypeReference<T> typeReference, final String jsonString) {
+
+        try {
+            return Optional.of(objectMapper.readValue(jsonString, typeReference));
+        } catch (IOException e) {
+            logger.error("Unable to convert given JSON String to Java Object. JSON String: " + jsonString, e);
+        }
+
+        return Optional.empty();
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/StringToURLFunction.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/StringToURLFunction.java
new file mode 100644 (file)
index 0000000..18f5cd5
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.function;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Optional;
+import java.util.function.Function;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Converts String to URL if possible
+ *
+ * @author Rajiv Singla
+ */
+public class StringToURLFunction implements Function<String, Optional<URL>> {
+
+    private static final Logger logger = LoggerFactory.getLogger(StringToURLFunction.class);
+
+    @Override
+    public Optional<URL> apply(final String urlString) {
+
+        try {
+            return Optional.of(new URL(urlString));
+        } catch (MalformedURLException e) {
+            logger.error("Unable to convert given String: {} to URL" + urlString, e);
+        }
+
+        return Optional.empty();
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/URLToHttpGetFunction.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/function/URLToHttpGetFunction.java
new file mode 100644 (file)
index 0000000..fe5ae07
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.function;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Optional;
+import java.util.Scanner;
+import java.util.function.Function;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Simple Function that calls http 'GET' on given URL and returns the response as String if successful. This function
+ * has side effects and only used for convenience in lambda expressions
+ * <p>
+ * NOTE: Suitable for only light weight http get requests as this will be a blocking call
+ *
+ * @author Rajiv Singla
+ */
+public class URLToHttpGetFunction implements Function<URL, Optional<String>> {
+
+    private static final Logger logger = LoggerFactory.getLogger(URLToHttpGetFunction.class);
+
+    @Override
+    public Optional<String> apply(final URL url) {
+
+        try {
+            final HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
+            httpConnection.setRequestMethod("GET");
+
+            logger.info("Sending 'GET' request to URL : {}", url);
+            final int responseCode = httpConnection.getResponseCode();
+
+            if (responseCode == 200) {
+                final StringBuilder responseString = new StringBuilder();
+                try (Scanner scanner = new Scanner(httpConnection.getInputStream(), StandardCharsets.UTF_8.name())) {
+                    while (scanner.hasNext()) {
+                        responseString.append(scanner.next());
+                    }
+                }
+
+                logger.info("Successful Response: {}", responseString);
+                return Optional.of(responseString.toString());
+            }
+
+            logger.error("Unsuccessful Response Code: {} when calling URL: {}", responseCode, url);
+
+        } catch (IOException e) {
+
+            logger.error("Unable to create HTTP URL Connection to URL:" + url, e);
+
+        }
+
+        return Optional.empty();
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/AnalyticsModelJsonConversion.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/AnalyticsModelJsonConversion.java
new file mode 100644 (file)
index 0000000..3ba3fe8
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Function;
+
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.model.configbindingservice.ConsulConfigBindingServiceQueryResponse;
+import org.onap.dcae.analytics.model.util.function.JsonToJavaObjectBiFunction;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class AnalyticsModelJsonConversion {
+
+    public static final ObjectMapper ANALYTICS_MODEL_OBJECT_MAPPER = new BaseObjectMapperSupplier() {
+        @Override
+        public void registerCustomModules(final ObjectMapper objectMapper) {
+            // do nothing
+        }
+    }.get();
+
+    // Type reference to convert a list or array of Config Service Binding
+    private static final TypeReference<List<ConsulConfigBindingServiceQueryResponse>>
+            CONFIG_BINDING_SERVICE_LIST_TYPE_REF = new TypeReference<List<ConsulConfigBindingServiceQueryResponse>>() {
+    };
+    // Type reference to convert a list or array of event listener list
+    private static final TypeReference<List<EventListener>> EVENT_LISTENER_LIST_TYPE_REF =
+            new TypeReference<List<EventListener>>() {
+            };
+    // Type reference to convert single event listener
+    private static final TypeReference<EventListener> EVENT_LISTENER_TYPE_REF = new TypeReference<EventListener>() {
+    };
+
+
+    // Event Listener Json Conversion Function
+    public static final Function<String, Optional<EventListener>> EVENT_LISTENER_JSON_FUNCTION =
+            new JsonToJavaObjectBiFunction<EventListener>(ANALYTICS_MODEL_OBJECT_MAPPER)
+                    .curry(EVENT_LISTENER_TYPE_REF);
+
+    // Event Listener List Json Conversion Function
+    public static final Function<String, Optional<List<EventListener>>> EVENT_LISTENER_LIST_JSON_FUNCTION =
+            new JsonToJavaObjectBiFunction<List<EventListener>>(ANALYTICS_MODEL_OBJECT_MAPPER)
+                    .curry(EVENT_LISTENER_LIST_TYPE_REF);
+
+    // Consul Config Binding Service Query Json Conversion Function
+    public static final Function<String, Optional<List<ConsulConfigBindingServiceQueryResponse>>>
+            CONFIG_BINDING_SERVICE_LIST_JSON_FUNCTION = new
+            JsonToJavaObjectBiFunction<List<ConsulConfigBindingServiceQueryResponse>>(ANALYTICS_MODEL_OBJECT_MAPPER)
+            .curry(CONFIG_BINDING_SERVICE_LIST_TYPE_REF);
+
+    private AnalyticsModelJsonConversion() {
+        // private constructor
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/BaseObjectMapperSupplier.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/BaseObjectMapperSupplier.java
new file mode 100644 (file)
index 0000000..18e8262
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.jayway.jsonpath.Configuration;
+import com.jayway.jsonpath.Option;
+import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
+import com.jayway.jsonpath.spi.json.JsonProvider;
+import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
+import com.jayway.jsonpath.spi.mapper.MappingProvider;
+
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.function.Supplier;
+
+import org.onap.dcae.analytics.model.util.json.module.CommonEventFormatModule;
+import org.onap.dcae.analytics.model.util.json.module.ConfigBindingServiceModule;
+import org.onap.dcae.analytics.model.util.json.module.DynamicPropertiesModule;
+
+/**
+ * Base Object mapper supplies Jackson {@link ObjectMapper} that specializes in serialize and deserialize -
+ * Analytics model objects. Various analytics components should inherit from this supplier and register
+ * their custom modules
+ *
+ * @author Rajiv Singla
+ */
+public abstract class BaseObjectMapperSupplier implements Supplier<ObjectMapper> {
+
+    /**
+     * Class that can used to configure Json Path configuration
+     */
+    public static class JsonPathConfiguration implements Configuration.Defaults {
+
+        private final JsonProvider jsonProvider;
+        private final MappingProvider mappingProvider;
+        private final Set<Option> options;
+
+        private JsonPathConfiguration(final ObjectMapper objectMapper, final Set<Option> options) {
+            jsonProvider = new JacksonJsonProvider(objectMapper);
+            mappingProvider = new JacksonMappingProvider(objectMapper);
+            this.options = options;
+        }
+
+
+        @Override
+        public JsonProvider jsonProvider() {
+            return jsonProvider;
+        }
+
+        @Override
+        public Set<Option> options() {
+            return options;
+        }
+
+        @Override
+        public MappingProvider mappingProvider() {
+            return mappingProvider;
+        }
+    }
+
+    public abstract void registerCustomModules(final ObjectMapper objectMapper);
+
+    @Override
+    public ObjectMapper get() {
+
+        final ObjectMapper objectMapper = new ObjectMapper();
+
+        //  Ignore null values during serialization. Null values will not be included in serialized JSON object
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+        // Don't fail on unknown properties
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+        // register dynamic properties module
+        objectMapper.registerModule(new DynamicPropertiesModule());
+        // register config binding service module
+        objectMapper.registerModule(new ConfigBindingServiceModule());
+        // register common event format module
+        objectMapper.registerModule(new CommonEventFormatModule());
+
+        // register custom modules
+        registerCustomModules(objectMapper);
+
+        // Setup JsonPath default config
+        setupJsonPathDefaultConfig(objectMapper);
+
+        return objectMapper;
+    }
+
+    /**
+     * Setups up default Config for Json Path
+     *
+     * @param objectMapper Jackson object mapper
+     */
+    private void setupJsonPathDefaultConfig(final ObjectMapper objectMapper) {
+
+        Configuration.setDefaults(new JsonPathConfiguration(objectMapper, EnumSet.of(
+                Option.DEFAULT_PATH_LEAF_TO_NULL,  // missing properties are tolerated
+                Option.SUPPRESS_EXCEPTIONS, // Json Path exceptions are suppressed
+                Option.ALWAYS_RETURN_LIST // always return results as list
+                ))
+        );
+
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/JsonMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/JsonMixin.java
new file mode 100644 (file)
index 0000000..99ab7c9
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin;
+
+import java.io.Serializable;
+
+/**
+ * Marker Interface for all Json Mixin classes
+ *
+ * @author Rajiv Singla
+ */
+public interface JsonMixin extends Serializable {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertActionMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertActionMixin.java
new file mode 100644 (file)
index 0000000..d1170a5
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class AlertActionMixin implements JsonMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertTypeMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertTypeMixin.java
new file mode 100644 (file)
index 0000000..da625ea
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+import org.onap.dcae.analytics.model.cef.AlertType;
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * Mixin for Alert Type
+ *
+ * @author Rajiv Singla
+ */
+public abstract class AlertTypeMixin implements JsonMixin {
+
+    private String name;
+
+    @JsonCreator
+    public static AlertType forValue(String name) {
+
+        switch (name) {
+            case "CARD-ANOMALY":
+                return AlertType.CARD_ANOMALY;
+            case "ELEMENT-ANOMALY":
+                return AlertType.ELEMENT_ANOMALY;
+            case "INTERFACE-ANOMALY":
+                return AlertType.INTERFACE_ANOMALY;
+            case "SERVICE-ANOMALY":
+                return AlertType.SERVICE_ANOMALY;
+            default:
+                return AlertType.UNKNOWN;
+        }
+
+    }
+
+    @JsonValue
+    public String getName() {
+        return name;
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/BaseCEFModelMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/BaseCEFModelMixin.java
new file mode 100644 (file)
index 0000000..2ea82ed
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+
+import org.onap.dcae.analytics.model.util.json.mixin.common.BaseDynamicPropertiesProviderMixin;
+
+/**
+ * Abstract Mixin for all CEF Model Mixins
+ *
+ * @author Rajiv Singla
+ */
+public abstract class BaseCEFModelMixin extends BaseDynamicPropertiesProviderMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CommonEventHeaderMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CommonEventHeaderMixin.java
new file mode 100644 (file)
index 0000000..b4b8eb2
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class CommonEventHeaderMixin extends BaseCEFModelMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CriticalityMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CriticalityMixin.java
new file mode 100644 (file)
index 0000000..09fd095
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class CriticalityMixin implements JsonMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/DomainMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/DomainMixin.java
new file mode 100644 (file)
index 0000000..fdceb21
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class DomainMixin implements JsonMixin {
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventListenerMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventListenerMixin.java
new file mode 100644 (file)
index 0000000..061a308
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * Event Listener Json Mixin class
+ * <p>
+ *
+ * @author Rajiv Singla
+ */
+public abstract class EventListenerMixin extends BaseCEFModelMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventMixin.java
new file mode 100644 (file)
index 0000000..5a73244
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * Event Json Mixin class
+ * <p>
+ *
+ * @author Rajiv Singla
+ */
+public abstract class EventMixin extends BaseCEFModelMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventSeverityMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventSeverityMixin.java
new file mode 100644 (file)
index 0000000..a7ca8a7
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class EventSeverityMixin implements JsonMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/FieldMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/FieldMixin.java
new file mode 100644 (file)
index 0000000..a9561ab
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class FieldMixin extends BaseCEFModelMixin {
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/InternalHeaderFieldsMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/InternalHeaderFieldsMixin.java
new file mode 100644 (file)
index 0000000..d121842
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class InternalHeaderFieldsMixin extends BaseCEFModelMixin {
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/MeasurementsForVfScalingFieldsMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/MeasurementsForVfScalingFieldsMixin.java
new file mode 100644 (file)
index 0000000..eda527a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonSetter;
+
+import java.util.List;
+
+import org.onap.dcae.analytics.model.cef.VNicPerformance;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class MeasurementsForVfScalingFieldsMixin extends BaseCEFModelMixin {
+
+    @JsonGetter("vNicPerformanceArray")
+    public abstract List<VNicPerformance> getVNicPerformanceArray();
+
+    @JsonSetter("vNicPerformanceArray")
+    public abstract void setVNicPerformanceArray(List<VNicPerformance> vNicPerformances);
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/NamedArrayOfFieldsMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/NamedArrayOfFieldsMixin.java
new file mode 100644 (file)
index 0000000..f23b803
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class NamedArrayOfFieldsMixin extends BaseCEFModelMixin {
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/PerformanceCounterMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/PerformanceCounterMixin.java
new file mode 100644 (file)
index 0000000..dd7ed61
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * CEF Performance Counter Mixin
+ *
+ * @author Rajiv Singla
+ */
+public abstract class PerformanceCounterMixin extends BaseCEFModelMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/PriorityMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/PriorityMixin.java
new file mode 100644 (file)
index 0000000..c36658e
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class PriorityMixin implements JsonMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/ThresholdCrossingAlertFieldsMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/ThresholdCrossingAlertFieldsMixin.java
new file mode 100644 (file)
index 0000000..ce4a129
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+/**
+ * Mixin class for ThresholdCrossingAlertFields
+ *
+ * @author Rajiv Singla
+ */
+public abstract class ThresholdCrossingAlertFieldsMixin extends BaseCEFModelMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/VNicUsageArrayMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/VNicUsageArrayMixin.java
new file mode 100644 (file)
index 0000000..6152d7f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import com.fasterxml.jackson.annotation.JsonSetter;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class VNicUsageArrayMixin extends BaseCEFModelMixin {
+
+    @JsonSetter("vNicIdentifier")
+    public abstract void setVNicIdentifier(String name);
+
+    @JsonSetter("vNicIdentifier")
+    public abstract String setVNicIdentifier();
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/common/BaseDynamicPropertiesProviderMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/common/BaseDynamicPropertiesProviderMixin.java
new file mode 100644 (file)
index 0000000..b4cd525
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.common;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider;
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * Json Mixin for {@link BaseDynamicPropertiesProvider}
+ *
+ * @author Rajiv Singla
+ */
+public abstract class BaseDynamicPropertiesProviderMixin implements JsonMixin {
+
+    /**
+     * Provides hint to Jackson Json Object mapper to bind any put all dynamic properties in a map
+     *
+     * @param propertyName dynamic property name
+     * @param propertyValue dynamic property value
+     */
+    @JsonAnySetter
+    public abstract void addDynamicProperties(String propertyName, Object propertyValue);
+
+    /**
+     * Provides hint to serialize dynamic properties as map
+     *
+     * @return dynamic properties map
+     */
+    @JsonAnyGetter
+    public abstract Map<String, Object> getDynamicProperties();
+
+    /**
+     * Ignores isDynamicPropertiesPresent for json serialization
+     *
+     * @return true if dynamic properties are present
+     */
+    @JsonIgnore
+    public abstract boolean isDynamicPropertiesPresent();
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/configbindingservice/ConsulConfigBindingServiceQueryResponseMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/configbindingservice/ConsulConfigBindingServiceQueryResponseMixin.java
new file mode 100644 (file)
index 0000000..e1da351
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.configbindingservice;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.util.json.mixin.common.BaseDynamicPropertiesProviderMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class ConsulConfigBindingServiceQueryResponseMixin extends BaseDynamicPropertiesProviderMixin {
+
+    @JsonProperty("ID")
+    private String id;
+    @JsonProperty("Node")
+    private String node;
+    @JsonProperty("Address")
+    private String address;
+    @JsonProperty("Datacenter")
+    private String dataCenter;
+    @JsonProperty("TaggedAddresses")
+    private Map<String, String> taggedAddresses;
+    @JsonProperty("NodeMeta")
+    private Map<String, String> nodeMeta;
+    @JsonProperty("ServiceID")
+    private String serviceId;
+    @JsonProperty("ServiceName")
+    private String serviceName;
+    @JsonProperty("ServiceTags")
+    private List<String> serviceTags;
+    @JsonProperty("ServiceAddress")
+    private String serviceAddress;
+    @JsonProperty("ServicePort")
+    private Integer servicePort;
+    @JsonProperty("ServiceEnableTagOverride")
+    private Boolean serviceEnableTagOverride;
+    @JsonProperty("CreateIndex")
+    private long createIndex;
+    @JsonProperty("ModifyIndex")
+    private long modifyIndex;
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModule.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModule.java
new file mode 100644 (file)
index 0000000..1daf2ef
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.module;
+
+import static org.onap.dcae.analytics.model.AnalyticsModelConstants.JSON_MODULE_ARTIFACT_ID;
+import static org.onap.dcae.analytics.model.AnalyticsModelConstants.JSON_MODULE_GROUP_ID;
+
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import org.onap.dcae.analytics.model.cef.AlertAction;
+import org.onap.dcae.analytics.model.cef.AlertType;
+import org.onap.dcae.analytics.model.cef.BaseCEFModel;
+import org.onap.dcae.analytics.model.cef.CommonEventHeader;
+import org.onap.dcae.analytics.model.cef.Criticality;
+import org.onap.dcae.analytics.model.cef.Domain;
+import org.onap.dcae.analytics.model.cef.Event;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.model.cef.EventSeverity;
+import org.onap.dcae.analytics.model.cef.Field;
+import org.onap.dcae.analytics.model.cef.InternalHeaderFields;
+import org.onap.dcae.analytics.model.cef.MeasurementsForVfScalingFields;
+import org.onap.dcae.analytics.model.cef.NamedArrayOfFields;
+import org.onap.dcae.analytics.model.cef.PerformanceCounter;
+import org.onap.dcae.analytics.model.cef.Priority;
+import org.onap.dcae.analytics.model.cef.ThresholdCrossingAlertFields;
+import org.onap.dcae.analytics.model.cef.VNicPerformance;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.AlertActionMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.AlertTypeMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.BaseCEFModelMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.CommonEventHeaderMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.CriticalityMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.DomainMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.EventListenerMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.EventMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.EventSeverityMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.FieldMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.InternalHeaderFieldsMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.MeasurementsForVfScalingFieldsMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.NamedArrayOfFieldsMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.PerformanceCounterMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.PriorityMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.ThresholdCrossingAlertFieldsMixin;
+import org.onap.dcae.analytics.model.util.json.mixin.cef.VNicUsageArrayMixin;
+
+
+/**
+ * @author Rajiv Singla
+ */
+public class CommonEventFormatModule extends SimpleModule {
+
+    private static final long serialVersionUID = 1L;
+
+    public CommonEventFormatModule() {
+        super("Common Event Format",
+                new Version(28, 3, 0, null, JSON_MODULE_GROUP_ID, JSON_MODULE_ARTIFACT_ID));
+    }
+
+    @Override
+    public void setupModule(final SetupContext setupContext) {
+
+        setupContext.setMixInAnnotations(AlertAction.class, AlertActionMixin.class);
+        setupContext.setMixInAnnotations(AlertType.class, AlertTypeMixin.class);
+        setupContext.setMixInAnnotations(BaseCEFModel.class, BaseCEFModelMixin.class);
+        setupContext.setMixInAnnotations(CommonEventHeader.class, CommonEventHeaderMixin.class);
+        setupContext.setMixInAnnotations(Domain.class, DomainMixin.class);
+        setupContext.setMixInAnnotations(InternalHeaderFields.class, InternalHeaderFieldsMixin.class);
+        setupContext.setMixInAnnotations(Field.class, FieldMixin.class);
+        setupContext.setMixInAnnotations(NamedArrayOfFields.class, NamedArrayOfFieldsMixin.class);
+        setupContext.setMixInAnnotations(Criticality.class, CriticalityMixin.class);
+        setupContext.setMixInAnnotations(EventListener.class, EventListenerMixin.class);
+        setupContext.setMixInAnnotations(Event.class, EventMixin.class);
+        setupContext.setMixInAnnotations(EventSeverity.class, EventSeverityMixin.class);
+        setupContext.setMixInAnnotations(MeasurementsForVfScalingFields.class,
+                MeasurementsForVfScalingFieldsMixin.class);
+        setupContext.setMixInAnnotations(PerformanceCounter.class, PerformanceCounterMixin.class);
+        setupContext.setMixInAnnotations(Priority.class, PriorityMixin.class);
+        setupContext.setMixInAnnotations(ThresholdCrossingAlertFields.class, ThresholdCrossingAlertFieldsMixin.class);
+        setupContext.setMixInAnnotations(VNicPerformance.class, VNicUsageArrayMixin.class);
+
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/ConfigBindingServiceModule.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/ConfigBindingServiceModule.java
new file mode 100644 (file)
index 0000000..19845d1
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.module;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import org.onap.dcae.analytics.model.configbindingservice.ConsulConfigBindingServiceQueryResponse;
+import org.onap.dcae.analytics.model.util.json.mixin.configbindingservice.ConsulConfigBindingServiceQueryResponseMixin;
+
+
+/**
+ * @author Rajiv Singla
+ */
+public class ConfigBindingServiceModule extends SimpleModule {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public void setupModule(final SetupContext setupContext) {
+        setupContext.setMixInAnnotations(ConsulConfigBindingServiceQueryResponse.class,
+                ConsulConfigBindingServiceQueryResponseMixin.class);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/DynamicPropertiesModule.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/DynamicPropertiesModule.java
new file mode 100644 (file)
index 0000000..a555023
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.module;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider;
+import org.onap.dcae.analytics.model.util.json.mixin.common.BaseDynamicPropertiesProviderMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public class DynamicPropertiesModule extends SimpleModule {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public void setupModule(final SetupContext setupContext) {
+        setupContext.setMixInAnnotations(BaseDynamicPropertiesProvider.class, BaseDynamicPropertiesProviderMixin.class);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/AnalyticsRequestIdSupplier.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/AnalyticsRequestIdSupplier.java
new file mode 100644 (file)
index 0000000..f359ff4
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.supplier;
+
+import java.util.UUID;
+import java.util.function.Supplier;
+
+/**
+ * Generates new Request id for Analytics ECOMP Components
+ *
+ * @author Rajiv Singla
+ */
+public class AnalyticsRequestIdSupplier implements Supplier<String> {
+
+    @Override
+    public String get() {
+        return UUID.randomUUID().toString();
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/ConfigBindingServiceJsonSupplier.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/ConfigBindingServiceJsonSupplier.java
new file mode 100644 (file)
index 0000000..b882bb0
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.supplier;
+
+
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.onap.dcae.analytics.model.configbindingservice.ConsulConfigBindingServiceQueryResponse;
+import org.onap.dcae.analytics.model.util.function.StringToURLFunction;
+import org.onap.dcae.analytics.model.util.function.URLToHttpGetFunction;
+import org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Function which fetches ApplicationProperties configuration from
+ * Config Binding Service when deployed via docker, typically during application startup time.
+ *
+ * @author Rajiv Singla
+ */
+public class ConfigBindingServiceJsonSupplier implements Supplier<Optional<String>> {
+
+    private static final Logger logger = LoggerFactory.getLogger(ConfigBindingServiceJsonSupplier.class);
+
+    private final Function<String, Optional<String>> fetchUrlContentFunction;
+
+    public ConfigBindingServiceJsonSupplier(final Function<String, Optional<String>> fetchUrlContentFunction) {
+        this.fetchUrlContentFunction = fetchUrlContentFunction;
+    }
+
+    public ConfigBindingServiceJsonSupplier() {
+        fetchUrlContentFunction = (String s) -> new StringToURLFunction().apply(s).flatMap(new URLToHttpGetFunction());
+    }
+
+    @Override
+    public Optional<String> get() {
+
+        logger.info("Consul Host Environment Variable: {}",
+                ConfigBindingServiceConstants.CONSUL_HOST_ENV_VARIABLE_VALUE);
+        logger.info("Config Binding Service Environment Variable: {}",
+                ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE);
+        logger.info("Service Name Environment Variable: {}",
+                ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE);
+
+        if (ConfigBindingServiceConstants.CONSUL_HOST_ENV_VARIABLE_VALUE == null ||
+                ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_ENV_VARIABLE_VALUE == null ||
+                ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE == null) {
+            logger.error("Environment variables required to query Config Binding Service are not present");
+            return Optional.empty();
+        }
+
+        return Optional.of(ConfigBindingServiceConstants.CONSUL_QUERY_URL_STRING)
+                // Step 1: Query CONSUL to get the IP/PORT of CONFIG BINDING SERVICE
+                .flatMap(fetchUrlContentFunction)
+                // Step 2: Fetch the generated configurations from CONFIG BINDING SERVICE
+                .flatMap(ConfigBindingServiceJsonSupplier::parseConsulConfigBindingServiceQueryResponseJson)
+                // Step 3: create url from service address and service port
+                .flatMap(ConfigBindingServiceJsonSupplier::createConfigServiceURL)
+                // Step 4: Fetch final config binding service generated application configuration json string
+                .flatMap(fetchUrlContentFunction);
+    }
+
+    /**
+     * Creates URL using config binding service ip address and port
+     *
+     * @param consulConfigBindingServiceQueryResponse consul config binding service query response containing config
+     * binding service address and service port
+     *
+     * @return config service url to fetch service configuration
+     */
+    private static Optional<String> createConfigServiceURL(final ConsulConfigBindingServiceQueryResponse
+                                                                   consulConfigBindingServiceQueryResponse) {
+        final String configBindingServiceAddress = consulConfigBindingServiceQueryResponse.getServiceAddress();
+        final Integer configServicePort = consulConfigBindingServiceQueryResponse.getServicePort();
+
+        if (configBindingServiceAddress == null && configServicePort == null) {
+            logger.error("Config Binding Service Address & Port are not present.");
+            return Optional.empty();
+        }
+
+        return Optional.of(String.format(ConfigBindingServiceConstants.CONFIG_SERVICE_QUERY_URL_STRING,
+                configBindingServiceAddress, configServicePort,
+                ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE));
+
+    }
+
+    private static Optional<ConsulConfigBindingServiceQueryResponse>
+    parseConsulConfigBindingServiceQueryResponseJson(final String configBindingServiceQueryResponseJson) {
+        // parse json
+        final Optional<List<ConsulConfigBindingServiceQueryResponse>> configBindingServiceQueryResponseOptional =
+                AnalyticsModelJsonConversion.CONFIG_BINDING_SERVICE_LIST_JSON_FUNCTION
+                        .apply(configBindingServiceQueryResponseJson);
+
+        // check parsing is successful and at least 1 config binding query response is present
+        if (!configBindingServiceQueryResponseOptional.isPresent() ||
+                configBindingServiceQueryResponseOptional.get().isEmpty()) {
+            logger.error("No Consul config binding service information found in JSON: {} ",
+                    configBindingServiceQueryResponseJson);
+            return Optional.empty();
+        }
+
+        // return first consul query response
+        return Optional.of(configBindingServiceQueryResponseOptional.get().get(0));
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/CreationTimestampSupplier.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/CreationTimestampSupplier.java
new file mode 100644 (file)
index 0000000..6837a55
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.supplier;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.function.Supplier;
+
+import org.onap.dcae.analytics.model.AnalyticsModelConstants;
+
+/**
+ * Provides current date/time in UTC formatted string
+ *
+ * @author Rajiv Singla
+ */
+public class CreationTimestampSupplier implements Supplier<String> {
+
+    private static final DateTimeFormatter DATE_TIME_FORMATTER =
+            DateTimeFormatter.ofPattern(AnalyticsModelConstants.ANALYTICS_DATE_FORMAT);
+
+    @Override
+    public String get() {
+        return DATE_TIME_FORMATTER.format(ZonedDateTime.now(ZoneOffset.UTC));
+    }
+
+
+    public static Date getParsedDate(final String dateString) {
+        return Date.from(ZonedDateTime.parse(dateString, DATE_TIME_FORMATTER).toInstant());
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/RandomIdSupplier.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/RandomIdSupplier.java
new file mode 100644 (file)
index 0000000..e1ec86a
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.supplier;
+
+import java.util.Locale;
+import java.util.Random;
+import java.util.function.Supplier;
+
+/**
+ * Supplies unsecured random ID with upper case with desired maximum length.
+ *
+ * @author Rajiv Singla
+ */
+public class RandomIdSupplier implements Supplier<String> {
+
+    private static final char[] LETTERS =
+            "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
+    private static final Random RANDOM = new Random();
+
+    private final int maxLength;
+
+    public RandomIdSupplier(int maxLength) {
+        this.maxLength = maxLength;
+    }
+
+
+    @Override
+    public String get() {
+
+        final StringBuilder sb = new StringBuilder(maxLength);
+        for (int i = 0; i < maxLength; i++) {
+            sb.append(LETTERS[RANDOM.nextInt(LETTERS.length)]);
+        }
+
+        return sb.toString().toUpperCase(Locale.getDefault());
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/UnboundedSupplier.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/supplier/UnboundedSupplier.java
new file mode 100644 (file)
index 0000000..21c04c2
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.supplier;
+
+
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Supplier;
+
+/**
+ * An unbounded supplier that can be used to generated unbounded sequence of elements
+ * in random or round robin generation mode.
+ *
+ * @param <T> The type of result supplied by the supplier
+ *
+ * @author Rajiv Singla
+ */
+public class UnboundedSupplier<T> implements Supplier<T> {
+
+    private final T[] elements;
+    private final GenerationMode generationMode;
+    private final int numElements;
+    private AtomicInteger index;
+    private Random random;
+
+    /**
+     * Sequence Generation Mode
+     */
+    public enum GenerationMode {
+        /**
+         * Sequence will be generated in uniformly distributed random
+         */
+        RANDOM,
+        /**
+         * Sequence will be generated in round robin manner
+         */
+        ROUND_ROBIN;
+    }
+
+    @SafeVarargs
+    public UnboundedSupplier(final GenerationMode generationMode, final T... elements) {
+        if (elements == null || elements.length < 1) {
+            throw new IllegalArgumentException("Element size must be greater than 1");
+        }
+        this.generationMode = generationMode;
+        this.elements = elements;
+        numElements = elements.length;
+        if (numElements > 1) {
+            if (generationMode == GenerationMode.ROUND_ROBIN) {
+                index = new AtomicInteger(-1);
+            } else {
+                random = new Random();
+            }
+        }
+    }
+
+    @SafeVarargs
+    public UnboundedSupplier(T... elements) {
+        this(GenerationMode.ROUND_ROBIN, elements);
+    }
+
+    @Override
+    public T get() {
+        if (numElements == 1) {
+            return elements[0];
+        }
+        if (generationMode == GenerationMode.ROUND_ROBIN) {
+            index.getAndUpdate(idx -> idx >= numElements - 1 ? 0 : idx + 1);
+            return elements[index.get()];
+        } else {
+            return elements[random.nextInt(numElements)];
+        }
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/BaseAnalyticsModelTest.java b/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/BaseAnalyticsModelTest.java
new file mode 100644 (file)
index 0000000..ec0f329
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model;
+
+import org.onap.dcae.analytics.test.BaseAnalyticsUnitTest;
+
+/**
+ * Base Analytics Model Unit Test.
+ *
+ * @author Rajiv Singla
+ */
+public abstract class BaseAnalyticsModelTest extends BaseAnalyticsUnitTest {
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertTypeMixinTest.java b/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/cef/AlertTypeMixinTest.java
new file mode 100644 (file)
index 0000000..d3368de
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import static org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion.ANALYTICS_MODEL_OBJECT_MAPPER;
+
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.model.BaseAnalyticsModelTest;
+import org.onap.dcae.analytics.model.cef.AlertType;
+
+
+/**
+ * Test Alert Type Mixin JSON conversions.
+ *
+ * @author Rajiv Singla
+ */
+class AlertTypeMixinTest extends BaseAnalyticsModelTest {
+
+    // NOTE: Alert type enum has some special customizations in AlertTypeMixin class
+    // as Java enum names does not allow for "-" so actual values are coded as enum names
+    @Test
+    @DisplayName("Test Alert Type Json Conversions")
+    public void testAlertTypeJsonConversions() throws Exception {
+
+        final String alertTypeJson = serializeModelToJson(AlertType.CARD_ANOMALY, ANALYTICS_MODEL_OBJECT_MAPPER);
+        Assertions.assertThat(alertTypeJson)
+                .as("Alert Type Json for CARD ANOMALY must have hyphen in it").isEqualTo("\"CARD-ANOMALY\"");
+        // convert parsed alert type back to enum
+        final AlertType alertType = ANALYTICS_MODEL_OBJECT_MAPPER.readValue(alertTypeJson, AlertType.class);
+        Assertions.assertThat(alertType)
+                .as("Json String for CARD ANOMALY with hyphen can be converted back to Alert Type")
+                .isEqualTo(AlertType.CARD_ANOMALY);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventListenerMixinTest.java b/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventListenerMixinTest.java
new file mode 100644 (file)
index 0000000..2e606cb
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.cef;
+
+import static org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion.ANALYTICS_MODEL_OBJECT_MAPPER;
+import static org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion.EVENT_LISTENER_JSON_FUNCTION;
+import static org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion.EVENT_LISTENER_LIST_JSON_FUNCTION;
+
+import java.util.List;
+
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.model.BaseAnalyticsModelTest;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.model.cef.Field;
+import org.onap.dcae.analytics.model.cef.NamedArrayOfFields;
+
+/**
+ * Contains test for CEF Event Listener JSON Conversions.
+ *
+ * @author Rajiv Singla
+ */
+class EventListenerMixinTest extends BaseAnalyticsModelTest {
+
+    @Test
+    @DisplayName("Test single CEF JSON conversions")
+    void testSingleEventListenerJsonConversion() {
+
+        final EventListener eventListener = assertJsonConversions(TestFileLocation.CEF_JSON_MESSAGE,
+                EVENT_LISTENER_JSON_FUNCTION, ANALYTICS_MODEL_OBJECT_MAPPER);
+
+        Assertions.assertThat(eventListener).isNotNull();
+        Assertions.assertThat(eventListener.getEvent()).isNotNull();
+        final List<Field> additionalFields =
+                eventListener.getEvent().getMeasurementsForVfScalingFields().getAdditionalFields();
+
+        Assertions.assertThat(additionalFields.size()).as("Additional Fields size is 2").isEqualTo(2);
+
+        final List<NamedArrayOfFields> additionalMeasurements =
+                eventListener.getEvent().getMeasurementsForVfScalingFields().getAdditionalMeasurements();
+
+        Assertions.assertThat(additionalMeasurements.size()).as("Additional Measurements size must be 1").isEqualTo(1);
+
+        final List<Field> arrayOfFields = additionalMeasurements.get(0).getArrayOfFields();
+
+        Assertions.assertThat(arrayOfFields.size()).as("Array Of Field size must be 6").isEqualTo(6);
+    }
+
+    @Test
+    @DisplayName("Test collection of CEF JSON messages conversions")
+    void testCollectionOfEventListenersJsonConversion() {
+
+        List<EventListener> eventListeners =
+                assertJsonConversions(TestFileLocation.CEF_JSON_MESSAGES,
+                        EVENT_LISTENER_LIST_JSON_FUNCTION, ANALYTICS_MODEL_OBJECT_MAPPER);
+        Assertions.assertThat(eventListeners).isNotNull();
+        Assertions.assertThat(eventListeners.size()).as("Event Listeners size must be 31").isEqualTo(31);
+
+        // Checks serialization
+        testSerialization(eventListeners, getClass());
+
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/configbindingservice/ConsulConfigBindingServiceQueryResponseMixinTest.java b/dcae-analytics/dcae-analytics-model/src/test/java/org/onap/dcae/analytics/model/util/json/mixin/configbindingservice/ConsulConfigBindingServiceQueryResponseMixinTest.java
new file mode 100644 (file)
index 0000000..b1b9fae
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.model.util.json.mixin.configbindingservice;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion.ANALYTICS_MODEL_OBJECT_MAPPER;
+import static org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion
+        .CONFIG_BINDING_SERVICE_LIST_JSON_FUNCTION;
+
+import java.util.List;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.model.BaseAnalyticsModelTest;
+import org.onap.dcae.analytics.model.configbindingservice.ConsulConfigBindingServiceQueryResponse;
+
+/**
+ * Consul Config Binding Service Query Response Mixin Test.
+ *
+ * @author Rajiv Singla
+ */
+class ConsulConfigBindingServiceQueryResponseMixinTest extends BaseAnalyticsModelTest {
+
+
+    @Test
+    @DisplayName("Test Config Service Bindings JSON conversions")
+    void testConfigServiceBindingsConversions() throws Exception {
+
+        List<ConsulConfigBindingServiceQueryResponse> configServiceBindings =
+                assertJsonConversions(TestFileLocation.CONFIG_SERVICE_BINDINGS_JSON,
+                        CONFIG_BINDING_SERVICE_LIST_JSON_FUNCTION, ANALYTICS_MODEL_OBJECT_MAPPER);
+
+        assertThat(configServiceBindings).isNotNull();
+        assertThat(configServiceBindings.size()).as("There should be only 1 binding config").isEqualTo(1);
+
+        final ConsulConfigBindingServiceQueryResponse configBindingServiceQueryResponse = configServiceBindings.get(0);
+        assertThat(configBindingServiceQueryResponse.getAddress())
+                .as("Config Service Binding ServiceAddress must be 135.25.108.161").isEqualTo("135.25.108.161");
+        assertThat(configBindingServiceQueryResponse.getServicePort())
+                .as("Config Service Binding ServicePort must be 32769").isEqualTo(32769);
+        assertThat(configBindingServiceQueryResponse.getDynamicProperties())
+                .as("Dynamic Properties must be empty if all bindings are successful").isEmpty();
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/pom.xml b/dcae-analytics/dcae-analytics-tca-core/pom.xml
new file mode 100644 (file)
index 0000000..c599c60
--- /dev/null
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.dcaegen2.analytics</groupId>
+        <artifactId>dcae-analytics</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dcae-analytics-tca-core</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- THIS MODULE CONTAINS CORE LOGIC FOR TCA ANALYTICS SERVICE -->
+    <name>DCAE Analytics TCA Core</name>
+    <description>Contins Core functionality for TCA</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+    </properties>
+
+    <dependencies>
+
+        <!-- PROJECT DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-tca-model</artifactId>
+        </dependency>
+
+        <!-- CODE GENERATION -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- FIND BUGS -->
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>annotations</artifactId>
+        </dependency>
+
+        <!-- TEST DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-test</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/exception/TcaProcessingException.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/exception/TcaProcessingException.java
new file mode 100644 (file)
index 0000000..87d0634
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.exception;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaProcessingException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * CDR Exception with message
+     *
+     * @param message Error Message for Exception
+     */
+    public TcaProcessingException(final String message) {
+        super(message);
+    }
+
+    /**
+     * CDR exception with message and cause
+     *
+     * @param message Error Message for Exception
+     * @param cause Actual Exception which caused {@link TcaProcessingException}
+     */
+    public TcaProcessingException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java
new file mode 100644 (file)
index 0000000..6a208d2
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+
+/**
+ * @author Rajiv Singla
+ */
+@Builder
+@Getter
+@EqualsAndHashCode
+@ToString
+public class GenericTcaExecutionContext implements TcaExecutionContext {
+
+    private final String requestId;
+    private final String transactionId;
+    private final int messageIndex;
+    private final String cefMessage;
+    private final TcaPolicy tcaPolicy;
+    private final TcaProcessingContext tcaProcessingContext;
+    private final TcaResultContext tcaResultContext;
+    private final TcaAbatementContext tcaAbatementContext;
+    private final TcaAaiEnrichmentContext tcaAaiEnrichmentContext;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaProcessingContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaProcessingContext.java
new file mode 100644 (file)
index 0000000..aceb4be
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+
+import lombok.Data;
+
+import org.onap.dcae.analytics.model.cef.EventListener;
+
+/**
+ * A Generic implementation for {@link TcaProcessingContext}
+ *
+ * @author Rajiv Singla
+ */
+
+@Data
+public class GenericTcaProcessingContext implements TcaProcessingContext {
+
+    private EventListener eventListener;
+    private boolean continueProcessing = true;
+    private String earlyTerminationMessage;
+    private String errorMessage;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaResultContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaResultContext.java
new file mode 100644 (file)
index 0000000..ee8ef86
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import lombok.Data;
+
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class GenericTcaResultContext implements TcaResultContext {
+
+    private MetricsPerEventName violatedMetricsPerEventName;
+    private TcaAlert tcaAlert;
+    private String previousRequestId;
+
+    @Override
+    public boolean isThresholdViolationsPresent() {
+        return getViolatedMetricsPerEventName() != null;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentContext.java
new file mode 100644 (file)
index 0000000..292905e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+/**
+ * Provides abstractions for TCA AAI Enrichment
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaAaiEnrichmentContext {
+
+    boolean isAaiEnrichmentEnabled();
+
+    TcaAaiEnrichmentService getAaiEnrichmentService();
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentService.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentService.java
new file mode 100644 (file)
index 0000000..f2d140c
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+
+/**
+ * TCA AAI Enrichment Service enriches {@link TcaAlert#getAai()}
+ *
+ * @author Rajiv Singla
+ */
+@FunctionalInterface
+public interface TcaAaiEnrichmentService {
+
+    /**
+     * @param tcaExecutionContext tca execution context
+     *
+     * @return tca alert with AAI enrichment
+     */
+    TcaAlert doAaiEnrichment(TcaExecutionContext tcaExecutionContext);
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementContext.java
new file mode 100644 (file)
index 0000000..9ec4192
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+/**
+ * Provides abstractions for TCA Abatement processing calculations
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaAbatementContext {
+
+    /**
+     * Returns true if TCA Abatement calculations are enabled
+     *
+     * @return true if TCA Abatement calculations are enabled
+     */
+    boolean isAbatementEnabled();
+
+
+    /**
+     * Provides abstractions for Tca Abatement Persistence
+     *
+     * @return abstractions for Tca Abatement Persistence
+     */
+    TcaAbatementRepository getTcaAbatementRepository();
+
+
+    /**
+     * Creates new instance of TCA Abatement persistence Entity
+     *
+     * @param lookupKey lookup key
+     * @param requestId request id
+     * @param isAbatementAlertSent true if abatement alert was already sent
+     *
+     * @return new instance of TCA Abatement Persistence Entity
+     */
+    TcaAbatementEntity create(String lookupKey, String requestId, boolean isAbatementAlertSent);
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementEntity.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementEntity.java
new file mode 100644 (file)
index 0000000..fe0ac5e
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import java.util.Date;
+
+/**
+ * TCA Abatement Persistence Entity
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaAbatementEntity {
+
+    /**
+     * Last Modified Date when entity was modified
+     *
+     * @return last modified date
+     */
+    Date getLastModificationDate();
+
+    /**
+     * Lookup Key
+     *
+     * @return provides Lookup Key
+     */
+    String getLookupKey();
+
+
+    /**
+     * Provides Request Id
+     *
+     * @return request id
+     */
+    String getRequestId();
+
+
+    /**
+     * Return true if alert was already sent for this Entity else false
+     *
+     * @return true if alert was already sent for this Entity else false
+     */
+    boolean isAbatementAlertSent();
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementRepository.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementRepository.java
new file mode 100644 (file)
index 0000000..c1d3a78
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import java.util.List;
+
+/**
+ * Provides abstractions for Tca Abatement Persistence
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaAbatementRepository {
+
+    /**
+     * Saves new Tca Abatement Entity to some persistent store
+     *
+     * @param tcaAbatementEntity Tca Abatement Entity that need to be stored
+     */
+    void save(TcaAbatementEntity tcaAbatementEntity);
+
+
+    /**
+     * Provides any saved Tca Abatement Entities which same look up key
+     *
+     * @param lookUpKey look up key for abatement persistence entity
+     *
+     * @return list of previously saved tca abatement persistence entities has given lookup key
+     */
+    List<TcaAbatementEntity> findByLookupKey(String lookUpKey);
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java
new file mode 100644 (file)
index 0000000..9a55151
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+
+/**
+ * TCA Execution context captures various fields required to calculate a TCA threshold violation calculation execution
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaExecutionContext {
+
+    /**
+     * Provides request id associated with execution context
+     *
+     * @return request id associated with execution context
+     */
+    String getRequestId();
+
+
+    /**
+     * Provides transaction id associated with execution context
+     *
+     * @return transaction id associated with execution context
+     */
+    String getTransactionId();
+
+
+    /**
+     * Provides message order number inside a execution batch
+     *
+     * @return message order number inside a execution batch
+     */
+    int getMessageIndex();
+
+
+    /**
+     * Provides common event format message as JSON string that is being analyzed
+     *
+     * @return common event format message as JSON string that is being analyzed
+     */
+    String getCefMessage();
+
+
+    /**
+     * Provides TCA Policy associated with the processing context
+     *
+     * @return TCA Policy associated with processing context
+     */
+    TcaPolicy getTcaPolicy();
+
+
+    /**
+     * Provides TCA Processing Context captures various mutable fields that are computed during TCA execution
+     *
+     * @return TCA Processing Context captures various mutable fields that are computed during TCA execution
+     */
+    TcaProcessingContext getTcaProcessingContext();
+
+
+    /**
+     * Provides TCA Processing Result Context which captures outputs of TCA execution
+     *
+     * @return TCA Processing Result Context which captures outputs of TCA execution
+     */
+    TcaResultContext getTcaResultContext();
+
+
+    /**
+     * Provides TCA Abatement context containing abstractions for TCA Abatement processing calculations
+     *
+     * @return TCA abatement context containing abstractions for TCA Abatement processing calculations
+     */
+    TcaAbatementContext getTcaAbatementContext();
+
+
+    /**
+     * Provides TCA AAI Enrichment Context
+     *
+     * @return TCA AAI enrichment context
+     */
+    TcaAaiEnrichmentContext getTcaAaiEnrichmentContext();
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaProcessingContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaProcessingContext.java
new file mode 100644 (file)
index 0000000..69a5ab0
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import org.onap.dcae.analytics.model.cef.EventListener;
+
+/**
+ * TCA Processing Context captures various mutable fields that are computed during TCA execution
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaProcessingContext {
+
+
+    /**
+     * Provides common event format message as JAVA object that is being analyzed
+     *
+     * @return common event format message as JAVA object that is being analyzed
+     */
+    EventListener getEventListener();
+
+
+    /**
+     * Sets new values for common event format message as JAVA object that is being analyzed
+     *
+     * @param eventListener new values for common event format message as JAVA object that is being analyzed
+     */
+    void setEventListener(EventListener eventListener);
+
+
+    /**
+     * Provides flag which is false if TCA processing cannot continue to next stage due to some prior condition
+     *
+     * @return false if TCA processing cannot continue to next stage due to some condition
+     */
+    boolean isContinueProcessing();
+
+    /**
+     * Sets TCA processing continue flag
+     *
+     * @param isContinueProcessing - TCA processing continue flag
+     */
+    void setContinueProcessing(boolean isContinueProcessing);
+
+
+    /**
+     * Provides early termination message message if present or null
+     *
+     * @return early termination message if present or null
+     */
+    String getEarlyTerminationMessage();
+
+    /**
+     * Sets early termination message
+     *
+     * @param earlyTerminationMessage sets a new value for early termination message
+     */
+    void setEarlyTerminationMessage(String earlyTerminationMessage);
+
+
+    /**
+     * Returns error message if present or null
+     *
+     * @return error message if present or null
+     */
+    String getErrorMessage();
+
+    /**
+     * Sets new value for error message
+     *
+     * @param errorMessage new value for error message
+     */
+    void setErrorMessage(final String errorMessage);
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaResultContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaResultContext.java
new file mode 100644 (file)
index 0000000..b166a5f
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.service;
+
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+
+/**
+ * TCA Processing Result Context which captures outputs of TCA Execution
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaResultContext {
+
+    /**
+     * Returns true if Threshold violations are present
+     *
+     * @return true if Threshold violations are present
+     */
+    boolean isThresholdViolationsPresent();
+
+
+    /**
+     * Returns TCA policy's violated metrics per event name that was violated by the incoming message
+     *
+     * @return TCA policy's violated metrics per event name that was violated by the incoming message
+     */
+    MetricsPerEventName getViolatedMetricsPerEventName();
+
+
+    /**
+     * Sets new value for violated metrics per event name that was violated by the incoming message
+     *
+     * @param violatedMetricsPerEventName new value for violated metrics per event name that was violated by the
+     * incoming message
+     */
+    void setViolatedMetricsPerEventName(MetricsPerEventName violatedMetricsPerEventName);
+
+
+    /**
+     * Provides TCA Alert message that is generated if there is any TCA policy's threshold violation
+     *
+     * @return TCA Alert message that is generated if there is any TCA policy's threshold violation
+     */
+    TcaAlert getTcaAlert();
+
+
+    /**
+     * Sets new value for TCA Alert
+     *
+     * @param tcaAlert new value for TCA Alert
+     */
+    void setTcaAlert(TcaAlert tcaAlert);
+
+    /**
+     * Provides previous request id for abated threshold violations if present or null
+     *
+     * @return previous request id for abated threshold violations if present or null
+     */
+    String getPreviousRequestId();
+
+
+    /**
+     * Sets previous request id for abated threshold violations
+     *
+     * @param previousRequestId new value of request id for abated threshold violations
+     */
+    void setPreviousRequestId(String previousRequestId);
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAaiEnrichmentFunction.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAaiEnrichmentFunction.java
new file mode 100644 (file)
index 0000000..27263c8
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.Optional;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.policy.ClosedLoopEventStatus;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAaiEnrichmentFunction implements TcaCalculationFunction {
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        final TcaAaiEnrichmentContext aaiEnrichmentContext = tcaExecutionContext.getTcaAaiEnrichmentContext();
+        final Optional<TcaAlert> tcaAlertOptional =
+                Optional.ofNullable(tcaExecutionContext.getTcaResultContext().getTcaAlert());
+
+        // Skip Aai Enrichment - if aai enrichment is not enabled or no alert is present
+        if (!aaiEnrichmentContext.isAaiEnrichmentEnabled() || !tcaAlertOptional.isPresent()) {
+            return tcaExecutionContext;
+        }
+
+        // Skip Aai Enrichment - if Alert Closed Loop Event status is not ONSET
+        final TcaAlert tcaAlert = tcaAlertOptional.get();
+        final ClosedLoopEventStatus closedLoopEventStatus =
+                ClosedLoopEventStatus.valueOf(tcaAlert.getClosedLoopEventStatus());
+        if (closedLoopEventStatus != ClosedLoopEventStatus.ONSET) {
+            return tcaExecutionContext;
+        }
+
+        // do Aai Enrichment
+        final TcaAaiEnrichmentService aaiEnrichmentService = aaiEnrichmentContext.getAaiEnrichmentService();
+        final TcaAlert enrichedTcaAlert = aaiEnrichmentService.doAaiEnrichment(tcaExecutionContext);
+        tcaExecutionContext.getTcaResultContext().setTcaAlert(enrichedTcaAlert);
+
+        return tcaExecutionContext;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAbatementCalculator.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAbatementCalculator.java
new file mode 100644 (file)
index 0000000..0322456
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.tca.core.exception.TcaProcessingException;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaProcessingContext;
+import org.onap.dcae.analytics.tca.core.service.TcaResultContext;
+import org.onap.dcae.analytics.tca.model.policy.ClosedLoopEventStatus;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+import org.onap.dcae.analytics.tca.model.policy.Threshold;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAbatementCalculator implements TcaCalculationFunction {
+
+    private static final Logger logger = LoggerFactory.getLogger(TcaAbatementCalculator.class);
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        final TcaAbatementContext abatementContext = tcaExecutionContext.getTcaAbatementContext();
+        final TcaAbatementRepository abatementPersistenceContext = abatementContext
+                .getTcaAbatementRepository();
+        final TcaResultContext resultContext = tcaExecutionContext.getTcaResultContext();
+        final TcaProcessingContext processingContext = tcaExecutionContext.getTcaProcessingContext();
+
+
+        // Skip Abatement processing - if it is not enabled
+        if (!abatementContext.isAbatementEnabled() ||
+                // Skip if no threshold violations are present
+                !resultContext.isThresholdViolationsPresent()) {
+            return tcaExecutionContext;
+        }
+
+
+        final EventListener eventListener = processingContext.getEventListener();
+        final MetricsPerEventName violatedMetricsPerEventName = resultContext.getViolatedMetricsPerEventName();
+        final Threshold violatedThreshold = violatedMetricsPerEventName.getThresholds().get(0);
+        final ClosedLoopEventStatus closedLoopEventStatus = violatedThreshold.getClosedLoopEventStatus();
+        final String requestId = tcaExecutionContext.getRequestId();
+        final String lookupKey = createLookupKey(eventListener, violatedMetricsPerEventName);
+
+
+        switch (closedLoopEventStatus) {
+
+            // ONSET - save alert info in database so that next abated event can fetch its request id for abated
+            // alert
+            case ONSET:
+
+                final TcaAbatementEntity tcaAbatementEntity =
+                        abatementContext.create(lookupKey, requestId, false);
+                logger.debug("Request Id: {}. Alert ClosedLoop Status is ONSET. " +
+                                "Saving abatement Entity to repository with lookupKey: {}",
+                        requestId, tcaAbatementEntity.getLookupKey());
+                abatementPersistenceContext.save(tcaAbatementEntity);
+                return tcaExecutionContext;
+
+            // ABATED - look up previous saved request id from db
+            case ABATED:
+
+                final List<TcaAbatementEntity> previousTcaAbatementEntities =
+                        abatementPersistenceContext.findByLookupKey(lookupKey);
+
+                // if previous abatement are indeed present - sort them my last modified date and get latest entity
+                if (previousTcaAbatementEntities != null && !previousTcaAbatementEntities.isEmpty()) {
+                    previousTcaAbatementEntities.sort(
+                            Comparator.comparing(TcaAbatementEntity::getLastModificationDate));
+                    final TcaAbatementEntity previousTcaAbatementEntity =
+                            previousTcaAbatementEntities.get(previousTcaAbatementEntities.size() - 1);
+
+                    logger.debug("Request Id: {}. Found previous Abatement Entity: {}", requestId,
+                            previousTcaAbatementEntity);
+
+                    // previous abatement entity was found - but it was already sent before - so ignore alert creation
+                    if (previousTcaAbatementEntity.isAbatementAlertSent()) {
+                        final String terminatingMessage = "Abatement alert was already sent before on: " +
+                                previousTcaAbatementEntity.getLastModificationDate();
+                        setTerminatingMessage(terminatingMessage, tcaExecutionContext, false);
+                        return tcaExecutionContext;
+                    }
+
+                    // no previous abatement was sent
+                    final String previousRequestId = previousTcaAbatementEntity.getRequestId();
+                    // set abated alert request id to previous ONSET alert request id
+                    logger.debug("Request Id: {}. No previous abated alert was sent. Setting previous request id: {}",
+                            requestId, previousRequestId);
+                    resultContext.setPreviousRequestId(previousRequestId);
+                    // save new entity with alert as sent
+                    final TcaAbatementEntity newTcaAbatementEntity =
+                            abatementContext.create(lookupKey, previousRequestId, true);
+                    logger.debug("Request Id: {}. Saving new entity with alert as sent: {}",
+                            requestId, newTcaAbatementEntity);
+                    abatementPersistenceContext.save(newTcaAbatementEntity);
+                    return tcaExecutionContext;
+
+                } else {
+                    // no previous onset event found
+                    final String terminatingMessage =
+                            "Ignored orphan Abated Message. No previous ONSET event found for lookup key: " + lookupKey;
+                    setTerminatingMessage(terminatingMessage, tcaExecutionContext, false);
+                    return tcaExecutionContext;
+                }
+
+                // Only ONSET and ABATED closed loop status are supported
+            default:
+                final String errorMessage = String.format(
+                        "Request Id: %s. Unexpected ClosedLoopEventStatus: %s - Only ONSET and ABATED are supported.",
+                        requestId, closedLoopEventStatus);
+                throw new TcaProcessingException(errorMessage, new IllegalStateException(errorMessage));
+        }
+
+    }
+
+    private static String createLookupKey(final EventListener eventListener,
+                                          final MetricsPerEventName violatedMetricsPerEventName) {
+        // no null check required as all are required fields
+        final String eventName = violatedMetricsPerEventName.getEventName();
+        final String sourceName = eventListener.getEvent().getCommonEventHeader().getSourceName();
+        final String reportingEntityName = eventListener.getEvent().getCommonEventHeader().getReportingEntityName();
+        // violated threshold will always be present
+        final Threshold violatedThreshold = violatedMetricsPerEventName.getThresholds().get(0);
+        final String closedLoopControlName = violatedThreshold.getClosedLoopControlName();
+        final String fieldPath = violatedThreshold.getFieldPath();
+        return Stream.of(eventName, sourceName, reportingEntityName, closedLoopControlName, fieldPath)
+                .collect(Collectors.joining(TcaModelConstants.TCA_ROW_KEY_DELIMITER));
+
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAlertCreationFunction.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaAlertCreationFunction.java
new file mode 100644 (file)
index 0000000..54ea48d
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.Optional;
+
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.model.cef.CommonEventHeader;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaResultContext;
+import org.onap.dcae.analytics.tca.model.facade.Aai;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.policy.ClosedLoopEventStatus;
+import org.onap.dcae.analytics.tca.model.policy.ControlLoopSchemaType;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+import org.onap.dcae.analytics.tca.model.policy.Threshold;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAlertCreationFunction implements TcaCalculationFunction {
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        // get violated metrics per event name
+        final Optional<MetricsPerEventName> violatedMetricsPerEventNameOptional =
+                Optional.ofNullable(tcaExecutionContext.getTcaResultContext())
+                        .map(TcaResultContext::getViolatedMetricsPerEventName);
+
+        // If no violated metrics per event name is present skip alert creation
+        if (!violatedMetricsPerEventNameOptional.isPresent()) {
+            return tcaExecutionContext;
+        }
+
+        final TcaResultContext resultContext = tcaExecutionContext.getTcaResultContext();
+
+        // Request id should be set to previous request id for abated events if present
+        final String requestId = Optional.ofNullable(resultContext.getPreviousRequestId())
+                .orElse(tcaExecutionContext.getRequestId());
+
+        // create new tca alert
+        final TcaAlert tcaAlert = createNewTcaAlert(requestId, tcaExecutionContext.getTcaProcessingContext()
+                .getEventListener(), violatedMetricsPerEventNameOptional.get());
+
+        // update tca processing result context with alert message
+        tcaExecutionContext.getTcaResultContext().setTcaAlert(tcaAlert);
+
+        return tcaExecutionContext;
+    }
+
+    private static TcaAlert createNewTcaAlert(final String requestId,
+                                              final EventListener eventListener,
+                                              final MetricsPerEventName violatedMetricsPerEventName) {
+        final Threshold violatedThreshold = violatedMetricsPerEventName.getThresholds().get(0);
+        final CommonEventHeader commonEventHeader = eventListener.getEvent().getCommonEventHeader();
+
+        final TcaAlert tcaAlert = new TcaAlert();
+        // ClosedLoopControlName included in the DCAE configuration Policy
+        tcaAlert.setClosedLoopControlName(violatedThreshold.getClosedLoopControlName());
+        // version included in the DCAE configuration Policy
+        tcaAlert.setVersion(violatedThreshold.getVersion());
+        // request id
+        tcaAlert.setRequestId(requestId);
+        // commonEventHeader.startEpochMicrosec from the received VES message
+        tcaAlert.setClosedLoopAlarmStart(commonEventHeader.getStartEpochMicrosec());
+        // commonEventHeader.lastEpochMicrosec from the received VES message for abated alerts
+        if (violatedThreshold.getClosedLoopEventStatus() == ClosedLoopEventStatus.ABATED) {
+            tcaAlert.setClosedLoopAlarmEnd(commonEventHeader.getLastEpochMicrosec());
+        }
+        // get service name
+        tcaAlert.setClosedLoopEventClient(TcaModelConstants.TCA_SERVICE_NAME);
+
+        final Aai aai = new Aai();
+        tcaAlert.setAai(aai);
+
+        // VM specific settings
+        if (violatedMetricsPerEventName.getControlLoopSchemaType() == ControlLoopSchemaType.VM) {
+            // Hard Coded - "VM"
+            tcaAlert.setTargetType(TcaModelConstants.TCA_ALERT_VM_TARGET_TYPE);
+            // Hard Coded - "vserver.vserver-name"
+            tcaAlert.setTarget(TcaModelConstants.TCA_ALERT_VM_TARGET);
+            // commonEventHeader.sourceName from the received VES message
+            aai.setGenericServerName(commonEventHeader.getSourceName());
+        } else {
+            // VNF specific settings
+            // Hard Coded - "VNF"
+            tcaAlert.setTargetType(TcaModelConstants.TCA_ALERT_VNF_TARGET_TYPE);
+            // Hard Coded - "generic-vnf.vnf-name"
+            tcaAlert.setTarget(TcaModelConstants.TCA_ALERT_VNF_TARGET);
+            // commonEventHeader.sourceName from the received VES message
+            aai.setGenericVNFName(commonEventHeader.getSourceName());
+        }
+
+        // Hard Coded - "DCAE"
+        tcaAlert.setFrom(TcaModelConstants.TCA_VES_RESPONSE_FROM);
+        // policyScope included in the DCAE configuration Policy
+        tcaAlert.setPolicyScope(violatedMetricsPerEventName.getPolicyScope());
+        // policyName included in the DCAE configuration Policy
+        tcaAlert.setPolicyName(violatedMetricsPerEventName.getPolicyName());
+        // policyVersion included in the DCAE configuration Policy
+        tcaAlert.setPolicyVersion(violatedMetricsPerEventName.getPolicyVersion());
+        // Extracted from violated threshold
+        tcaAlert.setClosedLoopEventStatus(violatedThreshold.getClosedLoopEventStatus().name());
+
+        // return new tca Alert
+        return tcaAlert;
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculationFunction.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculationFunction.java
new file mode 100644 (file)
index 0000000..ec9f7bd
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.function.Function;
+
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaProcessingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Functional interface which all TCA calculation functions should implement
+ *
+ * @author Rajiv Singla
+ */
+@FunctionalInterface
+public interface TcaCalculationFunction extends Function<TcaExecutionContext, TcaExecutionContext> {
+
+    Logger logger = LoggerFactory.getLogger(TcaCalculationFunction.class);
+
+    TcaExecutionContext calculate(TcaExecutionContext tcaExecutionContext);
+
+
+    default TcaExecutionContext preCalculation(TcaExecutionContext tcaExecutionContext) {
+        // do nothing
+        return tcaExecutionContext;
+    }
+
+    default TcaExecutionContext postCalculation(TcaExecutionContext tcaExecutionContext) {
+        // do nothing
+        return tcaExecutionContext;
+    }
+
+    @Override
+    default TcaExecutionContext apply(TcaExecutionContext tcaExecutionContext) {
+        // triggers pre calculate, calculate nad post calculate
+        return postCalculation(calculate(preCalculation(tcaExecutionContext)));
+    }
+
+    /**
+     * Updates TCA Processing context with early terminating message or error message
+     *
+     * @param terminatingMessage terminating message to be set in processing context
+     * @param tcaExecutionContext current tca execution context
+     * @param isErrorMessage specifies if terminating message is an error message
+     *
+     * @return updated tca execution context with early termination or error message and continue processing flag as
+     * false
+     */
+    default TcaExecutionContext setTerminatingMessage(final String terminatingMessage,
+                                                      final TcaExecutionContext tcaExecutionContext,
+                                                      final boolean isErrorMessage) {
+        final TcaProcessingContext tcaProcessingContext = tcaExecutionContext.getTcaProcessingContext();
+        if (isErrorMessage) {
+            logger.error("Request Id: {}. Error Message: {}", tcaExecutionContext.getRequestId(), terminatingMessage);
+            tcaProcessingContext.setErrorMessage(terminatingMessage);
+        } else {
+            logger.debug("Request Id: {}. Early Termination Message: {}", tcaExecutionContext.getRequestId(),
+                    terminatingMessage);
+            tcaProcessingContext.setEarlyTerminationMessage(terminatingMessage);
+        }
+        tcaProcessingContext.setContinueProcessing(false);
+        return tcaExecutionContext;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculator.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculator.java
new file mode 100644 (file)
index 0000000..d404ffe
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+
+/**
+ * TCA Calculator combines all TCA calculation functions into one single function
+ *
+ * @author Rajiv Singla
+ */
+public class TcaCalculator implements TcaCalculationFunction {
+
+    private static final List<TcaCalculationFunction> TCA_CALCULATOR_FUNCTIONS_CHAIN =
+            Stream.of(
+                    new TcaEventListenerExtractor(),
+                    new TcaDomainFilter(),
+                    new TcaEventNameFilter(),
+                    new TcaThresholdViolationCalculator(),
+                    new TcaAbatementCalculator(),
+                    new TcaAlertCreationFunction(),
+                    new TcaAaiEnrichmentFunction()).collect(Collectors.toList());
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        TcaExecutionContext accumulator = tcaExecutionContext;
+
+        for (TcaCalculationFunction tcaCalculationFunction : TCA_CALCULATOR_FUNCTIONS_CHAIN) {
+            if (!accumulator.getTcaProcessingContext().isContinueProcessing()) {
+                // do early termination
+                break;
+            } else {
+                accumulator = tcaCalculationFunction.apply(accumulator);
+            }
+        }
+        return accumulator;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaDomainFilter.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaDomainFilter.java
new file mode 100644 (file)
index 0000000..a54b615
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.Optional;
+
+import org.onap.dcae.analytics.model.cef.CommonEventHeader;
+import org.onap.dcae.analytics.model.cef.Domain;
+import org.onap.dcae.analytics.model.cef.Event;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaProcessingContext;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaDomainFilter implements TcaCalculationFunction {
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        final TcaProcessingContext tcaProcessingContext = tcaExecutionContext.getTcaProcessingContext();
+        final String cefMessage = tcaExecutionContext.getCefMessage();
+
+        // Extract CEF domain as it is must be present as per CEF Schema
+        final Optional<Domain> domainOptional = Optional.ofNullable(tcaProcessingContext.getEventListener())
+                .map(EventListener::getEvent)
+                .map(Event::getCommonEventHeader)
+                .map(CommonEventHeader::getDomain);
+
+        // Check domain is present
+        if (!domainOptional.isPresent()) {
+            final String errorMessage =
+                    "Event -> Common Event Header -> Domain not present. Invalid CEF Message: " + cefMessage;
+            setTerminatingMessage(errorMessage, tcaExecutionContext, true);
+            return tcaExecutionContext;
+        }
+
+        // Get Policy and CEF Message Domain
+        final String policyDomain = tcaExecutionContext.getTcaPolicy().getDomain();
+        final String cefMessageDomain = domainOptional.get().name();
+
+        // Check Policy domain matches CEF message domain
+        if (!policyDomain.equalsIgnoreCase(cefMessageDomain)) {
+            final String earlyTerminationMessage = String.format(
+                    "Policy Domain does not match CEF Message Domain. Policy Domain: %s, CEF  Message Domain: %s",
+                    policyDomain, cefMessageDomain);
+            setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false);
+            return tcaExecutionContext;
+        }
+
+
+        // Policy Domain and CEF Message Domain match successful
+        // do nothing
+
+        return tcaExecutionContext;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventListenerExtractor.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventListenerExtractor.java
new file mode 100644 (file)
index 0000000..b194da8
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.Optional;
+
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+
+/**
+ * Tca Event Listener Calculation Function converts incoming CEF string message
+ * to Java Object of type Event Listener
+ *
+ * @author Rajiv Singla
+ */
+public class TcaEventListenerExtractor implements TcaCalculationFunction {
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        final String cefMessage = tcaExecutionContext.getCefMessage();
+
+        // Check blank message
+        if (cefMessage == null || cefMessage.isEmpty() || cefMessage.trim().isEmpty()) {
+            final String errorMessage = "Blank CEF message cannot be converted to CEF Event Listener Object";
+            setTerminatingMessage(errorMessage, tcaExecutionContext, true);
+            return tcaExecutionContext;
+        }
+
+
+        // Check CEF message is a valid JSON Object
+        final String trimmedMessage = cefMessage.trim();
+        if (!(trimmedMessage.startsWith("{") && trimmedMessage.endsWith("}"))) {
+            final String errorMessage =
+                    "CEF Message must be a JSON object starting and ending with curly braces. Invalid JSON String: " +
+                            cefMessage;
+            setTerminatingMessage(errorMessage, tcaExecutionContext, true);
+            return tcaExecutionContext;
+        }
+
+        // Parse CEF message as JSON Object
+        final Optional<EventListener> eventListenerOptional =
+                AnalyticsModelJsonConversion.EVENT_LISTENER_JSON_FUNCTION.apply(cefMessage);
+
+        if (!eventListenerOptional.isPresent()) {
+            final String errorMessage =
+                    "Unable to parse given CEF Message as JSON Object. CEF Message String: " + cefMessage;
+            setTerminatingMessage(errorMessage, tcaExecutionContext, true);
+            return tcaExecutionContext;
+        }
+
+
+        // JSON parsing completed successfully
+        tcaExecutionContext.getTcaProcessingContext().setEventListener(eventListenerOptional.get());
+
+        return tcaExecutionContext;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventNameFilter.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventNameFilter.java
new file mode 100644 (file)
index 0000000..574e9ba
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.cef.CommonEventHeader;
+import org.onap.dcae.analytics.model.cef.Event;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaEventNameFilter implements TcaCalculationFunction {
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        final String cefMessage = tcaExecutionContext.getCefMessage();
+        final EventListener eventListener = tcaExecutionContext.getTcaProcessingContext().getEventListener();
+
+        final Optional<String> eventNameOptional = Optional.ofNullable(eventListener)
+                .map(EventListener::getEvent)
+                .map(Event::getCommonEventHeader)
+                .map(CommonEventHeader::getEventName);
+
+        // Check Event name is present
+        if (!eventNameOptional.isPresent()) {
+            final String errorMessage =
+                    "Event -> Common Event Header -> Event Name not present. Invalid CEF Message: " + cefMessage;
+            setTerminatingMessage(errorMessage, tcaExecutionContext, true);
+            return tcaExecutionContext;
+        }
+
+        // Get CEF Message Event name and Event names in tca policy
+        final String cefMessageEventName = eventNameOptional.get();
+        final TcaPolicy tcaPolicy = tcaExecutionContext.getTcaPolicy();
+        final Set<String> policyEventNames = tcaPolicy.getMetricsPerEventName().stream()
+                .map(MetricsPerEventName::getEventName).collect(Collectors.toSet());
+
+        // Check CEF Message Event name matches any Policy Event names
+        if (!policyEventNames.contains(cefMessageEventName)) {
+            final String earlyTerminationMessage = String.format(
+                    "CEF Message Event name does not match any Policy Event Names. " +
+                            "Message EventName: %s, Policy Event Names: %s", cefMessageEventName, policyEventNames);
+            setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false);
+            return tcaExecutionContext;
+        }
+
+        // CEF Messages one of the the Policy Event names
+        // do nothing
+
+        return tcaExecutionContext;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaThresholdViolationCalculator.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaThresholdViolationCalculator.java
new file mode 100644 (file)
index 0000000..053fcab
--- /dev/null
@@ -0,0 +1,270 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import com.jayway.jsonpath.DocumentContext;
+import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.TypeRef;
+
+import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nonnull;
+
+import org.onap.dcae.analytics.model.cef.CommonEventHeader;
+import org.onap.dcae.analytics.model.cef.Event;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.tca.core.exception.TcaProcessingException;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaResultContext;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.policy.Threshold;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaThresholdViolationCalculator implements TcaCalculationFunction {
+
+    @Override
+    public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) {
+
+        final String cefMessage = tcaExecutionContext.getCefMessage();
+        final EventListener eventListener = tcaExecutionContext.getTcaProcessingContext().getEventListener();
+        final TcaPolicy tcaPolicy = tcaExecutionContext.getTcaPolicy();
+
+        // Get CEF Event Name
+        final String cefEventName = Optional.ofNullable(eventListener)
+                .map(EventListener::getEvent)
+                .map(Event::getCommonEventHeader)
+                .map(CommonEventHeader::getEventName)
+                .orElseThrow(() -> new TcaProcessingException("Required Field: EventName not present"));
+
+        // Get Policy's metrics per event name matching CEF message event name
+        final MetricsPerEventName policyMetricsPerEventName =
+                tcaPolicy.getMetricsPerEventName().stream()
+                        .filter(m -> m.getEventName().equalsIgnoreCase(cefEventName))
+                        .findFirst().orElseThrow(() ->
+                        new TcaProcessingException("Required Field: MetricsPerEventName not present"));
+
+
+        // get violated policy threshold for cef event name sorted by severity
+        final Optional<Threshold> thresholdOptional =
+                getViolatedThreshold(policyMetricsPerEventName.getThresholds(), cefMessage);
+
+
+        // Check if threshold violation is present
+        if (!thresholdOptional.isPresent()) {
+            final String earlyTerminationMessage = "No Policy Threshold violation detected in CEF Message";
+            setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false);
+            return tcaExecutionContext;
+        }
+
+
+        // Threshold violations are present - update tca processing result context
+        final MetricsPerEventName violatedMetricsPerEventName = copyMetricsPerEventName(policyMetricsPerEventName);
+        final Threshold violatedThreshold = thresholdOptional.get();
+        violatedMetricsPerEventName.setThresholds(Collections.singletonList(violatedThreshold));
+        final TcaResultContext tcaResultContext =
+                tcaExecutionContext.getTcaResultContext();
+        tcaResultContext.setViolatedMetricsPerEventName(violatedMetricsPerEventName);
+
+        return tcaExecutionContext;
+    }
+
+
+    /**
+     * Provides violated threshold
+     *
+     * @param policyThresholds policy thresholds that need to applied to incoming cef message
+     * @param cefMessage incoming cef message
+     *
+     * @return list of all violated threshold
+     */
+    private static Optional<Threshold> getViolatedThreshold(final List<Threshold> policyThresholds,
+                                                            final String cefMessage) {
+
+        // map containing key as field path and associated policy thresholds
+        final Map<String, List<Threshold>> policyFieldPathsMap = new LinkedHashMap<>();
+        for (final Threshold policyThreshold : policyThresholds) {
+            if (policyFieldPathsMap.get(policyThreshold.getFieldPath()) == null) {
+                final LinkedList<Threshold> policyThresholdList = new LinkedList<>();
+                policyThresholdList.add(policyThreshold);
+                policyFieldPathsMap.put(policyThreshold.getFieldPath(), policyThresholdList);
+            } else {
+                policyFieldPathsMap.get(policyThreshold.getFieldPath()).add(policyThreshold);
+            }
+        }
+
+        // get map containing key as field path and values for json path
+        final Map<String, List<BigDecimal>> messageFieldValuesMap =
+                getJsonPathValues(cefMessage, policyFieldPathsMap.keySet());
+
+        // if no matching path values - assuming no threshold violations
+        if (messageFieldValuesMap.isEmpty()) {
+            return Optional.empty();
+        }
+
+        // Determine all violated thresholds per message field Path
+        final Map<String, Threshold> violatedThresholdsMap = new HashMap<>();
+        for (Map.Entry<String, List<BigDecimal>> messageFieldValuesMapEntry : messageFieldValuesMap.entrySet()) {
+            final String messageFieldPath = messageFieldValuesMapEntry.getKey();
+            final List<Threshold> messageFieldAssociatedPolicyThresholds = policyFieldPathsMap.get(messageFieldPath);
+            if (messageFieldAssociatedPolicyThresholds != null) {
+                final Optional<Threshold> thresholdOptional = computeViolatedThreshold(
+                        messageFieldValuesMapEntry.getValue(), messageFieldAssociatedPolicyThresholds);
+                thresholdOptional.ifPresent(threshold -> violatedThresholdsMap.put(messageFieldPath, threshold));
+            }
+        }
+
+        // if multiple fields have violated threshold - grab the first one with max severity
+        return violatedThresholdsMap.values().stream()
+                .sorted(Comparator.comparing(Threshold::getSeverity)).findFirst();
+
+    }
+
+    /**
+     * Computes if any CEF Message Fields have violated any Policy Thresholds. For the same policy field path
+     * it applies threshold in order of their severity and then by direction and returns first violated threshold
+     *
+     * @param messageFieldValues Field Path Values extracted from CEF Message
+     * @param fieldThresholds Policy Thresholds for Field Path
+     *
+     * @return Optional of violated threshold for a field path
+     */
+    private static Optional<Threshold> computeViolatedThreshold(final List<BigDecimal> messageFieldValues,
+                                                                final List<Threshold> fieldThresholds) {
+
+        // sort thresholds based on severity and then based on direction
+        final List<Threshold> sortedPolicyThresholds = fieldThresholds.stream()
+                .sorted((t1, t2) -> {
+                    if (t1.getSeverity().compareTo(t2.getSeverity()) != 0) {
+                        return t1.getSeverity().compareTo(t2.getSeverity());
+                    } else {
+                        return t1.getDirection().compareTo(t2.getDirection());
+                    }
+                })
+                .collect(Collectors.toList());
+
+        // Now apply each threshold to field values
+        for (final Threshold policyThreshold : sortedPolicyThresholds) {
+            for (final BigDecimal messageFieldValue : messageFieldValues) {
+                final Boolean isThresholdViolated =
+                        policyThreshold.getDirection().operate(messageFieldValue,
+                                new BigDecimal(policyThreshold.getThresholdValue()));
+                if (isThresholdViolated) {
+                    final Threshold violatedThreshold = copyThreshold(policyThreshold);
+                    violatedThreshold.setActualFieldValue(messageFieldValue);
+                    return Optional.of(violatedThreshold);
+                }
+            }
+        }
+        return Optional.empty();
+    }
+
+    /**
+     * Extracts json path values for given json Field Path from using Json path notation.
+     *
+     * @param message CEF Message
+     * @param jsonFieldPaths Json Field Paths
+     *
+     * @return Map containing key as json path and values as values associated with that json path
+     */
+    private static Map<String, List<BigDecimal>> getJsonPathValues(@Nonnull String message,
+                                                                   @Nonnull Set<String> jsonFieldPaths) {
+
+        final Map<String, List<BigDecimal>> jsonFieldPathMap = new HashMap<>();
+        final DocumentContext documentContext = JsonPath.parse(message);
+
+        for (String jsonFieldPath : jsonFieldPaths) {
+            List<BigDecimal> jsonFieldValues;
+
+            try {
+                jsonFieldValues = documentContext.read(jsonFieldPath, new TypeRef<List<BigDecimal>>() {
+                });
+            } catch (Exception e) {
+                final String errorMessage = String.format(
+                        "Unable to convert jsonFieldPath value to valid number." +
+                                "Json Path: %s.Incoming message: %s", jsonFieldPath, message);
+                throw new TcaProcessingException(errorMessage, e);
+            }
+            // If Json Field Values are present
+            if (jsonFieldValues != null && !jsonFieldValues.isEmpty()) {
+                // Filter out all null values in the filed values list
+                final List<BigDecimal> nonNullValues =
+                        jsonFieldValues.stream().filter(Objects::nonNull).collect(Collectors.toList());
+                // If there are non null values put them in the map
+                if (!nonNullValues.isEmpty()) {
+                    jsonFieldPathMap.put(jsonFieldPath, nonNullValues);
+                }
+            }
+        }
+
+        return jsonFieldPathMap;
+    }
+
+    /**
+     * Creates a new threshold hold object by copying the value of given threshold object
+     *
+     * @param threshold threshold that needs to be copied
+     *
+     * @return new threshold object which is copy of given threshold object
+     */
+    private static Threshold copyThreshold(final Threshold threshold) {
+        final Threshold copyThreshold = new Threshold();
+        copyThreshold.setClosedLoopControlName(threshold.getClosedLoopControlName());
+        copyThreshold.setClosedLoopEventStatus(threshold.getClosedLoopEventStatus());
+        copyThreshold.setVersion(threshold.getVersion());
+        copyThreshold.setFieldPath(threshold.getFieldPath());
+        copyThreshold.setThresholdValue(threshold.getThresholdValue());
+        copyThreshold.setDirection(threshold.getDirection());
+        copyThreshold.setSeverity(threshold.getSeverity());
+        return copyThreshold;
+    }
+
+    /**
+     * Returns a copy of metric Per event name without copying thresholds
+     *
+     * @param metricsPerEventName metric per event name that needs to be copied
+     *
+     * @return new metric per event name object which is copy of given object
+     */
+    private static MetricsPerEventName copyMetricsPerEventName(final MetricsPerEventName metricsPerEventName) {
+        final MetricsPerEventName copyMetricsPerEventName = new MetricsPerEventName();
+        copyMetricsPerEventName.setEventName(metricsPerEventName.getEventName());
+        copyMetricsPerEventName.setControlLoopSchemaType(metricsPerEventName.getControlLoopSchemaType());
+        copyMetricsPerEventName.setPolicyScope(metricsPerEventName.getPolicyScope());
+        copyMetricsPerEventName.setPolicyName(metricsPerEventName.getPolicyName());
+        copyMetricsPerEventName.setPolicyVersion(metricsPerEventName.getPolicyVersion());
+        // no thresholds copied
+        return copyMetricsPerEventName;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/BaseTcaCoreTest.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/BaseTcaCoreTest.java
new file mode 100644 (file)
index 0000000..0d32190
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core;
+
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion;
+import org.onap.dcae.analytics.tca.core.domain.TestTcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.domain.TestTcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaExecutionContext.GenericTcaExecutionContextBuilder;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaProcessingContext;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaResultContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaProcessingContext;
+import org.onap.dcae.analytics.tca.core.service.TcaResultContext;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion;
+import org.onap.dcae.analytics.test.BaseAnalyticsUnitTest;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class BaseTcaCoreTest extends BaseAnalyticsUnitTest {
+
+
+    protected static final String TEST_POLICY_JSON_STRING;
+    protected static final String TEST_CEF_EVENT_LISTENER_STRING;
+    protected static final String TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING;
+    protected static final String TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING;
+    protected static final String TEST_CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME;
+    protected static final String TEST_REQUEST_ID = "testRequestId";
+    protected static final TcaPolicy TEST_TCA_POLICY;
+
+    static {
+
+        TEST_POLICY_JSON_STRING = fromStream(TestFileLocation.TCA_POLICY_JSON);
+        TEST_CEF_EVENT_LISTENER_STRING = fromStream(TestFileLocation.CEF_JSON_MESSAGE);
+        TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING = fromStream(TestFileLocation.CEF_JSON_MESSAGE_WITH_VIOLATION);
+        TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING = fromStream(TestFileLocation.CEF_JSON_MESSAGE_WITH_ABATEMENT);
+        TEST_CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME = fromStream(TestFileLocation
+                .CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME);
+        TEST_TCA_POLICY = TcaModelJsonConversion.TCA_POLICY_JSON_FUNCTION.apply(TEST_POLICY_JSON_STRING)
+                .orElseThrow(() -> new IllegalStateException("Unable to get Test TcaPolicy"));
+    }
+
+    /**
+     * Provides Event Listener that can be used for testing purposes
+     *
+     * @return test Event Listener
+     */
+    protected EventListener getTestEventListener() {
+        return AnalyticsModelJsonConversion.EVENT_LISTENER_JSON_FUNCTION
+                .apply(TEST_CEF_EVENT_LISTENER_STRING)
+                .orElseThrow(() -> new IllegalStateException("Unable to get Test CEF Event Listener"));
+    }
+
+    /**
+     * Provides Event Listener with violation that can be used for testing purposes
+     *
+     * @return test Event Listener with violation
+     */
+    protected EventListener getTestEventListenerWithViolation() {
+        return AnalyticsModelJsonConversion.EVENT_LISTENER_JSON_FUNCTION
+                .apply(TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING)
+                .orElseThrow(() -> new IllegalStateException("Unable to get Test CEF Event Listeners with violation"));
+    }
+
+
+    /**
+     * Provides Event Listener with abatement that can be used for testing purposes
+     *
+     * @return test Event Listener with abatement
+     */
+    protected EventListener getTestEventListenerWithAbatement() {
+        return AnalyticsModelJsonConversion.EVENT_LISTENER_JSON_FUNCTION
+                .apply(TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING)
+                .orElseThrow(() -> new IllegalStateException("Unable to get Test CEF Event Listeners with abatement"));
+    }
+
+
+    protected TcaExecutionContext getTestExecutionContext(final String cefMessage) {
+        final TestTcaAbatementContext testTcaAbatementContext = new TestTcaAbatementContext();
+        return getTestExecutionContextBuilder(cefMessage, TEST_TCA_POLICY, testTcaAbatementContext).build();
+    }
+
+    protected GenericTcaExecutionContextBuilder getTestExecutionContextBuilder(
+            final String cefMessage, final TcaPolicy tcaPolicy, final TcaAbatementContext tcaAbatementContext) {
+
+        final TcaProcessingContext tcaProcessingContext = new GenericTcaProcessingContext();
+        final TcaResultContext tcaResultContext = new GenericTcaResultContext();
+        final TestTcaAaiEnrichmentContext testTcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext();
+
+        return GenericTcaExecutionContext.builder()
+                .requestId(TEST_REQUEST_ID)
+                .cefMessage(cefMessage)
+                .tcaPolicy(tcaPolicy)
+                .tcaProcessingContext(tcaProcessingContext)
+                .tcaResultContext(tcaResultContext)
+                .tcaAbatementContext(tcaAbatementContext)
+                .tcaAaiEnrichmentContext(testTcaAaiEnrichmentContext);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAaiEnrichmentContext.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAaiEnrichmentContext.java
new file mode 100644 (file)
index 0000000..db54a84
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.domain;
+
+import lombok.Data;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAaiEnrichmentContext implements TcaAaiEnrichmentContext {
+
+    private boolean isAaiEnrichmentEnabled = true;
+    private TcaAaiEnrichmentService aaiEnrichmentService = new TestTcaAaiEnrichmentService();
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAaiEnrichmentService.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAaiEnrichmentService.java
new file mode 100644 (file)
index 0000000..2352f50
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.domain;
+
+import lombok.Data;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAaiEnrichmentService implements TcaAaiEnrichmentService {
+
+    private TcaAlert enrichedTcaAlert;
+
+    @Override
+    public TcaAlert doAaiEnrichment(final TcaExecutionContext tcaExecutionContext) {
+        final TcaAlert tcaAlert = tcaExecutionContext.getTcaResultContext().getTcaAlert();
+        return enrichedTcaAlert == null ? tcaAlert : enrichedTcaAlert;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementContext.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementContext.java
new file mode 100644 (file)
index 0000000..6a456b0
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.domain;
+
+import lombok.Data;
+
+import java.util.Date;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAbatementContext implements TcaAbatementContext {
+
+    private boolean isAbatementEnabled = true;
+    private TcaAbatementRepository tcaAbatementRepository = new TestTcaAbatementRepository();
+
+
+    @Override
+    public TcaAbatementEntity create(
+            final String lookupKey, final String requestId, final boolean isAbatementAlertSent) {
+        return new TestTcaAbatementEntity(new Date(), lookupKey, requestId, isAbatementAlertSent);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementEntity.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementEntity.java
new file mode 100644 (file)
index 0000000..3e11405
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.Date;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+@AllArgsConstructor
+public class TestTcaAbatementEntity implements TcaAbatementEntity {
+
+    private Date lastModificationDate;
+    private String lookupKey;
+    private String requestId;
+    private boolean isAbatementAlertSent;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementRepository.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/domain/TestTcaAbatementRepository.java
new file mode 100644 (file)
index 0000000..a55422a
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.domain;
+
+import lombok.Data;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TestTcaAbatementRepository implements TcaAbatementRepository {
+
+    private List<TcaAbatementEntity> testLookupAbatementEntities = new LinkedList<>();
+
+    @Override
+    public void save(final TcaAbatementEntity tcaAbatementEntity) {
+        // do nothing
+    }
+
+    @Override
+    public List<TcaAbatementEntity> findByLookupKey(final String lookUpKey) {
+        return testLookupAbatementEntities;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculatorTest.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaCalculatorTest.java
new file mode 100644 (file)
index 0000000..d8fe043
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.core.util.function.calculation;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Collections;
+import java.util.Date;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.tca.core.BaseTcaCoreTest;
+import org.onap.dcae.analytics.tca.core.domain.TestTcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.domain.TestTcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.domain.TestTcaAbatementRepository;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+
+
+/**
+ * @author Rajiv Singla
+ */
+class TcaCalculatorTest extends BaseTcaCoreTest {
+
+    @Test
+    @DisplayName("Test TCA calculator with CEF Message without violation")
+    void testCEFMessageWithoutViolation() {
+        final TcaExecutionContext testExecutionContext =
+                getTestExecutionContext(TEST_CEF_EVENT_LISTENER_STRING);
+        final TcaExecutionContext result = new TcaCalculator().apply(testExecutionContext);
+        assertThat(result.getTcaProcessingContext().isContinueProcessing()).isFalse();
+        assertThat(result.getTcaProcessingContext().getErrorMessage()).isNull();
+        final String earlyTerminationMessage = result.getTcaProcessingContext().getEarlyTerminationMessage();
+        assertThat(earlyTerminationMessage).isNotNull();
+        logger.debug(earlyTerminationMessage);
+        assertThat(result.getTcaResultContext().isThresholdViolationsPresent()).isFalse();
+    }
+
+    @Test
+    @DisplayName("Test TCA calculator with CEF Message with violation")
+    void testCEFMessageWithViolation() {
+        final TcaExecutionContext testExecutionContext =
+                getTestExecutionContext(TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING);
+        final TcaExecutionContext result = new TcaCalculator().apply(testExecutionContext);
+        assertThat(result.getTcaProcessingContext().isContinueProcessing()).isTrue();
+        assertThat(result.getTcaResultContext().isThresholdViolationsPresent()).isTrue();
+        assertThat(result.getTcaResultContext().getTcaAlert().getRequestId()).isEqualTo(TEST_REQUEST_ID);
+    }
+
+
+    @Test
+    @DisplayName("Test TCA calculator with Abatement")
+    void testCEFMessageWithAbatement() {
+        final TestTcaAbatementContext testTcaAbatementContext = new TestTcaAbatementContext();
+        final TestTcaAbatementRepository testAbatementPersistenceContext =
+                (TestTcaAbatementRepository) testTcaAbatementContext.getTcaAbatementRepository();
+        final String previousRequestId = "previousRequestId";
+        final TestTcaAbatementEntity testTcaAbatementPersistenceEntity
+                = new TestTcaAbatementEntity(new Date(), "", previousRequestId, false);
+        testAbatementPersistenceContext.setTestLookupAbatementEntities(
+                Collections.singletonList(testTcaAbatementPersistenceEntity));
+
+        final TcaExecutionContext testExecutionContext =
+                getTestExecutionContextBuilder(TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING,
+                        TEST_TCA_POLICY, testTcaAbatementContext).build();
+
+        final TcaExecutionContext result = new TcaCalculator().apply(testExecutionContext);
+        assertThat(result.getTcaResultContext().getTcaAlert().getRequestId()).isEqualTo(previousRequestId);
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/pom.xml b/dcae-analytics/dcae-analytics-tca-model/pom.xml
new file mode 100644 (file)
index 0000000..71e05a6
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.dcaegen2.analytics</groupId>
+        <artifactId>dcae-analytics</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dcae-analytics-tca-model</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- THIS MODULE CONTAINS TCA MODELS -->
+    <name>DCAE Analytics TCA Model</name>
+    <description>Contains models for TCA (Threshold Crossing Alert) micro service</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+    </properties>
+
+
+    <dependencies>
+
+        <!-- PROJECT DEPENDENCIES-->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-model</artifactId>
+        </dependency>
+
+        <!-- CODE GENERATION -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- TEST DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-test</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/TcaModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/TcaModel.java
new file mode 100644 (file)
index 0000000..e4a1415
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model;
+
+import org.onap.dcae.analytics.model.AnalyticsModel;
+
+/**
+ * Marker interface for all TCA Models
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaModel extends AnalyticsModel {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java
new file mode 100644 (file)
index 0000000..796587b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.facade;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class Aai extends BaseDynamicPropertiesProvider implements TcaFacadeModel {
+
+    private static final long serialVersionUID = 1L;
+
+    private String genericVNFName;
+
+    private String genericServerName;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaAlert.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaAlert.java
new file mode 100644 (file)
index 0000000..a6cc8e0
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.facade;
+
+import lombok.Data;
+
+/**
+ * Alert message generated by TCA due to threshold violation
+ *
+ * @author Rajiv Singla
+ */
+@Data
+public class TcaAlert implements TcaFacadeModel {
+
+    private static final long serialVersionUID = 1L;
+
+    private Aai aai;
+    private Long closedLoopAlarmEnd;
+    private Long closedLoopAlarmStart;
+    private String closedLoopControlName;
+    private String closedLoopEventClient;
+    private String closedLoopEventStatus;
+    private String from;
+    private String policyName;
+    private String policyScope;
+    private String policyVersion;
+    private String requestId;
+    private String target;
+    private String targetType;
+    private String version;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaFacadeModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaFacadeModel.java
new file mode 100644 (file)
index 0000000..321ee74
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.facade;
+
+
+import org.onap.dcae.analytics.model.facade.AnalyticsFacadeModel;
+import org.onap.dcae.analytics.tca.model.TcaModel;
+
+/**
+ * Marker Interface for all TCA Facade Models
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaFacadeModel extends TcaModel, AnalyticsFacadeModel {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/BaseTcaPolicyModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/BaseTcaPolicyModel.java
new file mode 100644 (file)
index 0000000..d000ae0
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider;
+
+/**
+ * A Base TCA Policy Model which accumulates all dynamic properties in a dynamicProperties Map
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public abstract class BaseTcaPolicyModel extends BaseDynamicPropertiesProvider implements TcaPolicyModel {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ClosedLoopEventStatus.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ClosedLoopEventStatus.java
new file mode 100644 (file)
index 0000000..a36b705
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+
+/**
+ * TCA Policy Closed Loop Event Status
+ *
+ * @author Rajiv Singla
+ */
+public enum ClosedLoopEventStatus implements TcaPolicyModel {
+
+    ONSET,
+    ABATED,
+    CONTINUE;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ControlLoopSchemaType.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ControlLoopSchemaType.java
new file mode 100644 (file)
index 0000000..914d88c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+
+/**
+ * Control Loop Schema Type
+ *
+ * @author Rajiv Singla
+ */
+public enum ControlLoopSchemaType implements TcaPolicyModel {
+
+    VNF, VM;
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Direction.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Direction.java
new file mode 100644 (file)
index 0000000..2e3e5e6
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+import java.math.BigDecimal;
+
+/**
+ * Enum for Threshold Direction
+ *
+ * @author Rajiv Singla
+ */
+public enum Direction implements TcaPolicyModel {
+
+    EQUAL {
+        @Override
+        public Boolean operate(final BigDecimal value1, final BigDecimal value2) {
+            return value1.compareTo(value2) == 0;
+        }
+    },
+    LESS {
+        @Override
+        public Boolean operate(final BigDecimal value1, final BigDecimal value2) {
+            return value1.compareTo(value2) < 0;
+        }
+    },
+    LESS_OR_EQUAL {
+        @Override
+        public Boolean operate(final BigDecimal value1, final BigDecimal value2) {
+            return value1.compareTo(value2) <= 0;
+        }
+    },
+    GREATER {
+        @Override
+        public Boolean operate(final BigDecimal value1, final BigDecimal value2) {
+            return value1.compareTo(value2) > 0;
+        }
+    },
+    GREATER_OR_EQUAL {
+        @Override
+        public Boolean operate(final BigDecimal value1, final BigDecimal value2) {
+            return value1.compareTo(value2) >= 0;
+        }
+    };
+
+    /**
+     * Configure logic for a particular Direction
+     *
+     * @param value1 left operand for Direction operation
+     * @param value2 right operand for Direction operation
+     *
+     * @return result of operation for the direction logic
+     */
+    public abstract Boolean operate(final BigDecimal value1, final BigDecimal value2);
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java
new file mode 100644 (file)
index 0000000..024202a
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * TCA Metrics that need to applied to each Event Name
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class MetricsPerEventName extends BaseTcaPolicyModel {
+
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Event Name to which TCA Policy needs to applied.
+     */
+    private String eventName;
+
+    /**
+     * Control Loop Schema Type
+     */
+    private ControlLoopSchemaType controlLoopSchemaType;
+
+    /**
+     * Policy Scope
+     */
+    private String policyScope;
+
+    /**
+     * Policy Name
+     */
+    private String policyName;
+
+    /**
+     * Policy Version
+     */
+    private String policyVersion;
+
+    /**
+     * Policy Thresholds
+     */
+    private List<Threshold> thresholds;
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicy.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicy.java
new file mode 100644 (file)
index 0000000..0f453ef
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * TCA (Threshold Crossing Alert) Root
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class TcaPolicy extends BaseTcaPolicyModel {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * TCA Policy domain which is associated with TCA incoming CEF message domain
+     */
+    private String domain;
+
+    /**
+     * Contains TCA Policy metrics that needs to be applied to each Functional Role
+     */
+    private List<MetricsPerEventName> metricsPerEventName;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicyModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicyModel.java
new file mode 100644 (file)
index 0000000..a6a2df1
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+
+import org.onap.dcae.analytics.model.policy.AnalyticsPolicyModel;
+import org.onap.dcae.analytics.tca.model.TcaModel;
+
+/**
+ * Marker interface for all TCA Policy Models
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaPolicyModel extends TcaModel, AnalyticsPolicyModel {
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Threshold.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Threshold.java
new file mode 100644 (file)
index 0000000..e3f7de0
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.policy;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+
+import org.onap.dcae.analytics.model.cef.EventSeverity;
+
+/**
+ * TCA Policy Threshold
+ *
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class Threshold extends BaseTcaPolicyModel {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Closed Loop Control Name
+     */
+    private String closedLoopControlName;
+
+
+    /**
+     * Closed Loop Event Status
+     */
+    private ClosedLoopEventStatus closedLoopEventStatus;
+
+    /**
+     * Threshold Version
+     */
+    private String version;
+
+    /**
+     * Path of the field inside Common Event Format which needs to be monitored by TCA App
+     * for threshold crossing
+     */
+    private String fieldPath;
+
+    /**
+     * Threshold Value
+     */
+    private Long thresholdValue;
+
+    /**
+     * Direction of threshold
+     */
+    private Direction direction;
+
+    /**
+     * Severity of Event based on CEF Convention
+     */
+    private EventSeverity severity;
+
+
+    /**
+     * Actual Field value that caused the threshold violation. Note: Ignored for serialization / deserialization
+     */
+    private BigDecimal actualFieldValue;
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionRequest.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionRequest.java
new file mode 100644 (file)
index 0000000..5da6985
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.restapi;
+
+import lombok.Data;
+
+import java.util.List;
+
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TcaExecutionRequest implements TcaRestApiModel {
+
+    private static final long serialVersionUID = 1L;
+
+    private String requestId;
+    private String transactionId;
+    private TcaPolicy tcaPolicy;
+    private List<EventListener> eventListeners;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionResponse.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionResponse.java
new file mode 100644 (file)
index 0000000..e2995f6
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.restapi;
+
+import lombok.Data;
+
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+public class TcaExecutionResponse implements TcaRestApiModel {
+
+    private static final long serialVersionUID = 1L;
+
+    private String requestId;
+    private String transactionId;
+    private MetricsPerEventName violatedMetricsPerEventName;
+    private TcaAlert tcaAlert;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaRestApiModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaRestApiModel.java
new file mode 100644 (file)
index 0000000..cdad2c8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.restapi;
+
+import org.onap.dcae.analytics.tca.model.TcaModel;
+
+/**
+ * @author Rajiv Singla
+ */
+public interface TcaRestApiModel extends TcaModel {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java
new file mode 100644 (file)
index 0000000..aaec970
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.Optional;
+import java.util.function.Function;
+
+import org.onap.dcae.analytics.model.util.function.JsonToJavaObjectBiFunction;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class TcaModelJsonConversion {
+
+
+    public static final ObjectMapper TCA_OBJECT_MAPPER = new TcaObjectMapperSupplier().get();
+
+    // Type reference to convert tca policy string to tca policy object
+    private static final TypeReference<TcaPolicy> TCA_POLICY_TYPE_REF = new TypeReference<TcaPolicy>() {
+    };
+
+    // Type reference to convert tca alert string to tca alert
+    private static final TypeReference<TcaAlert> TCA_ALERT_TYPE_REF = new TypeReference<TcaAlert>() {
+    };
+
+    // Tca Policy JSON conversion function
+    public static final Function<String, Optional<TcaPolicy>> TCA_POLICY_JSON_FUNCTION = new
+            JsonToJavaObjectBiFunction<TcaPolicy>(TCA_OBJECT_MAPPER).curry(TCA_POLICY_TYPE_REF);
+
+    // Tca Alert JSON conversion function
+    public static final Function<String, Optional<TcaAlert>> TCA_ALERT_JSON_FUNCTION = new
+            JsonToJavaObjectBiFunction<TcaAlert>(TCA_OBJECT_MAPPER).curry(TCA_ALERT_TYPE_REF);
+
+    private TcaModelJsonConversion() {
+        // private constructor
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaObjectMapperSupplier.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaObjectMapperSupplier.java
new file mode 100644 (file)
index 0000000..f17819e
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.onap.dcae.analytics.model.util.json.BaseObjectMapperSupplier;
+import org.onap.dcae.analytics.tca.model.util.json.module.TcaFacadeModelModule;
+import org.onap.dcae.analytics.tca.model.util.json.module.TcaPolicyModule;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaObjectMapperSupplier extends BaseObjectMapperSupplier {
+
+    @Override
+    public void registerCustomModules(final ObjectMapper objectMapper) {
+        objectMapper.registerModule(new TcaFacadeModelModule());
+        objectMapper.registerModule(new TcaPolicyModule());
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/AaiMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/AaiMixin.java
new file mode 100644 (file)
index 0000000..5eed3c0
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.facade;
+
+import com.fasterxml.jackson.annotation.JsonGetter;
+import com.fasterxml.jackson.annotation.JsonSetter;
+
+import org.onap.dcae.analytics.model.util.json.mixin.common.BaseDynamicPropertiesProviderMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class AaiMixin extends BaseDynamicPropertiesProviderMixin {
+
+    private String genericVNFName;
+    private String genericServerName;
+
+    @JsonGetter("generic-vnf.vnf-name")
+    public String getGenericVNFName() {
+        return genericVNFName;
+    }
+
+    @JsonSetter("generic-vnf.vnf-name")
+    public void setGenericVNFName(String genericVNFName) {
+        this.genericVNFName = genericVNFName;
+    }
+
+    @JsonGetter("vserver.vserver-name")
+    public String getGenericServerName() {
+        return genericServerName;
+    }
+
+    @JsonSetter("vserver.vserver-name")
+    public void setGenericServerName(String genericServerName) {
+        this.genericServerName = genericServerName;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixin.java
new file mode 100644 (file)
index 0000000..6841e02
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.facade;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+import org.onap.dcae.analytics.tca.model.facade.Aai;
+
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class TcaAlertMixin implements JsonMixin {
+
+    @JsonProperty("target_type")
+    private String targetType;
+    @JsonProperty("AAI")
+    private Aai aai;
+    @JsonProperty("requestID")
+    private String requestId;
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/BaseTcaPolicyModelMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/BaseTcaPolicyModelMixin.java
new file mode 100644 (file)
index 0000000..8ab1180
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+
+import org.onap.dcae.analytics.model.util.json.mixin.common.BaseDynamicPropertiesProviderMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class BaseTcaPolicyModelMixin extends BaseDynamicPropertiesProviderMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ClosedLoopEventStatusMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ClosedLoopEventStatusMixin.java
new file mode 100644 (file)
index 0000000..3eb2ffa
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class ClosedLoopEventStatusMixin implements JsonMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ControlLoopSchemaTypeMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ControlLoopSchemaTypeMixin.java
new file mode 100644 (file)
index 0000000..895629f
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class ControlLoopSchemaTypeMixin implements JsonMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/DirectionMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/DirectionMixin.java
new file mode 100644 (file)
index 0000000..34891ea
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class DirectionMixin implements JsonMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/MetricsPerEventNameMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/MetricsPerEventNameMixin.java
new file mode 100644 (file)
index 0000000..5a41bfe
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class MetricsPerEventNameMixin extends BaseTcaPolicyModelMixin {
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixin.java
new file mode 100644 (file)
index 0000000..aa0561e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class TcaPolicyMixin extends BaseTcaPolicyModelMixin {
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ThresholdMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ThresholdMixin.java
new file mode 100644 (file)
index 0000000..f0cab59
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class ThresholdMixin extends BaseTcaPolicyModelMixin {
+
+    @JsonIgnore
+    private BigDecimal actualFieldValue;
+
+    @JsonIgnore
+    public BigDecimal getActualFieldValue() {
+        return actualFieldValue;
+    }
+
+    @JsonProperty
+    public void setActualFieldValue(BigDecimal actualFieldValue) {
+        this.actualFieldValue = actualFieldValue;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaFacadeModelModule.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaFacadeModelModule.java
new file mode 100644 (file)
index 0000000..7da75ce
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.module;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import org.onap.dcae.analytics.tca.model.facade.Aai;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.facade.AaiMixin;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.facade.TcaAlertMixin;
+
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaFacadeModelModule extends SimpleModule {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public void setupModule(final SetupContext setupContext) {
+        setupContext.setMixInAnnotations(TcaAlert.class, TcaAlertMixin.class);
+        setupContext.setMixInAnnotations(Aai.class, AaiMixin.class);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaPolicyModule.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaPolicyModule.java
new file mode 100644 (file)
index 0000000..33af18b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.module;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import org.onap.dcae.analytics.tca.model.policy.BaseTcaPolicyModel;
+import org.onap.dcae.analytics.tca.model.policy.ClosedLoopEventStatus;
+import org.onap.dcae.analytics.tca.model.policy.ControlLoopSchemaType;
+import org.onap.dcae.analytics.tca.model.policy.Direction;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.policy.Threshold;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.BaseTcaPolicyModelMixin;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.ClosedLoopEventStatusMixin;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.ControlLoopSchemaTypeMixin;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.DirectionMixin;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.MetricsPerEventNameMixin;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.TcaPolicyMixin;
+import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.ThresholdMixin;
+
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaPolicyModule extends SimpleModule {
+
+    private static final long serialVersionUID = 1L;
+
+
+    @Override
+    public void setupModule(final SetupContext setupContext) {
+        setupContext.setMixInAnnotations(BaseTcaPolicyModel.class, BaseTcaPolicyModelMixin.class);
+        setupContext.setMixInAnnotations(TcaPolicy.class, TcaPolicyMixin.class);
+        setupContext.setMixInAnnotations(ControlLoopSchemaType.class, ControlLoopSchemaTypeMixin.class);
+        setupContext.setMixInAnnotations(ClosedLoopEventStatus.class, ClosedLoopEventStatusMixin.class);
+        setupContext.setMixInAnnotations(MetricsPerEventName.class, MetricsPerEventNameMixin.class);
+        setupContext.setMixInAnnotations(Direction.class, DirectionMixin.class);
+        setupContext.setMixInAnnotations(Threshold.class, ThresholdMixin.class);
+        setupContext.setMixInAnnotations(TcaPolicy.class, TcaPolicyMixin.class);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/BaseTcaModelTest.java b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/BaseTcaModelTest.java
new file mode 100644 (file)
index 0000000..3d5add2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model;
+
+import org.onap.dcae.analytics.test.BaseAnalyticsUnitTest;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class BaseTcaModelTest extends BaseAnalyticsUnitTest {
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixinTest.java b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixinTest.java
new file mode 100644 (file)
index 0000000..a0ebc05
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.facade;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.tca.model.BaseTcaModelTest;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAlertMixinTest extends BaseTcaModelTest {
+
+    @Test
+    @DisplayName("Confirms TCA Alert JSON Conversions")
+    public void testTCAAlertConversion() throws Exception {
+        final TcaAlert tcaAlert =
+                assertJsonConversions(TestFileLocation.TCA_ALERT_JSON, TcaModelJsonConversion
+                        .TCA_ALERT_JSON_FUNCTION, TcaModelJsonConversion.TCA_OBJECT_MAPPER);
+
+        assertThat(tcaAlert).isNotNull();
+        assertThat(tcaAlert.getAai().getGenericVNFName()).isEqualTo("vpp-test(?)");
+
+        assertThat(tcaAlert.getTargetType()).isEqualTo("VNF");
+        assertThat(tcaAlert.getRequestId()).isEqualTo("0138afac-b032-4e4b-bd30-88260f444888");
+
+        assertThat(tcaAlert.getClosedLoopControlName())
+                .isEqualTo("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8");
+
+        assertThat(tcaAlert.getVersion()).isEqualTo("1.0.2");
+
+        assertThat(tcaAlert.getClosedLoopAlarmStart()).isEqualTo(1478189220547L);
+
+        assertThat(tcaAlert.getClosedLoopEventStatus()).isEqualTo("ONSET");
+
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java
new file mode 100644 (file)
index 0000000..5592f3b
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.model.util.json.mixin.policy;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.tca.model.BaseTcaModelTest;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion;
+
+/**
+ * @author Rajiv Singla
+ */
+class TcaPolicyMixinTest extends BaseTcaModelTest {
+
+    @Test
+    @DisplayName("Test TCA Policy JSON Conversions")
+    void testTCAPolicyJsonConversions() throws Exception {
+
+        final TcaPolicy tcaPolicy =
+                assertJsonConversions(TestFileLocation.TCA_POLICY_JSON, TcaModelJsonConversion
+                        .TCA_POLICY_JSON_FUNCTION, TcaModelJsonConversion.TCA_OBJECT_MAPPER);
+
+        assertThat(tcaPolicy).isNotNull();
+        assertThat(tcaPolicy.getMetricsPerEventName().size())
+                .as("TCA Policy Metrics Per Event Name must be 3").isEqualTo(3);
+
+        assertThat(tcaPolicy.getMetricsPerEventName().get(0).getThresholds().size())
+                .as("TCA Policy Thresholds for first event name must be 3").isEqualTo(3);
+
+        // test tca policy serialization
+        testSerialization(tcaPolicy, getClass());
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/Dockerfile b/dcae-analytics/dcae-analytics-tca-web/Dockerfile
new file mode 100644 (file)
index 0000000..83136ad
--- /dev/null
@@ -0,0 +1,15 @@
+# NOTE: This Dockerfile is auto generated and filtered via maven resources plugin.
+# Edits to generated Dockerfile will NOT be saved.
+# Only changes made in docker/Dockerfile template file will be persistent
+FROM openjdk:8-jre-alpine
+MAINTAINER Rajiv Singla <rs153v@att.com>
+ENTRYPOINT ["java", \
+            "-Djava.security.egd=file:/dev/./urandom", \
+            "-Dlogging.config=logback.xml", \
+            "-Dlogging.file=logs/dcae-analytics-tca-web.log", \
+            "-Dspring.profiles.active=dev", \
+            "-jar", "dcae-analytics-tca-web.jar"]
+EXPOSE 9091
+VOLUME /tmp
+ADD docker/logback.xml logback.xml
+ADD target/dcae-analytics-tca-web-3.0.0-SNAPSHOT.jar dcae-analytics-tca-web.jar
diff --git a/dcae-analytics/dcae-analytics-tca-web/docker/Dockerfile b/dcae-analytics/dcae-analytics-tca-web/docker/Dockerfile
new file mode 100644 (file)
index 0000000..fcbc5ac
--- /dev/null
@@ -0,0 +1,15 @@
+# NOTE: This Dockerfile is auto generated and filtered via maven resources plugin.
+# Edits to generated Dockerfile will NOT be saved.
+# Only changes made in docker/Dockerfile template file will be persistent
+FROM openjdk:8-jre-alpine
+MAINTAINER Rajiv Singla <rs153v@att.com>
+ENTRYPOINT ["java", \
+            "-Djava.security.egd=file:/dev/./urandom", \
+            "-Dlogging.config=logback.xml", \
+            "-Dlogging.file=logs/${project.artifactId}.log", \
+            "-Dspring.profiles.active=dev", \
+            "-jar", "${project.artifactId}.jar"]
+EXPOSE 9091
+VOLUME /tmp
+ADD docker/logback.xml logback.xml
+ADD target/${project.build.finalName}.jar ${project.artifactId}.jar
diff --git a/dcae-analytics/dcae-analytics-tca-web/docker/logback.xml b/dcae-analytics/dcae-analytics-tca-web/docker/logback.xml
new file mode 100644 (file)
index 0000000..cba7e63
--- /dev/null
@@ -0,0 +1,52 @@
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<configuration>
+
+    <!-- SET ECOMP COMPONENT NAME -->
+    <property scope="context" name="componentName" value="dcae-analytics-tca"/>
+    <contextName>${componentName}</contextName>
+
+    <include resource="ecomp-logback.xml"/>
+    <include resource="org/springframework/boot/logging/logback/base.xml"/>
+
+    <logger name="org.springframework" level="INFO"/>
+    <logger name="org.hibernate" level="WARN"/>
+    <logger name="springfox" level="INFO"/>
+    <logger name="org.xnio" level="INFO"/>
+    <logger name="io.undertow" level="INFO"/>
+    <logger name="org.apache" level="INFO"/>
+    <logger name="sun.rmi" level="INFO"/>
+    <logger name="org.mongodb" level="INFO"/>
+    <logger name="com.jayway" level="INFO"/>
+
+    <logger name="org.springframework.retry" level="INFO"/>
+    <logger name="org.onap.dcae.analytics" level="INFO"/>
+
+    <root level="INFO">
+        <!-- required appenders -->
+        <appender-ref ref="auditLogAppender"/>
+        <appender-ref ref="metricLogAppender"/>
+        <appender-ref ref="errorLogAppender"/>
+
+        <!-- app properties -->
+        <appender-ref ref="FILE"/>
+    </root>
+
+</configuration>
diff --git a/dcae-analytics/dcae-analytics-tca-web/pom.xml b/dcae-analytics/dcae-analytics-tca-web/pom.xml
new file mode 100644 (file)
index 0000000..e884f39
--- /dev/null
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.dcaegen2.analytics</groupId>
+        <artifactId>dcae-analytics</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dcae-analytics-tca-web</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- THE MODULE CONTAINS WEB RELATED CODE FOR TCA -->
+    <name>DCAE Analytics TCA Web</name>
+    <description>Contains Web related code for TCA</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+    </properties>
+
+    <dependencies>
+
+        <!-- PROJECT DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-tca-core</artifactId>
+        </dependency>
+
+
+        <!-- SPRING DEPENDENCIES -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.micrometer</groupId>
+            <artifactId>micrometer-registry-prometheus</artifactId>
+        </dependency>
+
+
+        <!-- SPRING CONFIGURATION META DATA ANNOTATION PROCESSOR -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-configuration-processor</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <!-- CODE GENERATION -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- FIND BUGS -->
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>annotations</artifactId>
+        </dependency>
+
+        <!-- REST API SWAGGER -->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+        </dependency>
+
+        <!-- TEST DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-test</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+    <build>
+        <resources>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+            </resource>
+            <resource>
+                <directory>${project.build.directory}/git</directory>
+            </resource>
+            <resource>
+                <directory>docker</directory>
+                <includes>
+                    <include>Dockerfile</include>
+                </includes>
+                <targetPath>${project.basedir}</targetPath>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+
+        <plugins>
+            <plugin>
+                <groupId>pl.project13.maven</groupId>
+                <artifactId>git-commit-id-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppMain.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppMain.java
new file mode 100644 (file)
index 0000000..5b8c8ea
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web;
+
+import org.onap.dcae.analytics.tca.web.config.TcaWebConfig;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Import;
+import org.springframework.integration.config.EnableIntegration;
+
+/**
+ * @author Rajiv Singla
+ */
+@Import(value = {TcaWebConfig.class})
+@EnableIntegration
+@SpringBootConfiguration
+@EnableAutoConfiguration
+public class TcaAppMain {
+
+    public static void main(String[] args) {
+        SpringApplication.run(TcaAppMain.class, args);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java
new file mode 100644 (file)
index 0000000..9ee625a
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties;
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceModel;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ConfigurationProperties(ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_PROPERTIES_KEY)
+@Validated
+public class TcaAppProperties extends BaseConfigBindingServiceProperties {
+
+    private static final long serialVersionUID = 1L;
+
+    private Tca tca;
+
+    /**
+     * TCA Application properties
+     */
+    @Data
+    public static class Tca implements ConfigBindingServiceModel {
+
+        private static final long serialVersionUID = 1L;
+
+        private String policy;
+        private Integer processingBatchSize = TcaModelConstants.DEFAULT_TCA_PROCESSING_BATCH_SIZE;
+        private Boolean enableAbatement = TcaModelConstants.DEFAULT_ABATEMENT_ENABLED;
+        private Boolean enableEcompLogging = TcaModelConstants.DEFAULT_ECOMP_LOGGING_ENABLED;
+        private Aai aai = new Aai();
+
+    }
+
+
+    /**
+     * A&amp;AI properties
+     */
+    @Data
+    @ToString(exclude = "password")
+    public static class Aai implements ConfigBindingServiceModel {
+
+        private static final long serialVersionUID = 1L;
+
+        private Boolean enableEnrichment = TcaModelConstants.DEFAULT_AAI_ENRICHMENT_ENABLED;
+        private String url;
+        private String username;
+        private String password;
+
+        private String proxyUrl = null;
+        private Boolean ignoreSSLValidation = TcaModelConstants.DEFAULT_TCA_AAI_IGNORE_SSL_VALIDATION;
+
+        private String genericVnfPath = TcaModelConstants.DEFAULT_TCA_AAI_GENERIC_VNF_PATH;
+        private String nodeQueryPath = TcaModelConstants.DEFAULT_TCA_AAI_NODE_QUERY_PATH;
+
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiEnrichmentContextImpl.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiEnrichmentContextImpl.java
new file mode 100644 (file)
index 0000000..73a600a
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.aai;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAaiEnrichmentContextImpl implements TcaAaiEnrichmentContext {
+
+    private final TcaAppProperties tcaAppProperties;
+    private final TcaAaiEnrichmentService tcaAaiEnrichmentService;
+
+    public TcaAaiEnrichmentContextImpl(final TcaAppProperties tcaAppProperties,
+                                       final TcaAaiEnrichmentService tcaAaiEnrichmentService) {
+        this.tcaAppProperties = tcaAppProperties;
+        this.tcaAaiEnrichmentService = tcaAaiEnrichmentService;
+    }
+
+
+    @Override
+    public boolean isAaiEnrichmentEnabled() {
+        return tcaAppProperties.getTca().getAai().getEnableEnrichment();
+    }
+
+    @Override
+    public TcaAaiEnrichmentService getAaiEnrichmentService() {
+        return tcaAaiEnrichmentService;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiEnrichmentServiceImpl.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiEnrichmentServiceImpl.java
new file mode 100644 (file)
index 0000000..d38bd23
--- /dev/null
@@ -0,0 +1,273 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.aai;
+
+import static org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion.TCA_OBJECT_MAPPER;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.facade.Aai;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAaiEnrichmentServiceImpl implements TcaAaiEnrichmentService {
+
+    private static final Logger logger = LoggerFactory.getLogger(TcaAaiEnrichmentServiceImpl.class);
+
+    private final TcaAppProperties tcaAppProperties;
+    private final RestTemplate aaiRestTemplate;
+
+    public TcaAaiEnrichmentServiceImpl(final TcaAppProperties tcaAppProperties,
+                                       final RestTemplate aaiRestTemplate) {
+        this.tcaAppProperties = tcaAppProperties;
+        this.aaiRestTemplate = aaiRestTemplate;
+    }
+
+
+    @Override
+    public TcaAlert doAaiEnrichment(final TcaExecutionContext tcaExecutionContext) {
+
+        final TcaAlert tcaAlert = tcaExecutionContext.getTcaResultContext().getTcaAlert();
+
+        // do aai enrichment
+        if (isVNFAlert(tcaAlert)) {
+            // do vnf enrichment
+            doAaiVnfEnrichment(tcaExecutionContext, aaiRestTemplate, tcaAppProperties);
+        } else {
+            // do vm enrichment
+            doAaiVmEnrichment(tcaExecutionContext, aaiRestTemplate, tcaAppProperties);
+        }
+
+        return tcaAlert;
+    }
+
+    private static void doAaiVmEnrichment(final TcaExecutionContext tcaExecutionContext,
+                                          final RestTemplate aaiRestTemplate,
+                                          final TcaAppProperties tcaAppProperties) {
+
+        final TcaAlert tcaAlert = tcaExecutionContext.getTcaResultContext().getTcaAlert();
+        final String requestId = tcaExecutionContext.getRequestId();
+        final String transactionId = tcaExecutionContext.getTransactionId();
+        final String vServerName = tcaAlert.getAai().getGenericServerName();
+
+        // create new node query uri
+        final TcaAppProperties.Aai aai = tcaAppProperties.getTca().getAai();
+        final URI nodeQueryUri = UriComponentsBuilder.fromHttpUrl(aai.getUrl())
+                .path(aai.getNodeQueryPath())
+                .queryParam("search-node-type", "vserver")
+                .queryParam("filter", "vserver-name:EQUALS:" + vServerName)
+                .build(Collections.emptyMap());
+
+        // get resource link
+        final String resourceLink =
+                getVMResourceLink(getAAIRestAPIResponse(aaiRestTemplate, nodeQueryUri, requestId, transactionId));
+        if (resourceLink == null) {
+            return;
+        }
+
+        // create virtual server enrichment uri
+        final URI vServerEnrichmentUri = UriComponentsBuilder.fromHttpUrl(aai.getUrl())
+                .path(resourceLink)
+                .build(Collections.emptyMap());
+
+        // fetch virtual server enrichment details
+        final String vServerEnrichmentDetails =
+                getAAIRestAPIResponse(aaiRestTemplate, vServerEnrichmentUri, requestId, transactionId);
+
+        // do aai enrichment
+        enrichAAI(vServerEnrichmentDetails, tcaAlert, TcaModelConstants.AAI_VSERVER_KEY_PREFIX);
+    }
+
+    private static void doAaiVnfEnrichment(final TcaExecutionContext tcaExecutionContext,
+                                           final RestTemplate aaiRestTemplate,
+                                           final TcaAppProperties tcaAppProperties) {
+
+        final TcaAlert tcaAlert = tcaExecutionContext.getTcaResultContext().getTcaAlert();
+        final String requestId = tcaExecutionContext.getRequestId();
+        final String transactionId = tcaExecutionContext.getTransactionId();
+        final String genericVnfName = tcaAlert.getAai().getGenericVNFName();
+
+        // create new generic vnf uri
+        final TcaAppProperties.Aai aai = tcaAppProperties.getTca().getAai();
+        final URI genericVnfUri = UriComponentsBuilder.fromHttpUrl(aai.getUrl())
+                .path(aai.getGenericVnfPath())
+                .queryParam("vnf-name", genericVnfName)
+                .build(Collections.emptyMap());
+
+        // fetch response
+        final String aaiResponse = getAAIRestAPIResponse(aaiRestTemplate, genericVnfUri, requestId, transactionId);
+
+        // do AAI enrichment
+        enrichAAI(aaiResponse, tcaAlert, TcaModelConstants.AAI_VNF_KEY_PREFIX);
+    }
+
+
+    /**
+     * Fetch response from A&AI Rest API as json string for given aai uri. Returns null if unable to fetch response
+     * from A&AI API
+     *
+     * @param aaiRestTemplate aai rest template
+     * @param aaiUri aai uri
+     *
+     * @return A&AI API response as json string
+     */
+    private static String getAAIRestAPIResponse(final RestTemplate aaiRestTemplate, final URI aaiUri,
+                                                final String requestId, final String transactionId) {
+        // fetch response
+        ResponseEntity<String> aaiResponseEntity = null;
+        try {
+            final HttpHeaders headers = new HttpHeaders();
+            headers.add(AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY, requestId);
+            headers.add(AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY, transactionId);
+            final HttpEntity<String> httpEntity = new HttpEntity<>(headers);
+            aaiResponseEntity = aaiRestTemplate.exchange(aaiUri, HttpMethod.GET, httpEntity, String.class);
+        } catch (Exception e) {
+            logger.debug("Request id: " + requestId + ". Unable to get A&AI enrichment details", e);
+        }
+
+        if (aaiResponseEntity != null && aaiResponseEntity.getStatusCode().is2xxSuccessful()) {
+            return aaiResponseEntity.getBody();
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Populates A&AI details retrieved from A&AI Enrichment API into Alerts A&AI Object
+     *
+     * @param aaiEnrichmentDetails A&AI Enrichment API fetched JSON String
+     * @param tcaAlert tca alert
+     * @param keyPrefix Key prefix that needs to be added to each fetched A&AI Enrichment record
+     *
+     * @return true if A&AI enrichment completed successfully
+     */
+    private static boolean enrichAAI(final String aaiEnrichmentDetails, final TcaAlert tcaAlert,
+                                     final String keyPrefix) {
+
+        final Aai preEnrichmentAAI = tcaAlert.getAai();
+        if (aaiEnrichmentDetails == null) {
+            logger.warn("Request id: {}. No A&AI Enrichment possible. A&AI Enrichment details are absent.",
+                    tcaAlert.getRequestId());
+            return false;
+        }
+
+        final Aai enrichedAAI = getNewEnrichedAAI(aaiEnrichmentDetails);
+
+        if (enrichedAAI != null) {
+            final Set<Map.Entry<String, Object>> enrichedAAIEntrySet =
+                    enrichedAAI.getDynamicProperties().entrySet();
+            final Map<String, Object> preEnrichmentAAIDynamicProperties = preEnrichmentAAI.getDynamicProperties();
+
+            // populate Alert A&AI Enrichment details and add prefix to key
+            for (Map.Entry<String, Object> enrichedAAIEntry : enrichedAAIEntrySet) {
+                preEnrichmentAAIDynamicProperties.put(
+                        keyPrefix + enrichedAAIEntry.getKey(), enrichedAAIEntry.getValue());
+            }
+
+            logger.debug("Request id: {}. A&AI Enrichment was completed successfully.", tcaAlert.getRequestId());
+            return true;
+        } else {
+            logger.warn("Request id: {}. No A&AI Enrichment possible. Skipped - Invalid A&AI Response.",
+                    tcaAlert.getRequestId());
+            return false;
+        }
+
+    }
+
+    /**
+     * Creates a new A&AI object with only top level A&AI Enrichment details
+     *
+     * @param aaiEnrichmentDetails A&AI Enrichment details
+     *
+     * @return new A&AI with only top level A&AI Enrichment details
+     */
+    private static Aai getNewEnrichedAAI(final String aaiEnrichmentDetails) {
+        try {
+            final JsonNode rootNode = TCA_OBJECT_MAPPER.readTree(aaiEnrichmentDetails);
+            final Iterator<Map.Entry<String, JsonNode>> fieldsIterator = rootNode.fields();
+            while (fieldsIterator.hasNext()) {
+                final Map.Entry<String, JsonNode> fieldEntry = fieldsIterator.next();
+                final JsonNode jsonNode = fieldEntry.getValue();
+                // remove all arrays, objects from A&AI Enrichment Json
+                if (jsonNode.isPojo() || jsonNode.isObject() || jsonNode.isArray()) {
+                    fieldsIterator.remove();
+                }
+            }
+            return TCA_OBJECT_MAPPER.treeToValue(rootNode, Aai.class);
+        } catch (IOException e) {
+            logger.error(
+                    "Failed to Parse AAI Enrichment Details from JSON: {}, Exception: {}.", aaiEnrichmentDetails, e);
+        }
+        return null;
+    }
+
+    /**
+     * Fetches VM Object Resource Link from A&AI Resource Link Json
+     *
+     * @param vmAAIResourceLinkDetails VM Object Resource Link from A&AI Resource Link Json
+     *
+     * @return object resource link String
+     */
+    private static String getVMResourceLink(final String vmAAIResourceLinkDetails) {
+        if (StringUtils.hasText(vmAAIResourceLinkDetails)) {
+            try {
+                final JsonNode jsonNode = TCA_OBJECT_MAPPER.readTree(vmAAIResourceLinkDetails);
+                final JsonNode resourceLinkJsonNode = jsonNode.findPath("resource-link");
+                if (!resourceLinkJsonNode.isMissingNode()) {
+                    return resourceLinkJsonNode.asText();
+                }
+            } catch (IOException e) {
+                logger.error("Unable to determine VM Object link inside AAI Resource Link Response JSON: {}",
+                        vmAAIResourceLinkDetails, e);
+            }
+        }
+        return null;
+    }
+
+
+    private static boolean isVNFAlert(final TcaAlert tcaAlert) {
+        return tcaAlert.getTargetType().equals(TcaModelConstants.TCA_ALERT_VNF_TARGET_TYPE);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiRestClientPreferences.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/aai/TcaAaiRestClientPreferences.java
new file mode 100644 (file)
index 0000000..93a54a9
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.aai;
+
+import java.net.URL;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.onap.dcae.analytics.web.http.BaseHttpClientPreferences;
+import org.springframework.http.HttpHeaders;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAaiRestClientPreferences extends BaseHttpClientPreferences {
+
+    private static final long serialVersionUID = 1L;
+
+    public TcaAaiRestClientPreferences(@Nonnull final String requestURL,
+                                       @Nullable final String httpClientId,
+                                       @Nullable final HttpHeaders httpHeaders,
+                                       @Nullable final String username,
+                                       @Nullable final String password,
+                                       @Nullable final URL proxyURL,
+                                       @Nullable final Boolean ignoreSSLValidation,
+                                       @Nullable final Boolean enableEcompAuditLogging) {
+        super(requestURL, httpClientId, httpHeaders, username, password, proxyURL, ignoreSSLValidation,
+                enableEcompAuditLogging);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementContextImpl.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementContextImpl.java
new file mode 100644 (file)
index 0000000..a4784e0
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.abatement.mongo;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+
+/**
+ * An implementation of {@link TcaAbatementContext} backed by mongo database as persistence provider
+ *
+ * @author Rajiv Singla
+ */
+public class MongoAbatementContextImpl implements TcaAbatementContext {
+
+    private TcaAppProperties tcaAppProperties;
+    private MongoAbatementRepository mongoAbatementRepository;
+
+    public MongoAbatementContextImpl(final TcaAppProperties tcaAppProperties,
+                                     final MongoAbatementRepository mongoAbatementRepository) {
+        this.tcaAppProperties = tcaAppProperties;
+        this.mongoAbatementRepository = mongoAbatementRepository;
+    }
+
+    @Override
+    public boolean isAbatementEnabled() {
+        return tcaAppProperties.getTca().getEnableAbatement();
+    }
+
+    @Override
+    public TcaAbatementRepository getTcaAbatementRepository() {
+        return mongoAbatementRepository;
+    }
+
+    @Override
+    public TcaAbatementEntity create(final String lookupKey, final String requestId,
+                                     final boolean isAbatementAlertSent) {
+        return new MongoAbatementEntity(lookupKey, requestId, isAbatementAlertSent);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementEntity.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementEntity.java
new file mode 100644 (file)
index 0000000..562c918
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.abatement.mongo;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.model.TcaModel;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+@NoArgsConstructor
+@Document(collection = "tca_abatement")
+public class MongoAbatementEntity implements TcaAbatementEntity, TcaModel {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    private String lookupKey;
+    private String requestId;
+    private boolean isAbatementAlertSent;
+
+    @LastModifiedDate
+    private Date lastModificationDate;
+    @CreatedDate
+    private Date createdDate;
+
+    MongoAbatementEntity(final String lookupKey, final String requestId, final boolean isAbatementAlertSent) {
+        this.lookupKey = lookupKey;
+        this.requestId = requestId;
+        this.isAbatementAlertSent = isAbatementAlertSent;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementRepository.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/mongo/MongoAbatementRepository.java
new file mode 100644 (file)
index 0000000..6727007
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.abatement.mongo;
+
+import java.util.List;
+
+import org.bson.types.ObjectId;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+/**
+ * @author Rajiv Singla
+ */
+public interface MongoAbatementRepository extends
+        TcaAbatementRepository, MongoRepository<MongoAbatementEntity, ObjectId> {
+
+    List<TcaAbatementEntity> findByLookupKey(final String lookUpKey);
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementContextImpl.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementContextImpl.java
new file mode 100644 (file)
index 0000000..6c17039
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.abatement.simple;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+
+/**
+ * A simple implementation for {@link TcaAbatementContext} which should be used for testing and development
+ * purposes only.
+ *
+ * @author Rajiv Singla
+ */
+public class SimpleAbatementContextImpl implements TcaAbatementContext {
+
+
+    private final TcaAppProperties tcaAppProperties;
+    private final TcaAbatementRepository tcaAbatementRepository;
+
+    public SimpleAbatementContextImpl(final TcaAppProperties tcaAppProperties,
+                                      final TcaAbatementRepository tcaAbatementRepository) {
+        this.tcaAppProperties = tcaAppProperties;
+        this.tcaAbatementRepository = tcaAbatementRepository;
+    }
+
+
+    @Override
+    public boolean isAbatementEnabled() {
+        return tcaAppProperties.getTca().getEnableAbatement();
+    }
+
+    @Override
+    public TcaAbatementRepository getTcaAbatementRepository() {
+        return tcaAbatementRepository;
+    }
+
+    @Override
+    public TcaAbatementEntity create(final String lookupKey, final String requestId,
+                                     final boolean isAbatementAlertSent) {
+        return new SimpleAbatementEntity(lookupKey, requestId, isAbatementAlertSent);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementEntity.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementEntity.java
new file mode 100644 (file)
index 0000000..c12306f
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.abatement.simple;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.model.TcaModel;
+
+/**
+ * @author Rajiv Singla
+ */
+@Data
+@NoArgsConstructor
+public class SimpleAbatementEntity implements TcaAbatementEntity, TcaModel {
+
+    private static final long serialVersionUID = 1L;
+
+    protected String lookupKey;
+    protected String requestId;
+    protected boolean isAbatementAlertSent;
+    protected Date lastModificationDate;
+
+    SimpleAbatementEntity(final String lookupKey, final String requestId, final boolean isAbatementAlertSent) {
+        this.lookupKey = lookupKey;
+        this.requestId = requestId;
+        this.isAbatementAlertSent = isAbatementAlertSent;
+        this.lastModificationDate = new Date();
+    }
+
+    public Date getLastModificationDate() {
+        return new Date(lastModificationDate.getTime());
+    }
+
+    public void setLastModificationDate(final Date lastModificationDate) {
+        this.lastModificationDate = new Date(lastModificationDate.getTime());
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementRepository.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/abatement/simple/SimpleAbatementRepository.java
new file mode 100644 (file)
index 0000000..452f07f
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.abatement.simple;
+
+import static org.onap.dcae.analytics.model.TcaModelConstants.TCA_ABATEMENT_SIMPLE_REPOSITORY_MAX_ENTITY_COUNT;
+import static org.onap.dcae.analytics.model.TcaModelConstants.TCA_ABATEMENT_SIMPLE_REPOSITORY_REMOVE_ENTITY_COUNT;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementEntity;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A simple implementation for {@link TcaAbatementRepository} which should be used for testing and development
+ * purposes only.
+ *
+ * @author Rajiv Singla
+ */
+public class SimpleAbatementRepository implements TcaAbatementRepository {
+
+    private static final Logger logger = LoggerFactory.getLogger(SimpleAbatementRepository.class);
+
+    private final ConcurrentLinkedQueue<String> lookupKeysQueue;
+    private final ConcurrentHashMap<String, SimpleAbatementEntity> repository;
+
+    public SimpleAbatementRepository() {
+        this.lookupKeysQueue = new ConcurrentLinkedQueue<>();
+        this.repository = new ConcurrentHashMap<>(TCA_ABATEMENT_SIMPLE_REPOSITORY_MAX_ENTITY_COUNT);
+    }
+
+
+    @Override
+    public synchronized void save(final TcaAbatementEntity tcaAbatementEntity) {
+
+        // remove entries from repository if required
+        if (lookupKeysQueue.size() == TCA_ABATEMENT_SIMPLE_REPOSITORY_MAX_ENTITY_COUNT) {
+
+            logger.warn("Simple Abatement Repository reached its max allowed size: {}, " +
+                            "Removing last inserted {} entries",
+                    TCA_ABATEMENT_SIMPLE_REPOSITORY_MAX_ENTITY_COUNT,
+                    TCA_ABATEMENT_SIMPLE_REPOSITORY_REMOVE_ENTITY_COUNT);
+
+            for (int i = 0; i < TCA_ABATEMENT_SIMPLE_REPOSITORY_REMOVE_ENTITY_COUNT; i++) {
+                final String lookupKey = lookupKeysQueue.poll();
+                logger.warn("Removing Abatement Lookup key: {} from Simple Abatement Repository", lookupKey);
+                repository.remove(lookupKey);
+            }
+
+        }
+
+        lookupKeysQueue.add(tcaAbatementEntity.getLookupKey());
+        final SimpleAbatementEntity simpleAbatementEntity =
+                new SimpleAbatementEntity(tcaAbatementEntity.getLookupKey(), tcaAbatementEntity.getRequestId(),
+                        tcaAbatementEntity.isAbatementAlertSent());
+        repository.put(tcaAbatementEntity.getLookupKey(), simpleAbatementEntity);
+
+    }
+
+    @Override
+    public List<TcaAbatementEntity> findByLookupKey(final String lookUpKey) {
+        final SimpleAbatementEntity repoEntity = repository.getOrDefault(lookUpKey, null);
+        if (repoEntity == null) {
+            return Collections.emptyList();
+        }
+        return Collections.singletonList(repoEntity);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/ControllerConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/ControllerConfig.java
new file mode 100644 (file)
index 0000000..930786e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import org.onap.dcae.analytics.tca.web.controller.TcaRestController;
+import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper;
+import org.onap.dcae.analytics.tca.web.service.TcaProcessingService;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+public class ControllerConfig {
+
+    @Bean
+    public TcaRestController tcaRestController(final TcaPolicyWrapper tcaPolicyWrapper,
+                                               final TcaProcessingService tcaProcessingService) {
+        return new TcaRestController(tcaProcessingService, tcaPolicyWrapper);
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/SwaggerConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/SwaggerConfig.java
new file mode 100644 (file)
index 0000000..11fa97c
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import static org.onap.dcae.analytics.model.TcaModelConstants.TCA_REST_API_PREFIX;
+
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+
+    @Bean
+    public Docket apiDocker() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(getApiInfo())
+                .useDefaultResponseMessages(false)
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("org.onap.dcae.analytics.tca.web.controller"))
+                .paths(PathSelectors.ant(TCA_REST_API_PREFIX + "**"))
+                .build();
+    }
+
+
+    private static ApiInfo getApiInfo() {
+        return new ApiInfoBuilder()
+                .title("TCA (Threshold Crossing Alert) Analytics RESTful API")
+                .description("RESTful API for Threshold Crossing Alerts Analytics")
+                .license("Apache License Version 2.0")
+                .version("3.0")
+                .build();
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaAaiConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaAaiConfig.java
new file mode 100644 (file)
index 0000000..773b9d3
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentService;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.aai.TcaAaiEnrichmentContextImpl;
+import org.onap.dcae.analytics.tca.web.aai.TcaAaiEnrichmentServiceImpl;
+import org.onap.dcae.analytics.tca.web.aai.TcaAaiRestClientPreferences;
+import org.onap.dcae.analytics.tca.web.util.function.TcaAppPropsToAaiRestClientPrefsFunction;
+import org.onap.dcae.analytics.web.http.HttpClientPreferencesCustomizer;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+public class TcaAaiConfig {
+
+    @Bean
+    public TcaAaiRestClientPreferences aaiRestClientPreferences(final TcaAppProperties tcaAppProperties) {
+        return new TcaAppPropsToAaiRestClientPrefsFunction().apply(tcaAppProperties);
+    }
+
+    @Bean
+    public RestTemplate aaiRestTemplate(final TcaAaiRestClientPreferences aaiRestClientPreferences,
+                                        final RestTemplateBuilder restTemplateBuilder) {
+        return restTemplateBuilder
+                .additionalCustomizers(new HttpClientPreferencesCustomizer<>(aaiRestClientPreferences))
+                .build();
+    }
+
+    @Bean
+    public TcaAaiEnrichmentService aaiEnrichmentService(final TcaAppProperties tcaAppProperties,
+                                                        final RestTemplate aaiRestTemplate) {
+        return new TcaAaiEnrichmentServiceImpl(tcaAppProperties, aaiRestTemplate);
+    }
+
+
+    @Bean
+    public TcaAaiEnrichmentContext tcaAaiEnrichmentContext(final TcaAppProperties tcaAppProperties,
+                                                           final TcaAaiEnrichmentService aaiEnrichmentService) {
+        return new TcaAaiEnrichmentContextImpl(tcaAppProperties, aaiEnrichmentService);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMongoAbatementConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMongoAbatementConfig.java
new file mode 100644 (file)
index 0000000..7b29f15
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.abatement.mongo.MongoAbatementContextImpl;
+import org.onap.dcae.analytics.tca.web.abatement.mongo.MongoAbatementRepository;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.mongodb.config.EnableMongoAuditing;
+import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Profile(AnalyticsProfile.MONGO_PROFILE_NAME)
+@EnableMongoRepositories("org.onap.dcae.analytics.tca.web.abatement.mongo")
+@EnableMongoAuditing
+public class TcaMongoAbatementConfig {
+
+    @Bean
+    public TcaAbatementContext mongoAbatementContext(final TcaAppProperties tcaAppProperties,
+                                                     final MongoAbatementRepository mongoAbatementRepository) {
+        return new MongoAbatementContextImpl(tcaAppProperties, mongoAbatementRepository);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaMrConfig.java
new file mode 100644 (file)
index 0000000..64cb6eb
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY;
+import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY;
+
+import java.util.List;
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper;
+import org.onap.dcae.analytics.tca.web.integration.TcaAlertTransformer;
+import org.onap.dcae.analytics.tca.web.integration.TcaPublisherResponseHandler;
+import org.onap.dcae.analytics.tca.web.service.TcaProcessingService;
+import org.onap.dcae.analytics.tca.web.util.function.TcaAppPropsToMrPublisherPrefsFunction;
+import org.onap.dcae.analytics.tca.web.util.function.TcaAppPropsToMrSubscriberPrefsFunction;
+import org.onap.dcae.analytics.web.dmaap.MrPublisherPreferences;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPreferences;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.channel.NullChannel;
+import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.dsl.IntegrationFlow;
+import org.springframework.integration.dsl.IntegrationFlows;
+import org.springframework.messaging.MessageHeaders;
+
+/**
+ * @author Rajiv Singla
+ */
+@Profile({AnalyticsProfile.DMAAP_PROFILE_NAME})
+@Configuration
+public class TcaMrConfig {
+
+    @Bean
+    public MrSubscriberPreferences mrSubscriberPreferences(final TcaAppProperties tcaAppProperties) {
+        return new TcaAppPropsToMrSubscriberPrefsFunction().apply(tcaAppProperties);
+    }
+
+    @Bean
+    public MrPublisherPreferences mrPublisherPreferences(final TcaAppProperties tcaAppProperties) {
+        return new TcaAppPropsToMrPublisherPrefsFunction().apply(tcaAppProperties);
+    }
+
+    @Bean
+    public Integer processingBatchSize(final TcaAppProperties tcaAppProperties) {
+        return tcaAppProperties.getTca().getProcessingBatchSize();
+    }
+
+    @Bean
+    public TcaAlertTransformer tcaAlertTransformer(final TcaAppProperties tcaAppProperties) {
+        return new TcaAlertTransformer(tcaAppProperties);
+    }
+
+
+    @Bean
+    public IntegrationFlow tcaMrFlow(final TcaPolicyWrapper tcaPolicyWrapper,
+                                     final QueueChannel mrSubscriberOutputChannel,
+                                     final DirectChannel mrPublisherInputChannel,
+                                     final TcaProcessingService tcaProcessingService,
+                                     final TcaAlertTransformer tcaAlertTransformer) {
+        // get messages from dmaap subscriber channel
+        return IntegrationFlows.from(mrSubscriberOutputChannel)
+                // handle incoming message from dmaap
+                .handle((List<String> cefMessages, Map<String, Object> headers) ->
+                        tcaProcessingService.getTcaExecutionResults(
+                                headers.getOrDefault(REQUEST_ID_HEADER_KEY, headers.get(MessageHeaders.ID)).toString(),
+                                headers.getOrDefault(REQUEST_TRANSACTION_ID_HEADER_KEY, "").toString(),
+                                tcaPolicyWrapper.getTcaPolicy(), cefMessages))
+                // transform tca execution results to alerts - if not alerts are detected terminate further processing
+                .transform(tcaAlertTransformer, c -> c.requiresReply(false))
+                // post messages to dmaap publisher input channel
+                .channel(mrPublisherInputChannel)
+                .get();
+    }
+
+
+    @Bean
+    public TcaPublisherResponseHandler tcaPublisherResponseHandler(final TcaAppProperties tcaAppProperties) {
+        return new TcaPublisherResponseHandler(tcaAppProperties);
+    }
+
+    @Bean
+    public IntegrationFlow tcaPublisherResponseFlow(final TcaPublisherResponseHandler tcaPublisherResponseHandler) {
+        return IntegrationFlows.from(DmaapMrConstants.DMAAP_MR_PUBLISHER_OUTPUT_CHANNEL)
+                // log response from dmaap publisher output channel
+                .handle(tcaPublisherResponseHandler)
+                // finish processing
+                .channel(new NullChannel())
+                .get();
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaSimpleAbatementConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaSimpleAbatementConfig.java
new file mode 100644 (file)
index 0000000..9f8cb92
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementRepository;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.abatement.simple.SimpleAbatementContextImpl;
+import org.onap.dcae.analytics.tca.web.abatement.simple.SimpleAbatementRepository;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Profile(AnalyticsProfile.NOT_MONGO_PROFILE_NAME)
+public class TcaSimpleAbatementConfig {
+
+    @Bean
+    public TcaAbatementRepository simpleAbatementRepository() {
+        return new SimpleAbatementRepository();
+    }
+
+    @Bean
+    public TcaAbatementContext tcaAbatementContext(final TcaAppProperties tcaAppProperties,
+                                                   final TcaAbatementRepository tcaAbatementRepository) {
+        return new SimpleAbatementContextImpl(tcaAppProperties, tcaAbatementRepository);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaWebConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/config/TcaWebConfig.java
new file mode 100644 (file)
index 0000000..7be20cc
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.stream.Stream;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.model.common.ConfigSource;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper;
+import org.onap.dcae.analytics.tca.web.service.TcaProcessingService;
+import org.onap.dcae.analytics.tca.web.service.TcaProcessingServiceImpl;
+import org.onap.dcae.analytics.tca.web.validation.TcaAppPropertiesValidator;
+import org.onap.dcae.analytics.web.config.AnalyticsWebConfig;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.core.env.Environment;
+import org.springframework.validation.Validator;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@EnableConfigurationProperties(value = TcaAppProperties.class)
+@Import(value = {AnalyticsWebConfig.class, TcaMrConfig.class, TcaAaiConfig.class,
+        TcaMongoAbatementConfig.class, TcaSimpleAbatementConfig.class, SwaggerConfig.class, ControllerConfig.class})
+public class TcaWebConfig {
+
+    @Bean
+    public static Validator configurationPropertiesValidator() {
+        return new TcaAppPropertiesValidator();
+    }
+
+    @Bean
+    public ObjectMapper objectMapper() {
+        return TcaModelJsonConversion.TCA_OBJECT_MAPPER;
+    }
+
+    @Bean
+    public TcaPolicyWrapper tcaPolicyWrapper(final TcaAppProperties tcaAppProperties,
+                                             final Environment environment) {
+        final String policy = tcaAppProperties.getTca().getPolicy();
+        final boolean isConfigBindingServiceProfileActive =
+                Stream.of(environment.getActiveProfiles())
+                        .anyMatch(profile ->
+                                profile.equalsIgnoreCase(AnalyticsProfile.CONFIG_BINDING_SERVICE_PROFILE_NAME));
+        if (isConfigBindingServiceProfileActive) {
+            return new TcaPolicyWrapper(policy, ConfigSource.CONFIG_BINDING_SERVICE);
+        } else {
+            return new TcaPolicyWrapper(policy, ConfigSource.CLASSPATH);
+        }
+    }
+
+    @Bean
+    public TcaProcessingService tcaProcessingService(final TcaAbatementContext tcaAbatementContext,
+                                                     final TcaAaiEnrichmentContext tcaAaiEnrichmentContext) {
+        return new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/controller/TcaRestController.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/controller/TcaRestController.java
new file mode 100644 (file)
index 0000000..eb9eb13
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.model.common.ConfigSource;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.TcaResultContext;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.restapi.TcaExecutionRequest;
+import org.onap.dcae.analytics.tca.model.restapi.TcaExecutionResponse;
+import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper;
+import org.onap.dcae.analytics.tca.web.service.TcaProcessingService;
+import org.onap.dcae.analytics.tca.web.util.TcaUtils;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author Rajiv Singla
+ */
+@RestController
+@RequestMapping(TcaModelConstants.TCA_REST_API_PREFIX)
+@Api(value = "Provides endpoints for TCA micro service")
+public class TcaRestController {
+
+    private final TcaProcessingService tcaProcessingService;
+    private final TcaPolicyWrapper tcaPolicyWrapper;
+
+
+    public TcaRestController(final TcaProcessingService tcaProcessingService,
+                             final TcaPolicyWrapper tcaPolicyWrapper) {
+        this.tcaProcessingService = tcaProcessingService;
+        this.tcaPolicyWrapper = tcaPolicyWrapper;
+    }
+
+    @GetMapping(value = TcaModelConstants.TCA_POLICY_ENDPOINT, produces = MediaType.APPLICATION_JSON_VALUE)
+    @ApiOperation(value = "Provides current TCA Policy")
+    public ResponseEntity<TcaPolicy> getTcaPolicy() {
+        return getTcaPolicyResponse(tcaPolicyWrapper);
+    }
+
+    @PostMapping(value = TcaModelConstants.TCA_POLICY_ENDPOINT, produces = MediaType.APPLICATION_JSON_VALUE,
+            consumes = MediaType.APPLICATION_JSON_VALUE)
+    @ApiOperation(value = "Sets new value for TCA Policy and returns current Policy")
+    public ResponseEntity<TcaPolicy> setTcaPolicy(@RequestBody final TcaPolicy tcaPolicy) {
+        tcaPolicyWrapper.setTcaPolicy(tcaPolicy, ConfigSource.REST_API);
+        return getTcaPolicyResponse(tcaPolicyWrapper);
+    }
+
+
+    @PostMapping(value = TcaModelConstants.TCA_EXECUTION_ENDPOINT, produces = MediaType.APPLICATION_JSON_VALUE,
+            consumes = MediaType.APPLICATION_JSON_VALUE)
+    @ApiOperation(value = "Applies TCA to provided execution request and generated TCA execution response")
+    public ResponseEntity<List<TcaExecutionResponse>> execute(@RequestBody final TcaExecutionRequest
+                                                                      tcaExecutionRequest) {
+        // process tca execution request
+        final List<TcaExecutionContext> executionContexts = tcaProcessingService.getTcaExecutionResults(
+                tcaExecutionRequest.getRequestId(), tcaExecutionRequest.getTransactionId(),
+                tcaExecutionRequest.getTcaPolicy(), TcaUtils.getCefMessagesFromEventListeners
+                        (tcaExecutionRequest.getEventListeners()));
+        // create execution response
+        final List<TcaExecutionResponse> tcaExecutionResponses = executionContexts.stream().map(tcaExecutionContext -> {
+            final TcaExecutionResponse tcaExecutionResponse = new TcaExecutionResponse();
+            tcaExecutionResponse.setRequestId(tcaExecutionContext.getRequestId());
+            tcaExecutionResponse.setTransactionId(tcaExecutionContext.getTransactionId());
+            final TcaResultContext tcaResultContext = tcaExecutionContext.getTcaResultContext();
+            tcaExecutionResponse.setViolatedMetricsPerEventName(tcaResultContext.getViolatedMetricsPerEventName());
+            tcaExecutionResponse.setTcaAlert(tcaResultContext.getTcaAlert());
+            return tcaExecutionResponse;
+        }).collect(Collectors.toList());
+
+        return ResponseEntity.ok().body(tcaExecutionResponses);
+    }
+
+
+    private static ResponseEntity<TcaPolicy> getTcaPolicyResponse(final TcaPolicyWrapper tcaPolicyWrapper) {
+        return ResponseEntity.ok()
+                .header(TcaModelConstants.TCA_POLICY_SOURCE_HEADER_KEY, tcaPolicyWrapper.getConfigSource().name())
+                .header(TcaModelConstants.TCA_POLICY_CREATION_HEADER_KEY,
+                        tcaPolicyWrapper.getCreationTime().format(DateTimeFormatter.ISO_OFFSET_DATE_TIME))
+                .header(TcaModelConstants.TCA_POLICY_VERSION_HEADER_KEY, tcaPolicyWrapper.getPolicyVersion())
+                .body(tcaPolicyWrapper.getTcaPolicy());
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java
new file mode 100644 (file)
index 0000000..e85932a
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.domain;
+
+import static org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion.TCA_POLICY_JSON_FUNCTION;
+
+import lombok.Getter;
+import lombok.ToString;
+
+import java.time.ZonedDateTime;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.onap.dcae.analytics.model.common.ConfigSource;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicyModel;
+import org.onap.dcae.analytics.tca.web.validation.TcaPolicyValidator;
+import org.onap.dcae.analytics.web.exception.AnalyticsParsingException;
+import org.onap.dcae.analytics.web.util.ValidationUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Rajiv Singla
+ */
+@Getter
+@ToString
+public class TcaPolicyWrapper implements TcaPolicyModel {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger logger = LoggerFactory.getLogger(TcaPolicyWrapper.class);
+
+    private final ZonedDateTime creationTime;
+    private ZonedDateTime updateDateTime;
+    private TcaPolicy tcaPolicy;
+    private ConfigSource configSource;
+    private AtomicInteger policyUpdateSequence;
+    private String policyVersion;
+
+    public TcaPolicyWrapper(final String tcaPolicyString, final ConfigSource configSource) {
+        createOrUpdatePolicy(getTcaPolicy(tcaPolicyString), configSource);
+        this.creationTime = ZonedDateTime.now();
+    }
+
+    public void setTcaPolicy(final String tcaPolicyString, final ConfigSource configSource) {
+        createOrUpdatePolicy(getTcaPolicy(tcaPolicyString), configSource);
+    }
+
+    public void setTcaPolicy(final TcaPolicy tcaPolicy, final ConfigSource configSource) {
+        createOrUpdatePolicy(tcaPolicy, configSource);
+    }
+
+    private void createOrUpdatePolicy(final TcaPolicy tcaPolicy, final ConfigSource configSource) {
+        ValidationUtils.validate(tcaPolicy, new TcaPolicyValidator());
+        this.tcaPolicy = tcaPolicy;
+        this.configSource = configSource;
+        this.updateDateTime = ZonedDateTime.now();
+        if (policyUpdateSequence == null) {
+            policyUpdateSequence = new AtomicInteger(0);
+        } else {
+            policyUpdateSequence.getAndUpdate(sequence -> sequence + 1);
+        }
+        this.policyVersion = getPolicyVersion(policyUpdateSequence);
+        final String configSourceName = configSource.name();
+        logger.info("Updated Tca Policy Wrapper with policy: {}, from Source: {}, policy Version: {}",
+                tcaPolicy, configSourceName, policyVersion);
+    }
+
+
+    private TcaPolicy getTcaPolicy(final String tcaPolicyString) {
+        return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow(
+                () -> new AnalyticsParsingException("Unable to parse Tca Policy String: " + tcaPolicyString,
+                        new IllegalArgumentException()));
+    }
+
+
+    private static String getPolicyVersion(final AtomicInteger policyUpdateSequence) {
+        return "version-" + policyUpdateSequence.intValue();
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformer.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformer.java
new file mode 100644 (file)
index 0000000..59acd2d
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.integration;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.model.ecomplogger.AnalyticsErrorType;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.util.TcaUtils;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.onap.dcae.utils.eelf.logger.api.info.ErrorLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.model.info.ErrorLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestIdLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestTimingLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ResponseLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.TargetServiceLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.AuditLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.ErrorLogSpecImpl;
+import org.springframework.integration.transformer.AbstractTransformer;
+import org.springframework.messaging.Message;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAlertTransformer extends AbstractTransformer {
+
+    private static final EELFLogger logger = EELFLogFactory.getLogger(TcaAlertTransformer.class);
+
+    private static final Predicate<TcaExecutionContext> ERROR_EXECUTION_CONTEXT_PREDICATE =
+            executionContext -> executionContext.getTcaProcessingContext().getErrorMessage() != null;
+    private static final Predicate<TcaExecutionContext> EARLY_TERMINATION_CONTEXT_PREDICATE =
+            tcaExecutionContext -> tcaExecutionContext.getTcaProcessingContext().getEarlyTerminationMessage() != null;
+    private static final Predicate<TcaExecutionContext> ABATED_EXECUTION_CONTEXT_PREDICATE =
+            tcaExecutionContext -> tcaExecutionContext.getTcaResultContext().getPreviousRequestId() != null;
+
+    private final TcaAppProperties tcaAppProperties;
+
+    public TcaAlertTransformer(final TcaAppProperties tcaAppProperties) {
+        this.tcaAppProperties = tcaAppProperties;
+    }
+
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected Object doTransform(final Message<?> message) throws Exception {
+
+        final Object messagePayload = message.getPayload();
+
+        final String requestId = AnalyticsHttpUtils.getRequestId(message.getHeaders());
+        final String transactionId = AnalyticsHttpUtils.getTransactionId(message.getHeaders());
+        final Date requestBeginTimestamp = AnalyticsHttpUtils.getTimestampFromHeaders(message.getHeaders(),
+                AnalyticsHttpConstants.REQUEST_BEGIN_TS_HEADER_KEY);
+
+        if (messagePayload instanceof List) {
+            // get execution contexts with alerts
+            final List<TcaExecutionContext> tcaExecutionContexts = (List<TcaExecutionContext>) messagePayload;
+            final List<TcaAlert> tcaAlerts =
+                    tcaExecutionContexts.stream()
+                            .map(e -> e.getTcaResultContext().getTcaAlert())
+                            .filter(Objects::nonNull).collect(Collectors.toList());
+
+            // do ecomp logging
+            if (tcaAppProperties.getTca().getEnableEcompLogging()) {
+                final List<TcaExecutionContext> errorExecutionContexts =
+                        tcaExecutionContexts.stream().filter(ERROR_EXECUTION_CONTEXT_PREDICATE)
+                                .collect(Collectors.toList());
+                createAuditLog(requestId, transactionId, requestBeginTimestamp, tcaExecutionContexts, tcaAlerts,
+                        errorExecutionContexts);
+                createErrorLog(requestId, transactionId, errorExecutionContexts);
+            }
+
+            // if no alerts terminate further processing
+            return tcaAlerts.isEmpty() ? null : tcaAlerts;
+        } else {
+            return null;
+        }
+    }
+
+
+    private static void createErrorLog(final String requestId,
+                                       final String transactionId,
+                                       final List<TcaExecutionContext> errorExecutionContexts) {
+        // no error log generated - if there was no error during tca processing
+        if (!errorExecutionContexts.isEmpty()) {
+            for (TcaExecutionContext errorExecutionContext : errorExecutionContexts) {
+                final RequestIdLogInfoImpl requestIdLogInfo =
+                        new RequestIdLogInfoImpl(errorExecutionContext.getRequestId());
+                final TargetServiceLogInfo targetServiceLogInfo = new TargetServiceLogInfoImpl(
+                        "DCAE-TCA", TcaModelConstants.TCA_SERVICE_NAME, "");
+                final ErrorLogInfo errorLogInfo =
+                        new ErrorLogInfoImpl(AnalyticsErrorType.SCHEMA_ERROR.getErrorCode(),
+                                AnalyticsErrorType.SCHEMA_ERROR.getErrorDescription());
+                final ErrorLogSpecImpl errorLogSpec = new ErrorLogSpecImpl(requestIdLogInfo,
+                        TcaUtils.TCA_SERVICE_LOG_INFO, targetServiceLogInfo, errorLogInfo);
+                logger.errorLog().error("Request Id: {}, Transaction Id: {}, Error Message: {} ",
+                        errorLogSpec, requestId, transactionId, errorExecutionContext.getTcaProcessingContext()
+                                .getErrorMessage());
+            }
+        }
+    }
+
+    private static void createAuditLog(final String requestId,
+                                       final String transactionId,
+                                       final Date requestBeginTimestamp,
+                                       final List<TcaExecutionContext> tcaExecutionContexts,
+                                       final List<TcaAlert> tcaAlerts,
+                                       final List<TcaExecutionContext> errorExecutionContexts) {
+        final List<TcaExecutionContext> earlyTerminationExecutionContexts =
+                tcaExecutionContexts.stream().filter(EARLY_TERMINATION_CONTEXT_PREDICATE)
+                        .collect(Collectors.toList());
+        final List<TcaExecutionContext> abatedExecutionContexts =
+                tcaExecutionContexts.stream().filter(ABATED_EXECUTION_CONTEXT_PREDICATE)
+                        .collect(Collectors.toList());
+        final RequestIdLogInfoImpl requestIdLogInfo = new RequestIdLogInfoImpl(requestId);
+        final Date endTimestamp = new Date();
+        final RequestTimingLogInfoImpl requestTimingLogInfo = new RequestTimingLogInfoImpl(requestBeginTimestamp,
+                endTimestamp, endTimestamp.getTime() - requestBeginTimestamp.getTime());
+        final ResponseLogInfo responseLogInfo =
+                new ResponseLogInfoImpl(AnalyticsErrorType.SUCCESSFUL.getErrorCode(),
+                        AnalyticsErrorType.SUCCESSFUL.getErrorDescription());
+        final AuditLogSpecImpl auditLogSpec = new AuditLogSpecImpl(requestIdLogInfo, TcaUtils.TCA_SERVICE_LOG_INFO,
+                requestTimingLogInfo, responseLogInfo);
+        logger.auditLog().info("Request Id: {}, Transaction Id: {}, " +
+                        "Message counts - Received: {}, Errors: {}, Terminated Early: {}, Abated: {}, Alerts: {}",
+                auditLogSpec, requestId, transactionId,
+                Integer.toString(tcaExecutionContexts.size()), Integer.toString(errorExecutionContexts.size()),
+                Integer.toString(earlyTerminationExecutionContexts.size()),
+                Integer.toString(abatedExecutionContexts.size()), Integer.toString(tcaAlerts.size()));
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandler.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/integration/TcaPublisherResponseHandler.java
new file mode 100644 (file)
index 0000000..0e81a28
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.integration;
+
+
+import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_BEGIN_TS_HEADER_KEY;
+import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_END_TS_HEADER_KEY;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.ecomplogger.AnalyticsErrorType;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.util.TcaUtils;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestIdLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestTimingLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ResponseLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.AuditLogSpecImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.integration.handler.GenericHandler;
+import org.springframework.messaging.MessageHeaders;
+
+/**
+ * TCA Publisher Response Handler is used to do logging of response received from DMaaP MR Publisher. It does not do
+ * any changes to payload or headers
+ *
+ * @author Rajiv Singla
+ */
+public class TcaPublisherResponseHandler implements GenericHandler<String> {
+
+    private static final EELFLogger ECOMP_LOGGER = EELFLogFactory.getLogger(TcaPublisherResponseHandler.class);
+    private static final Logger logger = LoggerFactory.getLogger(TcaPublisherResponseHandler.class);
+
+    private final TcaAppProperties tcaAppProperties;
+
+    public TcaPublisherResponseHandler(final TcaAppProperties tcaAppProperties) {
+        this.tcaAppProperties = tcaAppProperties;
+    }
+
+    @Override
+    public Object handle(final String payload, final Map<String, Object> headers) {
+
+        final MessageHeaders messageHeaders = new MessageHeaders(headers);
+        final String requestId = AnalyticsHttpUtils.getRequestId(messageHeaders);
+        final String transactionId = AnalyticsHttpUtils.getTransactionId(messageHeaders);
+        final Date beginTimestamp = AnalyticsHttpUtils.getTimestampFromHeaders(headers, REQUEST_BEGIN_TS_HEADER_KEY);
+        final Date endTimestamp = AnalyticsHttpUtils.getTimestampFromHeaders(headers, REQUEST_END_TS_HEADER_KEY);
+
+        if (tcaAppProperties.getTca().getEnableEcompLogging()) {
+            createAuditLog(requestId, transactionId, beginTimestamp, endTimestamp, payload);
+        } else {
+            logger.info("Request Id: {}, Transaction Id: {}, Transaction completion Time: {} ms, " +
+                            "DMaaP MR Publisher Response: {}", requestId, transactionId,
+                    endTimestamp.getTime() - beginTimestamp.getTime(), payload);
+        }
+        return payload;
+
+    }
+
+    private static void createAuditLog(final String requestId,
+                                       final String transactionId,
+                                       final Date requestBeginTimestamp,
+                                       final Date requestEndTimestamp,
+                                       final String tcaPublisherResponse) {
+        final RequestIdLogInfoImpl requestIdLogInfo = new RequestIdLogInfoImpl(requestId);
+        final long elapsedTime = requestEndTimestamp.getTime() - requestBeginTimestamp.getTime();
+        final RequestTimingLogInfoImpl requestTimingLogInfo = new RequestTimingLogInfoImpl(requestBeginTimestamp,
+                requestEndTimestamp, elapsedTime);
+        final ResponseLogInfo responseLogInfo =
+                new ResponseLogInfoImpl(AnalyticsErrorType.SUCCESSFUL.getErrorCode(),
+                        AnalyticsErrorType.SUCCESSFUL.getErrorDescription());
+        final AuditLogSpecImpl auditLogSpec = new AuditLogSpecImpl(requestIdLogInfo, TcaUtils.TCA_SERVICE_LOG_INFO,
+                requestTimingLogInfo, responseLogInfo);
+        ECOMP_LOGGER.auditLog().info("Request Id: {}, Transaction Id: {}, " +
+                        "Transaction completion Time: {} ms, DMaaP MR Publisher Response: {}",
+                auditLogSpec, requestId, transactionId, Long.toString(elapsedTime), tcaPublisherResponse);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingService.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingService.java
new file mode 100644 (file)
index 0000000..39a985c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.service;
+
+import java.util.List;
+
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+
+/**
+ * Provides TCA functionality
+ *
+ * @author Rajiv Singla
+ */
+public interface TcaProcessingService {
+
+    /**
+     * Apply policy thresholds to CEF messages and generate TCA execution results
+     *
+     * @param requestId request id associated with tca execution request
+     * @param transactionId transaction id associated with the tca execution request
+     * @param tcaPolicy tca policy that needs to be applied to CEF messages
+     * @param cefMessages list of CEF messages that needs to be processed by TCA
+     *
+     * @return results of TCA Processing
+     */
+    List<TcaExecutionContext> getTcaExecutionResults(String requestId, String transactionId,
+                                                     TcaPolicy tcaPolicy,
+                                                     List<String> cefMessages);
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImpl.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImpl.java
new file mode 100644 (file)
index 0000000..3bb742a
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.service;
+
+import static org.onap.dcae.analytics.web.util.AnalyticsWebUtils.RANDOM_ID_SUPPLIER;
+import static org.onap.dcae.analytics.web.util.AnalyticsWebUtils.REQUEST_ID_SUPPLIER;
+import static org.onap.dcae.analytics.web.util.ValidationUtils.isPresent;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import org.onap.dcae.analytics.model.AnalyticsModelConstants;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaProcessingContext;
+import org.onap.dcae.analytics.tca.core.service.GenericTcaResultContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAaiEnrichmentContext;
+import org.onap.dcae.analytics.tca.core.service.TcaAbatementContext;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.core.util.function.calculation.TcaCalculator;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.web.util.TcaUtils;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaProcessingServiceImpl implements TcaProcessingService {
+
+    private final TcaAbatementContext tcaAbatementContext;
+    private final TcaAaiEnrichmentContext tcaAaiEnrichmentContext;
+
+    public TcaProcessingServiceImpl(final TcaAbatementContext tcaAbatementContext,
+                                    final TcaAaiEnrichmentContext tcaAaiEnrichmentContext) {
+        this.tcaAbatementContext = tcaAbatementContext;
+        this.tcaAaiEnrichmentContext = tcaAaiEnrichmentContext;
+    }
+
+
+    @Override
+    public List<TcaExecutionContext> getTcaExecutionResults(final String requestId,
+                                                            final String transactionId,
+                                                            final TcaPolicy tcaPolicy,
+                                                            final List<String> cefMessages) {
+        // create tca policy deep copy as it should be same for current execution
+        final TcaPolicy tcaPolicyDeepCopy = TcaUtils.getTcaPolicyDeepCopy(tcaPolicy);
+        // create new request id if not present
+        final String executionRequestId = isPresent(requestId) ? requestId : REQUEST_ID_SUPPLIER.get();
+        // create transaction id if not present
+        final String executionTransactionId = isPresent(transactionId) ? transactionId : RANDOM_ID_SUPPLIER.get();
+
+        return IntStream.range(0, cefMessages.size())
+                // generate initial Processing contexts
+                .mapToObj(cefMessageIndex -> GenericTcaExecutionContext.builder()
+                        .requestId(executionRequestId +
+                                AnalyticsModelConstants.ANALYTICS_REQUEST_ID_DELIMITER + cefMessageIndex)
+                        .transactionId(executionTransactionId)
+                        .messageIndex(cefMessageIndex)
+                        .cefMessage(cefMessages.get(cefMessageIndex))
+                        .tcaPolicy(tcaPolicyDeepCopy)
+                        .tcaProcessingContext(new GenericTcaProcessingContext())
+                        .tcaAbatementContext(tcaAbatementContext)
+                        .tcaAaiEnrichmentContext(tcaAaiEnrichmentContext)
+                        .tcaResultContext(new GenericTcaResultContext())
+                        .build())
+                // apply tca calculator
+                .map(new TcaCalculator())
+                // return result
+                .collect(Collectors.toList());
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/TcaUtils.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/TcaUtils.java
new file mode 100644 (file)
index 0000000..6744cee
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.util;
+
+import static org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion.TCA_OBJECT_MAPPER;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.model.cef.EventListener;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.web.exception.AnalyticsParsingException;
+import org.onap.dcae.utils.eelf.logger.model.info.ServiceLogInfoImpl;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class TcaUtils {
+
+    /**
+     * TCA Service Log Info for ECOMP Logging
+     */
+    public static final ServiceLogInfoImpl TCA_SERVICE_LOG_INFO =
+            new ServiceLogInfoImpl(TcaModelConstants.TCA_SERVICE_NAME, System.getProperty("user.name"), "");
+
+    /**
+     * Creates a deep copy of Tca Policy
+     *
+     * @param tcaPolicy source tca policy object
+     *
+     * @return deep copy of provided tca policy
+     */
+    public static TcaPolicy getTcaPolicyDeepCopy(final TcaPolicy tcaPolicy) {
+        if (tcaPolicy != null) {
+            try {
+                return TCA_OBJECT_MAPPER.treeToValue(TCA_OBJECT_MAPPER.valueToTree(tcaPolicy), TcaPolicy.class);
+            } catch (JsonProcessingException e) {
+                throw new AnalyticsParsingException("Unable to create deep copy of TCA Policy: " + tcaPolicy, e);
+            }
+        } else {
+            final String errorMessage = "Invalid application state. TCA Policy must not be null";
+            throw new AnalyticsParsingException(errorMessage, new IllegalStateException(errorMessage));
+        }
+    }
+
+
+    /**
+     * Converts given event Listeners to list of CEF Message String
+     *
+     * @param eventListeners event listeners object
+     *
+     * @return cef messages as string
+     */
+    public static List<String> getCefMessagesFromEventListeners(final List<EventListener> eventListeners) {
+        if (!Optional.ofNullable(eventListeners).isPresent()) {
+            return Collections.emptyList();
+        }
+        return eventListeners.stream().map(eventListener -> {
+            try {
+                return TCA_OBJECT_MAPPER.writeValueAsString(eventListener);
+            } catch (JsonProcessingException e) {
+                throw new AnalyticsParsingException("Unable to parse EventLister to String: " + eventListener, e);
+            }
+        }).collect(Collectors.toList());
+    }
+
+    private TcaUtils() {
+        // private constructor
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToAaiRestClientPrefsFunction.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToAaiRestClientPrefsFunction.java
new file mode 100644 (file)
index 0000000..759d5dd
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.util.function;
+
+import java.util.Optional;
+import java.util.function.Function;
+
+import org.onap.dcae.analytics.model.util.function.StringToURLFunction;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.tca.web.aai.TcaAaiRestClientPreferences;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.springframework.http.HttpHeaders;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAppPropsToAaiRestClientPrefsFunction implements Function<TcaAppProperties,
+        TcaAaiRestClientPreferences> {
+
+    @Override
+    public TcaAaiRestClientPreferences apply(final TcaAppProperties tcaAppProperties) {
+
+        final TcaAppProperties.Aai aai = tcaAppProperties.getTca().getAai();
+
+        // if aai enrichment is not enabled no need to configure aai Rest client template
+        if (!tcaAppProperties.getTca().getAai().getEnableEnrichment()) {
+            return null;
+        }
+
+        final HttpHeaders aaiHeaders = AnalyticsHttpUtils.createDefaultHttpHeaders();
+        aaiHeaders.add("Real-Time", "true");
+
+        return new TcaAaiRestClientPreferences(
+                tcaAppProperties.getTca().getAai().getUrl(),
+                "aai-rest-client",
+                aaiHeaders,
+                aai.getUsername(),
+                aai.getPassword(),
+                Optional.ofNullable(aai.getProxyUrl()).flatMap(new StringToURLFunction()).orElse(null),
+                aai.getIgnoreSSLValidation(),
+                tcaAppProperties.getTca().getEnableEcompLogging()
+        );
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToMrPublisherPrefsFunction.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToMrPublisherPrefsFunction.java
new file mode 100644 (file)
index 0000000..fbdbac4
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.util.function;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.PublisherDetails;
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.onap.dcae.analytics.model.util.function.StringToURLFunction;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.web.dmaap.MrPublisherPreferences;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAppPropsToMrPublisherPrefsFunction implements Function<TcaAppProperties, MrPublisherPreferences> {
+
+    private static final Logger logger = LoggerFactory.getLogger(TcaAppPropsToMrPublisherPrefsFunction.class);
+
+    @Override
+    public MrPublisherPreferences apply(final TcaAppProperties tcaAppProperties) {
+
+        final Map<String, PublisherDetails> streamsPublishes = tcaAppProperties.getStreamsPublishes();
+
+        final List<Map.Entry<String, PublisherDetails>> messageRouterPublishes =
+                streamsPublishes.entrySet().stream()
+                        .filter(ConfigBindingServiceConstants.MESSAGE_ROUTER_PREDICATE)
+                        .collect(Collectors.toList());
+
+        // Use first publisher properties
+        final Map.Entry<String, PublisherDetails> firstPublisherProperties = messageRouterPublishes.get(0);
+
+        if (messageRouterPublishes.size() > 1) {
+            logger.warn("Expected only one DMaaP MR publisher properties but found: {}.", streamsPublishes.size());
+        }
+
+        final String publisherPropertiesKey = firstPublisherProperties.getKey();
+        final PublisherDetails publisherDetails = firstPublisherProperties.getValue();
+
+        logger.info("Creating DMaaP MR Publisher from config properties key: {}, props: {}",
+                publisherPropertiesKey, publisherDetails);
+
+        final String requestURL = publisherDetails.getDmaapInfo().getTopicUrl();
+        final HttpHeaders httpHeaders = AnalyticsHttpUtils.createDefaultHttpHeaders();
+        final String username = publisherDetails.getAafUsername();
+        final String password = publisherDetails.getAafPassword();
+
+        final URL proxyUrl = Optional.ofNullable(publisherDetails.getProxyUrl())
+                .flatMap(new StringToURLFunction()).orElse(null);
+
+        final Boolean ignoreSSLValidation = publisherDetails.getIgnoreSSLValidation();
+
+        return new MrPublisherPreferences(requestURL, publisherPropertiesKey, httpHeaders, username, password,
+                proxyUrl, ignoreSSLValidation, tcaAppProperties.getTca().getEnableEcompLogging());
+
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToMrSubscriberPrefsFunction.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/util/function/TcaAppPropsToMrSubscriberPrefsFunction.java
new file mode 100644 (file)
index 0000000..14e06a1
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.util.function;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.AutoAdjusting;
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.SubscriberDetails;
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.onap.dcae.analytics.model.util.function.StringToURLFunction;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPollingPreferences;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPreferences;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+
+/**
+ * @author Rajiv Singla
+ */
+public class TcaAppPropsToMrSubscriberPrefsFunction implements Function<TcaAppProperties, MrSubscriberPreferences> {
+
+    private static final Logger logger = LoggerFactory.getLogger(TcaAppPropsToMrSubscriberPrefsFunction.class);
+
+    @Override
+    public MrSubscriberPreferences apply(final TcaAppProperties tcaAppProperties) {
+
+        final Map<String, SubscriberDetails> streamsSubscribes = tcaAppProperties.getStreamsSubscribes();
+
+        final List<Map.Entry<String, SubscriberDetails>> messageRouterSubscribers =
+                streamsSubscribes.entrySet().stream()
+                        .filter(ConfigBindingServiceConstants.MESSAGE_ROUTER_PREDICATE)
+                        .collect(Collectors.toList());
+
+        // Use first subscriber properties
+        final Map.Entry<String, SubscriberDetails> firstSubscriberProperties = messageRouterSubscribers.get(0);
+
+        if (messageRouterSubscribers.size() > 1) {
+            logger.warn("Expected one DMaaP MR subscriber properties but found: {}.", messageRouterSubscribers.size());
+        }
+
+        final String subscriberPropertiesKey = firstSubscriberProperties.getKey();
+        final SubscriberDetails subscriberDetails = firstSubscriberProperties.getValue();
+
+        logger.info("Creating DMaaP MR Subscriber from config properties key: {}, props: {}",
+                subscriberPropertiesKey, subscriberDetails);
+
+        final String requestURL = subscriberDetails.getDmaapInfo().getTopicUrl();
+        final HttpHeaders httpHeaders = AnalyticsHttpUtils.createDefaultHttpHeaders();
+        final String username = subscriberDetails.getAafUsername();
+        final String password = subscriberDetails.getAafPassword();
+        final URL proxyUrl = Optional.ofNullable(subscriberDetails.getProxyUrl())
+                .flatMap(new StringToURLFunction()).orElse(null);
+        final Boolean ignoreSSLValidation = subscriberDetails.getIgnoreSSLValidation();
+
+        final String consumerGroup = subscriberDetails.getConsumerGroup();
+        final List<String> consumerIds = subscriberDetails.getConsumerIds();
+        final Integer messageLimit = subscriberDetails.getMessageLimit();
+        final Integer timeout = subscriberDetails.getTimeout();
+
+        final Boolean enableEcompLogging = tcaAppProperties.getTca().getEnableEcompLogging();
+
+        if (subscriberDetails.getPolling() == null) {
+
+            return new MrSubscriberPreferences(requestURL, subscriberPropertiesKey, httpHeaders, username, password,
+                    proxyUrl, ignoreSSLValidation, enableEcompLogging, consumerGroup, consumerIds, messageLimit,
+                    timeout, null);
+        }
+
+        final Integer fixedRate = subscriberDetails.getPolling().getFixedRate();
+
+        if (fixedRate != null && fixedRate != 0) {
+            logger.info("Fixed Rate polling will be used for DMaaP MR Subscriber: {}", subscriberPropertiesKey);
+            final MrSubscriberPollingPreferences pollingPreferences =
+                    new MrSubscriberPollingPreferences(fixedRate, 0, fixedRate, 0);
+            return new MrSubscriberPreferences(requestURL, subscriberPropertiesKey, httpHeaders, username, password,
+                    proxyUrl, ignoreSSLValidation, enableEcompLogging, consumerGroup, consumerIds, messageLimit,
+                    timeout, pollingPreferences);
+        }
+
+        final AutoAdjusting autoAdjusting = subscriberDetails.getPolling().getAutoAdjusting();
+        logger.info("Selecting Auto Adjusting polling rate for DMaaP MR Subscriber: {}", subscriberPropertiesKey);
+
+        final MrSubscriberPollingPreferences pollingPreferences =
+                new MrSubscriberPollingPreferences(autoAdjusting.getMin(), autoAdjusting.getStepUp(),
+                        autoAdjusting.getMax(), autoAdjusting.getStepDown());
+        return new MrSubscriberPreferences(requestURL, subscriberPropertiesKey, httpHeaders, username, password,
+                proxyUrl, ignoreSSLValidation, enableEcompLogging, consumerGroup, consumerIds, messageLimit, timeout,
+                pollingPreferences);
+
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/ConfigPropertiesAaiValidator.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/ConfigPropertiesAaiValidator.java
new file mode 100644 (file)
index 0000000..5b04e92
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.validation;
+
+
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.onap.dcae.analytics.web.util.ValidationUtils;
+import org.onap.dcae.analytics.web.validation.AnalyticsValidator;
+import org.onap.dcae.analytics.web.validation.GenericValidationResponse;
+import org.springframework.lang.Nullable;
+import org.springframework.validation.Errors;
+
+/**
+ * @author Rajiv Singla
+ */
+public class ConfigPropertiesAaiValidator implements
+        AnalyticsValidator<TcaAppProperties.Aai, GenericValidationResponse> {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public GenericValidationResponse apply(final TcaAppProperties.Aai aai) {
+
+        final GenericValidationResponse validationResponse = new GenericValidationResponse();
+
+        final String genericVnfPath = aai.getGenericVnfPath();
+        if (ValidationUtils.isEmpty(genericVnfPath)) {
+            validationResponse.addErrorMessage("generic_vnf_path", "AAI Generic vnf path must be present");
+        }
+
+        final String nodeQueryPath = aai.getNodeQueryPath();
+        if (ValidationUtils.isEmpty(nodeQueryPath)) {
+            validationResponse.addErrorMessage("node_query_path", "AAI Node Query Path must be present");
+        }
+
+
+        final String url = aai.getUrl();
+        if (ValidationUtils.isEmpty(url)) {
+            validationResponse.addErrorMessage("url", "AAI url must be present");
+        }
+
+        return validationResponse;
+    }
+
+    @Override
+    public boolean supports(final Class<?> type) {
+        return type == TcaAppProperties.Aai.class;
+    }
+
+    @Override
+    public void validate(@Nullable final Object target, final Errors errors) {
+
+        // if aai is not present - assuming no aai enrichment is required
+        if (target == null) {
+            return;
+        }
+        final TcaAppProperties.Aai aai = (TcaAppProperties.Aai) target;
+
+        // skip validation if aai enrichment is not enabled
+        if (aai.getEnableEnrichment() == null || !aai.getEnableEnrichment()) {
+            return;
+        }
+
+        final GenericValidationResponse validationResponse = apply(aai);
+
+        if (validationResponse.hasErrors()) {
+            errors.rejectValue("aai", validationResponse.getAllErrorMessage());
+        }
+
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaAppPropertiesValidator.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaAppPropertiesValidator.java
new file mode 100644 (file)
index 0000000..4204e41
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.validation;
+
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.PubSubCommonDetails;
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.PublisherDetails;
+import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServiceProperties.SubscriberDetails;
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.onap.dcae.analytics.tca.web.TcaAppProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.lang.Nullable;
+import org.springframework.validation.Errors;
+import org.springframework.validation.Validator;
+
+/**
+ * Validator for {@link TcaAppProperties}. This validator is used by spring at start up time to validate
+ * TCA Application properties
+ *
+ * @author Rajiv Singla
+ */
+public class TcaAppPropertiesValidator implements Validator {
+
+    private static final Logger logger = LoggerFactory.getLogger(TcaAppPropertiesValidator.class);
+
+    @Override
+    public boolean supports(final Class<?> type) {
+        return type == TcaAppProperties.class;
+    }
+
+    @Override
+    public void validate(@Nullable final Object props, final Errors errors) {
+
+        if (props == null) {
+            errors.rejectValue(ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_PROPERTIES_KEY,
+                    "TCA App Properties are not present");
+            return;
+        }
+
+        final TcaAppProperties tcaAppProperties = (TcaAppProperties) props;
+
+        logger.info("Validating TCA App Properties: {}", tcaAppProperties);
+
+        final Map<String, PublisherDetails> streamsPublishes = tcaAppProperties.getStreamsPublishes();
+        final Map<String, SubscriberDetails> streamsSubscribes = tcaAppProperties.getStreamsSubscribes();
+
+        // Validate that stream publishes has at least 1 publisher and subscriber
+        if (!validatePubSubArePresent(errors, streamsPublishes, streamsSubscribes)) {
+            return;
+        }
+
+        // Validate that streams publishes and subscribes has at least one message router
+        List<? super PubSubCommonDetails> pubSubMRCommonDetails =
+                validatePubSubHasMRDetails(errors, streamsPublishes, streamsSubscribes);
+        if (pubSubMRCommonDetails.isEmpty()) {
+            return;
+        }
+
+        //Confirm each message router has dmaap info and their url is present and valid
+        validateMRProperties(errors, pubSubMRCommonDetails);
+
+        // validated aai properties
+        validateAAIProperties(errors, tcaAppProperties.getTca().getAai());
+
+        logger.info("Validation of TCA App Properties completed successfully");
+
+    }
+
+
+    private void validateAAIProperties(final Errors errors, final TcaAppProperties.Aai aai) {
+        new ConfigPropertiesAaiValidator().validate(aai, errors);
+    }
+
+    private void validateMRProperties(final Errors errors,
+                                      final List<? super PubSubCommonDetails> pubSubMRCommonDetails) {
+
+        for (Object pubSubMRCommonDetail : pubSubMRCommonDetails) {
+            final PubSubCommonDetails mrDetails = (PubSubCommonDetails) pubSubMRCommonDetail;
+
+            if (mrDetails.getDmaapInfo() == null || mrDetails.getDmaapInfo().getTopicUrl() == null) {
+                errors.rejectValue("dmaap_info",
+                        "dmaap_info url not present for MR configuration properties: " + mrDetails);
+            }
+
+            if (mrDetails.getDmaapInfo() != null && mrDetails.getDmaapInfo().getTopicUrl() != null
+                    && !isURLValid(mrDetails.getDmaapInfo().getTopicUrl())) {
+                errors.rejectValue("topic_url",
+                        "Invalid MR Topic URL in configuration properties:" + mrDetails);
+
+            }
+
+            if (mrDetails.getProxyUrl() != null && !mrDetails.getProxyUrl().trim().isEmpty()
+                    && !isURLValid(mrDetails.getProxyUrl())) {
+                errors.rejectValue("proxy_url",
+                        "Invalid Proxy url in configuration properties:" + mrDetails);
+            }
+        }
+
+    }
+
+    private List<? super PubSubCommonDetails> validatePubSubHasMRDetails(
+            final Errors errors,
+            final Map<String, PublisherDetails> streamsPublishes,
+            final Map<String, SubscriberDetails> streamsSubscribes) {
+
+        final List<Map.Entry<String, PublisherDetails>> messageRouterPublishers =
+                streamsPublishes.entrySet().stream()
+                        .filter(ConfigBindingServiceConstants.MESSAGE_ROUTER_PREDICATE)
+                        .collect(Collectors.toList());
+        if (messageRouterPublishers.isEmpty()) {
+            errors.rejectValue("stream_publishes",
+                    "Stream publishes must contain at least 1 message router publisher");
+        }
+
+        final List<Map.Entry<String, SubscriberDetails>> messageRouterSubscribers =
+                streamsSubscribes.entrySet().stream()
+                        .filter(ConfigBindingServiceConstants.MESSAGE_ROUTER_PREDICATE)
+                        .collect(Collectors.toList());
+        if (messageRouterSubscribers.isEmpty()) {
+            errors.rejectValue("stream_subscribes",
+                    "Stream subscriber must contain at least 1 message router subscriber");
+        }
+
+        // create common pub sub MR list
+        final List<? super PubSubCommonDetails> pubSubMRCommonDetails = new LinkedList<>();
+        pubSubMRCommonDetails.addAll(messageRouterPublishers.stream()
+                .map(Map.Entry::getValue).collect(Collectors.toList()));
+        pubSubMRCommonDetails.addAll(messageRouterSubscribers.stream()
+                .map(Map.Entry::getValue).collect(Collectors.toList())
+        );
+
+        return pubSubMRCommonDetails;
+    }
+
+    private boolean validatePubSubArePresent(final Errors errors,
+                                             final Map<String, PublisherDetails> streamsPublishes,
+                                             final Map<String, SubscriberDetails>
+                                                     streamsSubscribes) {
+        if (streamsPublishes.isEmpty()) {
+            errors.rejectValue("streams_publishes", "Streams publishes must define at least 1 publisher");
+            return false;
+        }
+        if (streamsSubscribes.isEmpty()) {
+            errors.rejectValue("streams_subscribes", "Streams subscribes must define at least 1 subscriber");
+            return false;
+        }
+
+        return true;
+    }
+
+    private static boolean isURLValid(final String urlString) {
+        try {
+            new URL(urlString);
+            return true;
+        } catch (MalformedURLException ex) {
+            return false;
+        }
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidator.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidator.java
new file mode 100644 (file)
index 0000000..f380699
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.validation;
+
+
+import static org.onap.dcae.analytics.web.util.ValidationUtils.isEmpty;
+
+import java.util.List;
+
+import org.onap.dcae.analytics.model.cef.EventSeverity;
+import org.onap.dcae.analytics.tca.model.policy.ClosedLoopEventStatus;
+import org.onap.dcae.analytics.tca.model.policy.ControlLoopSchemaType;
+import org.onap.dcae.analytics.tca.model.policy.Direction;
+import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName;
+import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
+import org.onap.dcae.analytics.tca.model.policy.Threshold;
+import org.onap.dcae.analytics.web.validation.AnalyticsValidator;
+import org.onap.dcae.analytics.web.validation.GenericValidationResponse;
+import org.springframework.lang.Nullable;
+import org.springframework.validation.Errors;
+
+
+/**
+ * TCA Policy Validator validates {@link TcaPolicy}
+ *
+ * @author Rajiv Singla
+ */
+public class TcaPolicyValidator implements AnalyticsValidator<TcaPolicy, GenericValidationResponse> {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public GenericValidationResponse apply(final TcaPolicy tcaPolicy) {
+
+        final GenericValidationResponse validationResponse = new GenericValidationResponse();
+
+        // validate TCA Policy must domain present
+        final String domain = tcaPolicy.getDomain();
+        if (isEmpty(domain)) {
+            validationResponse.addErrorMessage("domain", "TCA Policy must have only one domain present");
+        }
+
+        // validate TCA Policy must have at lease one metrics per event name
+        final List<MetricsPerEventName> metricsPerEventNames = tcaPolicy.getMetricsPerEventName();
+        if (metricsPerEventNames == null || metricsPerEventNames.isEmpty()) {
+            validationResponse
+                    .addErrorMessage("metricsPerEventName", "TCA Policy metricsPerEventName is empty");
+            return validationResponse;
+        }
+
+        // validate Metrics Per Event Name
+        for (MetricsPerEventName metricsPerEventName : metricsPerEventNames) {
+
+            // event name must be present
+            final String eventName = metricsPerEventName.getEventName();
+            if (isEmpty(eventName)) {
+                validationResponse.addErrorMessage("eventName",
+                        "TCA Policy eventName is not present for metricsPerEventNames:" + metricsPerEventName);
+            }
+
+            // control Loop Schema type must be present
+            final ControlLoopSchemaType controlLoopSchemaType = metricsPerEventName.getControlLoopSchemaType();
+            if (controlLoopSchemaType == null) {
+                validationResponse.addErrorMessage("controlLoopEventType",
+                        "TCA Policy controlLoopSchemaType is not present for metricsPerEventNames:"
+                                + metricsPerEventName);
+            }
+
+            // must have at least 1 threshold defined
+            final List<Threshold> thresholds = metricsPerEventName.getThresholds();
+            if (thresholds == null || thresholds.isEmpty()) {
+                validationResponse.addErrorMessage("thresholds",
+                        "TCA Policy event Name must have at least one threshold. " +
+                                "Event Name causing this validation error:" + metricsPerEventName);
+            } else {
+                // validate each threshold must have non null - fieldPath, thresholdValue, direction and severity
+                for (Threshold eventNameThreshold : thresholds) {
+                    final String fieldPath = eventNameThreshold.getFieldPath();
+                    final Long thresholdValue = eventNameThreshold.getThresholdValue();
+                    final Direction direction = eventNameThreshold.getDirection();
+                    final EventSeverity severity = eventNameThreshold.getSeverity();
+                    final ClosedLoopEventStatus closedLoopEventStatus = eventNameThreshold.getClosedLoopEventStatus();
+                    if (isEmpty(fieldPath) || thresholdValue == null || direction == null || severity == null ||
+                            closedLoopEventStatus == null) {
+                        validationResponse.addErrorMessage("threshold",
+                                "TCA Policy threshold must have fieldPath,thresholdValue,direction, " +
+                                        "closedLoopEventStatus and severity defined." +
+                                        "Threshold causing this validation error:" + eventNameThreshold);
+                    }
+                }
+            }
+        }
+
+        return validationResponse;
+    }
+
+    @Override
+    public boolean supports(final Class<?> type) {
+        return type == TcaPolicy.class;
+    }
+
+    @Override
+    public void validate(@Nullable final Object target, final Errors errors) {
+
+        if (target == null) {
+            errors.rejectValue("tcaPolicy", "TCA Policy must not be null");
+            return;
+        }
+
+        final TcaPolicy tcaPolicy = (TcaPolicy) target;
+        final GenericValidationResponse validationResponse = apply(tcaPolicy);
+        if (validationResponse.hasErrors()) {
+            errors.rejectValue("tca policy", validationResponse.getAllErrorMessage());
+        }
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml
new file mode 100644 (file)
index 0000000..e8f2fe8
--- /dev/null
@@ -0,0 +1,50 @@
+# DEV PROFILE SETTINGS
+config-binding-service:
+  tca:
+    policy: "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}"
+    processing_batch_size: 10000
+    enable_abatement: true
+    enable_ecomp_logging: true
+    aai:
+      enable_enrichment: true
+      url: "http://localhost:8443"
+      username: "DCAE"
+      password: "DCAE"
+      generic_vnf_path: "aai/v11/network/generic-vnfs/generic-vnf"
+      node_query_path: "aai/v11/search/nodes-query"
+  service_calls:
+    aai_broker_handle:
+      - "135.205.226.128:32768"
+  streams_publishes:
+    tca_handle_out:
+      type: "message_router"
+      aaf_username: "USER"
+      aaf_password: "PASSWORD"
+      dmaap_info:
+        client_role: "publisher"
+        client_id: "tca-pub-0"
+        location: "ecomp"
+        topic_url: "http://localhost:8080/events/PubTopic"
+  streams_subscribes:
+    tca_handle_in:
+      type: "message_router"
+      aaf_username: "USER"
+      aaf_password : "PASSWORD"
+      dmaap_info:
+        client_role: "subscriber"
+        client_id: "tca-sub-0"
+        location: "ecomp"
+        topic_url: "http://localhost:8080/events/SubTopic"
+      consumer_group: "cg1"
+      consumer_ids:
+        - "c0"
+        - "c1"
+      message_limit: 50000
+      timeout: -1
+      polling:
+        fixed_rate: 0
+        auto_adjusting:
+          min: 30000
+          step_up: 10000
+          max: 60000
+          step_down: 30000
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-mongo.yaml b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-mongo.yaml
new file mode 100644 (file)
index 0000000..6727518
--- /dev/null
@@ -0,0 +1,4 @@
+spring:
+  data:
+    mongodb:
+      uri: "mongodb://localhost:27017/analytics-tca"
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application.yaml b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application.yaml
new file mode 100644 (file)
index 0000000..1fdb070
--- /dev/null
@@ -0,0 +1,53 @@
+# SPRING SETTINGS
+spring:
+  application:
+    name: "dcae-analytics-tca"
+  main:
+    banner-mode: "off"
+  profiles:
+    active: dev
+  servlet:
+    multipart:
+      # Enable multi part file uploads / download
+      enabled: true
+      # Threshold after which files are written to disk.
+      file-size-threshold: 100KB
+      # Max file size
+      max-file-size: 512MB
+      # Max Request size
+      max-request-size: 600MB
+  output:
+    ansi:
+      enabled: always
+
+# ENDPOINTS
+management:
+  endpoint:
+    health:
+      show-details: always
+    shutdown:
+      enabled: true
+  endpoints:
+    web:
+      exposure:
+        include: '*'
+  info:
+    git:
+      mode: full
+  health:
+    redis:
+      enabled: false
+    mongo:
+      enabled: false
+
+# SERVER
+server:
+  port: 9091
+  compression:
+    # Enable gzip compression of response
+    enabled: true
+    mime-types: application/json,text/plain
+    min-response-size: 4096
+  http2:
+    enabled: true
+
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/bootstrap.yaml b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/bootstrap.yaml
new file mode 100644 (file)
index 0000000..b17d963
--- /dev/null
@@ -0,0 +1,4 @@
+spring:
+  cloud:
+    config:
+      enabled: false
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/BaseTcaWebSpringBootIT.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/BaseTcaWebSpringBootIT.java
new file mode 100644 (file)
index 0000000..e331c95
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.tca.web.config.TcaWebTestConfig;
+import org.onap.dcae.analytics.test.BaseAnalyticsSpringBootIT;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+
+/**
+ * @author Rajiv Singla
+ */
+@ActiveProfiles({AnalyticsProfile.DEV_PROFILE_NAME})
+@ContextConfiguration(classes = {TcaWebTestConfig.class})
+public abstract class BaseTcaWebSpringBootIT extends BaseAnalyticsSpringBootIT {
+
+    protected static final String TEST_POLICY_JSON_STRING;
+    protected static final String TEST_CEF_EVENT_LISTENER_STRING;
+    protected static final String TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING;
+    protected static final String TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING;
+    protected static final String TEST_CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME;
+    protected static final String TEST_REQUEST_ID = "testRequestId";
+    protected static final String TEST_TRANSACTION_ID = "testTransactionId";
+
+    static {
+
+        TEST_POLICY_JSON_STRING = fromStream(TestFileLocation.TCA_POLICY_JSON);
+        TEST_CEF_EVENT_LISTENER_STRING = fromStream(TestFileLocation.CEF_JSON_MESSAGE);
+        TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING = fromStream(TestFileLocation.CEF_JSON_MESSAGE_WITH_VIOLATION);
+        TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING = fromStream(TestFileLocation.CEF_JSON_MESSAGE_WITH_ABATEMENT);
+        TEST_CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME = fromStream(TestFileLocation
+                .CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME);
+
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/config/TcaWebTestConfig.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/config/TcaWebTestConfig.java
new file mode 100644 (file)
index 0000000..ccd5d97
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.config;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@EnableAutoConfiguration
+@Import(value = {TcaWebConfig.class})
+public class TcaWebTestConfig {
+
+}
diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java
new file mode 100644 (file)
index 0000000..5723160
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.tca.web.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext;
+import org.onap.dcae.analytics.tca.model.facade.TcaAlert;
+import org.onap.dcae.analytics.tca.web.BaseTcaWebSpringBootIT;
+import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Rajiv Singla
+ */
+class TcaProcessingServiceImplTest extends BaseTcaWebSpringBootIT {
+
+    @Autowired
+    private TcaProcessingService tcaProcessingService;
+
+    @Autowired
+    private TcaPolicyWrapper tcaPolicyWrapper;
+
+    @Autowired
+    private ObjectMapper objectMapper;
+
+    @Test
+    void getTcaExecutionResults() throws Exception {
+
+        final List<TcaExecutionContext> tcaExecutionResults =
+                tcaProcessingService.getTcaExecutionResults
+                        (TEST_REQUEST_ID, TEST_TRANSACTION_ID, tcaPolicyWrapper.getTcaPolicy(),
+                                Arrays.asList(TEST_CEF_EVENT_LISTENER_STRING,
+                                        TEST_CEF_JSON_MESSAGE_WITH_VIOLATION_STRING,
+                                        TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING,
+                                        TEST_CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME));
+
+
+        for (TcaExecutionContext tcaExecutionResult : tcaExecutionResults) {
+            final TcaAlert tcaAlert = tcaExecutionResult.getTcaResultContext().getTcaAlert();
+            String tcaAlertString = "";
+            if (tcaAlert != null) {
+                tcaAlertString = objectMapper.writeValueAsString(tcaAlert);
+            }
+            logger.debug("{} -> {}", tcaExecutionResult.getRequestId(), tcaAlertString);
+
+        }
+
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-test/pom.xml b/dcae-analytics/dcae-analytics-test/pom.xml
new file mode 100644 (file)
index 0000000..43789a9
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.dcaegen2.analytics</groupId>
+        <artifactId>dcae-analytics</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dcae-analytics-test</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- THIS MODULE CONTAINS COMMON TESTING CODE AND MUST NEVER BE DEPLOYED IN PRODUCTION ENVIRONMENT -->
+    <name>DCAE Analytics Test</name>
+    <description>Contains common testing code for all DCAE Analytics Modules</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+    </properties>
+
+    <dependencies>
+
+        <!-- LOGGING -->
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <!-- SPRING TEST DEPENDENCIES -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <version>${spring.boot.version}</version>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- JSON SERIALIZATION/DESERIALIZATION LIBRARY -->
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <!-- JUNIT 5 DEPENDENCIES -->
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-engine</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apiguardian</groupId>
+            <artifactId>apiguardian-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <!-- ASSERTION UTILITIES -->
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.skyscreamer</groupId>
+            <artifactId>jsonassert</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <!-- MOCKING FRAMEWORK -->
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>
diff --git a/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsIT.java b/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsIT.java
new file mode 100644 (file)
index 0000000..9d11201
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.test;
+
+/**
+ * Base class for all DCAE Analytics Integration Test
+ *
+ * @author Rajiv Singla
+ */
+public class BaseAnalyticsIT extends BaseAnalyticsTest {
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsSpringBootIT.java b/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsSpringBootIT.java
new file mode 100644 (file)
index 0000000..cef9f89
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.test;
+
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+/**
+ * @author Rajiv Singla
+ */
+@ExtendWith(SpringExtension.class)
+@SpringBootTest
+public abstract class BaseAnalyticsSpringBootIT extends BaseAnalyticsIT {
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsTest.java b/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsTest.java
new file mode 100644 (file)
index 0000000..43cc377
--- /dev/null
@@ -0,0 +1,464 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.test;
+
+import static java.nio.file.Files.deleteIfExists;
+import static java.nio.file.Files.exists;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectOutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.nio.charset.Charset;
+import java.nio.file.Paths;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Function;
+
+import org.json.JSONException;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Base common test class for all DCAE Analytics Test e.g. unit tests, integration test etc.
+ *
+ * @author Rajiv Singla
+ */
+abstract class BaseAnalyticsTest {
+
+    protected static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+    /**
+     * Asserts if expected Json String and actual Json String contain the same properties ignoring
+     * property order. Simple String assertion might fail as property order during serialization and deserialization
+     * is generally non-deterministic. Also proper error message are generated more missing or unexpected
+     * properties
+     *
+     * @param expectedJsonString expected Json String
+     * @param actualJsonString actual Json String
+     *
+     * @throws JSONException Json Exception
+     */
+    public static void assertJson(final String expectedJsonString, final String actualJsonString) throws JSONException {
+        JSONAssert.assertEquals(expectedJsonString, actualJsonString, true);
+    }
+
+    /**
+     * Converts given file location to String
+     *
+     * @param fileLocation location of the file which needs to be converted to String
+     *
+     * @return Contents of file as string
+     */
+    public static String fromStream(final String fileLocation) {
+        try (InputStream fileInputStream = asInputStream(fileLocation);
+             BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream, Charset.forName
+                     ("UTF-8")))) {
+            final StringBuilder result = new StringBuilder();
+            final String newLine = System.getProperty("line.separator");
+            String line = reader.readLine();
+            while (line != null) {
+                result.append(line).append(newLine);
+                line = reader.readLine();
+            }
+            return result.toString();
+        } catch (IOException e) {
+            throw new RuntimeException("Unable to get contents for file Location: " + fileLocation, e);
+        }
+    }
+
+    /**
+     * Converts given file location to input stream
+     *
+     * @param fileLocation file location
+     *
+     * @return input stream of given file location
+     */
+    public static InputStream asInputStream(final String fileLocation) {
+        final InputStream fileInputStream =
+                BaseAnalyticsTest.class.getClassLoader().getResourceAsStream(fileLocation);
+        assertThat(fileInputStream).as("Input File Location must be valid").isNotNull();
+        return fileInputStream;
+    }
+
+    /**
+     * Checks if object can be serialized properly
+     *
+     * @param object input object
+     * @param callingClass calling class
+     */
+    public static void testSerialization(final Object object, final Class<?> callingClass) {
+
+        final URL location = callingClass.getProtectionDomain().getCodeSource().getLocation();
+        final File serializedOutputFile =
+                new File(location.getPath() + String.format("serialization/%s.ser", object.getClass().getSimpleName()));
+        try {
+            // Maybe file already exists try deleting it first
+            final boolean deleteIfExists = deleteIfExists(Paths.get(serializedOutputFile.getPath()));
+
+            if (deleteIfExists) {
+                logger.warn("Previous serialization file was overwritten at location: {}",
+                        serializedOutputFile.getPath());
+            }
+
+            boolean mkdirs = true;
+            if (!Paths.get(serializedOutputFile.getParentFile().getPath()).toFile().exists()) {
+                mkdirs = serializedOutputFile.getParentFile().mkdirs();
+            }
+            if (mkdirs) {
+                try (FileOutputStream fileOutputStream = new FileOutputStream(serializedOutputFile);
+                     ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream)) {
+                    objectOutputStream.writeObject(object);
+                    logger.debug("Successfully created serialization file at location: {}", serializedOutputFile
+                            .getPath());
+                }
+            }
+
+        } catch (IOException ex) {
+            throw new IllegalStateException(
+                    String.format("Failed to create location to store serialization file: %s", serializedOutputFile));
+        }
+    }
+
+    /**
+     * Writes Text to Output file
+     *
+     * @param textFileLocation location of text file e.g. textfiles/fileName.json
+     * @param content file content
+     * @param callingClass calling class
+     *
+     * @throws IOException ioException
+     */
+    public static void writeToOutputTextFile(final String textFileLocation,
+                                             final String content, Class<?> callingClass) throws IOException {
+        final URL location = callingClass.getProtectionDomain().getCodeSource().getLocation();
+        final File fileLocation = new File(location.getPath() + textFileLocation);
+
+        // Maybe file already try deleting it first
+        final boolean deleteIfExists = deleteIfExists(Paths.get(fileLocation.getPath()));
+
+        if (deleteIfExists) {
+            logger.warn("Previous file will be overwritten at location: {}", fileLocation.getPath());
+        }
+
+        boolean mkdirs = true;
+        if (!exists(Paths.get(fileLocation.getParentFile().getPath()))) {
+            mkdirs = fileLocation.getParentFile().mkdirs();
+        }
+        if (mkdirs) {
+            try (
+                    FileOutputStream fileOutputStream = new FileOutputStream(fileLocation);
+                    OutputStreamWriter outputStream =
+                            new OutputStreamWriter(fileOutputStream, Charset.forName("UTF-8"))) {
+                outputStream.write(content);
+                logger.debug("Successfully created text file at location: {}", fileLocation.getPath());
+            }
+        } else {
+            throw new IllegalStateException(
+                    String.format("Failed to create location to store text file: %s", fileLocation));
+        }
+
+    }
+
+    /**
+     * For testing purposes only sometime we may want to access private fields of underlying
+     * object to confirm the values are setup correctly.
+     * This method uses java reflection to get the value to private object in the class
+     *
+     * @param object Actual object which has the private field you want to check
+     * @param fieldName Field name in the Actual Object you want to get the value of
+     * @param privateFieldClass Type of the private field
+     * @param <T> Class of Actual Object
+     * @param <U> Class of private field
+     *
+     * @return value of the private field
+     */
+    @SuppressWarnings("unchecked")
+    public static <T, U> U getPrivateFiledValue(final T object, final String fieldName,
+                                                final Class<U> privateFieldClass) {
+
+        final Class<?> objectClass = object.getClass();
+        try {
+            final Field privateField = objectClass.getDeclaredField(fieldName);
+            try {
+
+                // mark private field to be accessible for testing purposes
+                AccessController.doPrivileged((PrivilegedAction) () -> {
+                    privateField.setAccessible(true);
+                    return null;
+                });
+
+                return privateFieldClass.cast(privateField.get(object));
+
+            } catch (IllegalAccessException e) {
+                logger.error("Unable to access field: {}", fieldName);
+                throw new IllegalStateException(e);
+            }
+        } catch (NoSuchFieldException e) {
+            logger.error("Unable to locate field name: {} in class: {}", fieldName, objectClass.getSimpleName());
+            throw new IllegalStateException(e);
+        }
+
+    }
+
+    /**
+     * For testing purposes only sometime we may want to print classpath jars which are visible inside the class
+     *
+     * @param classLoader classloader of the calling class
+     */
+    public static void dumpClasspath(final ClassLoader classLoader) {
+
+        logger.info("Dumping ClassPath for classloader: {}", classLoader);
+
+        if (classLoader instanceof URLClassLoader) {
+
+            URLClassLoader ucl = (URLClassLoader) classLoader;
+            logger.info("\t ==========>>>" + Arrays.toString(ucl.getURLs()));
+
+        } else {
+            logger.info("\t(cannot display components as it is not a URLClassLoader)");
+        }
+
+        if (classLoader.getParent() != null) {
+            dumpClasspath(classLoader.getParent());
+        }
+    }
+
+    /**
+     * Deserialize given Json file location to given model class and returns it back without any validation check.
+     *
+     * @param jsonFileLocation Classpath location of the json file
+     * @param modelClass Model Class type
+     * @param <T> Json Model Type
+     * @param objectMapper Jackson Json Object Mapper
+     *
+     * @return Deserialized Model Object
+     */
+    public static <T> T deserializeJsonFileToModel(final String jsonFileLocation, final Class<T> modelClass,
+                                                   final ObjectMapper objectMapper) {
+        final InputStream jsonFileInputStream =
+                BaseAnalyticsTest.class.getClassLoader().getResourceAsStream(jsonFileLocation);
+        assertThat(jsonFileInputStream).as("Input JSON File location must be valid").isNotNull();
+        try {
+            return objectMapper.readValue(jsonFileInputStream, modelClass);
+        } catch (IOException ex) {
+            logger.error("Error while doing assert Json for fileLocation: {}, modelClass: {}, Exception {}",
+                    jsonFileLocation, modelClass, ex);
+            throw new RuntimeException(ex);
+        } finally {
+            try {
+                jsonFileInputStream.close();
+            } catch (IOException e) {
+                logger.error("Error while closing input stream at file location: {}", jsonFileLocation);
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    /**
+     * Serialize model to json string
+     *
+     * @param model model object
+     * @param objectMapper Jackson Json Object Mapper
+     *
+     * @return json
+     *
+     * @throws JsonProcessingException when fails to process object
+     */
+    public static String serializeModelToJson(final Object model, final ObjectMapper objectMapper) throws
+            JsonProcessingException {
+        return objectMapper.writeValueAsString(model);
+    }
+
+    /**
+     * Converts given model to json string and compare it with json present at given file location.
+     *
+     * @param model Model which needs to be compared
+     * @param expectedJsonFileLocation Location of file containing expected json string
+     * @param objectMapper Jackson Json Object Mapper
+     * @param <T> Json Model Type
+     *
+     * @return If assertion passes returns the input model
+     */
+    public static <T> T assertJsonSerialization(final T model, final String expectedJsonFileLocation,
+                                                final ObjectMapper objectMapper) {
+        try {
+            final String actualModelString = serializeModelToJson(model, objectMapper);
+            final String expectedModelString = fromStream(expectedJsonFileLocation);
+            assertJson(expectedModelString, actualModelString);
+            return model;
+        } catch (IOException | JSONException ex) {
+            logger.error("Error while doing assert Json serialization Assertion: model: {}, "
+                    + "expected Json File Location: {}, Exception {}", model, expectedJsonFileLocation, ex);
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
+     * Checks both serialization and deserialization.
+     * <p>
+     * First checks deserialization and then serialize the deserialized object back to json
+     * and check if matches the given json file location string
+     *
+     * @param jsonFileLocation Classpath location of the json file
+     * @param modelClass Class type
+     * @param <T> Json Model Type
+     * @param objectMapper Jackson Json Object Mapper
+     *
+     * @return If assertion passes, returns deserialized object
+     */
+
+    public static <T> T assertJsonConversions(final String jsonFileLocation, final Class<T> modelClass,
+                                              final ObjectMapper objectMapper) {
+        //first check deserialization
+        final T actualValue = deserializeJsonFileToModel(jsonFileLocation, modelClass, objectMapper);
+        //then check serialization
+        assertJsonSerialization(actualValue, jsonFileLocation, objectMapper);
+
+        return actualValue;
+    }
+
+
+    public static <T> T assertJsonConversions(final String jsonFileLocation,
+                                              final Function<String, Optional<T>> jsonConversionFunction,
+                                              final ObjectMapper objectMapper) {
+        final Optional<T> actualValueOptional = jsonConversionFunction.apply(fromStream(jsonFileLocation));
+        assertThat(actualValueOptional).isPresent();
+        if (actualValueOptional.isPresent()) {
+            assertJsonSerialization(actualValueOptional.get(), jsonFileLocation, objectMapper);
+            return actualValueOptional.get();
+        }
+        return null;
+    }
+
+
+    /**
+     * Creates a mock URL Stream Handler
+     *
+     * @param mockURLConnection mock URL Connection
+     *
+     * @return Mock URL Stream Handler
+     */
+    public static URLStreamHandler createMockURLStreamHandler(final URLConnection mockURLConnection) {
+        return new URLStreamHandler() {
+            @Override
+            protected URLConnection openConnection(final URL url)
+                    throws IOException {
+                return mockURLConnection;
+            }
+        };
+    }
+
+    /**
+     * Sets up environment variables for testing purposes
+     *
+     * @param testEnvironmentVariables key value map containing test environment variables
+     *
+     * @throws ClassNotFoundException class not found exception
+     * @throws IllegalAccessException illegal access exception
+     * @throws NoSuchFieldException no such method exception
+     */
+    @SuppressWarnings("unchecked")
+    protected static void setEnvironmentVariables(final Map<String, String> testEnvironmentVariables)
+            throws ClassNotFoundException, IllegalAccessException, NoSuchFieldException {
+        try {
+            final Class<?> processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment");
+            final Field theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment");
+
+            AccessController.doPrivileged((PrivilegedAction) () -> {
+                theEnvironmentField.setAccessible(true);
+                return null;
+            });
+
+            final Map<String, String> env = (Map<String, String>) theEnvironmentField.get(null);
+            env.putAll(testEnvironmentVariables);
+            Field theCaseInsensitiveEnvironmentField =
+                    processEnvironmentClass.getDeclaredField("theCaseInsensitiveEnvironment");
+            AccessController.doPrivileged((PrivilegedAction) () -> {
+                theCaseInsensitiveEnvironmentField.setAccessible(true);
+                return null;
+            });
+            Map<String, String> cienv = (Map<String, String>) theCaseInsensitiveEnvironmentField.get(null);
+            cienv.putAll(testEnvironmentVariables);
+        } catch (NoSuchFieldException e) {
+            Class[] classes = Collections.class.getDeclaredClasses();
+            Map<String, String> env = System.getenv();
+            for (Class cl : classes) {
+                if ("java.util.Collections$UnmodifiableMap".equals(cl.getName())) {
+                    Field field = cl.getDeclaredField("m");
+                    AccessController.doPrivileged((PrivilegedAction) () -> {
+                        field.setAccessible(true);
+                        return null;
+                    });
+                    Object obj = field.get(env);
+                    Map<String, String> map = (Map<String, String>) obj;
+                    map.clear();
+                    map.putAll(testEnvironmentVariables);
+                }
+            }
+        }
+    }
+
+    /**
+     * Contains Locations for various files used for testing purposes
+     */
+    public abstract static class TestFileLocation {
+
+        public static final String CEF_JSON_MESSAGE = "data/json/cef/cef_message.json";
+        public static final String CEF_UNESCAPED_MESSAGES = "data/json/cef/cef_unescaped_messages.txt";
+        public static final String CEF_JSON_MESSAGE_WITH_VIOLATION = "data/json/cef/cef_message_with_violation.json";
+        public static final String CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME =
+                "data/json/cef/cef_meesage_with_inapplicable_event_name.json";
+        public static final String CEF_JSON_MESSAGE_WITH_ABATEMENT = "data/json/cef/cef_message_with_abatement.json";
+        public static final String CEF_JSON_MESSAGES = "data/json/cef/cef_messages.json";
+
+        public static final String TCA_POLICY_JSON = "data/json/policy/tca_policy.json";
+        public static final String TCA_APP_CONFIG_JSON = "data/json/config/tca_app_config.json";
+        public static final String TCA_ALERT_JSON = "data/json/facade/tca_alert.json";
+
+
+        public static final String CONFIG_SERVICE_BINDINGS_JSON =
+                "data/json/configservice/config_service_bindings.json";
+
+
+        public static final String TEST_JSON_MESSAGE = "data/json/test/test_message.json";
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsUnitTest.java b/dcae-analytics/dcae-analytics-test/src/main/java/org/onap/dcae/analytics/test/BaseAnalyticsUnitTest.java
new file mode 100644 (file)
index 0000000..554c718
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.test;
+
+/**
+ * Base class for all DCAE Analytics Unit Test
+ *
+ * @author Rajiv Singla
+ */
+public class BaseAnalyticsUnitTest extends BaseAnalyticsTest {
+
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/config/application-dev.yaml b/dcae-analytics/dcae-analytics-test/src/main/resources/config/application-dev.yaml
new file mode 100644 (file)
index 0000000..b41ad6a
--- /dev/null
@@ -0,0 +1,50 @@
+# DEV PROFILE SETTINGS
+config-binding-service:
+  tca:
+    policy: "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}"
+    processing_batch_size: 10000
+    enable_abatement: true
+    enable_ecomp_logging: false
+    aai:
+      enable_enrichment: true
+      url: "http://localhost:8443"
+      username: "DCAE"
+      password: "DCAE"
+      generic_vnf_path: "aai/v11/network/generic-vnfs/generic-vnf"
+      node_query_path: "aai/v11/search/nodes-query"
+  service_calls:
+    aai_broker_handle:
+      - "135.205.226.128:32768"
+  streams_publishes:
+    tca_handle_out:
+      type: "message_router"
+      aaf_username: "USER"
+      aaf_password: "PASSWORD"
+      dmaap_info:
+        client_role: "publisher"
+        client_id: "tca-pub-0"
+        location: "ecomp"
+        topic_url: "http://localhost:8080/events/PubTopic"
+  streams_subscribes:
+    tca_handle_in:
+      type: "message_router"
+      aaf_username: "USER"
+      aaf_password : "PASSWORD"
+      dmaap_info:
+        client_role: "subscriber"
+        client_id: "tca-sub-0"
+        location: "ecomp"
+        topic_url: "http://localhost:8080/events/SubTopic"
+      consumer_group: "cg1"
+      consumer_ids:
+        - "c0"
+        - "c1"
+      message_limit: 50000
+      timeout: -1
+      polling:
+        fixed_rate: 0
+        auto_adjusting:
+          min: 30000
+          step_up: 10000
+          max: 60000
+          step_down: 30000
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/config/application-mongo.yaml b/dcae-analytics/dcae-analytics-test/src/main/resources/config/application-mongo.yaml
new file mode 100644 (file)
index 0000000..6727518
--- /dev/null
@@ -0,0 +1,4 @@
+spring:
+  data:
+    mongodb:
+      uri: "mongodb://localhost:27017/analytics-tca"
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/config/application.yaml b/dcae-analytics/dcae-analytics-test/src/main/resources/config/application.yaml
new file mode 100644 (file)
index 0000000..9fb2192
--- /dev/null
@@ -0,0 +1,64 @@
+# SPRING SETTINGS
+spring:
+  application:
+    name: "dcae-analytics-tca"
+  main:
+    banner-mode: "off"
+  profiles:
+    active: dev
+  servlet:
+    multipart:
+      # Enable multi part file uploads / download
+      enabled: true
+      # Threshold after which files are written to disk.
+      file-size-threshold: 100KB
+      # Max file size
+      max-file-size: 512MB
+      # Max Request size
+      max-request-size: 600MB
+  data:
+    redis:
+      repositories:
+        enabled: false
+    mongodb:
+      repositories:
+        type: none
+  output:
+    ansi:
+      enabled: always
+
+# ENDPOINTS
+management:
+  endpoint:
+    health:
+      show-details: always
+    shutdown:
+      enabled: true
+  endpoints:
+    web:
+      exposure:
+        include: '*'
+  info:
+    git:
+      mode: full
+  health:
+    redis:
+      enabled: false
+
+# SERVER
+server:
+  port: 9091
+  compression:
+    # Enable gzip compression of response
+    enabled: true
+    mime-types: application/json,text/plain
+    min-response-size: 4096
+  http2:
+    enabled: true
+
+# LOGGING LEVEL
+logging:
+  file: logs/dcae-anlaytics-tca.log
+  level:
+    org:
+      onap: DEBUG
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/config/bootstrap.yaml b/dcae-analytics/dcae-analytics-test/src/main/resources/config/bootstrap.yaml
new file mode 100644 (file)
index 0000000..b17d963
--- /dev/null
@@ -0,0 +1,4 @@
+spring:
+  cloud:
+    config:
+      enabled: false
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vnf_enrichment.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vnf_enrichment.json
new file mode 100644 (file)
index 0000000..7360427
--- /dev/null
@@ -0,0 +1,39 @@
+{
+  "vnf-id": "63b31229-9a3a-444f-9159-04ce2dca3be9",
+  "vnf-name": "vCPEInfraVNF13",
+  "vnf-type": "vCPEInfraService10/vCPEInfraService10 0",
+  "service-id": "e8cb8968-5411-478b-906a-f28747de72cd",
+  "prov-status": "PREPROV",
+  "orchestration-status": "Created",
+  "in-maint": false,
+  "is-closed-loop-disabled": false,
+  "resource-version": "1504896046185",
+  "relationship-list": {
+    "relationship": [
+      {
+        "related-to": "service-instance",
+        "related-link": "/aai/v11/business/customers/customer/Demonstration3/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/e8feceb6-28ae-480a-bfbc-1985ce333526",
+        "relationship-data": [
+          {
+            "relationship-key": "customer.global-customer-id",
+            "relationship-value": "Demonstration3"
+          },
+          {
+            "relationship-key": "service-subscription.service-type",
+            "relationship-value": "vCPE"
+          },
+          {
+            "relationship-key": "service-instance.service-instance-id",
+            "relationship-value": "e8feceb6-28ae-480a-bfbc-1985ce333526"
+          }
+        ],
+        "related-to-property": [
+          {
+            "property-key": "service-instance.service-instance-name",
+            "property-value": "vCPEInfraSI13"
+          }
+        ]
+      }
+    ]
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vserver_enrichment.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vserver_enrichment.json
new file mode 100644 (file)
index 0000000..45c8df3
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "vserver-id": "example-vserver-id-val-2",
+  "vserver-name": "example-vserver-name-val-2",
+  "vserver-name2": "example-vserver-name2-val-2",
+  "prov-status": "example-prov-status-val-2",
+  "vserver-selflink": "example-vserver-selflink-val-2",
+  "in-maint": true,
+  "is-closed-loop-disabled": true,
+  "resource-version": "1504912891060"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vserver_resource_data.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/aai/aai_vserver_resource_data.json
new file mode 100644 (file)
index 0000000..f4a0334
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "result-data": [
+    {
+      "resource-type": "vserver",
+      "resource-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/DFW/tenants/tenant/1031120/vservers/vserver/example-vserver-id-val-2"
+    }
+  ]
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_meesage_with_inapplicable_event_name.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_meesage_with_inapplicable_event_name.json
new file mode 100644 (file)
index 0000000..773f7a4
--- /dev/null
@@ -0,0 +1,76 @@
+{
+  "event": {
+    "commonEventHeader": {
+      "domain": "measurementsForVfScaling",
+      "eventId": "UC1-SCL01081-1492639920787",
+      "eventName": "testEventName",
+      "lastEpochMicrosec": 1492639920787,
+      "nfNamingCode": "ENBE",
+      "priority": "Normal",
+      "reportingEntityId": "",
+      "reportingEntityName": "vtc2e7admn2",
+      "sequence": 0,
+      "sourceId": "SCL01081_9B_1",
+      "sourceName": "SCL01081",
+      "startEpochMicrosec": 1492639920787,
+      "version": 3.0
+    },
+    "measurementsForVfScalingFields": {
+      "additionalFields": [
+        {
+          "name": "software_version ",
+          "value": "version1"
+        },
+        {
+          "name": "vendor ",
+          "value": "Ericsson "
+        }
+      ],
+      "additionalMeasurements": [
+        {
+          "name": "OaaS_UC1_EricssonSleepingCell",
+          "arrayOfFields": [
+            {
+              "name": "PMRAATTCBRA",
+              "value": "1353"
+            },
+            {
+              "name": "PMRASUCCCBRA",
+              "value": "1351"
+            },
+            {
+              "name": "PMCELLDOWNTIMEAUTO",
+              "value": "0"
+            },
+            {
+              "name": "PMCELLDOWNTIMEMAN",
+              "value": "0"
+            },
+            {
+              "name": "PMRRCCONNESTABATT",
+              "value": "297"
+            },
+            {
+              "name": "PMRRCCONNESTABSUCC",
+              "value": "297"
+            }
+          ]
+        }
+      ],
+      "vNicPerformanceArray": [
+        {
+          "receivedBroadcastPacketsAccumulated": 5000,
+          "receivedBroadcastPacketsDelta": 5,
+          "receivedDiscardedPacketsAccumulated": 12,
+          "receivedDiscardedPacketsDelta": 2,
+          "receivedErrorPacketsAccumulated": 2,
+          "receivedErrorPacketsDelta": 1,
+          "valuesAreSuspect": false,
+          "vNicIdentifier": "someVNicIdentifier"
+        }
+      ],
+      "measurementInterval": 900,
+      "measurementsForVfScalingVersion": 2.0
+    }
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message.json
new file mode 100644 (file)
index 0000000..065962d
--- /dev/null
@@ -0,0 +1,76 @@
+{
+  "event": {
+    "commonEventHeader": {
+      "domain": "measurementsForVfScaling",
+      "eventId": "UC1-SCL01081-1492639920787",
+      "eventName": "Mfvs_eNodeB_RANKPI",
+      "lastEpochMicrosec": 1492639920787,
+      "nfNamingCode": "ENBE",
+      "priority": "Normal",
+      "reportingEntityId": "",
+      "reportingEntityName": "vtc2e7admn2",
+      "sequence": 0,
+      "sourceId": "SCL01081_9B_1",
+      "sourceName": "SCL01081",
+      "startEpochMicrosec": 1492639920787,
+      "version": 3.0
+    },
+    "measurementsForVfScalingFields": {
+      "additionalFields": [
+        {
+          "name": "software_version ",
+          "value": "version1"
+        },
+        {
+          "name": "vendor ",
+          "value": "Ericsson "
+        }
+      ],
+      "additionalMeasurements": [
+        {
+          "name": "OaaS_UC1_EricssonSleepingCell",
+          "arrayOfFields": [
+            {
+              "name": "PMRAATTCBRA",
+              "value": "1353"
+            },
+            {
+              "name": "PMRASUCCCBRA",
+              "value": "1351"
+            },
+            {
+              "name": "PMCELLDOWNTIMEAUTO",
+              "value": "0"
+            },
+            {
+              "name": "PMCELLDOWNTIMEMAN",
+              "value": "0"
+            },
+            {
+              "name": "PMRRCCONNESTABATT",
+              "value": "297"
+            },
+            {
+              "name": "PMRRCCONNESTABSUCC",
+              "value": "297"
+            }
+          ]
+        }
+      ],
+      "vNicPerformanceArray": [
+        {
+          "receivedBroadcastPacketsAccumulated": 5000,
+          "receivedBroadcastPacketsDelta": 5,
+          "receivedDiscardedPacketsAccumulated": 12,
+          "receivedDiscardedPacketsDelta": 2,
+          "receivedErrorPacketsAccumulated": 2,
+          "receivedErrorPacketsDelta": 1,
+          "valuesAreSuspect": false,
+          "vNicIdentifier": "someVNicIdentifier"
+        }
+      ],
+      "measurementInterval": 900,
+      "measurementsForVfScalingVersion": 2.0
+    }
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message_with_abatement.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message_with_abatement.json
new file mode 100644 (file)
index 0000000..c97df74
--- /dev/null
@@ -0,0 +1,76 @@
+{
+  "event": {
+    "commonEventHeader": {
+      "domain": "measurementsForVfScaling",
+      "eventId": "UC1-SCL01081-1492639920787",
+      "eventName": "Mfvs_eNodeB_RANKPI",
+      "lastEpochMicrosec": 1492639920787,
+      "nfNamingCode": "ENBE",
+      "priority": "Normal",
+      "reportingEntityId": "",
+      "reportingEntityName": "vtc2e7admn2",
+      "sequence": 0,
+      "sourceId": "SCL01081_9B_1",
+      "sourceName": "SCL01081",
+      "startEpochMicrosec": 1492639920787,
+      "version": 3.0
+    },
+    "measurementsForVfScalingFields": {
+      "additionalFields": [
+        {
+          "name": "software_version ",
+          "value": "version1"
+        },
+        {
+          "name": "vendor ",
+          "value": "Ericsson "
+        }
+      ],
+      "additionalMeasurements": [
+        {
+          "name": "OaaS_UC1_EricssonSleepingCell",
+          "arrayOfFields": [
+            {
+              "name": "PMRAATTCBRA",
+              "value": "1353"
+            },
+            {
+              "name": "PMRASUCCCBRA",
+              "value": "1351"
+            },
+            {
+              "name": "PMCELLDOWNTIMEAUTO",
+              "value": "0"
+            },
+            {
+              "name": "PMCELLDOWNTIMEMAN",
+              "value": "0"
+            },
+            {
+              "name": "PMRRCCONNESTABATT",
+              "value": "297"
+            },
+            {
+              "name": "PMRRCCONNESTABSUCC",
+              "value": "297"
+            }
+          ]
+        }
+      ],
+      "vNicPerformanceArray": [
+        {
+          "receivedBroadcastPacketsAccumulated": 0,
+          "receivedBroadcastPacketsDelta": 5,
+          "receivedDiscardedPacketsAccumulated": 12,
+          "receivedDiscardedPacketsDelta": 2,
+          "receivedErrorPacketsAccumulated": 2,
+          "receivedErrorPacketsDelta": 1,
+          "valuesAreSuspect": false,
+          "vNicIdentifier": "someVNicIdentifier"
+        }
+      ],
+      "measurementInterval": 900,
+      "measurementsForVfScalingVersion": 2.0
+    }
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message_with_violation.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_message_with_violation.json
new file mode 100644 (file)
index 0000000..c85f55b
--- /dev/null
@@ -0,0 +1,76 @@
+{
+  "event": {
+    "commonEventHeader": {
+      "domain": "measurementsForVfScaling",
+      "eventId": "UC1-SCL01081-1492639920787",
+      "eventName": "Mfvs_eNodeB_RANKPI",
+      "lastEpochMicrosec": 1492639920787,
+      "nfNamingCode": "ENBE",
+      "priority": "Normal",
+      "reportingEntityId": "",
+      "reportingEntityName": "vtc2e7admn2",
+      "sequence": 0,
+      "sourceId": "SCL01081_9B_1",
+      "sourceName": "SCL01081",
+      "startEpochMicrosec": 1492639920787,
+      "version": 3.0
+    },
+    "measurementsForVfScalingFields": {
+      "additionalFields": [
+        {
+          "name": "software_version ",
+          "value": "version1"
+        },
+        {
+          "name": "vendor ",
+          "value": "Ericsson "
+        }
+      ],
+      "additionalMeasurements": [
+        {
+          "name": "OaaS_UC1_EricssonSleepingCell",
+          "arrayOfFields": [
+            {
+              "name": "PMRAATTCBRA",
+              "value": "1353"
+            },
+            {
+              "name": "PMRASUCCCBRA",
+              "value": "1351"
+            },
+            {
+              "name": "PMCELLDOWNTIMEAUTO",
+              "value": "0"
+            },
+            {
+              "name": "PMCELLDOWNTIMEMAN",
+              "value": "0"
+            },
+            {
+              "name": "PMRRCCONNESTABATT",
+              "value": "297"
+            },
+            {
+              "name": "PMRRCCONNESTABSUCC",
+              "value": "297"
+            }
+          ]
+        }
+      ],
+      "vNicPerformanceArray": [
+        {
+          "receivedBroadcastPacketsAccumulated": 21000,
+          "receivedBroadcastPacketsDelta": 5,
+          "receivedDiscardedPacketsAccumulated": 12,
+          "receivedDiscardedPacketsDelta": 2,
+          "receivedErrorPacketsAccumulated": 2,
+          "receivedErrorPacketsDelta": 1,
+          "valuesAreSuspect": false,
+          "vNicIdentifier": "someVNicIdentifier"
+        }
+      ],
+      "measurementInterval": 900,
+      "measurementsForVfScalingVersion": 2.0
+    }
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_messages.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_messages.json
new file mode 100644 (file)
index 0000000..242ab9d
--- /dev/null
@@ -0,0 +1,1490 @@
+[
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/301:fclustr-301:FGroup-308:femto-34179",
+        "reportingEntityName": "1085190",
+        "startEpochMicrosec": 1493393250722,
+        "eventId": "UC2-BRHMALM02001-1493393250722",
+        "lastEpochMicrosec": 1493393250722,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "BRHMALM02001",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4860",
+        "reportingEntityName": "75160",
+        "startEpochMicrosec": 1493393250717,
+        "eventId": "UC2-PTLDORM58217-1493393250717",
+        "lastEpochMicrosec": 1493393250717,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58217",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-7558",
+        "reportingEntityName": "96140",
+        "startEpochMicrosec": 1493393250712,
+        "eventId": "UC2-PTLDORM58210-1493393250712",
+        "lastEpochMicrosec": 1493393250712,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58210",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/203:fclustr-203:FGroup-310:femto-37457",
+        "reportingEntityName": "1373204",
+        "startEpochMicrosec": 1493393250718,
+        "eventId": "UC2-BSTNVTM06013-1493393250718",
+        "lastEpochMicrosec": 1493393250718,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "BSTNVTM06013",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/203:fclustr-203:FGroup-223:femto-39355",
+        "reportingEntityName": "1060176",
+        "startEpochMicrosec": 1493393250721,
+        "eventId": "UC2-BSTNVTM06103-1493393250721",
+        "lastEpochMicrosec": 1493393250721,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "BSTNVTM06103",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/158:fclustr-158:FGroup-28:femto-30166",
+        "reportingEntityName": "954175",
+        "startEpochMicrosec": 1493393250720,
+        "eventId": "UC2-PITBPAM38246-1493393250720",
+        "lastEpochMicrosec": 1493393250720,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PITBPAM38246",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/203:fclustr-203:FGroup-223:femto-33673",
+        "reportingEntityName": "1060173",
+        "startEpochMicrosec": 1493393250723,
+        "eventId": "UC2-BSTNVTM06066-1493393250723",
+        "lastEpochMicrosec": 1493393250723,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "BSTNVTM06066",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/3:fclustr-3:FGroup-47:femto-34309",
+        "reportingEntityName": "1185198",
+        "startEpochMicrosec": 1493393250724,
+        "eventId": "UC2-SCRMCNM29032-1493393250724",
+        "lastEpochMicrosec": 1493393250724,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "SCRMCNM29032",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4855",
+        "reportingEntityName": "75138",
+        "startEpochMicrosec": 1493393250714,
+        "eventId": "UC2-PTLDORM58212-1493393250714",
+        "lastEpochMicrosec": 1493393250714,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58212",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-10466",
+        "reportingEntityName": "133734",
+        "startEpochMicrosec": 1493393250715,
+        "eventId": "UC2-PTLDORM58925-1493393250715",
+        "lastEpochMicrosec": 1493393250715,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58925",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/201:fclustr-201:FGroup-218:femto-29721",
+        "reportingEntityName": "844171",
+        "startEpochMicrosec": 1493393250719,
+        "eventId": "UC2-NYCMNYM23031-1493393250719",
+        "lastEpochMicrosec": 1493393250719,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "NYCMNYM23031",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4858",
+        "reportingEntityName": "75137",
+        "startEpochMicrosec": 1493393250715,
+        "eventId": "UC2-PTLDORM58215-1493393250715",
+        "lastEpochMicrosec": 1493393250715,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58215",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4852",
+        "reportingEntityName": "75173",
+        "startEpochMicrosec": 1493393250726,
+        "eventId": "UC2-PTLDORM58014-1493393250726",
+        "lastEpochMicrosec": 1493393250726,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58014",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/3:fclustr-3:FGroup-282:femto-36109",
+        "reportingEntityName": "1085174",
+        "startEpochMicrosec": 1493393250725,
+        "eventId": "UC2-SLKCUTM08059-1493393250725",
+        "lastEpochMicrosec": 1493393250725,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "SLKCUTM08059",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/3:fclustr-3:FGroup-366:femto-37721",
+        "reportingEntityName": "1385173",
+        "startEpochMicrosec": 1493393250720,
+        "eventId": "UC2-SLKCUTM08083-1493393250720",
+        "lastEpochMicrosec": 1493393250720,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "SLKCUTM08083",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/158:fclustr-158:FGroup-105:femto-33105",
+        "reportingEntityName": "1064173",
+        "startEpochMicrosec": 1493393250722,
+        "eventId": "UC2-STLSMOM29030-1493393250722",
+        "lastEpochMicrosec": 1493393250722,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "STLSMOM29030",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/152:fclustr-152:FGroup-45:femto-8549",
+        "reportingEntityName": "165395",
+        "startEpochMicrosec": 1493393250727,
+        "eventId": "UC2-MILWWIM04202-1493393250727",
+        "lastEpochMicrosec": 1493393250727,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "MILWWIM04202",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/3:fclustr-3:FGroup-42:femto-30554",
+        "reportingEntityName": "1304171",
+        "startEpochMicrosec": 1493393250723,
+        "eventId": "UC2-DNVRCOM04034-1493393250723",
+        "lastEpochMicrosec": 1493393250723,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "DNVRCOM04034",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4856",
+        "reportingEntityName": "75139",
+        "startEpochMicrosec": 1493393250714,
+        "eventId": "UC2-PTLDORM58213-1493393250714",
+        "lastEpochMicrosec": 1493393250714,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58213",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4862",
+        "reportingEntityName": "75158",
+        "startEpochMicrosec": 1493393250718,
+        "eventId": "UC2-PTLDORM58219-1493393250718",
+        "lastEpochMicrosec": 1493393250718,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58219",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-9407",
+        "reportingEntityName": "114953",
+        "startEpochMicrosec": 1493393250713,
+        "eventId": "UC2-PTLDORM58211-1493393250713",
+        "lastEpochMicrosec": 1493393250713,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58211",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/252:fclustr-252:FGroup-141:femto-36114",
+        "reportingEntityName": "1253171",
+        "startEpochMicrosec": 1493393250721,
+        "eventId": "UC2-BLTMMDM00025-1493393250721",
+        "lastEpochMicrosec": 1493393250721,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "BLTMMDM00025",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4861",
+        "reportingEntityName": "75159",
+        "startEpochMicrosec": 1493393250718,
+        "eventId": "UC2-PTLDORM58218-1493393250718",
+        "lastEpochMicrosec": 1493393250718,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58218",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/203:fclustr-203:FGroup-309:femto-37456",
+        "reportingEntityName": "1373227",
+        "startEpochMicrosec": 1493393250717,
+        "eventId": "UC2-BSTNVTM06011-1493393250717",
+        "lastEpochMicrosec": 1493393250717,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "BSTNVTM06011",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4859",
+        "reportingEntityName": "75166",
+        "startEpochMicrosec": 1493393250716,
+        "eventId": "UC2-PTLDORM58216-1493393250716",
+        "lastEpochMicrosec": 1493393250716,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58216",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/251:fclustr-251:FGroup-50:femto-11763",
+        "reportingEntityName": "165383",
+        "startEpochMicrosec": 1493393250724,
+        "eventId": "UC2-BLTMMDM00367-1493393250724",
+        "lastEpochMicrosec": 1493393250724,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "BLTMMDM00367",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-4857",
+        "reportingEntityName": "75142",
+        "startEpochMicrosec": 1493393250714,
+        "eventId": "UC2-PTLDORM58214-1493393250714",
+        "lastEpochMicrosec": 1493393250714,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58214",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-70:femto-10465",
+        "reportingEntityName": "133740",
+        "startEpochMicrosec": 1493393250716,
+        "eventId": "UC2-PTLDORM58924-1493393250716",
+        "lastEpochMicrosec": 1493393250716,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "PTLDORM58924",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/53:fclustr-53:FGroup-165:femto-32607",
+        "reportingEntityName": "977200",
+        "startEpochMicrosec": 1493393250726,
+        "eventId": "UC2-LSANCLM30038-1493393250726",
+        "lastEpochMicrosec": 1493393250726,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "LSANCLM30038",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/53:fclustr-53:FGroup-165:femto-32555",
+        "reportingEntityName": "977174",
+        "startEpochMicrosec": 1493393250725,
+        "eventId": "UC2-LSANCLM30037-1493393250725",
+        "lastEpochMicrosec": 1493393250725,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "LSANCLM30037",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  },
+  {
+    "event": {
+      "measurementsForVfScalingFields": {
+        "measurementInterval": 600,
+        "additionalMeasurements": [
+          {
+            "arrayOfFields": [
+              {
+                "name": "BS_Reset_Needed",
+                "value": "1"
+              }
+            ],
+            "name": "OaaS_UC2_ALUMetrocellBackhaul"
+          }
+        ],
+        "measurementsForVfScalingVersion": 2.0,
+        "additionalFields": [
+          {
+            "name": "software_version",
+            "value": ""
+          },
+          {
+            "name": "vendor",
+            "value": "ALU"
+          },
+          {
+            "name": "datetime",
+            "value": ""
+          }
+        ]
+      },
+      "commonEventHeader": {
+        "nfNamingCode": "MEAP",
+        "version": 3.0,
+        "sourceId": "network:FemtoCluster\/1:fclustr-1:FGroup-14:femto-5578",
+        "reportingEntityName": "70120",
+        "startEpochMicrosec": 1493393250720,
+        "eventId": "UC2-DNVRCOM04230-1493393250720",
+        "lastEpochMicrosec": 1493393250720,
+        "priority": "Normal",
+        "sequence": 0,
+        "sourceName": "DNVRCOM04230",
+        "domain": "measurementsForVfScaling",
+        "eventName": "Mfvs_eNodeB_RANKPI",
+        "reportingEntityId": ""
+      }
+    }
+  }
+]
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_unescaped_messages.txt b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/cef/cef_unescaped_messages.txt
new file mode 100644 (file)
index 0000000..b7811b4
--- /dev/null
@@ -0,0 +1,12 @@
+[
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}",
+  "{\"event\":{\"measurementsForVfScalingFields\":{\"measurementInterval\":900,\"additionalMeasurements\":[{\"arrayOfFields\":[{\"name\":\"PMRAATTCBRA\",\"value\":\"40000\"},{\"name\":\"PMRASUCCCBRA\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEAUTO\",\"value\":\"0\"},{\"name\":\"PMCELLDOWNTIMEMAN\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABATT\",\"value\":\"18\"},{\"name\":\"PMRRCCONNESTABSUCC\",\"value\":\"0\"},{\"name\":\"PMRRCCONNESTABFAILCELLLATENCY\",\"value\":\"0\"}],\"name\":\"OaaS_UC1_EricssonSleepingCell\"}],\"measurementsForVfScalingVersion\":2,\"additionalFields\":[{\"name\":\"software_version\",\"value\":\"CXP102051/24_R27CU\"},{\"name\":\"vendor\",\"value\":\"Ericsson\"},{\"name\":\"datetime\",\"value\":\"2017-05-0907:15:00.0\"}]},\"commonEventHeader\":{\"sourcename\":\"LALss103esig27\",\"nfNamingCode\":\"ENBE\",\"sourceId\":\"LAL01402_7S_1_DB_sig27rvsc\",\"version\":3,\"startEpochMicrosec\":1497290419742,\"eventId\":\"UC1-LAL01402-1494357632010\",\"lastEpochMicrosec\":1504910555000,\"sequence\":0,\"priority\":\"Normal\",\"domain\":\"measurementsForVfScaling\",\"reportingEntityId\":\"2001:506:4409:c2e8::11:3016:2\",\"reportingEntityname\":\"hou1e1ss103esig27\",\"eventName\":\"Mfvs_eNodeB_RANKPI\"}}}"
+]
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/config/tca_app_config.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/config/tca_app_config.json
new file mode 100644 (file)
index 0000000..6a3b0fa
--- /dev/null
@@ -0,0 +1,57 @@
+{
+  "application.name": "dcae-analytics",
+  "application.description": "DCAE Analytics Threshold Crossing Alert Application",
+  "application.tca_policy": "{}",
+  "application.tca_batch_size": 10000,
+  "streams_subscribes.tca_handle_in.consumer_group": "cg1",
+  "streams_subscribes.tca_handle_in.consumer_ids[0]": "c0",
+  "streams_subscribes.tca_handle_in.consumer_ids[1]": "c1",
+  "streams_subscribes.tca_handle_in.message_limit": 50000,
+  "streams_subscribes.tca_handle_in.timeout": -1,
+  "streams_subscribes.tca_handle_in.polling.fixed_rate": 0,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.min": 30000,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.step_up": 20000,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.max": 60000,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.step_down": 40000,
+  "service_calls": {
+    "aai_broker_handle": [
+      "135.205.226.128:32768"
+    ]
+  },
+  "streams_publishes": {
+    "tca_handle_out": {
+      "type": "message_router",
+      "aaf_username": "USER",
+      "aaf_password": "PASSWORD",
+      "dmaap_info": {
+        "client_role": "publisher",
+        "client_id": "tca-pub-0",
+        "location": "ecomp",
+        "topic_url": "http://localhost:8080/events/PubTopic"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "tca_handle_in": {
+      "type": "message_router",
+      "aaf_username": "USER",
+      "aaf_password": "PASSWORD",
+      "dmaap_info": {
+        "client_role": "subscriber",
+        "client_id": "tca-sub-0",
+        "location": "ecomp",
+        "topic_url": "http://localhost:8080/events/SubTopic"
+      }
+    }
+  },
+  "spring": {
+    "main": {
+      "banner-mode": "off"
+    },
+    "data": {
+      "mongodb": {
+        "uri": "mongodb://localhost:27017/analytics-tca"
+      }
+    }
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/configservice/config_service_bindings.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/configservice/config_service_bindings.json
new file mode 100644 (file)
index 0000000..43b01f8
--- /dev/null
@@ -0,0 +1,26 @@
+[
+  {
+    "ID": "81bc2a17-8cfa-3f6f-30a9-a545a9b6ac2f",
+    "Node": "zldcrdm5bdcc2dokr00",
+    "Address": "135.25.108.161",
+    "Datacenter": "zldcrdm5bdcc2",
+    "TaggedAddresses": {
+      "lan": "135.25.108.161",
+      "wan": "135.25.108.161"
+    },
+    "NodeMeta": {
+      "fqdn": "zldcrdm5bdcc2dokr00.2f3fb3.rdm5b.tci.att.com"
+    },
+    "ServiceID": "20299a144716:config_binding_service:10000",
+    "ServiceName": "config_binding_service",
+    "ServiceTags": [
+      "config_binding_service",
+      "no-op"
+    ],
+    "ServiceAddress": "135.25.108.161",
+    "ServicePort": 32769,
+    "ServiceEnableTagOverride": false,
+    "CreateIndex": 2991593,
+    "ModifyIndex": 2997835
+  }
+]
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/dmaap/dmaap_config.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/dmaap/dmaap_config.json
new file mode 100644 (file)
index 0000000..d0d304b
--- /dev/null
@@ -0,0 +1,68 @@
+{
+  "dmaap_subscribers": [
+    {
+      "id": "subscriber1",
+      "type": "message_router",
+      "url": "https://HOSTNAME:3905/events/DcaeTestVESSub1",
+      "username": "username",
+      "password": "password",
+      "message_limit": -1,
+      "timeout": 30000,
+      "consumer_group": "cg1",
+      "consumers": [
+        "c1",
+        "c2"
+      ],
+      "polling_strategy": {
+        "fixedRate": 30000
+      },
+      "proxy_url": "https//user:password@proxyhost:proxyport"
+    },
+    {
+      "id": "subscriber2",
+      "type": "message_router",
+      "url": "https://HOSTNAME:3905/events/DcaeTestVESSub2",
+      "username": "username",
+      "password": "password",
+      "message_limit": 50000,
+      "timeout": 30000,
+      "consumer_group": "cg2",
+      "consumers": [
+        "c1",
+        "c2"
+      ],
+      "polling_strategy": {
+        "auto_adjusting": {
+          "minimum": 20000,
+          "step_up": 20000,
+          "maximum": 120000,
+          "step_down": 100000
+        }
+      }
+    }
+  ],
+  "dmaap_publishers": [
+    {
+      "id": "publisher1",
+      "type": "message_router",
+      "url": "https://HOSTNAME:3905/events/DcaeTestVESPub1",
+      "username": "username",
+      "password": "password",
+      "batching": {
+        "enabled": true,
+        "maximum_messages": 10,
+        "maximum_time": 20000
+      }
+    },
+    {
+      "id": "publisher2",
+      "type": "message_router",
+      "url": "https://HOSTNAME:3905/events/DcaeTestVESPub1",
+      "username": "username",
+      "password": "password",
+      "batching": {
+        "enabled": false
+      }
+    }
+  ]
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/facade/tca_alert.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/facade/tca_alert.json
new file mode 100644 (file)
index 0000000..b7c70c1
--- /dev/null
@@ -0,0 +1,18 @@
+{
+  "closedLoopControlName": "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8",
+  "version": "1.0.2",
+  "requestID": "0138afac-b032-4e4b-bd30-88260f444888",
+  "closedLoopAlarmStart": 1478189220547,
+  "closedLoopEventClient": "tca.instance00001",
+  "target_type": "VNF",
+  "target": "generic-vnf.vnf-name",
+  "AAI": {
+    "generic-vnf.vnf-name": "vpp-test(?)",
+    "vserver.vserver-name": "dfw1lb01lb01"
+  },
+  "from": "DCAE",
+  "policyScope": "resource=vFirewall;type=configuration",
+  "policyName": "configuration.dcae.microservice.tca.xml",
+  "policyVersion": "v0.0.1",
+  "closedLoopEventStatus": "ONSET"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/policy/tca_policy.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/policy/tca_policy.json
new file mode 100644 (file)
index 0000000..e2560bd
--- /dev/null
@@ -0,0 +1,86 @@
+{
+  "domain": "measurementsForVfScaling",
+  "metricsPerEventName": [
+    {
+      "eventName": "Mfvs_eNodeB_RANKPI",
+      "controlLoopSchemaType": "VNF",
+      "policyScope": "resource=vFirewall;type=configuration",
+      "policyName": "configuration.dcae.microservice.tca.xml",
+      "policyVersion": "v0.0.1",
+      "thresholds": [
+        {
+          "closedLoopControlName": "CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8",
+          "closedLoopEventStatus": "ONSET",
+          "version": "1.0.2",
+          "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+          "thresholdValue": 4000,
+          "direction": "LESS_OR_EQUAL",
+          "severity": "MAJOR"
+        },
+        {
+          "closedLoopControlName": "CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09",
+          "closedLoopEventStatus": "ONSET",
+          "version": "1.0.2",
+          "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+          "thresholdValue": 20000,
+          "direction": "GREATER_OR_EQUAL",
+          "severity": "CRITICAL"
+        },
+        {
+          "closedLoopControlName": "CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09",
+          "closedLoopEventStatus": "ABATED",
+          "version": "1.0.2",
+          "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+          "thresholdValue": 0,
+          "direction": "EQUAL",
+          "severity": "CRITICAL"
+        }
+      ]
+    },
+    {
+      "eventName": "vLoadBalancer",
+      "controlLoopSchemaType": "VNF",
+      "policyScope": "resource=vLoadBalancer;type=configuration",
+      "policyName": "configuration.dcae.microservice.tca.xml",
+      "policyVersion": "v0.0.1",
+      "thresholds": [
+        {
+          "closedLoopControlName": "CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A",
+          "closedLoopEventStatus": "ONSET",
+          "version": "1.0.2",
+          "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+          "thresholdValue": 500,
+          "direction": "LESS_OR_EQUAL",
+          "severity": "MAJOR"
+        },
+        {
+          "closedLoopControlName": "CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B",
+          "closedLoopEventStatus": "ONSET",
+          "version": "1.0.2",
+          "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+          "thresholdValue": 5000,
+          "direction": "GREATER_OR_EQUAL",
+          "severity": "CRITICAL"
+        }
+      ]
+    },
+    {
+      "eventName": "virtualVMEventName",
+      "controlLoopSchemaType": "VM",
+      "policyScope": "resource=virtualVM;type=configuration",
+      "policyName": "configuration.dcae.microservice.tca.xml",
+      "policyVersion": "v0.0.1",
+      "thresholds": [
+        {
+          "closedLoopControlName": "CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A",
+          "closedLoopEventStatus": "ONSET",
+          "version": "1.0.2",
+          "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+          "thresholdValue": 500,
+          "direction": "LESS_OR_EQUAL",
+          "severity": "MAJOR"
+        }
+      ]
+    }
+  ]
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/test/test_message.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/test/test_message.json
new file mode 100644 (file)
index 0000000..54e7c8b
--- /dev/null
@@ -0,0 +1,8 @@
+[
+  {
+    "test": "message 1 from cg1 c1"
+  },
+  {
+    "test": "message 2 from cg1 c1"
+  }
+]
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy.properties b/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy.properties
new file mode 100644 (file)
index 0000000..f4633c2
--- /dev/null
@@ -0,0 +1,68 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
+subscriberContentType=application/json
+subscriberConsumerId=c12
+subscriberConsumerGroup=OpenDCAE-c12
+subscriberTimeoutMS=-1
+subscriberMessageLimit=-1
+subscriberPollingInterval=20000
+publisherContentType=application/json
+publisherMaxBatchSize=10
+publisherMaxRecoveryQueueSize=100000
+publisherPollingInterval=20000
+enableAlertCEFFormat=false
+domain=measurementsForVfScaling
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.policy.eventName=Mfvs_eNodeB_RANKPI
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.policyName=configuration.dcae.microservice.tca.xml
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.policyVersion=v0.0.1
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.policyScope=resource=Mfvs_eNodeB_RANKPI;type=configuration
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.controlLoopSchemaType=VNF
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.0.policy.closedLoopControlName=CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.0.policy.fieldPath=$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.0.policy.thresholdValue=4000
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.0.policy.direction=LESS_OR_EQUAL
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.0.policy.severity=MAJOR
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.0.policy.version=1.0.2
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.0.policy.closedLoopEventStatus=ONSET
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.1.policy.closedLoopControlName=L-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.1.policy.fieldPath=$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.1.policy.thresholdValue=20000
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.1.policy.direction=GREATER_OR_EQUAL
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.1.policy.severity=CRITICAL
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.1.policy.version=1.0.2
+configuration.violatedMetricsPerEventName.Mfvs_eNodeB_RANKPI.thresholds.1.policy.closedLoopEventStatus=ONSET
+configuration.violatedMetricsPerEventName.vLoadBalancer.policy.eventName=vLoadBalancer
+configuration.violatedMetricsPerEventName.vLoadBalancer.policyName=configuration.dcae.microservice.tca.xml
+configuration.violatedMetricsPerEventName.vLoadBalancer.policyVersion=v0.0.1
+configuration.violatedMetricsPerEventName.vLoadBalancer.policyScope=resource=vLoadBalancer;type=configuration
+configuration.violatedMetricsPerEventName.vLoadBalancer.controlLoopSchemaType=VNF
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.0.policy.closedLoopControlName=CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.0.policy.fieldPath=$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.0.policy.thresholdValue=500
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.0.policy.direction=LESS_OR_EQUAL
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.0.policy.severity=MAJOR
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.0.policy.version=1.0.2
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.0.policy.closedLoopEventStatus=ONSET
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.1.policy.closedLoopControlName=CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.1.policy.fieldPath=$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.1.policy.thresholdValue=5000
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.1.policy.direction=GREATER_OR_EQUAL
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.1.policy.severity=CRITICAL
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.1.policy.version=1.0.2
+configuration.violatedMetricsPerEventName.vLoadBalancer.thresholds.1.policy.closedLoopEventStatus=ONSET
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy_from_json.properties b/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy_from_json.properties
new file mode 100644 (file)
index 0000000..22216a6
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
+subscriberContentType=application/json
+subscriberConsumerId=c12
+subscriberConsumerGroup=OpenDCAE-c12
+subscriberTimeoutMS=-1
+subscriberMessageLimit=-1
+subscriberPollingInterval=20000
+publisherContentType=application/json
+publisherMaxBatchSize=10
+publisherMaxRecoveryQueueSize=100000
+publisherPollingInterval=20000
+enableAlertCEFFormat=false
+enableAAIEnrichment=true
+aaiEnrichmentHost=209.61.160.97
+aaiEnrichmentPortNumber=8443
+aaiEnrichmentProtocol=https
+aaiEnrichmentUserName=DCAE
+aaiEnrichmentUserPassword=DCAE
+aaiEnrichmentIgnoreSSLCertificateErrors=true
+aaiVNFEnrichmentAPIPath=/aai/v11/network/generic-vnfs/generic-vnf
+aaiVMEnrichmentAPIPath=/aai/v11/search/nodes-query
+aaiEnrichmentProxyURL=http://username:password@proxyhost.com:8080
+tca_policy={\"domain\":\"measurementsForVfScaling\",\"violatedMetricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]}]}
+
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vnf-enrichment.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vnf-enrichment.json
new file mode 100644 (file)
index 0000000..f19143c
--- /dev/null
@@ -0,0 +1,39 @@
+{
+  "vnf-id": "63b31229-9a3a-444f-9159-04ce2dca3be9",
+  "vnf-name": "SCL01081",
+  "vnf-type": "vCPEInfraService10/vCPEInfraService10 0",
+  "service-id": "e8cb8968-5411-478b-906a-f28747de72cd",
+  "prov-status": "PREPROV",
+  "orchestration-status": "Created",
+  "in-maint": false,
+  "is-closed-loop-disabled": false,
+  "resource-version": "1504896046185",
+  "relationship-list": {
+    "relationship": [
+      {
+        "related-to": "service-instance",
+        "related-link": "/aai/v11/business/customers/customer/Demonstration3/service-subscriptions/service-subscription/vCPE/service-instances/service-instance/e8feceb6-28ae-480a-bfbc-1985ce333526",
+        "relationship-data": [
+          {
+            "relationship-key": "customer.global-customer-id",
+            "relationship-value": "Demonstration3"
+          },
+          {
+            "relationship-key": "service-subscription.service-type",
+            "relationship-value": "vCPE"
+          },
+          {
+            "relationship-key": "service-instance.service-instance-id",
+            "relationship-value": "e8feceb6-28ae-480a-bfbc-1985ce333526"
+          }
+        ],
+        "related-to-property": [
+          {
+            "property-key": "service-instance.service-instance-name",
+            "property-value": "vCPEInfraSI13"
+          }
+        ]
+      }
+    ]
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vserver-enrichment.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vserver-enrichment.json
new file mode 100644 (file)
index 0000000..28f13d2
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "vserver-id": "testVserver",
+  "vserver-name": "example-vserver-name-val-2",
+  "vserver-name2": "example-vserver-name2-val-2",
+  "prov-status": "example-prov-status-val-2",
+  "vserver-selflink": "example-vserver-selflink-val-2",
+  "in-maint": true,
+  "is-closed-loop-disabled": true,
+  "resource-version": "1504912891060"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vserver-resource-data.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-aai-vserver-resource-data.json
new file mode 100644 (file)
index 0000000..59904f5
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "result-data": [
+    {
+      "resource-type": "vserver",
+      "resource-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/DFW/tenants/tenant/1031120/vservers/vserver/testVserver"
+    }
+  ]
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-configservice-binding.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-configservice-binding.json
new file mode 100644 (file)
index 0000000..a3be3f7
--- /dev/null
@@ -0,0 +1,26 @@
+[
+  {
+    "ID": "81bc2a17-8cfa-3f6f-30a9-a545a9b6ac2f",
+    "Node": "zldcrdm5bdcc2dokr00",
+    "Address": "135.25.108.161",
+    "Datacenter": "zldcrdm5bdcc2",
+    "TaggedAddresses": {
+      "lan": "135.25.108.161",
+      "wan": "135.25.108.161"
+    },
+    "NodeMeta": {
+      "fqdn": "zldcrdm5bdcc2dokr00.2f3fb3.rdm5b.tci.att.com"
+    },
+    "ServiceID": "20299a144716:config_binding_service:10000",
+    "ServiceName": "config_binding_service",
+    "ServiceTags": [
+      "config_binding_service",
+      "no-op"
+    ],
+    "ServiceAddress": "localhost",
+    "ServicePort": 8080,
+    "ServiceEnableTagOverride": false,
+    "CreateIndex": 2991593,
+    "ModifyIndex": 2997835
+  }
+]
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-configservice-tca.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-configservice-tca.json
new file mode 100644 (file)
index 0000000..88d8619
--- /dev/null
@@ -0,0 +1,63 @@
+{
+  "application.name": "dcae-analytics",
+  "application.description": "DCAE Analytics Threshold Crossing Alert Application",
+  "application.tca_policy": "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}",
+  "application.tca_batch_size": 10000,
+  "streams_subscribes.tca_handle_in.consumer_group": "cg1",
+  "streams_subscribes.tca_handle_in.consumer_ids[0]": "c0",
+  "streams_subscribes.tca_handle_in.consumer_ids[1]": "c1",
+  "streams_subscribes.tca_handle_in.message_limit": 50000,
+  "streams_subscribes.tca_handle_in.timeout": -1,
+  "streams_subscribes.tca_handle_in.polling.fixed_rate": 0,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.min": 30000,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.step_up": 20000,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.max": 60000,
+  "streams_subscribes.tca_handle_in.polling.auto_adjusting.step_down": 40000,
+  "aai.enable_tca_enrichment": true,
+  "aai.url": "http://localhost:8443",
+  "aai.username": "DCAE",
+  "aai.password": "DCAE",
+  "aai.generic_vnf_path": "aai/v11/network/generic-vnfs/generic-vnf",
+  "aai.node_query_path": "aai/v11/search/nodes-query",
+  "service_calls": {
+    "aai_broker_handle": [
+      "135.205.226.128:32768"
+    ]
+  },
+  "streams_publishes": {
+    "tca_handle_out": {
+      "type": "message_router",
+      "aaf_username": "USER",
+      "aaf_password": "PASSWORD",
+      "dmaap_info": {
+        "client_role": "publisher",
+        "client_id": "tca-pub-0",
+        "location": "ecomp",
+        "topic_url": "http://localhost:8080/events/PubTopic"
+      }
+    }
+  },
+  "streams_subscribes": {
+    "tca_handle_in": {
+      "type": "message_router",
+      "aaf_username": "USER",
+      "aaf_password": "PASSWORD",
+      "dmaap_info": {
+        "client_role": "subscriber",
+        "client_id": "tca-sub-0",
+        "location": "ecomp",
+        "topic_url": "http://localhost:8080/events/SubTopic"
+      }
+    }
+  },
+  "spring": {
+    "main": {
+      "banner-mode": "off"
+    },
+    "data": {
+      "mongodb": {
+        "uri": "mongodb://localhost:27017/analytics-tca"
+      }
+    }
+  }
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-pubTopic.txt b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-pubTopic.txt
new file mode 100644 (file)
index 0000000..ee6e620
--- /dev/null
@@ -0,0 +1 @@
+{"testResponseMessage" : "Accepted messages"}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-subTopic-cg1-c0.txt b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-subTopic-cg1-c0.txt
new file mode 100644 (file)
index 0000000..0752e5e
--- /dev/null
@@ -0,0 +1 @@
+[{"event":{"commonEventHeader":{"domain":"measurementsForVfScaling","eventId":"UC1-SCL01081-1492639920787","eventName":"Mfvs_eNodeB_RANKPI","lastEpochMicrosec":1492639920787,"nfNamingCode":"ENBE","priority":"Normal","reportingEntityId":"","reportingEntityName":"vtc2e7admn2","sequence":0,"sourceId":"SCL01081_9B_1","sourceName":"SCL01081","startEpochMicrosec":1492639920787,"version":3.0},"measurementsForVfScalingFields":{"additionalFields":[{"name":"software_version ","value":"version1"},{"name":"vendor ","value":"Ericsson "}],"additionalMeasurements":[{"name":"OaaS_UC1_EricssonSleepingCell","arrayOfFields":[{"name":"PMRAATTCBRA","value":"1353"},{"name":"PMRASUCCCBRA","value":"1351"},{"name":"PMCELLDOWNTIMEAUTO","value":"0"},{"name":"PMCELLDOWNTIMEMAN","value":"0"},{"name":"PMRRCCONNESTABATT","value":"297"},{"name":"PMRRCCONNESTABSUCC","value":"297"}]}],"vNicPerformanceArray":[{"receivedBroadcastPacketsAccumulated":5000,"receivedBroadcastPacketsDelta":5,"receivedDiscardedPacketsAccumulated":12,"receivedDiscardedPacketsDelta":2,"receivedErrorPacketsAccumulated":2,"receivedErrorPacketsDelta":1,"valuesAreSuspect":false,"vNicIdentifier":"someVNicIdentifier"}],"measurementInterval":900,"measurementsForVfScalingVersion":2.0}}},{"event":{"commonEventHeader":{"domain":"measurementsForVfScaling","eventId":"UC1-SCL01081-1492639920787","eventName":"Mfvs_eNodeB_RANKPI","lastEpochMicrosec":1492639920787,"nfNamingCode":"ENBE","priority":"Normal","reportingEntityId":"","reportingEntityName":"vtc2e7admn2","sequence":0,"sourceId":"SCL01081_9B_1","sourceName":"SCL01081","startEpochMicrosec":1492639920787,"version":3.0},"measurementsForVfScalingFields":{"additionalFields":[{"name":"software_version ","value":"version1"},{"name":"vendor ","value":"Ericsson "}],"additionalMeasurements":[{"name":"OaaS_UC1_EricssonSleepingCell","arrayOfFields":[{"name":"PMRAATTCBRA","value":"1353"},{"name":"PMRASUCCCBRA","value":"1351"},{"name":"PMCELLDOWNTIMEAUTO","value":"0"},{"name":"PMCELLDOWNTIMEMAN","value":"0"},{"name":"PMRRCCONNESTABATT","value":"297"},{"name":"PMRRCCONNESTABSUCC","value":"297"}]}],"vNicPerformanceArray":[{"receivedBroadcastPacketsAccumulated":21000,"receivedBroadcastPacketsDelta":5,"receivedDiscardedPacketsAccumulated":12,"receivedDiscardedPacketsDelta":2,"receivedErrorPacketsAccumulated":2,"receivedErrorPacketsDelta":1,"valuesAreSuspect":false,"vNicIdentifier":"someVNicIdentifier"}],"measurementInterval":900,"measurementsForVfScalingVersion":2.0}}},{"event":{"commonEventHeader":{"domain":"measurementsForVfScaling","eventId":"UC1-SCL01081-1492639920787","eventName":"Mfvs_eNodeB_RANKPI","lastEpochMicrosec":1492639920787,"nfNamingCode":"ENBE","priority":"Normal","reportingEntityId":"","reportingEntityName":"vtc2e7admn2","sequence":0,"sourceId":"SCL01081_9B_1","sourceName":"SCL01081","startEpochMicrosec":1492639920787,"version":3.0},"measurementsForVfScalingFields":{"additionalFields":[{"name":"software_version ","value":"version1"},{"name":"vendor ","value":"Ericsson "}],"additionalMeasurements":[{"name":"OaaS_UC1_EricssonSleepingCell","arrayOfFields":[{"name":"PMRAATTCBRA","value":"1353"},{"name":"PMRASUCCCBRA","value":"1351"},{"name":"PMCELLDOWNTIMEAUTO","value":"0"},{"name":"PMCELLDOWNTIMEMAN","value":"0"},{"name":"PMRRCCONNESTABATT","value":"297"},{"name":"PMRRCCONNESTABSUCC","value":"297"}]}],"vNicPerformanceArray":[{"receivedBroadcastPacketsAccumulated":0,"receivedBroadcastPacketsDelta":5,"receivedDiscardedPacketsAccumulated":12,"receivedDiscardedPacketsDelta":2,"receivedErrorPacketsAccumulated":2,"receivedErrorPacketsDelta":1,"valuesAreSuspect":false,"vNicIdentifier":"someVNicIdentifier"}],"measurementInterval":900,"measurementsForVfScalingVersion":2.0}}},{"event":{"commonEventHeader":{"domain":"measurementsForVfScaling","eventId":"UC1-SCL01081-1492639920787","eventName":"Mfvs_eNodeB_RANKPI","lastEpochMicrosec":1492639920787,"nfNamingCode":"ENBE","priority":"Normal","reportingEntityId":"","reportingEntityName":"vtc2e7admn2","sequence":0,"sourceId":"SCL01081_9B_1","sourceName":"SCL01081","startEpochMicrosec":1492639920787,"version":3.0},"measurementsForVfScalingFields":{"additionalFields":[{"name":"software_version ","value":"version1"},{"name":"vendor ","value":"Ericsson "}],"additionalMeasurements":[{"name":"OaaS_UC1_EricssonSleepingCell","arrayOfFields":[{"name":"PMRAATTCBRA","value":"1353"},{"name":"PMRASUCCCBRA","value":"1351"},{"name":"PMCELLDOWNTIMEAUTO","value":"0"},{"name":"PMCELLDOWNTIMEMAN","value":"0"},{"name":"PMRRCCONNESTABATT","value":"297"},{"name":"PMRRCCONNESTABSUCC","value":"297"}]}],"vNicPerformanceArray":[{"receivedBroadcastPacketsAccumulated":0,"receivedBroadcastPacketsDelta":5,"receivedDiscardedPacketsAccumulated":12,"receivedDiscardedPacketsDelta":2,"receivedErrorPacketsAccumulated":2,"receivedErrorPacketsDelta":1,"valuesAreSuspect":false,"vNicIdentifier":"someVNicIdentifier"}],"measurementInterval":900,"measurementsForVfScalingVersion":2.0}}},{"event":{"commonEventHeader":{"domain":"measurementsForVfScaling","eventId":"UC1-SCL01081-1492639920787","eventName":"virtualVMEventName","lastEpochMicrosec":1492639920787,"nfNamingCode":"ENBE","priority":"Normal","reportingEntityId":"","reportingEntityName":"vtc2e7admn2","sequence":0,"sourceId":"testVserver","sourceName":"testVserver","startEpochMicrosec":1492639920787,"version":3.0},"measurementsForVfScalingFields":{"additionalFields":[{"name":"software_version ","value":"version1"},{"name":"vendor ","value":"Ericsson "}],"additionalMeasurements":[{"name":"OaaS_UC1_EricssonSleepingCell","arrayOfFields":[{"name":"PMRAATTCBRA","value":"1353"},{"name":"PMRASUCCCBRA","value":"1351"},{"name":"PMCELLDOWNTIMEAUTO","value":"0"},{"name":"PMCELLDOWNTIMEMAN","value":"0"},{"name":"PMRRCCONNESTABATT","value":"297"},{"name":"PMRRCCONNESTABSUCC","value":"297"}]}],"vNicPerformanceArray":[{"receivedBroadcastPacketsAccumulated":200,"receivedBroadcastPacketsDelta":5,"receivedDiscardedPacketsAccumulated":12,"receivedDiscardedPacketsDelta":2,"receivedErrorPacketsAccumulated":2,"receivedErrorPacketsDelta":1,"valuesAreSuspect":false,"vNicIdentifier":"someVNicIdentifier"}],"measurementInterval":900,"measurementsForVfScalingVersion":2.0}}}]
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-subTopic-cg1-c1.txt b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/__files/body-subTopic-cg1-c1.txt
new file mode 100644 (file)
index 0000000..0637a08
--- /dev/null
@@ -0,0 +1 @@
+[]
\ No newline at end of file
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vnf-enrichment.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vnf-enrichment.json
new file mode 100644 (file)
index 0000000..f2869e9
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c101",
+  "request": {
+    "url": "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=SCL01081",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "body-aai-vnf-enrichment.json",
+    "headers": {
+      "Date": "Tue, 12 Dec 2017 02:54:22 GMT",
+      "Server": "Apache/2.2.22",
+      "Vary": "Accept-Encoding",
+      "Keep-Alive": "timeout=5, max=100",
+      "Connection": "Keep-Alive",
+      "Transfer-Encoding": "chunked",
+      "Content-Type": "application/json;charset=UTF-8"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c101"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vserver-enrichment.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vserver-enrichment.json
new file mode 100644 (file)
index 0000000..1ad6192
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c101",
+  "request": {
+    "url": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/DFW/tenants/tenant/1031120/vservers/vserver/testVserver",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "body-aai-vserver-enrichment.json",
+    "headers": {
+      "Date": "Tue, 12 Dec 2017 02:54:22 GMT",
+      "Server": "Apache/2.2.22",
+      "Vary": "Accept-Encoding",
+      "Keep-Alive": "timeout=5, max=100",
+      "Connection": "Keep-Alive",
+      "Transfer-Encoding": "chunked",
+      "Content-Type": "application/json;charset=UTF-8"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c101"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vserver-resource-data.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-aai-vserver-resource-data.json
new file mode 100644 (file)
index 0000000..764c32f
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c101",
+  "request": {
+    "url": "/aai/v11/search/nodes-query?search-node-type=vserver&filter=vserver-name:EQUALS:testVserver",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "body-aai-vserver-resource-data.json",
+    "headers": {
+      "Date": "Tue, 12 Dec 2017 02:54:22 GMT",
+      "Server": "Apache/2.2.22",
+      "Vary": "Accept-Encoding",
+      "Keep-Alive": "timeout=5, max=100",
+      "Connection": "Keep-Alive",
+      "Transfer-Encoding": "chunked",
+      "Content-Type": "application/json;charset=UTF-8"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c101"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-configservice-binding.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-configservice-binding.json
new file mode 100644 (file)
index 0000000..454292c
--- /dev/null
@@ -0,0 +1,17 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c111",
+  "request": {
+    "url": "/v1/catalog/service/config_binding_service",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "body-configservice-binding.json",
+    "headers": {
+      "Content-Type": "application/json",
+      "Server": "Apache/2.2.22",
+      "Date": "Tue, 02 Jan 2018 19:13:42 GMT"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c111"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-configservice-tca.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-configservice-tca.json
new file mode 100644 (file)
index 0000000..de528d8
--- /dev/null
@@ -0,0 +1,17 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c111",
+  "request": {
+    "url": "/service_component/tca_dev",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "body-configservice-tca.json",
+    "headers": {
+      "Content-Type": "application/json",
+      "Server": "Apache/2.2.22",
+      "Date": "Tue, 02 Jan 2018 19:13:42 GMT"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c111"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-pubTopic.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-pubTopic.json
new file mode 100644 (file)
index 0000000..9613803
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c102",
+  "request": {
+    "url": "/events/PubTopic",
+    "method": "POST"
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "body-pubTopic.txt",
+    "headers": {
+      "Date": "Tue, 12 Dec 2017 02:54:22 GMT",
+      "Server": "Apache/2.2.22",
+      "Vary": "Accept-Encoding",
+      "Keep-Alive": "timeout=5, max=100",
+      "Connection": "Keep-Alive",
+      "Transfer-Encoding": "chunked",
+      "Content-Type": "application/json;charset=UTF-8"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c102"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-subTopic-cg1-c0.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-subTopic-cg1-c0.json
new file mode 100644 (file)
index 0000000..f6795a7
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c101",
+  "request": {
+    "url": "/events/SubTopic/cg1/c0",
+    "method": "GET"
+  },
+  "response": {
+    "status": 200,
+    "bodyFileName": "body-subTopic-cg1-c0.txt",
+    "headers": {
+      "Date": "Tue, 12 Dec 2017 02:54:22 GMT",
+      "Server": "Apache/2.2.22",
+      "Vary": "Accept-Encoding",
+      "Keep-Alive": "timeout=5, max=100",
+      "Connection": "Keep-Alive",
+      "Transfer-Encoding": "chunked",
+      "Content-Type": "application/json;charset=UTF-8"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c101"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-subTopic-cg1-c1.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/wiremock/mappings/mapping-subTopic-cg1-c1.json
new file mode 100644 (file)
index 0000000..0411f5d
--- /dev/null
@@ -0,0 +1,21 @@
+{
+  "id": "e4a02fea-17d7-3090-a443-56384f45c101",
+  "request": {
+    "url": "/events/SubTopic/cg1/c1",
+    "method": "GET"
+  },
+  "response": {
+    "status": 500,
+    "bodyFileName": "body-subTopic-cg1-c1.txt",
+    "headers": {
+      "Date": "Tue, 12 Dec 2017 02:54:22 GMT",
+      "Server": "Apache/2.2.22",
+      "Vary": "Accept-Encoding",
+      "Keep-Alive": "timeout=5, max=100",
+      "Connection": "Keep-Alive",
+      "Transfer-Encoding": "chunked",
+      "Content-Type": "application/json;charset=UTF-8"
+    }
+  },
+  "uuid": "e4a02fea-17d7-3090-a443-56384f45c101"
+}
diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/logback-test.xml b/dcae-analytics/dcae-analytics-test/src/main/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..d35cf8b
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+<configuration debug="false">
+
+    <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
+    <include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
+
+    <logger name="org.onap.dcae.analytics" level="DEBUG"/>
+
+    <root level="INFO">
+        <appender-ref ref="CONSOLE"/>
+    </root>
+
+</configuration>
+
diff --git a/dcae-analytics/dcae-analytics-web/pom.xml b/dcae-analytics/dcae-analytics-web/pom.xml
new file mode 100644 (file)
index 0000000..f79c8ec
--- /dev/null
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.dcaegen2.analytics</groupId>
+        <artifactId>dcae-analytics</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>dcae-analytics-web</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- THIS MODULE CONTAINS WEB RELATED COMMON CODE FOR ALL DCAE ANALYTICS MODULES -->
+    <name>DCAE Analytics Web</name>
+    <description>Contains common web code for all DCAE Analytics Modules</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+    </properties>
+
+
+    <dependencies>
+
+        <!-- PROJECT DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-model</artifactId>
+        </dependency>
+
+        <!-- ECOMP LOGGER -->
+        <dependency>
+            <groupId>org.onap.dcaegen2.utils</groupId>
+            <artifactId>eelf-logger-logback-impl</artifactId>
+        </dependency>
+
+        <!-- SPRING DEPENDENCIES -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <!-- EXCLUDE DEFAULT TOMCAT, AS UNDERTOW IS PREFERRED OVER TOMCAT -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>io.undertow</groupId>
+                    <artifactId>undertow-websockets-jsr</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+
+        <!-- SPRING INTEGRATION -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-integration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-mongodb</artifactId>
+        </dependency>
+
+
+        <!-- APACHE HTTP CLIENT -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+
+        <!-- UTILITIES -->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-text</artifactId>
+        </dependency>
+
+        <!-- CODE GENERATION -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- FIND BUGS -->
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>annotations</artifactId>
+        </dependency>
+
+        <!-- TEST DEPENDENCIES -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>dcae-analytics-test</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/AnalyticsWebConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/AnalyticsWebConfig.java
new file mode 100644 (file)
index 0000000..a3863f5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Import(DmaapMrConfig.class)
+public class AnalyticsWebConfig {
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapMrConfig.java
new file mode 100644 (file)
index 0000000..97fdcc5
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.onap.dcae.analytics.web.dmaap.MrMessageSplitter;
+import org.onap.dcae.analytics.web.dmaap.MrPublisherPreferences;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPollingAdvice;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPreferences;
+import org.onap.dcae.analytics.web.dmaap.MrTriggerMessageProvider;
+import org.onap.dcae.analytics.web.http.HttpClientPreferencesCustomizer;
+import org.onap.dcae.analytics.web.util.AnalyticsWebUtils;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.Profile;
+import org.springframework.http.HttpMethod;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.core.MessageSource;
+import org.springframework.integration.dsl.IntegrationFlow;
+import org.springframework.integration.dsl.IntegrationFlows;
+import org.springframework.integration.dsl.channel.MessageChannels;
+import org.springframework.integration.endpoint.MethodInvokingMessageSource;
+import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
+import org.springframework.integration.http.dsl.Http;
+import org.springframework.integration.scheduling.PollerMetadata;
+import org.springframework.integration.store.BasicMessageGroupStore;
+import org.springframework.integration.store.MessageGroupQueue;
+import org.springframework.integration.support.MessageBuilder;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Import(value = {DmaapPollerConfig.class, DmaapRetryConfig.class})
+@Profile(AnalyticsProfile.DMAAP_PROFILE_NAME)
+public class DmaapMrConfig {
+
+    private static final String[] DMAAP_MAPPED_REQUEST_HEADERS =
+            DmaapMrConstants.DMAAP_MAPPED_HEADERS.toArray(new String[DmaapMrConstants.DMAAP_MAPPED_HEADERS.size()]);
+
+    @Bean(name = DmaapMrConstants.DMAAP_MR_SUBSCRIBER_OUTPUT_CHANNEL_NAME)
+    public QueueChannel mrSubscriberOutputChannel(final BasicMessageGroupStore basicMessageGroupStore) {
+        return MessageChannels.queue(new MessageGroupQueue(basicMessageGroupStore,
+                DmaapMrConstants.DMAAP_MR_SUBSCRIBER_OUTPUT_MESSAGE_STORE_GROUP_ID)).get();
+    }
+
+    @Bean(name = DmaapMrConstants.DMAAP_MR_PUBLISHER_INPUT_CHANNEL)
+    public DirectChannel mrPublisherInputChannel() {
+        return MessageChannels.direct().get();
+    }
+
+
+    @Bean
+    public RestTemplate mrSubscriberRestTemplate(final MrSubscriberPreferences mrSubscriberPreferences,
+                                                 final RestTemplateBuilder restTemplateBuilder) {
+        return restTemplateBuilder
+                .additionalCustomizers(new HttpClientPreferencesCustomizer<>(mrSubscriberPreferences))
+                .build();
+    }
+
+    @Bean
+    public RestTemplate mrPublisherRestTemplate(final MrPublisherPreferences mrPublisherPreferences,
+                                                final RestTemplateBuilder restTemplateBuilder) {
+        return restTemplateBuilder
+                .additionalCustomizers(new HttpClientPreferencesCustomizer<>(mrPublisherPreferences))
+                .build();
+    }
+
+    @Bean
+    public MrMessageSplitter mrMessageSplitter(final ObjectMapper objectMapper,
+                                               final Integer processingBatchSize) {
+        final Integer batchSize = processingBatchSize != null ? processingBatchSize :
+                DmaapMrConstants.SUBSCRIBER_DEFAULT_PROCESSING_BATCH_SIZE;
+        return new MrMessageSplitter(objectMapper, batchSize);
+    }
+
+
+    @Bean
+    public MrTriggerMessageProvider mrTriggerMessageProvider(
+            final MrSubscriberPreferences mrSubscriberPreferences) {
+        return new MrTriggerMessageProvider(mrSubscriberPreferences);
+    }
+
+    @Bean
+    public MessageSource mrMessageSource(final MrTriggerMessageProvider mrTriggerMessageProvider) {
+        final MethodInvokingMessageSource source = new MethodInvokingMessageSource();
+        source.setObject(mrTriggerMessageProvider);
+        source.setMethodName(MrTriggerMessageProvider.TRIGGER_METHOD_NAME);
+        return source;
+    }
+
+    @Bean
+    public IntegrationFlow mrSubscriberFlow(final PollerMetadata pollerMetadata,
+                                            final RestTemplate mrSubscriberRestTemplate,
+                                            final MessageSource mrMessageSource,
+                                            final QueueChannel mrSubscriberOutputChannel,
+                                            final MrMessageSplitter mrMessageSplitter,
+                                            final MrSubscriberPollingAdvice mrSubscriberPollingAdvice) {
+        return IntegrationFlows.from(mrMessageSource, c -> c.poller(pollerMetadata))
+                .handle(Http.outboundGateway(m -> String.class.cast(m.getPayload()), mrSubscriberRestTemplate)
+                        .mappedRequestHeaders(DMAAP_MAPPED_REQUEST_HEADERS)
+                        .httpMethod(HttpMethod.GET)
+                        .expectedResponseType(String.class), c -> c.advice(mrSubscriberPollingAdvice))
+                .split(mrMessageSplitter)
+                .channel(mrSubscriberOutputChannel)
+                .get();
+    }
+
+
+    @Bean
+    public IntegrationFlow mrPublisherFlow(final MrPublisherPreferences mrPublisherPreferences,
+                                           final RestTemplate mrPublisherRestTemplate,
+                                           final DirectChannel mrPublisherInputChannel,
+                                           final RequestHandlerRetryAdvice requestHandlerRetryAdvice) {
+
+        return IntegrationFlows.from(mrPublisherInputChannel)
+                .handle(Http.outboundGateway(mrPublisherPreferences.getRequestURL(), mrPublisherRestTemplate)
+                        .mappedRequestHeaders(DMAAP_MAPPED_REQUEST_HEADERS)
+                        .httpMethod(HttpMethod.POST)
+                        .extractPayload(true)
+                        .expectedResponseType(String.class), c -> c.advice(requestHandlerRetryAdvice))
+                // add end timestamp
+                .handle((String p, Map<String, Object> headers) ->
+                        MessageBuilder.withPayload(p).copyHeaders(headers)
+                                .setHeader(AnalyticsHttpConstants.REQUEST_END_TS_HEADER_KEY,
+                                        AnalyticsWebUtils.CREATION_TIMESTAMP_SUPPLIER.get()).build()
+                )
+                .channel(DmaapMrConstants.DMAAP_MR_PUBLISHER_OUTPUT_CHANNEL)
+                .get();
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapPollerConfig.java
new file mode 100644 (file)
index 0000000..ab85d5f
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.config;
+
+import java.util.concurrent.TimeUnit;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPollingAdvice;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPollingPreferences;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPreferences;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.integration.scheduling.PollerMetadata;
+import org.springframework.integration.util.DynamicPeriodicTrigger;
+import org.springframework.scheduling.support.PeriodicTrigger;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Profile(AnalyticsProfile.DMAAP_PROFILE_NAME)
+public class DmaapPollerConfig {
+
+    @Bean
+    public MrSubscriberPollingAdvice mrSubscriberPollingAdvice(final DynamicPeriodicTrigger dynamicPeriodicTrigger,
+                                                               final MrSubscriberPreferences mrSubscriberPreferences) {
+        final MrSubscriberPollingPreferences pollingPreferences = mrSubscriberPreferences.getPollingPreferences();
+        final int minInterval = pollingPreferences.getMinPollingInterval();
+        final int stepUpDelta = pollingPreferences.getStepUpDelta();
+        final int maxInterval = pollingPreferences.getMaxPollingInterval();
+        final int stepDownDelta = pollingPreferences.getStepDownDelta();
+        return new MrSubscriberPollingAdvice(dynamicPeriodicTrigger, minInterval,
+                stepUpDelta, maxInterval, stepDownDelta);
+    }
+
+    @Bean
+    public DynamicPeriodicTrigger dynamicPeriodicTrigger(final MrSubscriberPreferences mrSubscriberPreferences) {
+        final MrSubscriberPollingPreferences pollingPreferences = mrSubscriberPreferences.getPollingPreferences();
+        final int minInterval = pollingPreferences.getMinPollingInterval();
+        final DynamicPeriodicTrigger dynamicPeriodicTrigger =
+                new DynamicPeriodicTrigger(minInterval, TimeUnit.MILLISECONDS);
+        dynamicPeriodicTrigger.setFixedRate(true);
+        return dynamicPeriodicTrigger;
+    }
+
+    @Bean
+    public PollerMetadata pollerMetadata(final DynamicPeriodicTrigger dynamicPeriodicTrigger) {
+        final PollerMetadata pollerMetadata = new PollerMetadata();
+        pollerMetadata.setTrigger(dynamicPeriodicTrigger);
+        return pollerMetadata;
+    }
+
+
+    @Bean(name = PollerMetadata.DEFAULT_POLLER)
+    public PollerMetadata defaultPoller() {
+        PollerMetadata pollerMetadata = new PollerMetadata();
+        pollerMetadata.setTrigger(new PeriodicTrigger(1000));
+        return pollerMetadata;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/DmaapRetryConfig.java
new file mode 100644 (file)
index 0000000..48f0144
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.config;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.Profile;
+import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.dsl.IntegrationFlow;
+import org.springframework.integration.dsl.IntegrationFlows;
+import org.springframework.integration.dsl.channel.MessageChannels;
+import org.springframework.integration.handler.LoggingHandler;
+import org.springframework.integration.handler.advice.ErrorMessageSendingRecoverer;
+import org.springframework.integration.handler.advice.RequestHandlerRetryAdvice;
+import org.springframework.integration.store.BasicMessageGroupStore;
+import org.springframework.integration.store.MessageGroupQueue;
+import org.springframework.messaging.MessageHandlingException;
+import org.springframework.messaging.PollableChannel;
+import org.springframework.retry.RetryPolicy;
+import org.springframework.retry.backoff.BackOffPolicy;
+import org.springframework.retry.backoff.ExponentialBackOffPolicy;
+import org.springframework.retry.policy.SimpleRetryPolicy;
+import org.springframework.retry.support.RetryTemplate;
+import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.RestClientException;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Profile(AnalyticsProfile.DMAAP_PROFILE_NAME)
+@Import(MessageStoreConfig.class)
+public class DmaapRetryConfig {
+
+    @Bean
+    public QueueChannel errorChannel() {
+        return MessageChannels.queue().get();
+    }
+
+    @Bean
+    public IntegrationFlow loggingFlow() {
+        return IntegrationFlows.from(errorChannel())
+                .log(LoggingHandler.Level.ERROR)
+                .get();
+    }
+
+    @Bean
+    public ErrorMessageSendingRecoverer errorMessageSendingRecoverer(final PollableChannel recoveryChannel) {
+        final ErrorMessageSendingRecoverer errorMessageSendingRecoverer = new ErrorMessageSendingRecoverer();
+        errorMessageSendingRecoverer.setChannel(recoveryChannel);
+        return errorMessageSendingRecoverer;
+    }
+
+    @Bean
+    public PollableChannel recoveryChannel(final BasicMessageGroupStore basicMessageGroupStore) {
+        return MessageChannels.queue(new MessageGroupQueue(basicMessageGroupStore,
+                DmaapMrConstants.DMAAP_MR_PUBLISHER_RECOVERY_MESSAGE_STORE_GROUP_ID)).get();
+    }
+
+    @Bean
+    public RequestHandlerRetryAdvice requestHandlerRetryAdvice(final RetryTemplate retryTemplate,
+                                                               final ErrorMessageSendingRecoverer
+                                                                       errorMessageSendingRecoverer) {
+        final RequestHandlerRetryAdvice requestHandlerRetryAdvice = new RequestHandlerRetryAdvice();
+        requestHandlerRetryAdvice.setRetryTemplate(retryTemplate);
+        requestHandlerRetryAdvice.setRecoveryCallback(errorMessageSendingRecoverer);
+        return requestHandlerRetryAdvice;
+    }
+
+    @Bean
+    public RetryTemplate retryTemplate(final RetryPolicy retryPolicy,
+                                       final BackOffPolicy backOffPolicy) {
+        final RetryTemplate retryTemplate = new RetryTemplate();
+        retryTemplate.setRetryPolicy(retryPolicy);
+        retryTemplate.setBackOffPolicy(backOffPolicy);
+        return retryTemplate;
+    }
+
+    @Bean
+    public RetryPolicy retryPolicy() {
+        final Map<Class<? extends Throwable>, Boolean> retryableExceptions = new LinkedHashMap<>();
+        retryableExceptions.put(MessageHandlingException.class, true);
+        retryableExceptions.put(HttpStatusCodeException.class, true);
+        retryableExceptions.put(RestClientException.class, true);
+        return new SimpleRetryPolicy(DmaapMrConstants.DEFAULT_NUM_OF_RETRIES_ON_FAILURE, retryableExceptions);
+    }
+
+    @Bean
+    public BackOffPolicy backOffPolicy() {
+        final ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
+        backOffPolicy.setInitialInterval(DmaapMrConstants.DEFAULT_RETRY_INITIAL_INTERVAL);
+        backOffPolicy.setMultiplier(DmaapMrConstants.DEFAULT_RETRY_MULTIPLIER);
+        backOffPolicy.setMaxInterval(DmaapMrConstants.DEFAULT_RETRY_MAX_INTERVAL);
+        return backOffPolicy;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/config/MessageStoreConfig.java
new file mode 100644 (file)
index 0000000..aa1c502
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.config;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.mongodb.MongoDbFactory;
+import org.springframework.integration.mongodb.store.MongoDbChannelMessageStore;
+import org.springframework.integration.store.BasicMessageGroupStore;
+import org.springframework.integration.store.SimpleMessageStore;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Profile(AnalyticsProfile.DMAAP_PROFILE_NAME)
+public class MessageStoreConfig {
+
+    @Bean
+    @Profile(AnalyticsProfile.NOT_MONGO_PROFILE_NAME)
+    public BasicMessageGroupStore simpleMessageGroupStore() {
+        return new SimpleMessageStore();
+    }
+
+    @Bean
+    @Profile(AnalyticsProfile.MONGO_PROFILE_NAME)
+    public BasicMessageGroupStore mongoMessageGroupStore(final MongoDbFactory mongoDbFactory) {
+        final MongoDbChannelMessageStore store = new MongoDbChannelMessageStore(mongoDbFactory);
+        store.setPriorityEnabled(true);
+        return store;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrMessageSplitter.java
new file mode 100644 (file)
index 0000000..fe8f7ed
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.dmaap;
+
+import static org.apache.commons.text.StringEscapeUtils.unescapeJava;
+import static org.apache.commons.text.StringEscapeUtils.unescapeJson;
+import static org.onap.dcae.analytics.model.AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY;
+import static org.onap.dcae.analytics.model.AnalyticsModelConstants.ANALYTICS_REQUEST_ID_DELIMITER;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.stream.IntStream;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.onap.dcae.analytics.web.exception.AnalyticsParsingException;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.integration.splitter.AbstractMessageSplitter;
+import org.springframework.integration.support.MessageBuilder;
+import org.springframework.messaging.Message;
+
+/**
+ * DMaaP MR message splitter split the incoming messages into batch of given batch size
+ *
+ * @author Rajiv Singla
+ */
+public class MrMessageSplitter extends AbstractMessageSplitter {
+
+    private static final Logger logger = LoggerFactory.getLogger(MrMessageSplitter.class);
+
+    private final ObjectMapper objectMapper;
+    private final Integer batchSize;
+
+    public MrMessageSplitter(@Nonnull final ObjectMapper objectMapper,
+                             @Nonnull final Integer batchSize) {
+        this.objectMapper = objectMapper;
+        this.batchSize = batchSize;
+    }
+
+    @Override
+    protected Object splitMessage(final Message<?> message) {
+
+        final List<String> dmaapMessages = convertJsonToStringMessages(String.class.cast(message.getPayload()).trim());
+
+        final String requestId = AnalyticsHttpUtils.getRequestId(message.getHeaders());
+        final String transactionId = AnalyticsHttpUtils.getTransactionId(message.getHeaders());
+
+        logger.info("Request Id: {}, Transaction Id: {}, Received new messages from DMaaP MR. Count: {}",
+                requestId, transactionId, dmaapMessages.size());
+
+        final List<List<String>> messagePartitions = partition(dmaapMessages, batchSize);
+
+        logger.debug("Request Id: {}, Transaction Id: {},  Max allowed messages per batch: {}. " +
+                "No of batches created: {}", requestId, transactionId, batchSize, messagePartitions.size());
+
+        // append batch id to request id header
+        return messagePartitions.isEmpty() ? null : IntStream.range(0, messagePartitions.size())
+                .mapToObj(batchIndex ->
+                        MessageBuilder
+                                .withPayload(messagePartitions.get(0))
+                                .copyHeaders(message.getHeaders())
+                                .setHeader(REQUEST_ID_HEADER_KEY,
+                                        requestId + ANALYTICS_REQUEST_ID_DELIMITER + batchIndex)
+                                .build()
+
+                );
+    }
+
+    /**
+     * Converts DMaaP MR subscriber messages json string to List of messages. If message Json String is empty
+     * or null
+     *
+     * @param messagesJsonString json messages String
+     *
+     * @return List containing DMaaP MR Messages
+     */
+    private List<String> convertJsonToStringMessages(@Nullable final String messagesJsonString) {
+
+        final LinkedList<String> messages = new LinkedList<>();
+
+        // If message string is not null or not empty parse json message array to List of string messages
+        if (messagesJsonString != null && !messagesJsonString.trim().isEmpty()
+                && !DmaapMrConstants.SUBSCRIBER_EMPTY_MESSAGE_RESPONSE_STRING.equals(messagesJsonString.trim())) {
+
+            try {
+                // get root node
+                final JsonNode rootNode = objectMapper.readTree(messagesJsonString);
+                // iterate over root node and parse arrays messages
+                for (JsonNode jsonNode : rootNode) {
+                    // if array parse it is array of messages
+                    final String incomingMessageString = jsonNode.toString();
+                    if (jsonNode.isArray()) {
+                        final List messageList = objectMapper.readValue(incomingMessageString, List.class);
+                        for (Object message : messageList) {
+                            final String jsonMessageString = objectMapper.writeValueAsString(message);
+                            addUnescapedJsonToMessage(messages, jsonMessageString);
+                        }
+                    } else {
+                        // parse it as object
+                        addUnescapedJsonToMessage(messages, incomingMessageString);
+                    }
+                }
+
+            } catch (IOException e) {
+                final String errorMessage = String.format("Unable to convert subscriber Json String to Messages. " +
+                        "Subscriber Response String: %s, Json Error: %s", messagesJsonString, e);
+                logger.error(errorMessage, e);
+                throw new AnalyticsParsingException(errorMessage, e);
+            }
+
+        }
+        return messages;
+    }
+
+    /**
+     * Adds unescaped Json messages to given messages list
+     *
+     * @param messages message list in which unescaped messages will be added
+     * @param incomingMessageString incoming message string that may need to be escaped
+     */
+    private static void addUnescapedJsonToMessage(List<String> messages, String incomingMessageString) {
+        if (incomingMessageString.startsWith("\"") && incomingMessageString.endsWith("\"")) {
+            messages.add(unescapeJava(unescapeJson(
+                    incomingMessageString.substring(1, incomingMessageString.length() - 1))));
+        } else {
+            messages.add(unescapeJava(unescapeJson(incomingMessageString)));
+        }
+    }
+
+    /**
+     * Partition list into multiple lists
+     *
+     * @param list input list that needs to be broken into chunks
+     * @param batchSize batch size for each list
+     * @param <E> element type of the list
+     *
+     * @return List containing list of entries of specified batch size
+     */
+    private static <E> List<List<E>> partition(List<E> list, final Integer batchSize) {
+
+        if (list == null || batchSize == null || batchSize <= 0 || list.size() < batchSize) {
+            return Collections.singletonList(list);
+        }
+
+        final List<List<E>> result = new LinkedList<>();
+
+        for (int i = 0; i < list.size(); i++) {
+
+            if (i == 0 || i % batchSize == 0) {
+                List<E> sublist = new LinkedList<>();
+                result.add(sublist);
+            }
+
+            final List<E> lastSubList = result.get(result.size() - 1);
+            lastSubList.add(list.get(i));
+
+        }
+        return result;
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrPublisherPreferences.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrPublisherPreferences.java
new file mode 100644 (file)
index 0000000..c37049d
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.dmaap;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+import java.net.URL;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.onap.dcae.analytics.web.http.BaseHttpClientPreferences;
+import org.springframework.http.HttpHeaders;
+
+/**
+ * @author Rajiv Singla
+ */
+@Getter
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+public class MrPublisherPreferences extends BaseHttpClientPreferences {
+
+    private static final long serialVersionUID = 1L;
+
+    public MrPublisherPreferences(@Nonnull final String requestURL) {
+        super(requestURL);
+    }
+
+    public MrPublisherPreferences(@Nonnull final String requestURL,
+                                  @Nullable final String httpClientId,
+                                  @Nullable final HttpHeaders httpHeaders,
+                                  @Nullable final String username,
+                                  @Nullable final String password,
+                                  @Nullable final URL proxyURL,
+                                  @Nullable final Boolean ignoreSSLValidation,
+                                  @Nullable final Boolean enableEcompAuditLogging) {
+        super(requestURL, httpClientId, httpHeaders, username, password, proxyURL,
+                ignoreSSLValidation, enableEcompAuditLogging);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingAdvice.java
new file mode 100644 (file)
index 0000000..33115c5
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.dmaap;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
+import org.springframework.integration.support.MessageBuilder;
+import org.springframework.integration.util.DynamicPeriodicTrigger;
+import org.springframework.messaging.Message;
+
+/**
+ * A polling advice which can auto adjust polling intervals depending on DMaaP MR message availability.
+ * Can be configured to slow down polling when messages are not available and increase polling when messages are
+ * indeed available.
+ * <p>
+ * The next polling interval is <b>increased</b> by given step up delta if message is <b>not found</b> up to maximum
+ * Polling Interval
+ * <br>
+ * The next polling interval is <b>decreased</b> by step down delta if message <b>is found</b> up to minimum
+ * polling interval
+ *
+ * @author Rajiv Singla
+ */
+public class MrSubscriberPollingAdvice extends AbstractRequestHandlerAdvice {
+
+    private static final Logger log = LoggerFactory.getLogger(MrSubscriberPollingAdvice.class);
+
+    private final DynamicPeriodicTrigger trigger;
+    private final int minPollingInterval;
+    private final int stepUpPollingDelta;
+    private final int maxPollingInterval;
+    private final int stepDownPollingDelta;
+
+    private final AtomicInteger nextPollingInterval;
+
+    /**
+     * Creates variable polling intervals based on message availability.
+     *
+     * @param trigger Dynamic Trigger instance
+     * @param minPollingInterval Minimum polling interval
+     * @param stepUpPollingDelta Delta by which next polling interval will be increased when message is not found
+     * @param maxPollingInterval Maximum polling interval
+     * @param stepDownPollingDelta Delta by which next polling interval will be decreased when message is found
+     */
+    public MrSubscriberPollingAdvice(final DynamicPeriodicTrigger trigger,
+                                     final int minPollingInterval,
+                                     final int stepUpPollingDelta,
+                                     final int maxPollingInterval,
+                                     final int stepDownPollingDelta) {
+        this.trigger = trigger;
+        this.minPollingInterval = minPollingInterval;
+        this.stepUpPollingDelta = stepUpPollingDelta;
+        this.maxPollingInterval = maxPollingInterval;
+        this.stepDownPollingDelta = stepDownPollingDelta;
+        nextPollingInterval = new AtomicInteger(minPollingInterval);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected Object doInvoke(final ExecutionCallback callback, final Object target, final Message<?> message)
+            throws Exception {
+
+        // execute call back
+        Object result = callback.execute();
+
+        // if result is not of type message builder just return
+        if (!(result instanceof MessageBuilder)) {
+            return result;
+        }
+
+        final MessageBuilder<String> resultMessageBuilder = (MessageBuilder<String>) result;
+        final String payload = resultMessageBuilder.getPayload();
+        final Map<String, Object> headers = resultMessageBuilder.getHeaders();
+        final Object httpStatusCode = headers.get(AnalyticsHttpConstants.HTTP_STATUS_CODE_HEADER_KEY);
+
+        // get http status code
+        if (httpStatusCode == null) {
+            return result;
+        }
+        final HttpStatus httpStatus = HttpStatus.resolve(Integer.parseInt(httpStatusCode.toString()));
+
+
+        // if status code is present and successful apply polling adjustments
+        if (httpStatus != null && httpStatus.is2xxSuccessful()) {
+            final boolean areMessagesPresent = areMessagesPresent(payload);
+            updateNextPollingInterval(areMessagesPresent);
+
+            final String requestId = AnalyticsHttpUtils.getRequestId(message.getHeaders());
+            final String transactionId = AnalyticsHttpUtils.getTransactionId(message.getHeaders());
+
+            log.debug("Request Id: {}, Transaction Id: {}, Messages Present: {}, " +
+                            "Next Polling Interval will be: {}", requestId, transactionId,
+                    areMessagesPresent, nextPollingInterval);
+
+            trigger.setPeriod(nextPollingInterval.get());
+
+            // if no messages were found in dmaap poll - terminate further processing
+            if (!areMessagesPresent) {
+                log.info("Request Id: {}, Transaction Id: {}, No new messages found in DMaaP MR Response. " +
+                        "No further processing required", requestId, transactionId);
+                return null;
+            }
+
+        }
+
+        return result;
+    }
+
+    private boolean areMessagesPresent(final String payload) {
+
+        return !(payload.isEmpty() || payload.equals(DmaapMrConstants.SUBSCRIBER_EMPTY_MESSAGE_RESPONSE_STRING));
+    }
+
+    private void updateNextPollingInterval(final boolean areMessagesPresent) {
+        if (areMessagesPresent) {
+            nextPollingInterval.getAndUpdate(interval -> interval - stepDownPollingDelta <= minPollingInterval ?
+                    minPollingInterval : interval - stepDownPollingDelta);
+        } else {
+            nextPollingInterval.getAndUpdate(interval -> interval + stepUpPollingDelta >= maxPollingInterval ?
+                    maxPollingInterval : interval + stepUpPollingDelta);
+        }
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingPreferences.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPollingPreferences.java
new file mode 100644 (file)
index 0000000..0fe662e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.dmaap;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+import java.io.Serializable;
+
+/**
+ * @author Rajiv Singla
+ */
+@Getter
+@ToString
+@AllArgsConstructor
+@EqualsAndHashCode
+public class MrSubscriberPollingPreferences implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private final int minPollingInterval;
+    private final int stepUpDelta;
+    private final int maxPollingInterval;
+    private final int stepDownDelta;
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPreferences.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrSubscriberPreferences.java
new file mode 100644 (file)
index 0000000..0590d83
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.dmaap;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.onap.dcae.analytics.web.http.BaseHttpClientPreferences;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+
+/**
+ * DMaaP MR Subscriber config
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = true)
+public class MrSubscriberPreferences extends BaseHttpClientPreferences {
+
+    private static final long serialVersionUID = 1L;
+
+    private static final Logger logger = LoggerFactory.getLogger(MrSubscriberPreferences.class);
+
+    private String consumerGroup;
+    private List<String> consumerIds;
+    private Integer messageLimit;
+    private Integer timeout;
+    private MrSubscriberPollingPreferences pollingPreferences;
+
+    public MrSubscriberPreferences(@Nonnull final String requestURL) {
+        super(requestURL);
+    }
+
+    public MrSubscriberPreferences(@Nonnull final String requestURL,
+                                   @Nullable final String httpClientId,
+                                   @Nullable final HttpHeaders httpHeaders,
+                                   @Nullable final String username,
+                                   @Nullable final String password,
+                                   @Nullable final URL proxyURL,
+                                   @Nullable final Boolean ignoreSSLValidation,
+                                   @Nullable final Boolean enableEcompAuditLogging,
+                                   @Nullable final String consumerGroup,
+                                   @Nullable final List<String> consumerIds,
+                                   @Nullable final Integer messageLimit,
+                                   @Nullable final Integer timeout,
+                                   @Nullable final MrSubscriberPollingPreferences pollingPreferences) {
+        super(requestURL, httpClientId, httpHeaders, username, password, proxyURL,
+                ignoreSSLValidation, enableEcompAuditLogging);
+        this.consumerGroup = consumerGroup;
+        this.consumerIds = consumerIds;
+        this.messageLimit = messageLimit;
+        this.timeout = timeout;
+        this.pollingPreferences = pollingPreferences;
+    }
+
+
+    public MrSubscriberPollingPreferences getPollingPreferences() {
+        if (pollingPreferences == null) {
+            logger.warn("DMaaP MR Subscriber Polling details are missing. " +
+                            "Fixed polling rate will be used by default with polling interval: {}",
+                    DmaapMrConstants.SUBSCRIBER_DEFAULT_FIXED_POLLING_INTERVAL);
+            setFixedPollingRate(DmaapMrConstants.SUBSCRIBER_DEFAULT_FIXED_POLLING_INTERVAL);
+        }
+        return pollingPreferences;
+    }
+
+    private void setFixedPollingRate(final int fixedPollingInterval) {
+        this.pollingPreferences =
+                new MrSubscriberPollingPreferences(fixedPollingInterval, 0, fixedPollingInterval, 0);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/dmaap/MrTriggerMessageProvider.java
new file mode 100644 (file)
index 0000000..183957d
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.dmaap;
+
+
+import java.net.URL;
+import java.util.List;
+import java.util.function.Supplier;
+
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.util.supplier.UnboundedSupplier;
+import org.onap.dcae.analytics.web.util.AnalyticsWebUtils;
+import org.onap.dcae.analytics.web.util.function.MrSubscriberURLFunction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.integration.support.MessageBuilder;
+import org.springframework.messaging.Message;
+
+/**
+ * Provides DMaaP MR Subscriber Trigger Message
+ *
+ * @author Rajiv Singla
+ */
+public class MrTriggerMessageProvider {
+
+    private static final Logger logger = LoggerFactory.getLogger(MrTriggerMessageProvider.class);
+
+    public static final String TRIGGER_METHOD_NAME = "getTriggerMessage";
+
+    private final Supplier<URL> subscriberUrlSupplier;
+
+    public MrTriggerMessageProvider(final MrSubscriberPreferences subscriberPreferences) {
+        final List<URL> urls = new MrSubscriberURLFunction().apply(subscriberPreferences);
+        subscriberUrlSupplier = new UnboundedSupplier<>(urls.toArray(new URL[urls.size()]));
+    }
+
+    /**
+     * DMaaP MR subscriber trigger message
+     *
+     * @return dmaap mr subscriber trigger message
+     */
+    public Message<String> getTriggerMessage() {
+        final String requestId = AnalyticsWebUtils.REQUEST_ID_SUPPLIER.get();
+        final String transactionId = AnalyticsWebUtils.RANDOM_ID_SUPPLIER.get();
+        final String beginTimestamp = AnalyticsWebUtils.CREATION_TIMESTAMP_SUPPLIER.get();
+        logger.debug("Request Id: {}. Transaction Id: {}. Begin TS: {}. Starting new DMaaP MR Subscriber poll.",
+                requestId, transactionId, beginTimestamp);
+        return MessageBuilder
+                .withPayload(subscriberUrlSupplier.get().toString())
+                .setHeader(AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY, requestId)
+                .setHeader(AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY, transactionId)
+                .setHeader(AnalyticsHttpConstants.REQUEST_BEGIN_TS_HEADER_KEY, beginTimestamp)
+                .build();
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsParsingException.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsParsingException.java
new file mode 100644 (file)
index 0000000..1af40f2
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.exception;
+
+/**
+ * @author Rajiv Singla
+ */
+public class AnalyticsParsingException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    public AnalyticsParsingException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsValidationException.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/exception/AnalyticsValidationException.java
new file mode 100644 (file)
index 0000000..b59a2bd
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.exception;
+
+/**
+ * @author Rajiv Singla
+ */
+public class AnalyticsValidationException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    public AnalyticsValidationException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/BaseHttpClientPreferences.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/BaseHttpClientPreferences.java
new file mode 100644 (file)
index 0000000..3799961
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.http;
+
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+
+import java.net.URL;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.AnalyticsModelConstants;
+import org.onap.dcae.analytics.model.util.supplier.RandomIdSupplier;
+import org.springframework.http.HttpHeaders;
+
+/**
+ * Base implementation for {@link HttpClientPreferences}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@ToString(exclude = "password")
+@EqualsAndHashCode
+public abstract class BaseHttpClientPreferences implements HttpClientPreferences {
+
+    protected String requestURL;
+    protected String httpClientId;
+    protected HttpHeaders requestHeaders;
+    protected String username;
+    protected String password;
+    protected URL proxyURL;
+    protected Boolean ignoreSSLValidation;
+    protected Boolean enableEcompAuditLogging;
+
+    public BaseHttpClientPreferences(@Nonnull final String requestURL) {
+        this.requestURL = requestURL;
+    }
+
+    public BaseHttpClientPreferences(@Nonnull final String requestURL,
+                                     @Nullable final String httpClientId,
+                                     @Nullable final HttpHeaders httpHeaders,
+                                     @Nullable final String username,
+                                     @Nullable final String password,
+                                     @Nullable final URL proxyURL,
+                                     @Nullable final Boolean ignoreSSLValidation,
+                                     @Nullable final Boolean enableEcompAuditLogging) {
+        this.requestURL = requestURL;
+        // create http client id if not present
+        this.httpClientId = httpClientId != null ? httpClientId :
+                AnalyticsHttpConstants.DEFAULT_HTTP_CLIENT_ID_PREFIX +
+                        new RandomIdSupplier(AnalyticsModelConstants.DEFAULT_RANDOM_ID_LENGTH);
+        this.requestHeaders = httpHeaders;
+        this.username = username;
+        this.password = password;
+        this.proxyURL = proxyURL;
+        this.ignoreSSLValidation = ignoreSSLValidation != null && ignoreSSLValidation;
+        this.enableEcompAuditLogging = enableEcompAuditLogging != null && enableEcompAuditLogging;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/EelfAuditLogInterceptor.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/EelfAuditLogInterceptor.java
new file mode 100644 (file)
index 0000000..54b5446
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.http;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.util.Date;
+import java.util.Locale;
+
+import org.onap.dcae.analytics.model.AnalyticsModelConstants;
+import org.onap.dcae.analytics.model.TcaModelConstants;
+import org.onap.dcae.analytics.model.ecomplogger.AnalyticsErrorType;
+import org.onap.dcae.analytics.web.util.AnalyticsHttpUtils;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestIdLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestTimingLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ResponseLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ServiceLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.TargetServiceLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.MetricLogSpecImpl;
+import org.springframework.core.Ordered;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.client.AbstractClientHttpResponse;
+import org.springframework.http.client.ClientHttpRequestExecution;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.util.StreamUtils;
+
+/**
+ * Eelf Audit log interceptor is used to log ECOMP Audit Logging
+ *
+ * @author Rajiv Singla
+ */
+public class EelfAuditLogInterceptor implements ClientHttpRequestInterceptor, Ordered {
+
+    private static final EELFLogger logger = EELFLogFactory.getLogger(EelfAuditLogInterceptor.class);
+
+    private final ServiceLogInfo serviceLogInfo;
+    private final String targetEntityName;
+
+    public EelfAuditLogInterceptor(final HttpClientPreferences httpClientPreferences) {
+        this.serviceLogInfo = getServiceLogInfo(httpClientPreferences);
+        this.targetEntityName = getTargetEntityName(httpClientPreferences);
+    }
+
+    @Override
+    public ClientHttpResponse intercept(final HttpRequest request,
+                                        final byte[] body,
+                                        final ClientHttpRequestExecution execution) throws IOException {
+
+        final String requestId = AnalyticsHttpUtils.getRequestId(request.getHeaders());
+        final String transactionId = AnalyticsHttpUtils.getTransactionId(request.getHeaders());
+
+        ClientHttpResponse clientHttpResponse = null;
+        HttpStatus httpStatus = null;
+        String statusText = "";
+        String errorMessage = null;
+        final Date requestBeginTimeStamp = new Date();
+        try {
+            clientHttpResponse = execution.execute(request, body);
+            httpStatus = clientHttpResponse.getStatusCode();
+            if (httpStatus.is2xxSuccessful()) {
+                errorMessage = null;
+                statusText = clientHttpResponse.getStatusText();
+            } else {
+                errorMessage = StreamUtils.copyToString(clientHttpResponse.getBody(), Charset.defaultCharset());
+                statusText = clientHttpResponse.getStatusText();
+            }
+        } catch (IOException e) {
+            httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
+            statusText = AnalyticsErrorType.TIMEOUT_ERROR.getErrorDescription();
+            errorMessage = e.toString();
+        }
+        final Date requestEndTimeStamp = new Date();
+        final long elapsedTime = requestEndTimeStamp.getTime() - requestBeginTimeStamp.getTime();
+        final RequestTimingLogInfoImpl requestTimingLogInfo = new RequestTimingLogInfoImpl(requestBeginTimeStamp,
+                requestEndTimeStamp, elapsedTime);
+        final MetricLogSpecImpl metricLogSpec = new MetricLogSpecImpl(new RequestIdLogInfoImpl(requestId),
+                serviceLogInfo, requestTimingLogInfo,
+                getResponseLogInfo(httpStatus, statusText), getTargetServiceLogInfo(request, targetEntityName));
+
+        if (errorMessage != null) {
+            logger.metricLog().error("Request Id: {}, Transaction Id: {}, Elapsed Time: {} ms, Error Message: {} ",
+                    metricLogSpec, requestId, transactionId, Long.toString(elapsedTime), errorMessage);
+        } else {
+            logger.metricLog().info("Request Id: {}, Transaction Id: {}, Elapsed Time: {} ms, REST Endpoint Call: {}",
+                    metricLogSpec, requestId, transactionId, Long.toString(elapsedTime),
+                    statusText + "-" + getTargetService(request));
+        }
+
+        return clientHttpResponse != null ? clientHttpResponse : new SimpleClientHttpResponse();
+    }
+
+    @Override
+    public int getOrder() {
+        return LOWEST_PRECEDENCE;
+    }
+
+    private static ServiceLogInfo getServiceLogInfo(final HttpClientPreferences httpClientPreferences) {
+        return new ServiceLogInfoImpl(TcaModelConstants.TCA_SERVICE_NAME,
+                httpClientPreferences.getUsername(), "");
+    }
+
+    // translate well known http status code to corresponding Ecomp Logging error codes
+    private static ResponseLogInfo getResponseLogInfo(final HttpStatus httpStatus, final String statusText) {
+        if (httpStatus.is2xxSuccessful()) {
+            return new ResponseLogInfoImpl(AnalyticsErrorType.SUCCESSFUL.getErrorCode(), statusText);
+        } else if (httpStatus.is4xxClientError()) {
+            if (httpStatus == HttpStatus.UNAUTHORIZED || httpStatus == HttpStatus.FORBIDDEN) {
+                return new ResponseLogInfoImpl(AnalyticsErrorType.PERMISSION_ERROR.getErrorCode(), statusText);
+            }
+            return new ResponseLogInfoImpl(AnalyticsErrorType.DATA_ERROR.getErrorCode(), statusText);
+        } else if (httpStatus.is5xxServerError()) {
+            if (httpStatus == HttpStatus.SERVICE_UNAVAILABLE) {
+                return new ResponseLogInfoImpl(AnalyticsErrorType.TIMEOUT_ERROR.getErrorCode(), statusText);
+            }
+            return new ResponseLogInfoImpl(AnalyticsErrorType.BUSINESS_PROCESS_ERROR.getErrorCode(),
+                    statusText);
+        }
+        return new ResponseLogInfoImpl(AnalyticsErrorType.UNKNOWN_ERROR.getErrorCode(), statusText);
+    }
+
+
+    private static TargetServiceLogInfo getTargetServiceLogInfo(final HttpRequest httpRequest,
+                                                                final String targetEntityName) {
+        return new TargetServiceLogInfoImpl(targetEntityName, getTargetService(httpRequest),
+                getTargetVirtualEntity(httpRequest));
+    }
+
+    private static String getTargetVirtualEntity(final HttpRequest httpRequest) {
+        return httpRequest.getURI().getAuthority();
+    }
+
+    private static String getTargetService(final HttpRequest httpRequest) {
+        return httpRequest.getMethod() + "-" + httpRequest.getURI().getPath();
+    }
+
+    private static String getTargetEntityName(final HttpClientPreferences httpClientPreferences) {
+        final String simpleName = httpClientPreferences.getClass().getSimpleName().toUpperCase(Locale.getDefault());
+        if (simpleName.contains("MRSUB")) {
+            return "DMAAP_MR_SUBSCRIBER";
+        } else if (simpleName.contains("MRPUB")) {
+            return "DMAAP_MR_PUBLISHER";
+        } else if (simpleName.contains("AAI")) {
+            return "AAI_ENRICHMENT";
+        } else {
+            return "UNKNOWN";
+        }
+    }
+
+
+    private static class SimpleClientHttpResponse extends AbstractClientHttpResponse {
+        @Override
+        public int getRawStatusCode() throws IOException {
+            return HttpStatus.SERVICE_UNAVAILABLE.value();
+        }
+
+        @Override
+        public String getStatusText() throws IOException {
+            return HttpStatus.SERVICE_UNAVAILABLE.getReasonPhrase();
+        }
+
+        @Override
+        public void close() {
+            // do nothing
+        }
+
+        @Override
+        public InputStream getBody() throws IOException {
+            return new ByteArrayInputStream("".getBytes(Charset.forName(AnalyticsModelConstants.UTF8_CHARSET_NAME)));
+        }
+
+        @Override
+        public HttpHeaders getHeaders() {
+            return new HttpHeaders();
+        }
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/HttpClientPreferences.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/HttpClientPreferences.java
new file mode 100644 (file)
index 0000000..34d0124
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.http;
+
+import java.io.Serializable;
+import java.net.URL;
+
+import org.springframework.http.HttpHeaders;
+
+/**
+ * DCAE Analytics HTTP Client Preferences
+ *
+ * @author Rajiv Singla
+ */
+public interface HttpClientPreferences extends Serializable {
+
+    String getRequestURL();
+
+    String getHttpClientId();
+
+    HttpHeaders getRequestHeaders();
+
+    String getUsername();
+
+    String getPassword();
+
+    URL getProxyURL();
+
+    Boolean getIgnoreSSLValidation();
+
+    Boolean getEnableEcompAuditLogging();
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/HttpClientPreferencesCustomizer.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/http/HttpClientPreferencesCustomizer.java
new file mode 100644 (file)
index 0000000..c5f66be
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.http;
+
+
+import java.io.IOException;
+import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.util.function.StringToURLFunction;
+import org.onap.dcae.analytics.web.util.AnalyticsWebUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.web.client.RestTemplateCustomizer;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpRequest;
+import org.springframework.http.client.BufferingClientHttpRequestFactory;
+import org.springframework.http.client.ClientHttpRequestExecution;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.http.client.support.BasicAuthorizationInterceptor;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.DefaultUriBuilderFactory;
+
+/**
+ * Creates a {@link RestTemplateCustomizer} which can be used to configure the spring rest templates
+ * based on given {@link HttpClientPreferences}
+ *
+ * @param <T> Http Client Configurations
+ *
+ * @author Rajiv Singla
+ */
+public class HttpClientPreferencesCustomizer<T extends HttpClientPreferences> implements RestTemplateCustomizer {
+
+    private static final Logger logger = LoggerFactory.getLogger(HttpClientPreferencesCustomizer.class);
+
+    private final T httpClientConfig;
+
+    public HttpClientPreferencesCustomizer(final T httpClientConfig) {
+        this.httpClientConfig = httpClientConfig;
+    }
+
+    @Override
+    public void customize(final RestTemplate restTemplate) {
+
+        final String httpClientId = httpClientConfig.getHttpClientId() != null ? httpClientConfig.getHttpClientId()
+                : AnalyticsHttpConstants.DEFAULT_HTTP_CLIENT_ID_PREFIX + AnalyticsWebUtils.RANDOM_ID_SUPPLIER.get();
+        logger.debug("Customizing Rest Template for Http Client Id: {}", httpClientId);
+
+        // set request url
+        final URL requestURL = new StringToURLFunction().apply(httpClientConfig.getRequestURL())
+                .orElseThrow(() -> new IllegalArgumentException("Http Client URL is required"));
+        restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(requestURL.toString()));
+
+        // add basic authentication headers
+        final String username = httpClientConfig.getUsername();
+        if (username != null) {
+            restTemplate.getInterceptors().add(
+                    new BasicAuthorizationInterceptor(username, httpClientConfig.getPassword()));
+        }
+
+        // set default request headers
+        final HttpHeaders defaultRequestHeaders = httpClientConfig.getRequestHeaders();
+        if (defaultRequestHeaders != null) {
+            restTemplate.getInterceptors().add(new DefaultHeadersRequestInterceptor(defaultRequestHeaders));
+        }
+
+        // create new http client builder
+        final HttpClientBuilder httpClientBuilder = HttpClients.custom().useSystemProperties()
+                .disableContentCompression();
+        final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+
+        // set basic authentication credentials
+        configureAuthenticationCredentials(httpClientId, requestURL, credentialsProvider);
+        // set up proxy url
+        configureProxySettings(httpClientId, httpClientBuilder, credentialsProvider);
+        // setup credentials provider
+        httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
+        // set up ssl Context
+        configureSSLContext(httpClientId, httpClientBuilder);
+
+        // set rest client builder
+        final HttpComponentsClientHttpRequestFactory httpRequestFactory =
+                new HttpComponentsClientHttpRequestFactory(httpClientBuilder.build());
+
+        // set ecomp logging interceptor
+        if (httpClientConfig.getEnableEcompAuditLogging()) {
+            restTemplate.getInterceptors().add(new EelfAuditLogInterceptor(httpClientConfig));
+        }
+
+        restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(httpRequestFactory));
+    }
+
+    /**
+     * Configures authentication credentials
+     *
+     * @param httpClientId http client id
+     * @param requestURL request url
+     * @param credentialsProvider credentials provider
+     */
+    private void configureAuthenticationCredentials(final String httpClientId, final URL requestURL,
+                                                    final CredentialsProvider credentialsProvider) {
+        final String username = httpClientConfig.getUsername();
+        if (username != null) {
+            logger.info("Setting basic Authentication credentials for Http Client Id: {} with username: {}",
+                    httpClientId, username);
+            final String requestURLProtocol = requestURL.getProtocol();
+            final String requestUrlHost = requestURL.getHost();
+            final Integer requestUrlPortNumber = requestURL.getPort();
+            final HttpHost requestURLHost = new HttpHost(requestUrlHost, requestUrlPortNumber, requestURLProtocol);
+            final String password = httpClientConfig.getPassword();
+            final AuthScope httpClientAuthScope = new AuthScope(requestURLHost);
+            final Credentials credentials = new UsernamePasswordCredentials(username, password);
+            credentialsProvider.setCredentials(httpClientAuthScope, credentials);
+        } else {
+            logger.warn("No credentials set for Http Client Id: {}. No username present", httpClientId);
+        }
+    }
+
+    /**
+     * Configures proxy host, port and authentication
+     *
+     * @param httpClientId http client id
+     * @param httpClientBuilder http client builder
+     * @param credentialsProvider http credentials provider
+     */
+    private void configureProxySettings(final String httpClientId, final HttpClientBuilder httpClientBuilder,
+                                        final CredentialsProvider credentialsProvider) {
+
+        final URL proxyURL = httpClientConfig.getProxyURL();
+
+        if (proxyURL == null) {
+            logger.debug("Proxy not Enabled - bypassing setting Proxy settings for Http Client Id: {}", httpClientId);
+            return;
+        }
+
+        final String proxyProtocol = proxyURL.getProtocol();
+        final String proxyHost = proxyURL.getHost();
+        final Integer proxyPort = proxyURL.getPort();
+        final HttpHost proxy = new HttpHost(proxyHost, proxyPort, proxyProtocol);
+
+        logger.info("Setting up proxy for Http Client Id: {} as: {}", httpClientId, proxy);
+
+        final DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
+        httpClientBuilder.setRoutePlanner(routePlanner);
+
+        // get proxy credentials information
+        final String userInfo = proxyURL.getUserInfo();
+
+        if (!StringUtils.hasText(userInfo)) {
+            logger.debug("Proxy username not present. " +
+                    "No proxy authentication credentials will be set for Http Client Id: {}", httpClientId);
+            return;
+        }
+
+        final String[] userInfoArray = userInfo.split(":");
+        final String proxyUsername = userInfoArray[0];
+        String proxyPassword = null;
+        if (userInfoArray.length > 1) {
+            proxyPassword = userInfoArray[1];
+        }
+        logger.info("Setting proxy credentials with username: {} for Http Client Id: {}", proxyUsername, httpClientId);
+        final AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort);
+        final Credentials proxyCredentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
+        credentialsProvider.setCredentials(proxyAuthScope, proxyCredentials);
+    }
+
+    /**
+     * Configures SSL Context
+     *
+     * @param httpClientId http client id
+     * @param httpClientBuilder http client builder
+     */
+    private void configureSSLContext(final String httpClientId, final HttpClientBuilder httpClientBuilder) {
+
+        // Setup SSL Context to ignore SSL certificate issues if ignoreSSLCertificateErrors is true
+        final boolean ignoreSSLValidation =
+                Optional.ofNullable(httpClientConfig.getIgnoreSSLValidation()).orElse(false);
+        logger.info("Ignore SSL Certificate Errors attributed is set to: {} for Http Client Id: {}",
+                ignoreSSLValidation, httpClientId);
+
+        if (!ignoreSSLValidation) {
+            logger.info("SSL Validation will be enforced for Http Client Id: {}", httpClientId);
+            return;
+        }
+
+        logger.warn("SSL Certificate Errors will be ignored for Http Client Id: {}", httpClientId);
+        try {
+            SSLContextBuilder sslContextBuilder = new SSLContextBuilder();
+            sslContextBuilder.loadTrustMaterial(null, new AlwaysTrustingTrustStrategy());
+            httpClientBuilder.setSSLContext(sslContextBuilder.build());
+        } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
+            ReflectionUtils.rethrowRuntimeException(e);
+        }
+        httpClientBuilder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
+
+    }
+
+
+    /**
+     * Header Request Interceptor adds defaults headers if not set explicitly
+     */
+    private static class DefaultHeadersRequestInterceptor implements ClientHttpRequestInterceptor {
+        private final HttpHeaders httpHeaders;
+
+        DefaultHeadersRequestInterceptor(final HttpHeaders httpHeaders) {
+            this.httpHeaders = httpHeaders;
+        }
+
+        @Override
+        public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
+                                            final ClientHttpRequestExecution execution) throws IOException {
+            final HttpHeaders currentRequestHeaders = request.getHeaders();
+            for (Map.Entry<String, List<String>> defaultHttpHeader : httpHeaders.entrySet()) {
+                if (!currentRequestHeaders.containsKey(defaultHttpHeader.getKey())) {
+                    currentRequestHeaders.addAll(defaultHttpHeader.getKey(), defaultHttpHeader.getValue());
+                }
+            }
+            currentRequestHeaders.setAccept(httpHeaders.getAccept());
+            currentRequestHeaders.setAcceptCharset(httpHeaders.getAcceptCharset());
+            currentRequestHeaders.remove(HttpHeaders.ACCEPT_ENCODING);
+            return execution.execute(request, body);
+        }
+    }
+
+    /**
+     * An implementation of SSL Trust Strategy which does no SSL certificate validation effectively
+     * bypassing any SSL certificate related issues
+     */
+    private static class AlwaysTrustingTrustStrategy implements TrustStrategy {
+        @Override
+        public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+            return true;
+        }
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/mongo/MongoProfileCondition.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/mongo/MongoProfileCondition.java
new file mode 100644 (file)
index 0000000..d984085
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.mongo;
+
+import java.util.Arrays;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+/**
+ * Condition that configures mongo support only if mongo profile is present
+ *
+ * @author Rajiv Singla
+ */
+public class MongoProfileCondition implements Condition {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoProfileCondition.class);
+
+    @Override
+    public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
+
+        final boolean isMongoProfileActive = Arrays.stream(context.getEnvironment().getActiveProfiles())
+                .anyMatch(activeProfile -> activeProfile.equalsIgnoreCase(AnalyticsProfile.MONGO_PROFILE_NAME));
+
+        if (isMongoProfileActive) {
+            logger.info("Mongo Profile is Active. Mongo support is enabled");
+            return true;
+        }
+
+        logger.info("Mongo Profile is NOT Active. Mongo support is disabled");
+        return false;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java
new file mode 100644 (file)
index 0000000..2073127
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.spring;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.onap.dcae.analytics.model.util.function.JsonStringToMapFunction;
+import org.onap.dcae.analytics.model.util.supplier.ConfigBindingServiceJsonSupplier;
+import org.onap.dcae.analytics.web.exception.AnalyticsValidationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
+import org.springframework.core.env.StandardEnvironment;
+import org.springframework.util.ClassUtils;
+import org.springframework.web.context.support.StandardServletEnvironment;
+
+/**
+ * A custom spring framework environment post processor which can fetch and populate spring context with
+ * Config Binding Service application properties.
+ * <p>
+ * Activated only when config binding service profile is active.
+ *
+ * @author Rajiv Singla
+ */
+public class ConfigBindingServiceEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
+
+    private static final Logger logger = LoggerFactory.getLogger(ConfigBindingServiceEnvironmentPostProcessor.class);
+    private static final String SERVLET_ENVIRONMENT_CLASS =
+            "org.springframework.web.context.support.StandardServletEnvironment";
+
+    private static final int DEFAULT_ORDER = Ordered.HIGHEST_PRECEDENCE;
+
+    @Override
+    public void postProcessEnvironment(final ConfigurableEnvironment environment, final SpringApplication application) {
+
+        final boolean isConfigServiceProfilePresent = Arrays.stream(environment.getActiveProfiles())
+                .anyMatch(p -> p.equalsIgnoreCase(AnalyticsProfile.CONFIG_BINDING_SERVICE_PROFILE_NAME));
+
+        if (!isConfigServiceProfilePresent) {
+            logger.info("Config Binding Service Profile is not active. " +
+                    "Skipping Adding config binding service properties");
+            return;
+        }
+
+        logger.info("Config Binding Service Profile is active. " +
+                "Application properties will be fetched from config binding service");
+
+        // Fetch config binding service json
+        final Optional<String> configServiceJsonOptional = new ConfigBindingServiceJsonSupplier().get();
+
+        if (!configServiceJsonOptional.isPresent()) {
+            final String errorMessage = "Unable to get fetch application configuration from config binding service";
+            throw new AnalyticsValidationException(errorMessage, new IllegalStateException(errorMessage));
+        }
+
+        final String configServicePropertiesKey = ConfigBindingServiceConstants.CONFIG_BINDING_SERVICE_PROPERTIES_KEY;
+
+        // convert fetch config binding service json string to Map of property key and values
+        final Map<String, Object> configPropertiesMap = configServiceJsonOptional
+                .map(new JsonStringToMapFunction(configServicePropertiesKey))
+                .orElse(Collections.emptyMap());
+
+        if (configPropertiesMap.isEmpty()) {
+
+            logger.warn("No properties found in config binding service");
+
+        } else {
+
+            // remove config service key prefix on spring reserved property key prefixes
+            final Set<String> springKeyPrefixes = ConfigBindingServiceConstants.SPRING_RESERVED_PROPERTIES_KEY_PREFIXES;
+            final Set<String> springKeys = springKeyPrefixes.stream()
+                    .map(springKeyPrefix -> configServicePropertiesKey + "." + springKeyPrefix)
+                    .collect(Collectors.toSet());
+
+            final Map<String, Object> filterKeyMap = configPropertiesMap.entrySet()
+                    .stream()
+                    .collect(Collectors.toMap(
+                            (Map.Entry<String, Object> e) ->
+                                    springKeys.stream().anyMatch(springKey -> e.getKey().startsWith(springKey)) ?
+                                            e.getKey().substring(configServicePropertiesKey.toCharArray().length + 1) :
+                                            e.getKey(),
+                            Map.Entry::getValue)
+                    );
+
+            filterKeyMap.forEach((key, value) ->
+                    logger.info("Adding property from config service in spring context: {} -> {}", key, value));
+
+            addJsonPropertySource(environment, new MapPropertySource(configServicePropertiesKey, filterKeyMap));
+        }
+
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    private void addJsonPropertySource(final ConfigurableEnvironment environment, final PropertySource<?> source) {
+        final MutablePropertySources sources = environment.getPropertySources();
+        final String name = findPropertySource(sources);
+        if (sources.contains(name)) {
+            sources.addBefore(name, source);
+        } else {
+            sources.addFirst(source);
+        }
+    }
+
+    private String findPropertySource(final MutablePropertySources sources) {
+        if (ClassUtils.isPresent(SERVLET_ENVIRONMENT_CLASS, null) &&
+                sources.contains(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME)) {
+            return StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME;
+
+        }
+        return StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/MongoAutoConfigurationPostProcessor.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/MongoAutoConfigurationPostProcessor.java
new file mode 100644 (file)
index 0000000..94f877e
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.spring;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
+
+/**
+ * Disables mongo auto configuration if {@link AnalyticsProfile#MONGO_PROFILE_NAME} is not present
+ *
+ * @author Rajiv Singla
+ */
+public class MongoAutoConfigurationPostProcessor implements EnvironmentPostProcessor, Ordered {
+
+    private static final Logger logger = LoggerFactory.getLogger(MongoAutoConfigurationPostProcessor.class);
+
+    private static final String PROPERTY_SOURCE_NAME = "defaultProperties";
+    private static final String SPRING_AUTO_CONFIG_EXCLUDE_PROPERTY_KEY = "spring.autoconfigure.exclude";
+    private static final List<String> MONGO_AUTO_CONFIG_PROPERTIES = Arrays.asList(
+            "org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration",
+            "org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration",
+            "org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration");
+
+    @Override
+    public void postProcessEnvironment(final ConfigurableEnvironment environment, final SpringApplication application) {
+
+        final boolean isMongoProfileActive = Arrays.stream(environment.getActiveProfiles())
+                .anyMatch(profile -> profile.equalsIgnoreCase(AnalyticsProfile.MONGO_PROFILE_NAME));
+
+        // if mongo profile is not active disable mongo auto configuration
+        if (!isMongoProfileActive) {
+            logger.info("Mongo Profile is not active - disabling Mongo Auto Configuration");
+            final Map<String, Object> mongoExcludePropsMap = new HashMap<>();
+            mongoExcludePropsMap.put(SPRING_AUTO_CONFIG_EXCLUDE_PROPERTY_KEY, MONGO_AUTO_CONFIG_PROPERTIES);
+            addMongoPropertiesIfAbsent(environment.getPropertySources(), mongoExcludePropsMap);
+        }
+    }
+
+    private void addMongoPropertiesIfAbsent(final MutablePropertySources propertySources,
+                                            final Map<String, Object> mongoPropertiesMap) {
+        MapPropertySource target = null;
+        if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
+            PropertySource<?> source = propertySources.get(PROPERTY_SOURCE_NAME);
+            if (source instanceof MapPropertySource) {
+                target = (MapPropertySource) source;
+                for (final Map.Entry<String, Object> entry : mongoPropertiesMap.entrySet()) {
+                    if (!target.containsProperty(entry.getKey())) {
+                        target.getSource().putIfAbsent(entry.getKey(), entry.getValue());
+                    }
+                }
+            }
+        }
+        if (target == null) {
+            target = new MapPropertySource(PROPERTY_SOURCE_NAME, mongoPropertiesMap);
+        }
+        if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
+            propertySources.addLast(target);
+        }
+    }
+
+    @Override
+    public int getOrder() {
+        return Ordered.LOWEST_PRECEDENCE;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/AnalyticsHttpUtils.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/AnalyticsHttpUtils.java
new file mode 100644 (file)
index 0000000..96e16f9
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.util;
+
+/**
+ * @author Rajiv Singla
+ */
+
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.annotation.Nullable;
+
+import org.onap.dcae.analytics.model.AnalyticsHttpConstants;
+import org.onap.dcae.analytics.model.AnalyticsModelConstants;
+import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants;
+import org.onap.dcae.analytics.model.util.supplier.CreationTimestampSupplier;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.messaging.MessageHeaders;
+
+/**
+ * Provides utility methods for Analytics HTTP Operations
+ *
+ * @author Rajiv Singla
+ */
+public abstract class AnalyticsHttpUtils {
+
+    /**
+     * Creates default http headers for analytics http requests to other services like DMaaP, AAI etc with randomly
+     * generated request id header
+     *
+     * @return default analytics http headers
+     */
+    public static HttpHeaders createDefaultHttpHeaders() {
+        return createDefaultHttpHeaders(null);
+    }
+
+    /**
+     * Creates default http headers for analytics http requests to other services like DMaaP, AAI etc
+     *
+     * @param requestId request id
+     *
+     * @return default analytics http headers
+     */
+    public static HttpHeaders createDefaultHttpHeaders(@Nullable final String requestId) {
+
+        final HttpHeaders httpHeaders = new HttpHeaders();
+
+        // set analytics from app name header.
+        // Look up service name set by config service "SERVICE_NAME" environment variable or assign default value
+        httpHeaders.add(
+                AnalyticsHttpConstants.REQUEST_APP_NAME_HEADER_KEY,
+                ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE != null ?
+                        ConfigBindingServiceConstants.SERVICE_NAME_ENV_VARIABLE_VALUE :
+                        AnalyticsHttpConstants.REQUEST_APP_NAME_HEADER_DEFAULT_VALUE);
+
+        // if request id is not present create random UUID
+        httpHeaders.add(AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY, requestId != null ?
+                requestId : AnalyticsWebUtils.REQUEST_ID_SUPPLIER.get());
+
+        // sub transaction id is created randomly for each http request
+        httpHeaders.add(AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY,
+                AnalyticsWebUtils.RANDOM_ID_SUPPLIER.get());
+
+        // by default analytics will accept only json
+        httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON_UTF8));
+        httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
+        httpHeaders.setAcceptCharset(
+                Collections.singletonList(Charset.forName(AnalyticsModelConstants.UTF8_CHARSET_NAME)));
+
+        return httpHeaders;
+    }
+
+
+    public static String getRequestId(final MessageHeaders messageHeaders) {
+        return Optional.ofNullable(messageHeaders.get(AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY))
+                .map(requestId -> (String) requestId).orElse("UNKNOWN-REQUEST_ID");
+    }
+
+    public static String getTransactionId(final MessageHeaders messageHeaders) {
+        return Optional.ofNullable(messageHeaders.get(AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY))
+                .map(transactionId -> (String) transactionId).orElse("UNKNOWN-TRANSACTION_ID");
+    }
+
+    public static Date getTimestampFromHeaders(final Map<String, Object> headers, final String headerTsKey) {
+        return Optional.ofNullable(headers.get(headerTsKey))
+                .map(ts -> CreationTimestampSupplier.getParsedDate((String) ts)).orElse(new Date());
+    }
+
+    public static String getRequestId(final HttpHeaders httpHeaders) {
+        return Optional.ofNullable(
+                httpHeaders.get(AnalyticsHttpConstants.REQUEST_ID_HEADER_KEY)).map(headerList ->
+                headerList.get(0)).orElse(AnalyticsWebUtils.REQUEST_ID_SUPPLIER.get());
+    }
+
+    public static String getTransactionId(final HttpHeaders httpHeaders) {
+        return Optional.ofNullable(
+                httpHeaders.get(AnalyticsHttpConstants.REQUEST_TRANSACTION_ID_HEADER_KEY)).map(headerList ->
+                headerList.get(0)).orElse(AnalyticsWebUtils.RANDOM_ID_SUPPLIER.get());
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/AnalyticsWebUtils.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/AnalyticsWebUtils.java
new file mode 100644 (file)
index 0000000..a0bf558
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.util;
+
+import java.util.function.Supplier;
+
+import org.onap.dcae.analytics.model.AnalyticsModelConstants;
+import org.onap.dcae.analytics.model.util.supplier.AnalyticsRequestIdSupplier;
+import org.onap.dcae.analytics.model.util.supplier.CreationTimestampSupplier;
+import org.onap.dcae.analytics.model.util.supplier.RandomIdSupplier;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class AnalyticsWebUtils {
+
+    public static final Supplier<String> REQUEST_ID_SUPPLIER = new AnalyticsRequestIdSupplier();
+    public static final Supplier<String> RANDOM_ID_SUPPLIER =
+            new RandomIdSupplier(AnalyticsModelConstants.DEFAULT_RANDOM_ID_LENGTH);
+    public static final Supplier<String> CREATION_TIMESTAMP_SUPPLIER = new CreationTimestampSupplier();
+
+    private AnalyticsWebUtils() {
+        // private constructor
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/ValidationUtils.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/ValidationUtils.java
new file mode 100644 (file)
index 0000000..5c734d8
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.util;
+
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.onap.dcae.analytics.web.exception.AnalyticsValidationException;
+import org.onap.dcae.analytics.web.validation.AnalyticsValidator;
+import org.onap.dcae.analytics.web.validation.ValidationResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.Assert;
+
+/**
+ * Validation Utilities
+ *
+ * @author Rajiv Singla
+ */
+public abstract class ValidationUtils {
+
+    private static final Logger log = LoggerFactory.getLogger(ValidationUtils.class);
+
+    private ValidationUtils() {
+
+    }
+
+    /**
+     * Checks if String is empty. For null string true is returned
+     *
+     * @param stringValue string value
+     *
+     * @return returns true is string is empty or null
+     */
+    public static boolean isEmpty(@Nullable final String stringValue) {
+        return stringValue == null || stringValue.isEmpty() || stringValue.trim().isEmpty();
+    }
+
+
+    /**
+     * Checks if String value is present. A null, empty, or blank values of string
+     * are considered not present.
+     *
+     * @param stringValue string value to check if it is present or not
+     *
+     * @return true if string value is not null, empty or blank
+     */
+    public static boolean isPresent(@Nullable final String stringValue) {
+        return !isEmpty(stringValue);
+    }
+
+
+    /**
+     * Provides common functionality to validate analytics objects.
+     * Throws {@link AnalyticsValidationException} exception if validation fails
+     *
+     * @param targetObject target object that needs to be validated
+     * @param validator validator that will be used to validate the target object
+     * @param <T> target object type that needs to be validated
+     * @param <R> Validation Response type
+     * @param <V> Validator Type
+     *
+     * @return target object if validation is successful
+     */
+    public static <T, R extends ValidationResponse, V extends AnalyticsValidator<T, R>> T validate(
+            @Nonnull final T targetObject,
+            @Nonnull final V validator) {
+
+        Assert.notNull(targetObject, "target object that needs to validated must not be null");
+        Assert.notNull(validator, "validator must not be null");
+
+        final String targetObjectClass = targetObject.getClass().getSimpleName();
+        final String validatorClass = validator.getClass().getSimpleName();
+
+        log.debug("Validating target object of type: {} with validator type: {} ", targetObjectClass, validatorClass);
+
+        final R validationResponse = validator.apply(targetObject);
+
+        // If setting validation fails throw an exception
+        if (validationResponse.hasErrors()) {
+            throw new AnalyticsValidationException(validationResponse.getAllErrorMessage(),
+                    new IllegalArgumentException(validationResponse.getAllErrorMessage()));
+        }
+
+        log.info("Validation Successful for target object type: {} with validator type: {}", targetObjectClass,
+                validatorClass);
+
+        return targetObject;
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/function/MrSubscriberURLFunction.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/util/function/MrSubscriberURLFunction.java
new file mode 100644 (file)
index 0000000..2f32d6d
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.util.function;
+
+
+import static org.onap.dcae.analytics.web.util.AnalyticsWebUtils.RANDOM_ID_SUPPLIER;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.onap.dcae.analytics.model.DmaapMrConstants;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPreferences;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.util.UriComponentsBuilder;
+
+/**
+ * Creates DMaaP MR Subscriber URLs from {@link MrSubscriberPreferences}
+ *
+ * @author Rajiv Singla
+ */
+public class MrSubscriberURLFunction implements Function<MrSubscriberPreferences, List<URL>> {
+
+    private static final Logger logger = LoggerFactory.getLogger(MrSubscriberURLFunction.class);
+    private static final String URL_PATH_SEPARATOR = "/";
+
+    @Override
+    public List<URL> apply(final MrSubscriberPreferences subscriberConfig) {
+
+        final List<URL> subscriberURLs = new LinkedList<>();
+
+        // if consumer ids is not present generate single random consumer id
+        final List<String> consumerIds = subscriberConfig.getConsumerIds() != null ?
+                subscriberConfig.getConsumerIds() : Stream.of(RANDOM_ID_SUPPLIER.get()).collect(Collectors.toList());
+
+        for (final String consumerId : consumerIds) {
+
+            // request url must be present
+            final String requestURL = subscriberConfig.getRequestURL();
+
+            // generate random consumer group if not present
+            final String consumerGroup = subscriberConfig.getConsumerGroup() != null ?
+                    subscriberConfig.getConsumerGroup() :
+                    DmaapMrConstants.SUBSCRIBER_RANDOM_CONSUMER_GROUP_PREFIX + RANDOM_ID_SUPPLIER.get();
+
+            // set default message limit if not present
+            final Integer messageLimit = subscriberConfig.getMessageLimit() != null ?
+                    subscriberConfig.getMessageLimit() : DmaapMrConstants.SUBSCRIBER_DEFAULT_MESSAGE_LIMIT;
+
+            // set default timeout if not present
+            final Integer timeout = subscriberConfig.getTimeout() != null ?
+                    subscriberConfig.getTimeout() : DmaapMrConstants.SUBSCRIBER_DEFAULT_TIMEOUT;
+
+            final UriComponentsBuilder componentsBuilder = UriComponentsBuilder
+                    .fromHttpUrl(requestURL)
+                    .path(URL_PATH_SEPARATOR + consumerGroup + URL_PATH_SEPARATOR + consumerId);
+
+            if (messageLimit != null && messageLimit >= 1) {
+                componentsBuilder
+                        .queryParam(DmaapMrConstants.SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME, messageLimit);
+            }
+
+            if (timeout != null && timeout >= 1) {
+                componentsBuilder
+                        .queryParam(DmaapMrConstants.SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME, timeout);
+            }
+
+            subscriberURLs.add(createURL(componentsBuilder));
+
+        }
+
+        return subscriberURLs;
+    }
+
+    private URL createURL(final UriComponentsBuilder uriComponentsBuilder) {
+        try {
+            final URL subscriberURL = uriComponentsBuilder.build().toUri().toURL();
+            logger.info("Created DMaaP MR Subscriber URL: {}", subscriberURL);
+            return subscriberURL;
+        } catch (MalformedURLException e) {
+            throw new IllegalStateException("Unable to build DMaaP MR Subscriber URL", e);
+        }
+    }
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/AnalyticsValidator.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/AnalyticsValidator.java
new file mode 100644 (file)
index 0000000..0eaa800
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.validation;
+
+import java.io.Serializable;
+import java.util.function.Function;
+
+import org.springframework.validation.Validator;
+
+/**
+ * Analytics Validator can be used to validate Analytics components
+ *
+ * @param <T> object class that needs too be validated
+ * @param <R> validation Response
+ *
+ * @author Rajiv Singla
+ */
+public interface AnalyticsValidator<T, R extends ValidationResponse> extends Function<T, R>, Validator, Serializable {
+
+}
+
+
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/GenericValidationResponse.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/GenericValidationResponse.java
new file mode 100644 (file)
index 0000000..d5da8f2
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.validation;
+
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * A generic implementation of Validation Response
+ *
+ * @author Rajiv Singla
+ */
+@ToString
+@EqualsAndHashCode
+public class GenericValidationResponse implements ValidationResponse {
+
+    private static final String DEFAULT_DELIMITER = ",";
+
+    private LinkedHashMap<String, String> errorMessageMap = new LinkedHashMap<>();
+
+    @Override
+    public boolean hasErrors() {
+        return !errorMessageMap.isEmpty();
+    }
+
+    @Override
+    public Set<String> getFieldNamesWithError() {
+        return errorMessageMap.keySet();
+    }
+
+    @Override
+    public Collection<String> getErrorMessages() {
+        return errorMessageMap.values();
+    }
+
+    @Override
+    public Map<String, String> getValidationResultsAsMap() {
+        return errorMessageMap;
+    }
+
+    @Override
+    public String getAllErrorMessage() {
+        return getAllErrorMessage(DEFAULT_DELIMITER);
+    }
+
+    @Override
+    public String getAllErrorMessage(String delimiter) {
+        return errorMessageMap.values()
+                .stream().collect(Collectors.joining(delimiter));
+    }
+
+    @Override
+    public void addErrorMessage(String fieldName, String filedErrorMessage) {
+        errorMessageMap.put(fieldName, filedErrorMessage);
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/ValidationResponse.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/validation/ValidationResponse.java
new file mode 100644 (file)
index 0000000..bf06263
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.validation;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Validation Response
+ *
+ * @author Rajiv Singla
+ */
+public interface ValidationResponse {
+
+    /**
+     * Returns true if validation resulted in one or more errors
+     *
+     * @return true if validation has errors
+     */
+    boolean hasErrors();
+
+    /**
+     * Returns all field names which have error
+     *
+     * @return names of fields which have error
+     */
+    Set<String> getFieldNamesWithError();
+
+    /**
+     * Returns list of all error messages
+     *
+     * @return list of error messages
+     */
+    Collection<String> getErrorMessages();
+
+
+    /**
+     * Returns all error messages as string delimited by comma
+     *
+     * @return all error messages delimited by given delimiter
+     */
+    String getAllErrorMessage();
+
+    /**
+     * Returns all error messages as string delimited by given delimited
+     *
+     * @param delimiter delimited to be used for error message
+     *
+     * @return all error messages delimited by given delimiter
+     */
+    String getAllErrorMessage(String delimiter);
+
+    /**
+     * Adds field name and error message to the validation response
+     *
+     * @param fieldName field name which has validation error
+     * @param filedErrorMessage validation error message
+     */
+    void addErrorMessage(String fieldName, String filedErrorMessage);
+
+
+    /**
+     * Returns validation results as map containing values as keys and values
+     * as error Message
+     *
+     * @return Map containing field names and error message associated with those fields
+     */
+    Map<String, String> getValidationResultsAsMap();
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/main/resources/META-INF/spring.factories b/dcae-analytics/dcae-analytics-web/src/main/resources/META-INF/spring.factories
new file mode 100644 (file)
index 0000000..23fe87e
--- /dev/null
@@ -0,0 +1,4 @@
+# Config Binding Service Environment Post processor
+org.springframework.boot.env.EnvironmentPostProcessor=\
+  org.onap.dcae.analytics.web.spring.ConfigBindingServiceEnvironmentPostProcessor,\
+  org.onap.dcae.analytics.web.spring.MongoAutoConfigurationPostProcessor
diff --git a/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/BaseAnalyticsWebSpringBootIT.java b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/BaseAnalyticsWebSpringBootIT.java
new file mode 100644 (file)
index 0000000..6184d34
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.test.BaseAnalyticsSpringBootIT;
+import org.onap.dcae.analytics.web.config.AnalyticsWebTestConfig;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+
+/**
+ * @author Rajiv Singla
+ */
+@ActiveProfiles({AnalyticsProfile.DEV_PROFILE_NAME})
+@ContextConfiguration(classes = {AnalyticsWebTestConfig.class})
+public abstract class BaseAnalyticsWebSpringBootIT extends BaseAnalyticsSpringBootIT {
+
+    public static final String TEST_SUBSCRIBER_TOPIC_URL = "http://localhost:8080/events/SubTopic";
+    public static final String TEST_SUBSCRIBER_AAF_USERNAME = "USER";
+    public static final String TEST_SUBSCRIBER_AAF_PASSWORD = "PASSWORD";
+
+    public static final String TEST_SUBSCRIBER_CONSUMER_GROUP = "cg1";
+    public static final List<String> TEST_SUBSCRIBER_CONSUMER_IDS = Arrays.asList("c0", "c1");
+
+
+    public static final String TEST_PUBLISHER_TOPIC_URL = "http://localhost:8080/events/PubTopic";
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/BaseAnalyticsWebTest.java b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/BaseAnalyticsWebTest.java
new file mode 100644 (file)
index 0000000..4258973
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web;
+
+import org.onap.dcae.analytics.test.BaseAnalyticsUnitTest;
+
+/**
+ * @author Rajiv Singla
+ */
+public abstract class BaseAnalyticsWebTest extends BaseAnalyticsUnitTest {
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/DmaapMrFlowsIT.java b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/DmaapMrFlowsIT.java
new file mode 100644 (file)
index 0000000..b9c3d8e
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web;
+
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.channel.QueueChannel;
+import org.springframework.test.context.ActiveProfiles;
+
+/**
+ * @author Rajiv Singla
+ */
+@ActiveProfiles(value = {AnalyticsProfile.DMAAP_PROFILE_NAME})
+@Disabled
+class DmaapMrFlowsIT extends BaseAnalyticsWebSpringBootIT {
+
+    @Autowired
+    private QueueChannel mrSubscriberOutputChannel;
+    @Autowired
+    private DirectChannel mrPublisherInputChannel;
+
+    @Test
+    void mrPubSubFlows() {
+
+        try {
+            Thread.sleep(300_000);
+        } catch (InterruptedException e) {
+            logger.error("", e);
+        }
+    }
+
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/config/AnalyticsWebTestConfig.java b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/config/AnalyticsWebTestConfig.java
new file mode 100644 (file)
index 0000000..b80be2c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@EnableAutoConfiguration
+@Import(value = {AnalyticsWebConfig.class, DmaapMrTestConfig.class})
+public class AnalyticsWebTestConfig {
+
+    @Bean
+    public ObjectMapper objectMapper() {
+        return AnalyticsModelJsonConversion.ANALYTICS_MODEL_OBJECT_MAPPER;
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/config/DmaapMrTestConfig.java b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/config/DmaapMrTestConfig.java
new file mode 100644 (file)
index 0000000..9e884ea
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.config;
+
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.web.BaseAnalyticsWebSpringBootIT;
+import org.onap.dcae.analytics.web.dmaap.MrPublisherPreferences;
+import org.onap.dcae.analytics.web.dmaap.MrSubscriberPreferences;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.integration.channel.DirectChannel;
+import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.dsl.IntegrationFlow;
+import org.springframework.integration.dsl.IntegrationFlows;
+import org.springframework.integration.handler.LoggingHandler;
+
+/**
+ * @author Rajiv Singla
+ */
+@Configuration
+@Profile({AnalyticsProfile.DMAAP_PROFILE_NAME})
+public class DmaapMrTestConfig {
+
+    @Bean
+    public MrSubscriberPreferences mrSubscriberPreferences() {
+        return new MrSubscriberPreferences(BaseAnalyticsWebSpringBootIT.TEST_SUBSCRIBER_TOPIC_URL, null,
+                null, BaseAnalyticsWebSpringBootIT.TEST_SUBSCRIBER_AAF_USERNAME,
+                BaseAnalyticsWebSpringBootIT.TEST_SUBSCRIBER_AAF_PASSWORD,
+                null, null, null,
+                BaseAnalyticsWebSpringBootIT.TEST_SUBSCRIBER_CONSUMER_GROUP,
+                BaseAnalyticsWebSpringBootIT.TEST_SUBSCRIBER_CONSUMER_IDS,
+                null, null, null);
+    }
+
+    @Bean
+    public MrPublisherPreferences mrPublisherPreferences() {
+        return new MrPublisherPreferences(BaseAnalyticsWebSpringBootIT.TEST_PUBLISHER_TOPIC_URL);
+    }
+
+    @Bean
+    public Integer processingBatchSize() {
+        return 1;
+    }
+
+
+    @Bean
+    public IntegrationFlow noOperationMrFlow(final QueueChannel mrSubscriberOutputChannel,
+                                             final DirectChannel mrPublisherInputChannel) {
+        return IntegrationFlows.from(mrSubscriberOutputChannel)
+                .log(LoggingHandler.Level.INFO)
+                .channel(mrPublisherInputChannel)
+                .get();
+    }
+
+}
diff --git a/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessorIT.java b/dcae-analytics/dcae-analytics-web/src/test/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessorIT.java
new file mode 100644 (file)
index 0000000..d459212
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.analytics.web.spring;
+
+import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
+        .CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY;
+import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
+        .CONFIG_BINDING_SERVICE_PROPERTIES_KEY;
+import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
+        .CONSUL_HOST_ENV_VARIABLE_KEY;
+import static org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants
+        .SERVICE_NAME_ENV_VARIABLE_KEY;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.onap.dcae.analytics.model.AnalyticsProfile;
+import org.onap.dcae.analytics.web.BaseAnalyticsWebSpringBootIT;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.AbstractEnvironment;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.PropertySource;
+import org.springframework.test.context.ActiveProfiles;
+
+/**
+ * @author Rajiv Singla
+ */
+@ActiveProfiles(value = {AnalyticsProfile.CONFIG_BINDING_SERVICE_PROFILE_NAME}, inheritProfiles = false)
+@Disabled
+class ConfigBindingServiceEnvironmentPostProcessorIT extends BaseAnalyticsWebSpringBootIT {
+
+    @BeforeAll
+    static void beforeAll() throws Exception {
+        // sets up environment variables for testing purposes
+        final HashMap<String, String> testEnvironmentVariables = new HashMap<>();
+        final String testConsulHostValue = "localhost";
+        final String testConfigBindingService = "config_binding_service";
+        final String testServiceName = "tca_dev";
+        testEnvironmentVariables.put(CONSUL_HOST_ENV_VARIABLE_KEY, testConsulHostValue);
+        testEnvironmentVariables.put(CONFIG_BINDING_SERVICE_ENV_VARIABLE_KEY, testConfigBindingService);
+        testEnvironmentVariables.put(SERVICE_NAME_ENV_VARIABLE_KEY, testServiceName);
+        setEnvironmentVariables(testEnvironmentVariables);
+    }
+
+    @Autowired
+    private Environment environment;
+
+    @Test
+    void postProcessEnvironment() {
+
+        final Map<String, Object> properties = new HashMap<>();
+        for (final PropertySource<?> propertySource : ((AbstractEnvironment) environment).getPropertySources()) {
+            if (propertySource.getName().equals(CONFIG_BINDING_SERVICE_PROPERTIES_KEY)) {
+                properties.putAll(((MapPropertySource) propertySource).getSource());
+            }
+        }
+        properties.forEach((key, value) -> logger.debug("{} -> {}", key, value));
+
+    }
+
+}
diff --git a/dcae-analytics/dpo/tca/commands b/dcae-analytics/dpo/tca/commands
new file mode 100644 (file)
index 0000000..168681b
--- /dev/null
@@ -0,0 +1,19 @@
+unset http_proxy; unset https_proxy
+
+dcae_cli data_format add --update tca_output.json
+dcae_cli component add --update tca_spec.json
+dcae_cli component run --dmaap-file dmaap.json --force docker.tca
+
+# publish
+dcae_cli data_format publish "TCA Alert Definition"
+dcae_cli component publish docker.tca
+
+# to un-deploy
+dcae_cli component undeploy docker.tca
+
+# to inspect
+dcae_cli component show docker.tca
+dcae_cli component list
+dcae_cli component list --deployed
+
+dcae_cli catalog list --expanded
diff --git a/dcae-analytics/dpo/tca/dmaap.json b/dcae-analytics/dpo/tca/dmaap.json
new file mode 100644 (file)
index 0000000..6ee67d2
--- /dev/null
@@ -0,0 +1,24 @@
+{
+  "tca_handle_in": {
+    "aaf_username": "USER",
+    "aaf_password": "PASSWORD",
+    "type": "message_router",
+    "dmaap_info": {
+      "client_role": "ves-subscriber",
+      "client_id": "ves-sub-1",
+      "location": "ecomp",
+      "topic_url": "https://HOSTNAME:3905/events/org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub"
+    }
+  },
+  "tca_handle_out": {
+    "aaf_username": "USER",
+    "aaf_password": "PASSWORD",
+    "type": "message_router",
+    "dmaap_info": {
+      "client_role": "policy-publisher",
+      "client_id": "policy-pub-1",
+      "location": "ecomp",
+      "topic_url": "https://HOSTNAME:3905/events/org.onap.dcae.dmaap.mtnje2.DcaeTestVESPub"
+    }
+  }
+}
diff --git a/dcae-analytics/dpo/tca/tca_output.json b/dcae-analytics/dpo/tca/tca_output.json
new file mode 100644 (file)
index 0000000..f593fda
--- /dev/null
@@ -0,0 +1,109 @@
+{
+  "self": {
+    "name": "TCA Alert Definition",
+    "version": "1.0.1",
+    "description": "The format of the output event from TCA"
+  },
+  "dataformatversion": "1.0.0",
+  "jsonschema": {
+    "name": "TCA Alert",
+    "version": "1.0.0",
+    "properties": {
+      "version": {
+        "type": "string",
+        "enum": [
+          "1.0.2"
+        ]
+      },
+      "closedLoopControlName": {
+        "type": "string",
+        "description": "This is the unique ID for the Control Loop. It is created by the CLAMP platform during Control Loop design"
+      },
+      "requestID": {
+        "type": "string",
+        "description": "For the control loop, when an instance of the Control Loop occurs, this unique ID must be created. The same ID must be forwarded for both the ONSET and the ABATED control loop messages"
+      },
+      "closedLoopEventStatus": {
+        "type": "string",
+        "description": "This is the status of the closedLoopControlName/requestID pair",
+        "enum": [
+          "ONSET",
+          "ABATED"
+        ]
+      },
+      "closedLoopAlarmStart": {
+        "type": "string",
+        "description": "When the alarm was first detected"
+      },
+      "closedLoopAlarmEnd": {
+        "type": "string",
+        "description": "When the alarm was cleared. This field need only be present in the ABATED message"
+      },
+      "closedLoopEventClient": {
+        "type": "string",
+        "description": "For monitoring/logging/auditing purposes, if there is an instance ID of the DCAE micro service this field should be populated with it"
+      },
+      "policyVersion": {
+        "type": "string",
+        "description": "The version of the Policy driving the DCAE Micro service. Should be a part of the configuration policy setup by CLAMP and passed by DCAE controller"
+      },
+      "policyName": {
+        "type": "string",
+        "description": "The name of the Policy driving the DCAE micro service. Should be a part of the configuration policy setup by CLAMP and passed by DCAE controller"
+      },
+      "policyScope": {
+        "type": "string",
+        "description": "The scope of the Policy driving the DCAE micro service. Should be a part of the configuration policy setup by CLAMP and passed by DCAE controller"
+      },
+      "from": {
+        "type": "string",
+        "description": "The ONAP platform component publishing this message",
+        "enum": [
+          "DCAE"
+        ]
+      },
+      "target_type": {
+        "type": "string",
+        "description": "The type of the target: VM or VNF",
+        "enum": [
+          "VNF",
+          "VM"
+        ]
+      },
+      "target": {
+        "type": "string",
+        "description": "This is the name of the field within the A&AI sub-tag that indicates the actual entity Node details. There should be a matching node field within the A&AI subtag holding this value",
+        "enum": [
+          "generic-vnf.vnf-id",
+          "vserver.vserver-name"
+        ]
+      },
+      "AAI": {
+        "description": "Contains the A&AI Node-Attribute list",
+        "anyOf": [
+          {
+            "generic-vnf.vnf-id": {
+              "type": "string"
+            }
+          },
+          {
+            "vserver.vserver-name": {
+              "type": "string"
+            }
+          }
+        ]
+      }
+    },
+    "required": [
+      "version",
+      "closedLoopControlName",
+      "requestID",
+      "closedLoopEventStatus",
+      "closedLoopAlarmStart",
+      "from",
+      "target_type",
+      "target",
+      "AAI"
+    ]
+  }
+}
diff --git a/dcae-analytics/dpo/tca/tca_spec.json b/dcae-analytics/dpo/tca/tca_spec.json
new file mode 100644 (file)
index 0000000..4d99201
--- /dev/null
@@ -0,0 +1,269 @@
+{
+  "self": {
+    "name": "docker.tca",
+    "version": "1.0.5",
+    "description": "TCA Docker Application",
+    "component_type": "docker"
+  },
+  "streams": {
+    "subscribes": [
+      {
+        "config_key": "tca_handle_in",
+        "format": "VES_specification",
+        "version": "5.28.4",
+        "type": "message router"
+      }
+    ],
+    "publishes": [
+      {
+        "config_key": "tca_handle_out",
+        "format": "TCA Alert Definition",
+        "version": "1.0.0",
+        "type": "message router"
+      }
+    ]
+  },
+  "services": {
+    "calls": [
+      {
+        "config_key": "aai_broker_handle",
+        "verb": "GET",
+        "request": {
+          "format": "get_with_query_params",
+          "version": "1.0.0"
+        },
+        "response": {
+          "format": "aai_broker_response",
+          "version": "3.0.0"
+        }
+      }
+    ],
+    "provides": []
+  },
+  "auxilary": {
+    "healthcheck": {
+      "type": "http",
+      "interval": "30s",
+      "timeout": "10s",
+      "endpoint": "actuator/health"
+    }
+  },
+  "artifacts": [
+    {
+      "uri": "docker_repository.com:5100/org.onap.dcae.analytics/dcae-analytics-web:1.0",
+      "type": "docker image"
+    }
+  ],
+  "parameters": [
+    {
+      "name": "spring.mongodb.uri",
+      "value": "mongodb://localhost:27017/analytics-tca",
+      "description": "Mongodb database uri",
+      "designer_editable": true,
+      "sourced_at_deployment": true,
+      "policy_editable": false,
+      "type": "string",
+      "required": true
+    },
+    {
+      "name": "tca.policy",
+      "value": "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}",
+      "description": "Threshold Crossing Alert Policy JSON as string",
+      "designer_editable": false,
+      "sourced_at_deployment": false,
+      "policy_editable": true,
+      "type": "string",
+      "required": true
+    },
+    {
+      "name": "tca.processing_batch_size",
+      "value": 10000,
+      "description": "Batch size for TCA Application Transaction",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": false
+    },
+    {
+      "name": "tca.enable_abatement",
+      "value": true,
+      "description": "Enables / Disables TCA Alerts Abatement",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "boolean",
+      "required": false
+    },
+    {
+      "name": "tca.enable_ecomp_logging",
+      "value": true,
+      "description": "Enables / Disables ECOMP Logging",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "boolean",
+      "required": false
+    },
+    {
+      "name": "tca.aai.enable_enrichment",
+      "value": false,
+      "description": "Enables / Disables TCA A&AI Enrichment",
+      "designer_editable": true,
+      "sourced_at_deployment": true,
+      "policy_editable": false,
+      "type": "boolean",
+      "required": false
+    },
+    {
+      "name": "tca.aai.url",
+      "value": "http://localhost:8443",
+      "description": "A&AI Enrichment Service URL. Required only if A&AI Enrichment is enabled",
+      "designer_editable": true,
+      "sourced_at_deployment": true,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "tca.aai.username",
+      "value": "DCAE",
+      "description": "A&AI Enrichment Service basic authentication user name",
+      "designer_editable": true,
+      "sourced_at_deployment": true,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "tca.aai.password",
+      "value": "DCAE",
+      "description": "A&AI Enrichment Service basic authentication user password",
+      "designer_editable": true,
+      "sourced_at_deployment": true,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "tca.aai.generic_vnf_path",
+      "value": "aai/v11/network/generic-vnfs/generic-vnf",
+      "description": "A&AI Enrichment Service VNF query endpoint path",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "tca.aai.node_query_path",
+      "value": "aai/v11/search/nodes-query",
+      "description": "A&AI Enrichment Service Node query endpoint path",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.consumer_group",
+      "value": "cg1",
+      "description": "Subscriber consumer group",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.consumer_ids[0]",
+      "value": "c0",
+      "description": "Subscriber first consumer id",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.consumer_ids[1]",
+      "value": "c1",
+      "description": "Subscriber second consumer id",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "string",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.message_limit",
+      "value": 50000,
+      "description": "Maximum message fetched by TCA Subscriber",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": true
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.timeout",
+      "value": -1,
+      "description": "Timeout for TCA Subscriber",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.polling.fixedRate",
+      "value": 0,
+      "description": "Subscriber fixed polling interval in milliseconds. Value of 0 indicated auto adjusting polling will be used",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.polling.auto_adjusting.min",
+      "value": 30000,
+      "description": "Subscriber Auto Adjusting polling minimum interval in milliseconds",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.polling.auto_adjusting.step_up",
+      "value": 10000,
+      "description": "Subscriber Auto Adjusting polling step up delta in milliseconds when message is not found",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.polling.auto_adjusting.max",
+      "value": 60000,
+      "description": "Subscriber Auto Adjusting polling maximum interval in milliseconds",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": false
+    },
+    {
+      "name": "streams_subscribes.tca_handle_in.polling.auto_adjusting.step_down",
+      "value": 30000,
+      "description": "Subscriber Auto Adjusting polling step down delta in milliseconds when message is found",
+      "designer_editable": true,
+      "sourced_at_deployment": false,
+      "policy_editable": false,
+      "type": "number",
+      "required": false
+    }
+  ]
+}
diff --git a/dcae-analytics/findbugs-exclude.xml b/dcae-analytics/findbugs-exclude.xml
new file mode 100644 (file)
index 0000000..c35a021
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<FindBugsFilter>
+
+    <Class name="org.onap.dcae.analytics.web.dmaap.MrSubscriberPreferences"/>
+    <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
+
+    <Class name="org.onap.dcae.analytics.tca.web.abatement.mongo.MongoAbatementEntity"/>
+    <Bug pattern="MF_CLASS_MASKS_FIELD"/>
+
+    <Class name="org.onap.dcae.analytics.tca.web.abatement.simple.SimpleAbatementEntity"/>
+    <Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
+
+</FindBugsFilter>
diff --git a/dcae-analytics/pmd-exclude.properties b/dcae-analytics/pmd-exclude.properties
new file mode 100644 (file)
index 0000000..88e72e8
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
diff --git a/dcae-analytics/pom.xml b/dcae-analytics/pom.xml
new file mode 100644 (file)
index 0000000..4f3e705
--- /dev/null
@@ -0,0 +1,757 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+       
+       <parent>
+               <groupId>org.onap.dcaegen2</groupId>
+               <artifactId>tca-gen2</artifactId>
+               <version>3.0.0-SNAPSHOT</version>
+       </parent>
+
+    <groupId>org.onap.dcaegen2.analytics</groupId>
+    <artifactId>dcae-analytics</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <name>DCAE Analytics Parent</name>
+    <description>Parent project for all DCAE Analytics Applications</description>
+
+
+    <modules>
+        <module>dcae-analytics-test</module>
+        <module>dcae-analytics-model</module>
+        <module>dcae-analytics-tca-model</module>
+        <module>dcae-analytics-tca-core</module>
+        <module>dcae-analytics-web</module>
+        <module>dcae-analytics-tca-web</module>
+    </modules>
+
+    <properties>
+
+        <!-- PROJECT SETTINGS-->
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <main.basedir>${project.basedir}</main.basedir>
+
+        <!-- DEPENDENCIES VERSION -->
+        <eelf.logger.version>3.0.0-SNAPSHOT</eelf.logger.version>
+        <spring.boot.version>2.0.1.RELEASE</spring.boot.version>
+        <spring.cloud.version>Finchley.RC2</spring.cloud.version>
+        <commons.text.version>1.4</commons.text.version>
+        <springfox-swagger2.version>2.9.2</springfox-swagger2.version>
+        <findbugs.jsr305.version>3.0.2</findbugs.jsr305.version>
+        <findbugs.annotations.version>3.0.1</findbugs.annotations.version>
+
+        <!-- TEST DEPENDENCIES -->
+        <junit-jupiter.version>5.0.2</junit-jupiter.version>
+        <junit-platform.version>1.0.2</junit-platform.version>
+        <apiguardian-api.version>1.0.0</apiguardian-api.version>
+
+        <!--TEST SETTINGS -->
+        <surefire.redirectTestOutputToFile>true</surefire.redirectTestOutputToFile>
+        <!-- PLUGINS VERSIONS -->
+        <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+        <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
+        <maven-assembly-plugin.version>3.1.0</maven-assembly-plugin.version>
+        <maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
+        <maven-surefire-plugin.version>2.19</maven-surefire-plugin.version>
+        <maven-failsafe-plugin.version>2.19.1</maven-failsafe-plugin.version>
+        <maven-source-plugin.version>3.0.1</maven-source-plugin.version>
+        <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
+        <jacoco.plugin.version>0.8.1</jacoco.plugin.version>
+        <findbugs.plugin.version>3.0.5</findbugs.plugin.version>
+        <pmd.plugin.version>3.8</pmd.plugin.version>
+        <checkstyle.plugin.version>2.17</checkstyle.plugin.version>
+        <lombok.plugin.version>1.16.18.1</lombok.plugin.version>
+        <gitcommitid.plugin.version>2.2.3</gitcommitid.plugin.version>
+        <maven.build.helper.plugin.version>3.0.0</maven.build.helper.plugin.version>
+        <dockerfile-maven-version>1.4.3</dockerfile-maven-version>
+
+        <!--PLUGIN SETTINGS -->
+        <compiler.source.version>1.8</compiler.source.version>
+        <compiler.target.version>1.8</compiler.target.version>
+        <unit.test.pattern>**/*Test.java</unit.test.pattern>
+        <skip.unit.tests>false</skip.unit.tests>
+        <integration.test.pattern>**/*IT.java</integration.test.pattern>
+        <skip.integration.tests>false</skip.integration.tests>
+        <pmd.violation.buildfail>true</pmd.violation.buildfail>
+        <findbugs.failOnError>true</findbugs.failOnError>
+        <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+        <checkstyle.file.name>checkstyle.xml</checkstyle.file.name>
+        <checkstyle.suppression.file.name>checkstyle-suppressions.xml</checkstyle.suppression.file.name>
+
+
+        <dependency.locations.enabled>false</dependency.locations.enabled>
+        <nexusproxy>https://nexus.onap.org</nexusproxy>
+        <snapshots.path>content/repositories/snapshots/</snapshots.path>
+        <releases.path>content/repositories/releases/</releases.path>
+        <docker.repository>nexus3.onap.org:10003</docker.repository>
+
+    </properties>
+
+  
+
+    <dependencyManagement>
+
+        <dependencies>
+
+            <!-- PROJECT DEPENDENCIES -->
+            <dependency>
+                <groupId>org.onap.dcaegen2.analytics</groupId>
+                <artifactId>dcae-analytics-test</artifactId>
+                <version>${project.version}</version>
+                <scope>test</scope>
+            </dependency>
+
+            <dependency>
+                <groupId>org.onap.dcaegen2.analytics</groupId>
+                <artifactId>dcae-analytics-model</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.onap.dcaegen2.analytics</groupId>
+                <artifactId>dcae-analytics-web</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.onap.dcaegen2.analytics</groupId>
+                <artifactId>dcae-analytics-tca-model</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.onap.dcaegen2.analytics</groupId>
+                <artifactId>dcae-analytics-tca-core</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+
+
+            <!-- EELF LOGGER -->
+            <dependency>
+                <groupId>org.onap.dcaegen2.utils</groupId>
+                <artifactId>eelf-logger-logback-impl</artifactId>
+                <version>${eelf.logger.version}</version>
+            </dependency>
+
+            <!-- UTILITIES -->
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-text</artifactId>
+                <version>${commons.text.version}</version>
+            </dependency>
+
+            <!-- REST API SWAGGER -->
+            <dependency>
+                <groupId>io.springfox</groupId>
+                <artifactId>springfox-swagger2</artifactId>
+                <version>${springfox-swagger2.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.springfox</groupId>
+                <artifactId>springfox-swagger-ui</artifactId>
+                <version>${springfox-swagger2.version}</version>
+            </dependency>
+
+            <!-- FIND BUGS -->
+            <dependency>
+                <groupId>com.google.code.findbugs</groupId>
+                <artifactId>jsr305</artifactId>
+                <version>${findbugs.jsr305.version}</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>com.google.code.findbugs</groupId>
+                <artifactId>annotations</artifactId>
+                <version>${findbugs.annotations.version}</version>
+                <scope>provided</scope>
+            </dependency>
+
+            <!-- JUNIT 5 DEPENDENCIES -->
+            <dependency>
+                <groupId>org.junit.jupiter</groupId>
+                <artifactId>junit-jupiter-api</artifactId>
+                <version>${junit-jupiter.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.junit.jupiter</groupId>
+                <artifactId>junit-jupiter-engine</artifactId>
+                <version>${junit-jupiter.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.junit.jupiter</groupId>
+                <artifactId>junit-jupiter-params</artifactId>
+                <version>${junit-jupiter.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.junit.platform</groupId>
+                <artifactId>junit-platform-engine</artifactId>
+                <version>${junit-platform.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.junit.platform</groupId>
+                <artifactId>junit-platform-launcher</artifactId>
+                <version>${junit-platform.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apiguardian</groupId>
+                <artifactId>apiguardian-api</artifactId>
+                <version>${apiguardian-api.version}</version>
+                <scope>test</scope>
+            </dependency>
+
+            <!-- IMPORT DEPENDENCY MANAGEMENT FROM SPRING BOOT -->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring.boot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <!-- IMPORT DEPENDENCY MANAGEMENT FROM SPRING CLOUD -->
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>${spring.cloud.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+
+        <pluginManagement>
+
+            <plugins>
+
+                <!-- COMPILER PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>${maven-compiler-plugin.version}</version>
+                    <configuration>
+                        <fork>true</fork>
+                        <debug>true</debug>
+                        <meminitial>256m</meminitial>
+                        <maxmem>1024m</maxmem>
+                        <source>${compiler.target.version}</source>
+                        <target>${compiler.source.version}</target>
+                        <showWarnings>true</showWarnings>
+                        <showDeprecation>true</showDeprecation>
+                    </configuration>
+                </plugin>
+
+                <!-- MAVEN SOURCE PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <version>${maven-source-plugin.version}</version>
+                    <configuration>
+                        <excludeResources>true</excludeResources>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>attach-sources</id>
+                            <phase>verify</phase>
+                            <goals>
+                                <goal>jar-no-fork</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- MAVEN JAVADOC PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-javadoc-plugin</artifactId>
+                    <version>${maven-javadoc-plugin.version}</version>
+                    <configuration>
+                        <!-- minimize console output messages -->
+                        <quiet>true</quiet>
+                        <verbose>false</verbose>
+                        <useStandardDocletOptions>false</useStandardDocletOptions>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>aggregate</id>
+                            <phase>site</phase>
+                            <goals>
+                                <goal>aggregate</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>attach-javadoc</id>
+                            <goals>
+                                <goal>jar</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- MAVEN DEPLOY PLUGIN -->
+                <plugin>
+                    <artifactId>maven-deploy-plugin</artifactId>
+                    <version>${maven-deploy-plugin.version}</version>
+                    <configuration>
+                        <deployAtEnd>true</deployAtEnd>
+                    </configuration>
+                </plugin>
+
+                <!-- SUREFIRE TEST PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>${maven-surefire-plugin.version}</version>
+                    <configuration>
+                        <skipTests>${skip.unit.tests}</skipTests>
+                        <argLine>-Xmx2048m -Djava.awt.headless=true -XX:+UseConcMarkSweepGC
+                            -XX:OnOutOfMemoryError="kill -9 %p" -XX:+HeapDumpOnOutOfMemoryError ${surefireArgLine}
+                        </argLine>
+                        <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}</redirectTestOutputToFile>
+                        <parallel>classesAndMethods</parallel>
+                        <threadCount>4</threadCount>
+                        <forkCount>4</forkCount>
+                        <reuseForks>false</reuseForks>
+                        <reportFormat>xml</reportFormat>
+                        <trimStackTrace>false</trimStackTrace>
+                        <systemPropertyVariables>
+                            <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+                            <logback.configurationFile>
+                                ${basedir}/src/test/resources/logback-test.xml
+                            </logback.configurationFile>
+                            <logging.config>classpath:logback-test.xml</logging.config>
+                        </systemPropertyVariables>
+                        <includes>
+                            <include>${unit.test.pattern}</include>
+                        </includes>
+                        <excludes>
+                            <exclude>${integration.test.pattern}</exclude>
+                        </excludes>
+                    </configuration>
+                    <dependencies>
+                        <dependency>
+                            <groupId>org.junit.platform</groupId>
+                            <artifactId>junit-platform-surefire-provider</artifactId>
+                            <version>${junit-platform.version}</version>
+                        </dependency>
+                    </dependencies>
+                </plugin>
+
+                <!-- FAIL SAFE PLUGIN FOR INTEGRATION TEST -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-failsafe-plugin</artifactId>
+                    <version>${maven-failsafe-plugin.version}</version>
+                    <dependencies>
+                        <dependency>
+                            <groupId>org.junit.platform</groupId>
+                            <artifactId>junit-platform-surefire-provider</artifactId>
+                            <version>${junit-platform.version}</version>
+                        </dependency>
+                    </dependencies>
+                    <executions>
+                        <execution>
+                            <id>integration-tests</id>
+                            <goals>
+                                <goal>integration-test</goal>
+                                <goal>verify</goal>
+                            </goals>
+                            <configuration>
+                                <argLine>${failsafeArgLine}</argLine>
+                                <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                                <skipTests>${skip.integration.tests}</skipTests>
+                                <includes>
+                                    <include>${integration.test.pattern}</include>
+                                </includes>
+                                <excludes>
+                                    <exclude>${unit.test.pattern}</exclude>
+                                </excludes>
+                                <systemPropertyVariables>
+                                    <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+                                    <logging.config>classpath:logback-test.xml</logging.config>
+                                </systemPropertyVariables>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+
+
+                <plugin>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <version>${jacoco.plugin.version}</version>
+                    <configuration>
+                        <excludes>
+                            <exclude>**/generated/**</exclude>
+                            <exclude>**/generated-sources/**</exclude>
+                        </excludes>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>pre-unit-test</id>
+                            <goals>
+                                <goal>prepare-agent</goal>
+                            </goals>
+                            <configuration>
+                                <!-- Sets the path to the file which contains the execution data. -->
+                                <destFile>${project.build.directory}/jacoco/jacoco-ut.exec</destFile>
+                                <propertyName>surefireArgLine</propertyName>
+                            </configuration>
+                        </execution>
+                        <execution>
+                            <id>post-unit-test</id>
+                            <phase>test</phase>
+                            <goals>
+                                <goal>report</goal>
+                            </goals>
+                            <configuration>
+                                <!-- Sets the path to the file which contains the execution data. -->
+                                <dataFile>${project.build.directory}/jacoco/jacoco-ut.exec</dataFile>
+                                <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+                            </configuration>
+                        </execution>
+                        <execution>
+                            <id>pre-integration-test</id>
+                            <phase>pre-integration-test</phase>
+                            <goals>
+                                <goal>prepare-agent</goal>
+                            </goals>
+                            <configuration>
+                                <!-- Sets the path to the file which contains the execution data. -->
+                                <destFile>${project.build.directory}/jacoco/jacoco-it.exec</destFile>
+                                <propertyName>failsafeArgLine</propertyName>
+                            </configuration>
+                        </execution>
+                        <execution>
+                            <id>post-integration-test</id>
+                            <phase>post-integration-test</phase>
+                            <goals>
+                                <goal>report</goal>
+                            </goals>
+                            <configuration>
+                                <!-- Sets the path to the file which contains the execution data. -->
+                                <dataFile>${project.build.directory}/jacoco/jacoco-it.exec</dataFile>
+                                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
+                            </configuration>
+                        </execution>
+                    </executions>
+
+                </plugin>
+
+                <!-- FIND BUGS (STATIC CODE ANALYSIS) PLUGIN -->
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>findbugs-maven-plugin</artifactId>
+                    <version>${findbugs.plugin.version}</version>
+                    <configuration>
+                        <effort>Max</effort>
+                        <threshold>Low</threshold>
+                        <xmlOutput>true</xmlOutput>
+                        <!-- BUILD FAIL ON FINDBUGS ERRORS -->
+                        <failOnError>${findbugs.failOnError}</failOnError>
+                        <excludeFilterFile>${main.basedir}/findbugs-exclude.xml</excludeFilterFile>
+                        <outputDirectory>${project.reporting.outputDirectory}/findbugs</outputDirectory>
+                        <findbugsXmlOutputDirectory>${project.reporting.outputDirectory}/findbugs
+                        </findbugsXmlOutputDirectory>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>analyze-compile</id>
+                            <phase>compile</phase>
+                            <goals>
+                                <goal>check</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- PMD PLUGIN SETUP -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-pmd-plugin</artifactId>
+                    <version>${pmd.plugin.version}</version>
+                    <configuration>
+                        <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
+                        <targetJdk>${compiler.target.version}</targetJdk>
+                        <linkXRef>false</linkXRef>
+                        <excludes>
+                            <exclude>**/*Mixin.java</exclude>
+                        </excludes>
+                        <!-- BUILD FAIL ON PMD VIOLATION -->
+                        <failOnViolation>${pmd.violation.buildfail}</failOnViolation>
+                        <targetDirectory>${project.reporting.outputDirectory}/pmd</targetDirectory>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>pmd-check</id>
+                            <goals>
+                                <goal>check</goal>
+                            </goals>
+                            <configuration>
+                                <printFailingErrors>true</printFailingErrors>
+                                <excludeFromFailureFile>${main.basedir}/pmd-exclude.properties</excludeFromFailureFile>
+                            </configuration>
+                        </execution>
+                        <execution>
+                            <id>cpd-check</id>
+                            <goals>
+                                <goal>cpd-check</goal>
+                            </goals>
+                            <configuration>
+                                <printFailingErrors>true</printFailingErrors>
+                                <excludeFromFailureFile>${main.basedir}/cpd-exclude.properties</excludeFromFailureFile>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- CHECKSTYLE PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-checkstyle-plugin</artifactId>
+                    <version>${checkstyle.plugin.version}</version>
+                    <executions>
+                        <execution>
+                            <id>validate</id>
+                            <phase>validate</phase>
+                            <configuration>
+                                <configLocation>${checkstyle.file.name}</configLocation>
+                                <suppressionsLocation>${checkstyle.suppression.file.name}</suppressionsLocation>
+                                <encoding>UTF-8</encoding>
+                                <consoleOutput>true</consoleOutput>
+                                <!-- BUILD FAIL ON CHECKSTYLE VIOLATION -->
+                                <failOnViolation>${checkstyle.failOnViolation}</failOnViolation>
+                                <includeTestSourceDirectory>true</includeTestSourceDirectory>
+                                <outputFile>${project.reporting.outputDirectory}/checkstyle</outputFile>
+                            </configuration>
+                            <goals>
+                                <goal>check</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                    <dependencies>
+                        <dependency>
+                            <groupId>com.puppycrawl.tools</groupId>
+                            <artifactId>checkstyle</artifactId>
+                            <version>6.19</version>
+                        </dependency>
+                    </dependencies>
+                </plugin>
+
+                <!-- LOMBOK PLUGIN -->
+                <plugin>
+                    <groupId>org.projectlombok</groupId>
+                    <artifactId>lombok-maven-plugin</artifactId>
+                    <version>${lombok.plugin.version}</version>
+                    <executions>
+                        <execution>
+                            <id>delombok</id>
+                            <phase>generate-sources</phase>
+                            <goals>
+                                <goal>delombok</goal>
+                            </goals>
+                            <configuration>
+                                <addOutputDirectory>false</addOutputDirectory>
+                                <sourceDirectory>src/main/java</sourceDirectory>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- GIT COMMIT ID PLUGIN -->
+                <plugin>
+                    <groupId>pl.project13.maven</groupId>
+                    <artifactId>git-commit-id-plugin</artifactId>
+                    <version>${gitcommitid.plugin.version}</version>
+                    <executions>
+                        <execution>
+                            <id>generate-git-properties</id>
+                            <phase>generate-resources</phase>
+                            <goals>
+                                <goal>revision</goal>
+                            </goals>
+                            <configuration>
+                                <failOnNoGitDirectory>false</failOnNoGitDirectory>
+                                <generateGitPropertiesFile>true</generateGitPropertiesFile>
+                                <generateGitPropertiesFilename>
+                                    ${project.build.directory}/git/git.properties
+                                </generateGitPropertiesFilename>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- JAR PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>${maven-jar-plugin.version}</version>
+                    <configuration>
+                        <archive>
+                            <manifest>
+                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+                            </manifest>
+                            <manifestEntries>
+                                <Implementation-Build-Version>${project.version}</Implementation-Build-Version>
+                            </manifestEntries>
+                        </archive>
+                    </configuration>
+                </plugin>
+
+
+                <!-- ASSEMBLY PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-assembly-plugin</artifactId>
+                    <version>${maven-assembly-plugin.version}</version>
+                    <configuration>
+                        <descriptors>
+                            <descriptor>${main.basedir}/assembly/cdp-assembly-descriptor.xml</descriptor>
+                        </descriptors>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>cdp-assembly</id>
+                            <phase>package</phase>
+                            <goals>
+                                <goal>single</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- BUILD HELPER PLUGIN -->
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>build-helper-maven-plugin</artifactId>
+                    <version>${maven.build.helper.plugin.version}</version>
+                </plugin>
+
+                <!-- SPRING BOOT PLUGIN -->
+                <plugin>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-maven-plugin</artifactId>
+                    <version>${spring.boot.version}</version>
+                    <executions>
+                        <execution>
+                            <id>build-info</id>
+                            <goals>
+                                <goal>build-info</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>spring-boot-uber-jar</id>
+                            <goals>
+                                <goal>repackage</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- DOCKER PLUGIN -->
+                <plugin>
+                    <groupId>com.spotify</groupId>
+                    <artifactId>dockerfile-maven-plugin</artifactId>
+                    <version>${dockerfile-maven-version}</version>
+                    <configuration>
+                        <repository>${docker.repository}/${project.artifactId}</repository>
+                        <tag>${project.version}</tag>
+                    </configuration>
+                </plugin>
+
+            </plugins>
+
+        </pluginManagement>
+
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+            </plugin>
+
+        </plugins>
+    </build>
+
+</project>
diff --git a/dcae-analytics/version.properties b/dcae-analytics/version.properties
new file mode 100644 (file)
index 0000000..96df429
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
+major=3
+minor=0
+patch=0
+base_version=${major}.${minor}.${patch}
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT
diff --git a/eelf-logger/cpd-exclude.properties b/eelf-logger/cpd-exclude.properties
new file mode 100644 (file)
index 0000000..76066f7
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
+
+# Ignored as there are different log specs
+org.onap.dcae.utils.eelf.logger.model.spec.AuditLogSpecImpl,org.onap.dcae.utils.eelf.logger.model.spec.MetricLogSpecImpl
diff --git a/eelf-logger/eelf-logger-api/pom.xml b/eelf-logger/eelf-logger-api/pom.xml
new file mode 100644 (file)
index 0000000..cd8e15c
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.dcaegen2.utils</groupId>
+        <artifactId>eelf-logger</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>eelf-logger-api</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- EELF LOGGING API CONTAINS VARIOUS INTERFACES REQUIRED TO SUPPORT SUPPORT EELF LOGGING SPECIFICATIONS -->
+    <name>EELF Logger API</name>
+    <description>API contracts for EELF Logging Framework</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+        <!-- SONAR SETTINGS : EXCLUDE TEST COVERAGE AS API ONLY CONTAINS INTERFACES AND NO BUSINESS LOGIC-->
+        <sonar.coverage.exclusions>**/api/**</sonar.coverage.exclusions>
+    </properties>
+
+    <!-- NOTE: THIS API MODULE MUST NOT HAVE ANY DEPENDENCIES IN COMPILE SCOPE-->
+
+</project>
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/AppLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/AppLogInfo.java
new file mode 100644 (file)
index 0000000..bdce8d1
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ *  Captures information about application which is doing the logging. All app log fields must remain same for
+ *  the whole duration of the application once its instance is created.
+ *
+ * @author Rajiv Singla
+ */
+public interface AppLogInfo extends LogInfo {
+
+    /**
+     * Required field contains UUID which identifies this service instance inside an inventory management system
+     * (e.g. A&AI) to reference/manage this service as a unit
+     *
+     * @return remote VM Name or service the request is acting upon.
+     */
+    String getServiceInstanceID();
+
+    /**
+     * Required field contains a universally unique identifier used to differentiate between multiple instances of
+     * the same (named), log writing service/application. Its value is set at instance creation time (and read by it,
+     * e.g. at start/initialization time from the environment).  This value should be picked up by the component
+     * instance from its configuration file and subsequently used to enable differentiating log records created by
+     * multiple, locally load balanced EELF component or sub component instances that are otherwise identically
+     * configured.
+     *
+     * @return instance UUID
+     */
+    String getInstanceUUID();
+
+    /**
+     * Optional field contains VM Name where app is deployed.
+     * DCAE sub components should populate this field but it can be empty if
+     * determined that its value can be added by the log files collecting agent itself (e.g. Splunk).
+     * <p>
+     * <b> Example: host.vm.name.com</b>
+     * </p>
+     *
+     * @return virtual server name
+     */
+    String getVirtualServerName();
+
+    /**
+     * Optional field contains the logging component host server’s IP address.
+     * <p>
+     * <b>Example: 127.0.0.100</b>
+     * </p>
+     *
+     * @return server ip address
+     */
+    String getServerIPAddress();
+
+    /**
+     * Required field for VM's fully qualified domain name or hosting machine fully qualified domain name.
+     * <p>
+     * <b> Example: host.fqdn.com</b>
+     * </p>
+     *
+     * @return server host fully qualified domain name
+     */
+    String getServerFQDN();
+
+
+    /**
+     * Contains default values for {@link AppLogInfo}
+     */
+    interface Defaults {
+
+        String DEFAULT_SERVICE_INSTANCE_ID = "UNKNOWN_INSTANCE_ID";
+
+        String DEFAULT_INSTANCE_UUID = "";
+
+        String DEFAULT_VIRTUAL_SERVER_NAME = "";
+
+        String DEFAULT_SERVER_IP_ADDRESS = "UNKNOWN_IP_ADDRESS";
+
+        String DEFAULT_SERVER_FQDN = "UNKNOWN_SERVER_FQDN";
+
+    }
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CodeLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CodeLogInfo.java
new file mode 100644 (file)
index 0000000..bea195d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Capture field required to log details about code which is generating the log message.
+ * <p>
+ * <b>NOTE: When using a logging framework(e.g. logback) implementation these fields may be automatically deduced - so
+ * settings these fields is not required by the application and even if application sets these fields the logging
+ * framework may ignore it
+ * </b>
+ * </p>
+ *
+ * @author Rajiv Singla
+ */
+public interface CodeLogInfo extends LogInfo {
+
+
+    /**
+     * Optional field used if wanting to trace processing of a request over a number of sub-components of a single EELF
+     * component. It should be preceded by a log record that establishes its chaining back to the corresponding
+     * requestID.
+     *
+     * @return thread ID used to trace processing of request over number of sub-components of single EELF Component.
+     */
+    String getThreadId();
+
+
+    /**
+     * Optional field: If available for OO programing languages that support this concept. This is the name of the
+     * class that has caused the log record to be created.
+     *
+     * @return name of the class that has the caused the log record to be created
+     */
+    String getClassName();
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CustomFieldsLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/CustomFieldsLogInfo.java
new file mode 100644 (file)
index 0000000..634afa6
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures fields required to log Custom fields
+ *
+ * @author Rajiv Singla
+ */
+public interface CustomFieldsLogInfo extends LogInfo {
+
+    /**
+     * Optional field that can be used by developers to include additional application-specific
+     * information to support operations and troubleshooting of the system.
+     *
+     * @return additional application-specific information to support operations and troubleshooting of the system.
+     */
+    String getCustomField1();
+
+    /**
+     * Optional field that can be used by developers to include additional application-specific
+     * information to support operations and troubleshooting of the system.
+     *
+     * @return additional application-specific information to support operations and troubleshooting of the system.
+     */
+    String getCustomField2();
+
+    /**
+     * Optional field that can be used by developers to include additional application-specific
+     * information to support operations and troubleshooting of the system.
+     *
+     * @return additional application-specific information to support operations and troubleshooting of the system.
+     */
+    String getCustomField3();
+
+    /**
+     * Optional field that can be used by developers to include additional application-specific
+     * information to support operations and troubleshooting of the system.
+     *
+     * @return additional application-specific information to support operations and troubleshooting of the system.
+     */
+    String getCustomField4();
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ErrorLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ErrorLogInfo.java
new file mode 100644 (file)
index 0000000..876037c
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures fields required to log error related information
+ *
+ * @author Rajiv Singla
+ */
+public interface ErrorLogInfo extends LogInfo {
+
+
+    /**
+     * Required field contains an error code representing the error condition. The codes can be chose by
+     * the logging application but they should adhere to the guidelines embodied in the table below:
+     * <table summary="Error Codes" cellspacing=0 border=1>
+     * <tr>
+     * <td style=min-width:50px>Error type</td>
+     * <td style=min-width:50px>Notes</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>100</td>
+     * <td style=min-width:50px>Permission errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>200</td>
+     * <td style=min-width:50px>Availability errors/Timeouts</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>300</td>
+     * <td style=min-width:50px>Data errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>400</td>
+     * <td style=min-width:50px>Schema errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>500</td>
+     * <td style=min-width:50px>Business process errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>900</td>
+     * <td style=min-width:50px>Unknown Errors</td>
+     * </tr>
+     * </table>
+     *
+     * @return error Code
+     */
+    Integer getErrorCode();
+
+
+    /**
+     * Required field contains a human readable description of the error condition.
+     *
+     * @return human readable description of the error condition
+     */
+    String getErrorDescription();
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogInfo.java
new file mode 100644 (file)
index 0000000..4a3680f
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+import java.io.Serializable;
+
+/**
+ * Marker interface for all EELF Logging Information Components
+ *
+ * @author Rajiv Singla
+ */
+public interface LogInfo extends Serializable {
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogLevelCategory.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/LogLevelCategory.java
new file mode 100644 (file)
index 0000000..665a280
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures various logging levels.
+ * NOTE: Enum ordered signifies low to high log level severity
+ *
+ * @author Rajiv Singla
+ */
+public enum LogLevelCategory implements LogInfo {
+
+    DEBUG,
+    INFO,
+    WARN,
+    ERROR,
+    FATAL;
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MessageLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MessageLogInfo.java
new file mode 100644 (file)
index 0000000..cd53ccf
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+import java.util.Date;
+
+/**
+ * Captures fields required for message level logging. These fields are mostly derived fields. For example: creation
+ * timestamp can be auto generated based on system time, {@link RequestStatusCode} and {@link NagiosAlertLevel} can be
+ * derived based on {@link LogLevelCategory}
+ *
+ * @author Rajiv Singla
+ */
+public interface MessageLogInfo extends LogInfo {
+
+
+    /**
+     * Required field to capture when the message was created
+     * The value should be represented in UTC and formatted according to ISO 8601.
+     * <p>
+     * <b>Example: 2015-06-03T13:21:58+00:00</b>
+     * </p>
+     *
+     * @return message creation creationTimestamp
+     */
+    Date getCreationTimestamp();
+
+    /**
+     * Required field contains a value of COMPLETE or ERROR to indicate high level success or failure of the
+     * request related activities.
+     *
+     * @return value to indicate high level success or failure of the request related activities
+     */
+    RequestStatusCode getStatusCode();
+
+
+    /**
+     * Optional field for Nagios monitoring/alerting severity code
+     *
+     * @return nagios monitoring/alerting severity code
+     */
+    NagiosAlertLevel getAlertSeverity();
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MiscLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/MiscLogInfo.java
new file mode 100644 (file)
index 0000000..bf1e451
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures optional / deprecated fields that can be populated as per EELF Logging Requirements
+ *
+ * @author Rajiv Singla
+ */
+public interface MiscLogInfo extends LogInfo {
+
+    /**
+     * Optional field that can can be used to capture the flow of a transaction through the system by
+     * indicating the components and operations involved in processed. If present, it can be denoted by a comma
+     * separated list of components and applications.
+     *
+     * @return list of comma separated components and operations involved in processing
+     */
+    String getProcessId();
+
+    /**
+     * This field is deprecated and should be left empty.
+     *
+     * @return deprecated field value - should be empty
+     */
+    String getUnused();
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/NagiosAlertLevel.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/NagiosAlertLevel.java
new file mode 100644 (file)
index 0000000..3da5fc3
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Enum for Nagios monitoring/alerting codes as per table below.
+ * <p>
+ * <table cellspacing=0 border=1>
+ * <tr><th>Return Code</th><th>Service State</th><th>Host State</th></tr>
+ * <tr><td>0</td><td>OK</td><td>UP</td></tr>
+ * <tr><td>1</td><td>WARNING</td><td>UP or DOWN/UNREACHABLE*</td></tr>
+ * <tr><td>2</td><td>CRITICAL</td><td>DOWN/UNREACHABLE</td></tr>
+ * <tr><td>3</td><td>UNKNOWN</td><td>DOWN/UNREACHABLE</td></tr>
+ * </table>
+ *
+ * @author Rajiv Singla
+ */
+public enum NagiosAlertLevel implements LogInfo {
+
+    OK("0"),
+    WARNING("1"),
+    CRITICAL("2"),
+    UNKNOWN("3");
+
+    private String severityCode;
+
+    NagiosAlertLevel(final String severityCode) {
+        this.severityCode = severityCode;
+    }
+
+    public String getSeverityCode() {
+        return severityCode;
+    }
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestIdLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestIdLogInfo.java
new file mode 100644 (file)
index 0000000..68d5a17
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures fields required for logging request information
+ *
+ * @author Rajiv Singla
+ */
+public interface RequestIdLogInfo extends LogInfo {
+
+    /**
+     * Required field containing requestID which uniquely that identifies a single transaction request within the EELF
+     * platform. Its value is conforms to RFC4122 UUID. The requestID value is passed using a REST API from one
+     * EELF component to another via HTTP Headers named X-RequestID
+     * <p>
+     * <b>724229c0-9945-11e5-bcde-0002a5d5c51b:1234</b>
+     * </p>
+     * If receiving a composite requestID value, e.g. something of the form UUID-1:UUID-2, the receiving component
+     * should only use the UUID-1 portion (i.e. remove the “:” and any trailing suffix, e.g. UUID-2) as the requestID
+     * field value for its log files.
+     *
+     * @return requestID which uniquely that identifies a single transaction request within the EELF
+     */
+    String getRequestId();
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestStatusCode.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestStatusCode.java
new file mode 100644 (file)
index 0000000..b022b80
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Enum to indicate high level success or failure of the request related activities
+ *
+ * @author Rajiv Singla
+ */
+public enum RequestStatusCode {
+
+    ERROR,
+    COMPLETE;
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestTimingLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/RequestTimingLogInfo.java
new file mode 100644 (file)
index 0000000..7448e69
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+import java.util.Date;
+
+/**
+ * Captures Logging fields required for request timing related information
+ *
+ * @author Rajiv Singla
+ */
+public interface RequestTimingLogInfo extends LogInfo {
+
+    /**
+     * Required field containing creationTimestamp when the request processing started.
+     * The value should be represented in UTC and formatted according to ISO 8601.
+     * <p>
+     * <b>Example: 2015-06-03T13:21:58+00:00</b>
+     * </p>
+     *
+     * @return request activity begin creationTimestamp
+     */
+    Date getBeginTimestamp();
+
+
+    /**
+     * Required field containing creationTimestamp when the request processed stopped.
+     * The value should be represented in UTC and formatted according to ISO 8601.
+     * <p>
+     * <b>Example: 2015-06-03T13:21:58+00:00</b>
+     * </p>
+     *
+     * @return request activity end creationTimestamp
+     */
+    Date getEndTimestamp();
+
+
+    /**
+     * Required field contains the elapsed time to complete processing of an API call or transaction request (e.g.,
+     * processing of a message that was received). This value should be the difference between EndTimestamp and
+     * BeginTimestamp fields and should be expressed in milliseconds.
+     *
+     * @return request processing elapsed time in milliseconds
+     */
+    Long getElapsedTime();
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ResponseLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ResponseLogInfo.java
new file mode 100644 (file)
index 0000000..1929e7f
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures field required for logging Response information
+ *
+ * @author Rajiv Singla
+ */
+public interface ResponseLogInfo extends LogInfo {
+
+    /**
+     * Required field contains application-specific response codes. While error codes are
+     * application-specific, they
+     * should conform categories mentioned in table below in order to provide consistency
+     * <p>
+     * <table cellspacing=0 border=1>
+     * <tr>
+     * <th style=min-width:50px><b>Error type</b></th>
+     * <th style=min-width:50px><b>Notes</b></th>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>0</td>
+     * <td style=min-width:50px>Success</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>100</td>
+     * <td style=min-width:50px>Permission errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>200</td>
+     * <td style=min-width:50px>Availability errors/Timeouts</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>300</td>
+     * <td style=min-width:50px>Data errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>400</td>
+     * <td style=min-width:50px>Schema errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>500</td>
+     * <td style=min-width:50px>Business process errors</td>
+     * </tr>
+     * <tr>
+     * <td style=min-width:50px>900</td>
+     * <td style=min-width:50px>Unknown Errors</td>
+     * </tr>
+     * </table>
+     *
+     * @return application-specific error code
+     */
+    Integer getResponseCode();
+
+
+    /**
+     * Required field contains a human readable description of the {@link #getResponseCode()}.
+     *
+     * @return human readable description of the response code
+     */
+    String getResponseDescription();
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ServiceLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/ServiceLogInfo.java
new file mode 100644 (file)
index 0000000..0287cef
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures information about logging fields for application acting as service and handling requests from other
+ * applications
+ *
+ * @author Rajiv Singla
+ */
+public interface ServiceLogInfo extends LogInfo {
+
+    /**
+     * Required field contains the developer given name of the ecomp component's exposed api (~='method', function')
+     * invoked. For example if the application is exposing a REST interface and exposing runtime metrics then the
+     * service name can be: appName-getMetrics
+     *
+     * @return name of the API invoked by the application
+     */
+    String getServiceName();
+
+
+    /**
+     * Optional field contains the name of the client or user invoking the service.
+     * It may be an application, user name or mech id.
+     *
+     * @return name of the client or user invoking the API if known
+     */
+    String getPartnerName();
+
+
+    /**
+     * Optional field contains requesting remote client application’s IP address. Use UNKNOWN or an empty string if not
+     * available.
+     *
+     * @return remote client application’s IP address
+     */
+    String getClientIPAddress();
+
+
+}
+
+
+
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/TargetServiceLogInfo.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/TargetServiceLogInfo.java
new file mode 100644 (file)
index 0000000..d9b1f98
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.info;
+
+/**
+ * Captures fields for logging application which is calling an external/target service
+ *
+ * @author Rajiv Singla
+ */
+public interface TargetServiceLogInfo extends LogInfo {
+
+    /**
+     * Required field containing name of EELF component/sub component or non-EELF entity which is invoked by the
+     * logging application
+     *
+     * @return target entity name which is invoked by the logging application
+     */
+    String getTargetEntity();
+
+
+    /**
+     * Required field containing name of External API/operation activities invoked on {@link #getTargetEntity()}
+     *
+     * @return target service name invoked by the logging application
+     */
+    String getTargetServiceName();
+
+
+    /**
+     * Optional field containing target VNF or VM being acted upon by the logging application. This field contains the
+     * virtual entity that is the target of the action for example the FQDN of the target virtual entity
+     *
+     * @return target Virtual Entity
+     */
+    String getTargetVirtualEntity();
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/info/package-info.java
new file mode 100644 (file)
index 0000000..45bddd1
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+/**
+ *  Captures EELF logging information about various types.
+ *  <p>
+ *  The logging information is segregated into various information different types as to their relevance in particular
+ *  cases.
+ *
+ *  @author Rajiv Singla
+ */
+package org.onap.dcae.utils.eelf.logger.api.info;
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/AuditLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/AuditLog.java
new file mode 100644 (file)
index 0000000..952176e
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * Audit Log captures all log levels supported by audit specifications
+ *
+ * @author Rajiv Singla
+ */
+public interface AuditLog {
+
+    /**
+     * Logs audit message with provided {@link LogLevelCategory}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param optionalLogSpec optional log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, AuditLogSpec auditLogSpec,
+             OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs audit message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, AuditLogSpec auditLogSpec, String... args);
+
+
+    /**
+     * Logs audit message with provided INFO {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void info(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs audit message with provided INFO {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void info(String message, AuditLogSpec auditLogSpec, String... args);
+
+
+    /**
+     * Logs audit message with provided WARN {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void warn(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs audit message with provided WARN {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void warn(String message, AuditLogSpec auditLogSpec, String... args);
+
+    /**
+     * Logs audit message with provided ERROR {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void error(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs audit message with provided ERROR {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void error(String message, AuditLogSpec auditLogSpec, String... args);
+
+    /**
+     * Logs audit message with provided FATAL {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void fatal(String message, AuditLogSpec auditLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs audit message with provided FATAL {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param auditLogSpec audit log spec
+     * @param args argument values for log message interpolation
+     */
+    void fatal(String message, AuditLogSpec auditLogSpec, String... args);
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/DebugLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/DebugLog.java
new file mode 100644 (file)
index 0000000..98a0921
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.log;
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * Debug Log captures all log levels supported by debug specifications.
+ * <p>
+ * <b>NOTE: DEBUG Log is optional as per EELF Specifications</b>
+ *
+ * @author Rajiv Singla
+ */
+public interface DebugLog {
+
+    /**
+     * Logs debug message with provided {@link LogLevelCategory}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param debugLogSpec debug log spec
+     * @param optionalLogSpec optional log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, DebugLogSpec debugLogSpec,
+             OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs debug message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param debugLogSpec debug log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, DebugLogSpec debugLogSpec, String... args);
+
+
+    /**
+     * Logs debug message with provided DEBUG {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param debugLogSpec debug log spec
+     * @param args argument values for log message interpolation
+     */
+    void debug(String message, DebugLogSpec debugLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs debug message with provided DEBUG {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param debugLogSpec debug log spec
+     * @param args argument values for log message interpolation
+     */
+    void debug(String message, DebugLogSpec debugLogSpec, String... args);
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogFactory.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogFactory.java
new file mode 100644 (file)
index 0000000..2cfb2ec
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.noop.NoOpEELFLogger;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.WeakHashMap;
+
+/**
+ * EELF Log Factory uses {@link ServiceLoader} to load implementations of {@link EELFLogger} in application
+ * classpath. If no EELF Logging implementations are found - eelf logging is disabled and {@link NoOpEELFLogger}
+ * is used.
+ *
+ * @author Rajiv Singla
+ */
+public class EELFLogFactory {
+
+    private static final ServiceLoader<EELFLogger> SERVICE_LOADER = ServiceLoader.load(EELFLogger.class);
+    private static final Map<Class<?>, EELFLogger> LOGGER_CACHE = new WeakHashMap<>(64);
+
+    private static List<EELFLogger> loggerImplementations = new LinkedList<>();
+
+    static {
+
+        for (EELFLogger loggerImplementation : SERVICE_LOADER) {
+            loggerImplementations.add(loggerImplementation);
+        }
+
+        if (loggerImplementations.isEmpty()) {
+            System.err.println(
+                    "EELF LOGGING ERROR: Unable to find any EELF Logger Implementations in the classpath.");
+            System.err.println("=============EELF LOGGING IS DISABLED================");
+            loggerImplementations.add(NoOpEELFLogger.getInstance());
+        }
+
+    }
+
+    private EELFLogFactory() {
+        // private constructor
+    }
+
+    public static <T> EELFLogger getLogger(Class<T> clazz) {
+
+        if (LOGGER_CACHE.get(clazz) != null) {
+            return LOGGER_CACHE.get(clazz);
+        }
+
+        EELFLogger EELFLogger = null;
+        try {
+            EELFLogger = loggerImplementations.get(0).getClass().getConstructor(Class.class)
+                    .newInstance(clazz);
+            return EELFLogger;
+
+        } catch (
+                InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+            throw new IllegalStateException("Error while Creating EELF Logger", e);
+        }
+
+    }
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogger.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLogger.java
new file mode 100644 (file)
index 0000000..500d814
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.log;
+
+/**
+ * EELF Logger is main abstraction which applications use to log EELF Compliant log messages
+ *
+ * @author Rajiv Singla
+ */
+public interface EELFLogger {
+
+    /**
+     * Provides Audit Log
+     *
+     * @return Audit log
+     */
+    AuditLog auditLog();
+
+
+    /**
+     * Provides Metric Log
+     *
+     * @return metric log
+     */
+    MetricLog metricLog();
+
+    /**
+     * Provides Error Log
+     *
+     * @return error log
+     */
+    ErrorLog errorLog();
+
+
+    /**
+     * Provides Debug Log
+     *
+     * @return debug log
+     */
+    DebugLog debugLog();
+
+    /**
+     * Provides logging context
+     *
+     * @return logging context
+     */
+    EELFLoggerContext loggingContext();
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLoggerContext.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/EELFLoggerContext.java
new file mode 100644 (file)
index 0000000..5910da5
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.spec.AppLogSpec;
+
+/**
+ * EELF Logger Context contains fields are set during application creation time and are fixed for the entire
+ * duration of the application lifetime
+ *
+ * @author Rajiv Singla
+ */
+public interface EELFLoggerContext {
+
+    /**
+     * Returns App Log Spec
+     *
+     * @return current app log spec
+     */
+    AppLogSpec getAppLogSpec();
+
+
+    /**
+     * Sets new App Log Spec
+     *
+     * @param appLogSpec new app log spec
+     */
+    void setAppLogSpec(AppLogSpec appLogSpec);
+
+
+    /**
+     * Returns true if logging context is already initialized
+     *
+     * @return true if logger context is already initialized
+     */
+    boolean isInitialized();
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/ErrorLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/ErrorLog.java
new file mode 100644 (file)
index 0000000..6b27755
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * @author Rajiv Singla
+ */
+public interface ErrorLog {
+
+    /**
+     * Logs error message with provided {@link LogLevelCategory}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param errorLogSpec error log spec
+     * @param optionalLogSpec optional log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, ErrorLogSpec errorLogSpec,
+             OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs error message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param errorLogSpec error log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, ErrorLogSpec errorLogSpec, String... args);
+
+
+    /**
+     * Logs error message with ERROR {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param errorLogSpec error log spec
+     * @param args argument values for log message interpolation
+     */
+    void error(String message, ErrorLogSpec errorLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs error message with ERROR {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param errorLogSpec error log spec
+     * @param args argument values for log message interpolation
+     */
+    void error(String message, ErrorLogSpec errorLogSpec, String... args);
+
+
+    /**
+     * Logs error message with WARN {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param errorLogSpec error log spec
+     * @param args argument values for log message interpolation
+     */
+    void warn(String message, ErrorLogSpec errorLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs error message with WARN {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param errorLogSpec error log spec
+     * @param args argument values for log message interpolation
+     */
+    void warn(String message, ErrorLogSpec errorLogSpec, String... args);
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/MetricLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/MetricLog.java
new file mode 100644 (file)
index 0000000..ebc33ca
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * Metric Log captures all log levels supported by metric specifications
+ *
+ * @author Rajiv Singla
+ */
+public interface MetricLog {
+
+    /**
+     * Logs metric message with provided {@link LogLevelCategory}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param optionalLogSpec optional log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, MetricLogSpec metricLogSpec,
+             OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs metric message with provided {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param logLevelCategory log level category
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void log(LogLevelCategory logLevelCategory, String message, MetricLogSpec metricLogSpec, String... args);
+
+
+    /**
+     * Logs metric message with provided INFO {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void info(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs metric message with provided INFO {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void info(String message, MetricLogSpec metricLogSpec, String... args);
+
+
+    /**
+     * Logs metric message with provided WARN {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void warn(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs metric message with provided WARN {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void warn(String message, MetricLogSpec metricLogSpec, String... args);
+
+    /**
+     * Logs metric message with provided ERROR {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void error(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs metric message with provided ERROR {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void error(String message, MetricLogSpec metricLogSpec, String... args);
+
+    /**
+     * Logs metric message with provided FATAL {@link LogLevelCategory}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void fatal(String message, MetricLogSpec metricLogSpec, OptionalLogSpec optionalLogSpec, String... args);
+
+    /**
+     * Logs metric message with provided FATAL {@link LogLevelCategory} and with default {@link OptionalLogSpec}
+     *
+     * @param message log message
+     * @param metricLogSpec metric log spec
+     * @param args argument values for log message interpolation
+     */
+    void fatal(String message, MetricLogSpec metricLogSpec, String... args);
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/log/package-info.java
new file mode 100644 (file)
index 0000000..e24ccc9
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+/**
+ * Contains Logging API contracts for various EELF Logs (e.g. Audit, Metric, Error, Debug etc)
+ */
+package org.onap.dcae.utils.eelf.logger.api.log;
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpAuditLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpAuditLog.java
new file mode 100644 (file)
index 0000000..6c1c583
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.noop;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.AuditLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * A no operation implementation of AuditLog
+ *
+ * @author Rajiv Singla
+ */
+public class NoOpAuditLog implements AuditLog {
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final AuditLogSpec auditLogSpec,
+                    final OptionalLogSpec optionalLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final AuditLogSpec auditLogSpec,
+                    final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void info(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void info(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void warn(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void warn(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void error(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void error(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void fatal(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void fatal(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        // no operation
+    }
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpDebugLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpDebugLog.java
new file mode 100644 (file)
index 0000000..dd36b52
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.noop;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.DebugLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * A no operation implementation of Debug Log
+ *
+ * @author Rajiv Singla
+ */
+public class NoOpDebugLog implements DebugLog {
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final DebugLogSpec debugLogSpec,
+                    final OptionalLogSpec optionalLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final DebugLogSpec debugLogSpec,
+                    final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void debug(final String message, final DebugLogSpec debugLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void debug(final String message, final DebugLogSpec debugLogSpec, final String... args) {
+        // no operation
+    }
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpEELFLogger.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpEELFLogger.java
new file mode 100644 (file)
index 0000000..c761ba1
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.noop;
+
+
+import org.onap.dcae.utils.eelf.logger.api.log.AuditLog;
+import org.onap.dcae.utils.eelf.logger.api.log.DebugLog;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLoggerContext;
+import org.onap.dcae.utils.eelf.logger.api.log.ErrorLog;
+import org.onap.dcae.utils.eelf.logger.api.log.MetricLog;
+
+/**
+ * A no operation implementation of {@link EELFLogger}
+ *
+ * @author Rajiv Singla
+ */
+public class NoOpEELFLogger implements EELFLogger {
+
+    private static final AuditLog NO_OP_AUDIT_LOG = new NoOpAuditLog();
+    private static final MetricLog NO_OP_METRIC_LOG = new NoOpMetricLog();
+    private static final ErrorLog NO_OP_ERROR_LOG = new NoOpErrorLog();
+    private static final DebugLog NO_OP_DEBUG_LOG = new NoOpDebugLog();
+
+    private static final NoOpEELFLogger NO_OP_EELF_LOGGER = new NoOpEELFLogger();
+
+    private NoOpEELFLogger() {
+        // private constructor
+    }
+
+    public static NoOpEELFLogger getInstance() {
+        return NO_OP_EELF_LOGGER;
+    }
+
+    @Override
+    public AuditLog auditLog() {
+        return NO_OP_AUDIT_LOG;
+    }
+
+    @Override
+    public MetricLog metricLog() {
+        return NO_OP_METRIC_LOG;
+    }
+
+    @Override
+    public ErrorLog errorLog() {
+        return NO_OP_ERROR_LOG;
+    }
+
+    @Override
+    public DebugLog debugLog() {
+        return NO_OP_DEBUG_LOG;
+    }
+
+    @Override
+    public EELFLoggerContext loggingContext() {
+        return null;
+    }
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpErrorLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpErrorLog.java
new file mode 100644 (file)
index 0000000..c1b4e13
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.noop;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.ErrorLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * A no operation implementation of Error Log
+ *
+ * @author Rajiv Singla
+ */
+public class NoOpErrorLog implements ErrorLog {
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final ErrorLogSpec errorLogSpec,
+                    final OptionalLogSpec optionalLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final ErrorLogSpec errorLogSpec,
+                    final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void error(final String message, final ErrorLogSpec errorLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void error(final String message, final ErrorLogSpec errorLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void warn(final String message, final ErrorLogSpec errorLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void warn(final String message, final ErrorLogSpec errorLogSpec, final String... args) {
+        // no operation
+    }
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpMetricLog.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/NoOpMetricLog.java
new file mode 100644 (file)
index 0000000..1c67862
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.noop;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.MetricLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+/**
+ * A no operation implementation of Metric Log
+ *
+ * @author Rajiv Singla
+ */
+public class NoOpMetricLog implements MetricLog {
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final MetricLogSpec metricLogSpec,
+                    final OptionalLogSpec optionalLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final MetricLogSpec metricLogSpec,
+                    final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void info(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void info(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void warn(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void warn(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void error(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void error(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void fatal(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        // no operation
+    }
+
+    @Override
+    public void fatal(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        // no operation
+    }
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/noop/package-info.java
new file mode 100644 (file)
index 0000000..f7ed917
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+/**
+ *  Contains no operation implementation of EELF Logging API. Generally used as a fallback when no EELF Logging
+ *  implementation is detected in the application classpath
+ *
+ *  @author Rajiv Singla
+ */
+package org.onap.dcae.utils.eelf.logger.api.noop;
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AppLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AppLogSpec.java
new file mode 100644 (file)
index 0000000..83643fb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.spec;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.AppLogInfo;
+
+/**
+ * App Log spec captures fields which are fixed for the duration of application once its instance is created. They
+ * should be populated for all specifications regardless of if they are relevant to that specification
+ *
+ * @author Rajiv Singla
+ */
+public interface AppLogSpec extends AppLogInfo {
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AuditLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/AuditLogSpec.java
new file mode 100644 (file)
index 0000000..46360b1
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.spec;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestTimingLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+
+/**
+ * Captures fields required for EELF Audit Log Specification.
+ *
+ * @author Rajiv Singla
+ */
+public interface AuditLogSpec extends
+        // request id must be preset for all log specifications
+        RequestIdLogInfo,
+        // duration related fields
+        RequestTimingLogInfo,
+        // app acting as a service fields
+        ServiceLogInfo, ResponseLogInfo {
+
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/DebugLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/DebugLogSpec.java
new file mode 100644 (file)
index 0000000..ac4bd64
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.spec;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+
+/**
+ * Captures fields required for EELF Debug Log Specification.
+ * NOTE: As per specification debug log is optional
+ *
+ * @author Rajiv Singla
+ */
+public interface DebugLogSpec extends
+        // request id must be preset for all log specifications
+        RequestIdLogInfo {
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/ErrorLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/ErrorLogSpec.java
new file mode 100644 (file)
index 0000000..455f433
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.spec;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.ErrorLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+
+/**
+ * Captures fields required for EELF Error Log Specification
+ *
+ * @author Rajiv Singla
+ */
+public interface ErrorLogSpec extends
+        // request id must be preset for all log specifications
+        RequestIdLogInfo,
+        // app acting as a service fields
+        ServiceLogInfo,
+        // app calling external service fields
+        TargetServiceLogInfo,
+        // error details fields
+        ErrorLogInfo {
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/MetricLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/MetricLogSpec.java
new file mode 100644 (file)
index 0000000..5b5f698
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.spec;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+
+/**
+ * Captures fields required for EELF Metric Log Specification.
+ *
+ * @author Rajiv Singla
+ */
+public interface MetricLogSpec extends
+        // Audit log spec
+        AuditLogSpec,
+        // App calling external service fields
+        TargetServiceLogInfo {
+
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/OptionalLogSpec.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/OptionalLogSpec.java
new file mode 100644 (file)
index 0000000..dac08ab
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.api.spec;
+
+import org.onap.dcae.utils.eelf.logger.api.info.CodeLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.CustomFieldsLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.MessageLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.MiscLogInfo;
+
+/**
+ * Captures fields which are optional or derived from other fields
+ *
+ * @author Rajiv Singla
+ */
+public interface OptionalLogSpec extends
+        // message fields are mostly auto generated or can be derived from other fields
+        MessageLogInfo,
+        // Code log info can be derived by the underlying logging framework or provided optionally by the app
+        CodeLogInfo,
+        // custom and misc log info are mostly optional
+        CustomFieldsLogInfo, MiscLogInfo {
+}
diff --git a/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/package-info.java b/eelf-logger/eelf-logger-api/src/main/java/org/onap/dcae/utils/eelf/logger/api/spec/package-info.java
new file mode 100644 (file)
index 0000000..b4c1df8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+/**
+ * Contains various EELF Logging Specifications.
+ * <p>
+ * Some specifications are fixed for the whole duration of the
+ * application, some specification are either optional or derived and some are required for particular EELF Logging
+ * specification. These logging specification are composed of various logging information in
+ * {@link org.onap.dcae.utils.eelf.logger.api.info} package
+ */
+package org.onap.dcae.utils.eelf.logger.api.spec;
diff --git a/eelf-logger/eelf-logger-logback-impl/pom.xml b/eelf-logger/eelf-logger-logback-impl/pom.xml
new file mode 100644 (file)
index 0000000..bd27526
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+               <groupId>org.onap.dcaegen2.utils</groupId>
+        <artifactId>eelf-logger</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>eelf-logger-logback-impl</artifactId>
+    <packaging>jar</packaging>
+
+    <!-- EELF LOGGING IMPLEMENTATION BACKED BY LOGBACK LOGGING FRAMEWORK-->
+    <name>EELF Logger Logback Impl</name>
+    <description>Implements EEL Logging Specification using Logback</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+    </properties>
+
+    <dependencies>
+
+        <!-- ECOMP LOGGER MODEL -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>eelf-logger-model</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- LOGBACK -->
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/EELFLoggerDefaults.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/EELFLoggerDefaults.java
new file mode 100644 (file)
index 0000000..eceaf20
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogInfo;
+import org.onap.dcae.utils.eelf.logger.model.info.AppLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.CustomFieldsLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ErrorLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.MiscLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestTimingLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ResponseLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ServiceLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.TargetServiceLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.OptionalLogSpecImpl;
+
+import java.util.Date;
+
+import static org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils.createDefaultAppLogInfo;
+
+
+/**
+ * This utility class various default implementations for EELF Logger. Users should use these default rather then
+ * creating their own {@link LogInfo} objects.
+ *
+ * @author Rajiv Singla
+ */
+public class EELFLoggerDefaults {
+
+    private static final String UNKNOWN_FIELD_VALUE = "UNKNOWN";
+
+    // =============== APP LOG SPEC ======================//
+    /**
+     * Provides Default {@link AppLogInfoImpl}
+     */
+    public static final AppLogInfoImpl DEFAULT_APP_LOG_INFO = createDefaultAppLogInfo();
+
+
+    // =============== AUDIT LOG SPEC ===================== //
+
+    private static final String DEFAULT_PARTNER_NAME =
+            System.getProperty("user.name") != null ? System.getProperty("user.name") : UNKNOWN_FIELD_VALUE;
+
+    public static final ServiceLogInfoImpl DEFAULT_SERVICE_LOG_INFO =
+            new ServiceLogInfoImpl(UNKNOWN_FIELD_VALUE, DEFAULT_PARTNER_NAME, "");
+
+
+    public static final RequestTimingLogInfoImpl DEFAULT_REQUEST_TIMING_LOG_INFO =
+            new RequestTimingLogInfoImpl(new Date(), new Date(), null);
+
+
+    public static final ResponseLogInfoImpl DEFAULT_RESPONSE_LOG_INFO =
+            new ResponseLogInfoImpl(900, "UNDEFINED");
+
+
+    // =============== METRIC LOG SPEC ===================== //
+
+    public static final TargetServiceLogInfoImpl DEFAULT_TARGET_SERVICE_LOG_INFO =
+            new TargetServiceLogInfoImpl(UNKNOWN_FIELD_VALUE, UNKNOWN_FIELD_VALUE, UNKNOWN_FIELD_VALUE);
+
+    // =============== ERROR LOG SPEC ===================== //
+
+    public static final ErrorLogInfoImpl DEFAULT_ERROR_LOG_INFO =
+            new ErrorLogInfoImpl(900, "UNDEFINED ERROR");
+
+
+    // ============= OPTIONAL LOG SPEC =================== //
+
+    /**
+     * Provides Default {@link CustomFieldsLogInfoImpl}
+     */
+    public static final CustomFieldsLogInfoImpl DEFAULT_CUSTOM_FIELDS_LOG_INFO =
+            new CustomFieldsLogInfoImpl("", "", "", "");
+
+    /**
+     * Provides Default {@link MiscLogInfoImpl}
+     */
+    public static final MiscLogInfoImpl DEFAULT_MISC_LOG_INFO = new MiscLogInfoImpl("", "");
+
+
+    /**
+     * Provides Default {@link OptionalLogSpecImpl}
+     */
+    public static final OptionalLogSpecImpl DEFAULT_OPTIONAL_LOG_SPEC = new OptionalLogSpecImpl(null, null,
+            DEFAULT_CUSTOM_FIELDS_LOG_INFO, DEFAULT_MISC_LOG_INFO);
+
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/filter/MarkerFilter.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/filter/MarkerFilter.java
new file mode 100644 (file)
index 0000000..a664190
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.filter;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.filter.AbstractMatcherFilter;
+import ch.qos.logback.core.spi.FilterReply;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Logback Marker filter
+ *
+ * @author Rajiv Singla
+ */
+public class MarkerFilter extends AbstractMatcherFilter<ILoggingEvent> {
+
+    private String markersString;
+    private Set<Marker> markersToAccept = new HashSet<>();
+
+    @Override
+    public FilterReply decide(final ILoggingEvent event) {
+
+        if (!isStarted()) {
+            return FilterReply.NEUTRAL;
+        }
+
+        if (markersToAccept.contains(event.getMarker())) {
+            return onMatch;
+        } else {
+            return onMismatch;
+        }
+    }
+
+    public void setMarkers(String markersString) {
+        this.markersString = markersString;
+    }
+
+
+    public void start() {
+
+        if (markersString != null && markersString.trim().split(",").length > 0) {
+
+            final String[] markerStrings = markersString.trim().split(",");
+            for (String markerString : markerStrings) {
+                markersToAccept.add(MarkerFactory.getMarker(markerString.trim()));
+            }
+            super.start();
+        }
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/AuditLogLayout.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/AuditLogLayout.java
new file mode 100644 (file)
index 0000000..5d848ac
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.layout;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.LayoutBase;
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.AppLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+
+
+/**
+ * Audit log layout generates log messages as per EELF Audit Log Specifications
+ *
+ * @author Rajiv Singla
+ */
+public class AuditLogLayout extends LayoutBase<ILoggingEvent> {
+
+    @Override
+    public String doLayout(final ILoggingEvent event) {
+
+        final AppLogSpec appLogSpec = LogUtils.getAppLogSpec();
+        final LogLevelCategory logLevelCategory = LogUtils.getLogLevelCategory();
+        final Class<?> loggerClass = LogUtils.getLoggerClass();
+        final OptionalLogSpec optionalLogSpec = LogUtils.getOptionalLogSpec(loggerClass, logLevelCategory);
+        final AuditLogSpec auditLogSpec = LogUtils.getAuditLogSpec();
+
+        final String beginTimestamp = LogUtils.formatDate(auditLogSpec.getBeginTimestamp());
+        final String endTimestamp = LogUtils.formatDate(auditLogSpec.getEndTimestamp());
+
+        final String[] auditLogValues = {
+                beginTimestamp,
+                endTimestamp,
+                auditLogSpec.getRequestId(),
+                appLogSpec.getServiceInstanceID(),
+                event.getThreadName(),
+                appLogSpec.getVirtualServerName(),
+                auditLogSpec.getServiceName(),
+                auditLogSpec.getPartnerName(),
+                optionalLogSpec.getStatusCode().name(),
+                auditLogSpec.getResponseCode().toString(),
+                auditLogSpec.getResponseDescription(),
+                appLogSpec.getInstanceUUID(),
+                logLevelCategory != null ? logLevelCategory.name() : "",
+                optionalLogSpec.getAlertSeverity().getSeverityCode(),
+                appLogSpec.getServerIPAddress(),
+                auditLogSpec.getElapsedTime().toString(),
+                appLogSpec.getServerFQDN(),
+                auditLogSpec.getClientIPAddress(),
+                optionalLogSpec.getClassName(),
+                optionalLogSpec.getUnused(),
+                optionalLogSpec.getProcessId(),
+                optionalLogSpec.getCustomField1(),
+                optionalLogSpec.getCustomField2(),
+                optionalLogSpec.getCustomField3(),
+                optionalLogSpec.getCustomField4(),
+                event.getFormattedMessage()
+        };
+
+        return LogUtils.createLogMessageString(auditLogValues);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/ConsoleLayout.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/ConsoleLayout.java
new file mode 100644 (file)
index 0000000..589d863
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.layout;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.LayoutBase;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+import org.slf4j.Marker;
+
+/**
+ * Console layout is used to log messages on the console for debugging purposes.
+ *
+ * @author Rajiv Singla
+ */
+public class ConsoleLayout extends LayoutBase<ILoggingEvent> {
+
+    private static final MetricLogLayout METRIC_LOG_LAYOUT = new MetricLogLayout();
+    private static final AuditLogLayout AUDIT_LOG_LAYOUT = new AuditLogLayout();
+    private static final ErrorLogLayout ERROR_LOG_LAYOUT = new ErrorLogLayout();
+    private static final DebugLogLayout DEBUG_LOG_LAYOUT = new DebugLogLayout();
+
+    @Override
+    public String doLayout(final ILoggingEvent event) {
+
+        final Marker eventMarker = event.getMarker();
+
+        if (eventMarker.equals(LogUtils.AUDIT_LOG_MARKER)) {
+            return AUDIT_LOG_LAYOUT.doLayout(event);
+        } else if (eventMarker.equals(LogUtils.METRIC_LOG_MARKER)) {
+            return METRIC_LOG_LAYOUT.doLayout(event);
+        } else if (eventMarker.equals(LogUtils.ERROR_LOG_MARKER)) {
+            return ERROR_LOG_LAYOUT.doLayout(event);
+        } else if (eventMarker.equals(LogUtils.DEBUG_LOG_MARKER)) {
+            return DEBUG_LOG_LAYOUT.doLayout(event);
+        }
+
+        return "Console Layout not defined for Marker: " + eventMarker;
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/DebugLogLayout.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/DebugLogLayout.java
new file mode 100644 (file)
index 0000000..e7b1cd4
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.layout;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.LayoutBase;
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+
+
+/**
+ * @author Rajiv Singla
+ */
+public class DebugLogLayout extends LayoutBase<ILoggingEvent> {
+
+    @Override
+    public String doLayout(final ILoggingEvent event) {
+
+        final LogLevelCategory logLevelCategory = LogUtils.getLogLevelCategory();
+        final Class<?> loggerClass = LogUtils.getLoggerClass();
+        final OptionalLogSpec optionalLogSpec = LogUtils.getOptionalLogSpec(loggerClass, logLevelCategory);
+
+        final DebugLogSpec debugLogSpec = LogUtils.getDebugLogSpec();
+
+        final String creationTimestamp = LogUtils.formatDate(optionalLogSpec.getCreationTimestamp());
+
+        final String[] debugLogValues = {
+                creationTimestamp,
+                debugLogSpec.getRequestId(),
+                event.getFormattedMessage()
+        };
+
+        return LogUtils.createLogMessageString(debugLogValues);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/ErrorLogLayout.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/ErrorLogLayout.java
new file mode 100644 (file)
index 0000000..4eefe36
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.layout;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.LayoutBase;
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+
+
+/**
+ * Error Log Layout generates log messages as per EELF Error Log Specifications
+ *
+ * @author Rajiv Singla
+ */
+public class ErrorLogLayout extends LayoutBase<ILoggingEvent> {
+
+    @Override
+    public String doLayout(final ILoggingEvent event) {
+
+        final LogLevelCategory logLevelCategory = LogUtils.getLogLevelCategory();
+        final Class<?> loggerClass = LogUtils.getLoggerClass();
+        final OptionalLogSpec optionalLogSpec = LogUtils.getOptionalLogSpec(loggerClass, logLevelCategory);
+
+        final ErrorLogSpec errorLogSpec = LogUtils.getErrorLogSpec();
+
+        final String creationTimestamp = LogUtils.formatDate(optionalLogSpec.getCreationTimestamp());
+
+        final String[] errorLogValues = {
+                creationTimestamp,
+                errorLogSpec.getRequestId(),
+                event.getThreadName(),
+                errorLogSpec.getServiceName(),
+                errorLogSpec.getPartnerName(),
+                errorLogSpec.getTargetEntity(),
+                errorLogSpec.getTargetServiceName(),
+                logLevelCategory != null ? logLevelCategory.name() : "",
+                errorLogSpec.getErrorCode() != null ? errorLogSpec.getErrorCode().toString() : "",
+                errorLogSpec.getErrorDescription(),
+                event.getFormattedMessage()
+        };
+
+        return LogUtils.createLogMessageString(errorLogValues);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/MetricLogLayout.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/layout/MetricLogLayout.java
new file mode 100644 (file)
index 0000000..509ff8f
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.layout;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.LayoutBase;
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.spec.AppLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+
+/**
+ * Metric Log Layout generates log messages as per EELF Metric Log Specifications
+ *
+ * @author Rajiv Singla
+ */
+public class MetricLogLayout extends LayoutBase<ILoggingEvent> {
+
+    @Override
+    public String doLayout(final ILoggingEvent event) {
+
+        final AppLogSpec appLogSpec = LogUtils.getAppLogSpec();
+        final LogLevelCategory logLevelCategory = LogUtils.getLogLevelCategory();
+        final Class<?> loggerClass = LogUtils.getLoggerClass();
+        final OptionalLogSpec optionalLogSpec = LogUtils.getOptionalLogSpec(loggerClass, logLevelCategory);
+        final MetricLogSpec metricLogSpec = LogUtils.getMetricLogSpec();
+
+        final String beginTimestamp = LogUtils.formatDate(metricLogSpec.getBeginTimestamp());
+        final String endTimestamp = LogUtils.formatDate(metricLogSpec.getEndTimestamp());
+
+        final String[] metricLogValues = {
+                beginTimestamp,
+                endTimestamp,
+                metricLogSpec.getRequestId(),
+                appLogSpec.getServiceInstanceID(),
+                event.getThreadName(),
+                appLogSpec.getVirtualServerName(),
+                metricLogSpec.getServiceName(),
+                metricLogSpec.getPartnerName(),
+                metricLogSpec.getTargetEntity(),
+                metricLogSpec.getTargetServiceName(),
+                optionalLogSpec.getStatusCode().name(),
+                metricLogSpec.getResponseCode().toString(),
+                metricLogSpec.getResponseDescription(),
+                appLogSpec.getInstanceUUID(),
+                logLevelCategory != null ? logLevelCategory.name() : "",
+                optionalLogSpec.getAlertSeverity().getSeverityCode(),
+                appLogSpec.getServerIPAddress(),
+                metricLogSpec.getElapsedTime().toString(),
+                appLogSpec.getServerFQDN(),
+                metricLogSpec.getClientIPAddress(),
+                optionalLogSpec.getClassName(),
+                optionalLogSpec.getUnused(),
+                optionalLogSpec.getProcessId(),
+                metricLogSpec.getTargetVirtualEntity(),
+                optionalLogSpec.getCustomField1(),
+                optionalLogSpec.getCustomField2(),
+                optionalLogSpec.getCustomField3(),
+                optionalLogSpec.getCustomField4(),
+                event.getFormattedMessage()
+        };
+
+        return LogUtils.createLogMessageString(metricLogValues);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/listener/LogbackStartupListener.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/listener/LogbackStartupListener.java
new file mode 100644 (file)
index 0000000..b02c471
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.listener;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.spi.LoggerContextListener;
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.spi.ContextAwareBase;
+import ch.qos.logback.core.spi.LifeCycle;
+import ch.qos.logback.core.status.InfoStatus;
+import ch.qos.logback.core.status.WarnStatus;
+import org.onap.dcae.utils.eelf.logger.api.info.AppLogInfo;
+import org.onap.dcae.utils.eelf.logger.model.spec.AppLogSpecImpl;
+
+
+import java.io.File;
+
+import static org.onap.dcae.utils.eelf.logger.logback.EELFLoggerDefaults.DEFAULT_APP_LOG_INFO;
+import static org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils.APP_LOG_SPEC_KEY;
+import static org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils.CUSTOM_MDC_MAP;
+
+
+/**
+ * Logback Startup Listener is used to inject {@link AppLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+public class LogbackStartupListener extends ContextAwareBase implements LoggerContextListener, LifeCycle {
+
+    private static final String APP_LOG_INFO_KEY_IN_CONTEXT = "APP_LOG_INFO";
+    private static final String CONTEXT_COMPONENT_NAME_PROPERTY_KEY = "componentName";
+    private static final String CONTEXT_MODIFY_WINDOWS_LOG_PATH_PROPERTY_KEY = "modifyLogPathInWindows";
+    private static final String CONTEXT_LOG_DIRECTORY_PROPERTY_KEY = "logDirectory";
+    private static final String CONTEXT_DEBUG_LOG_DIRECTORY_PROPERTY_KEY = "debugLogDirectory";
+    private static final String CONTEXT_APPEND_DIRECTORY_PROPERTY_KEY = "appendDirectory";
+
+    private boolean started = false;
+
+    @Override
+    public boolean isResetResistant() {
+        return true;
+    }
+
+    @Override
+    public void onStart(final LoggerContext context) {
+
+    }
+
+    @Override
+    public void onReset(final LoggerContext context) {
+
+    }
+
+    @Override
+    public void onStop(final LoggerContext context) {
+
+    }
+
+    @Override
+    public void onLevelChange(final Logger logger, final Level level) {
+
+    }
+
+    @Override
+    public void start() {
+        if (started) {
+            return;
+        }
+
+        Context context = getContext();
+
+        CUSTOM_MDC_MAP.put(APP_LOG_SPEC_KEY, new AppLogSpecImpl(DEFAULT_APP_LOG_INFO));
+        context.putObject(APP_LOG_INFO_KEY_IN_CONTEXT, DEFAULT_APP_LOG_INFO);
+        context.getStatusManager().add(new InfoStatus("Initialized APP LOG INFO", DEFAULT_APP_LOG_INFO));
+
+        // if Component name is not set derive from jar file name
+        if (context.getProperty(CONTEXT_COMPONENT_NAME_PROPERTY_KEY) == null) {
+            final String appName =
+                    new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getName();
+            context.putProperty(CONTEXT_COMPONENT_NAME_PROPERTY_KEY, appName);
+            context.getStatusManager().add(new WarnStatus(
+                    "No componentName Property found. Deriving it from jar name", appName));
+        }
+
+        // if modify windows log path is enabled - then append target before log directories
+        if (context.getProperty(CONTEXT_MODIFY_WINDOWS_LOG_PATH_PROPERTY_KEY).equalsIgnoreCase("true")) {
+            final String os = System.getProperty("os.name");
+            if (os != null && os.startsWith("Windows")) {
+                final String logDirectory = context.getProperty(CONTEXT_LOG_DIRECTORY_PROPERTY_KEY);
+                final String debugLogDirectory = context.getProperty(CONTEXT_DEBUG_LOG_DIRECTORY_PROPERTY_KEY);
+                final String appendDir = context.getProperty(CONTEXT_APPEND_DIRECTORY_PROPERTY_KEY);
+                context.putProperty(CONTEXT_LOG_DIRECTORY_PROPERTY_KEY, appendDir + "/" + logDirectory);
+                context.putProperty(CONTEXT_DEBUG_LOG_DIRECTORY_PROPERTY_KEY, appendDir + "/" + debugLogDirectory);
+            }
+        }
+
+        started = true;
+    }
+
+    @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public boolean isStarted() {
+        return started;
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/AuditLogImpl.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/AuditLogImpl.java
new file mode 100644 (file)
index 0000000..947b4c2
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.AuditLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+import org.slf4j.Logger;
+
+
+/**
+ * Audit Log Logback Implementation
+ *
+ * @author Rajiv Singla
+ */
+public class AuditLogImpl implements AuditLog {
+
+    private final Logger logger;
+    private final Class<?> clazz;
+
+    public AuditLogImpl(final Logger logger, final Class<?> clazz) {
+        this.logger = logger;
+        this.clazz = clazz;
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final AuditLogSpec
+            auditLogSpec, final OptionalLogSpec optionalLogSpec, final String... args) {
+        // if audit log spec or log level category is null throw an exception
+        if (auditLogSpec == null || logLevelCategory == null) {
+            throw new IllegalArgumentException("Audit Log Spec and Log level category must not be null");
+        }
+        // required fields
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOG_LEVEL_CATEGORY_KEY, logLevelCategory);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.AUDIT_LOG_SPEC_KEY, auditLogSpec);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOGGER_CLASS_KEY, clazz);
+        // optional fields
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.OPTIONAL_LOG_SPEC_KEY, optionalLogSpec);
+
+        // log with normalized log level category
+        LogUtils.logWithLogLevel(logLevelCategory, logger, LogUtils.AUDIT_LOG_MARKER, message, args);
+
+        // clean up
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOG_LEVEL_CATEGORY_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.AUDIT_LOG_SPEC_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOGGER_CLASS_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.OPTIONAL_LOG_SPEC_KEY);
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final AuditLogSpec auditLogSpec,
+                    final String... args) {
+        log(logLevelCategory, message, auditLogSpec, null, args);
+    }
+
+    @Override
+    public void info(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        log(LogLevelCategory.INFO, message, auditLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void info(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        info(message, auditLogSpec, null, args);
+    }
+
+    @Override
+    public void warn(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        log(LogLevelCategory.WARN, message, auditLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void warn(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        warn(message, auditLogSpec, null, args);
+    }
+
+    @Override
+    public void error(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        log(LogLevelCategory.ERROR, message, auditLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void error(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        error(message, auditLogSpec, null, args);
+    }
+
+    @Override
+    public void fatal(final String message, final AuditLogSpec auditLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        log(LogLevelCategory.FATAL, message, auditLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void fatal(final String message, final AuditLogSpec auditLogSpec, final String... args) {
+        fatal(message, auditLogSpec, null, args);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/DebugLogImpl.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/DebugLogImpl.java
new file mode 100644 (file)
index 0000000..1e17f3b
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.DebugLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+import org.slf4j.Logger;
+
+
+/**
+ * Debug Log Logback Implementation
+ *
+ * @author Rajiv Singla
+ */
+public class DebugLogImpl implements DebugLog {
+
+    private final Logger logger;
+    private final Class<?> clazz;
+
+    public DebugLogImpl(final Logger logger, final Class<?> clazz) {
+        this.logger = logger;
+        this.clazz = clazz;
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final DebugLogSpec debugLogSpec,
+                    final OptionalLogSpec optionalLogSpec, final String... args) {
+
+        // if log level category is null throw an exception
+        if (logLevelCategory == null) {
+            throw new IllegalArgumentException("Log level category must not be null");
+        }
+
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOG_LEVEL_CATEGORY_KEY, logLevelCategory);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.DEBUG_LOG_SPEC_KEY, debugLogSpec);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOGGER_CLASS_KEY, clazz);
+        // optional fields
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.OPTIONAL_LOG_SPEC_KEY, optionalLogSpec);
+
+        // log with normalized log level category
+        LogUtils.logWithLogLevel(logLevelCategory, logger, LogUtils.DEBUG_LOG_MARKER, message, args);
+
+        // clean up
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOG_LEVEL_CATEGORY_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.DEBUG_LOG_SPEC_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOGGER_CLASS_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.OPTIONAL_LOG_SPEC_KEY);
+
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final DebugLogSpec debugLogSpec,
+                    final String... args) {
+        log(logLevelCategory, message, debugLogSpec, null, args);
+    }
+
+    @Override
+    public void debug(final String message, final DebugLogSpec debugLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        log(LogLevelCategory.DEBUG, message, debugLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void debug(final String message, final DebugLogSpec debugLogSpec, final String... args) {
+        debug(message, debugLogSpec, null, args);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/EELFLoggerContextImpl.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/EELFLoggerContextImpl.java
new file mode 100644 (file)
index 0000000..e5be1d8
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLoggerContext;
+import org.onap.dcae.utils.eelf.logger.api.spec.AppLogSpec;
+import org.onap.dcae.utils.eelf.logger.model.spec.AppLogSpecImpl;
+
+import static org.onap.dcae.utils.eelf.logger.logback.EELFLoggerDefaults.DEFAULT_APP_LOG_INFO;
+import static org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils.APP_LOG_SPEC_KEY;
+import static org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils.CUSTOM_MDC_MAP;
+
+
+/**
+ * Default EELF Logger Context which contains EELF Specs which are usually constant for entire life cycle of the
+ * application
+ *
+ * @author Rajiv Singla
+ */
+public class EELFLoggerContextImpl implements EELFLoggerContext {
+
+    @Override
+    public AppLogSpec getAppLogSpec() {
+        return CUSTOM_MDC_MAP.get(APP_LOG_SPEC_KEY) == null ? null : (AppLogSpec) CUSTOM_MDC_MAP.get(APP_LOG_SPEC_KEY);
+    }
+
+    @Override
+    public void setAppLogSpec(final AppLogSpec appLogSpec) {
+        if (appLogSpec == null) {
+            CUSTOM_MDC_MAP.put(APP_LOG_SPEC_KEY, new AppLogSpecImpl(DEFAULT_APP_LOG_INFO));
+        } else {
+            CUSTOM_MDC_MAP.put(APP_LOG_SPEC_KEY, appLogSpec);
+        }
+    }
+
+    @Override
+    public boolean isInitialized() {
+        return CUSTOM_MDC_MAP.get(APP_LOG_SPEC_KEY) == null;
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/EELFLoggerImpl.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/EELFLoggerImpl.java
new file mode 100644 (file)
index 0000000..3f1e716
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+
+import org.onap.dcae.utils.eelf.logger.api.log.AuditLog;
+import org.onap.dcae.utils.eelf.logger.api.log.DebugLog;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLoggerContext;
+import org.onap.dcae.utils.eelf.logger.api.log.ErrorLog;
+import org.onap.dcae.utils.eelf.logger.api.log.MetricLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * EELF Logger Logback Implementation
+ *
+ * @author Rajiv Singla
+ */
+public class EELFLoggerImpl implements EELFLogger {
+
+    private Logger logger;
+    private Class<?> clazz;
+
+    public EELFLoggerImpl() {
+        // no arg constructor required for Service Loader discovery
+    }
+
+    public EELFLoggerImpl(final Class<?> clazz) {
+        logger = LoggerFactory.getLogger(clazz);
+        this.clazz = clazz;
+    }
+
+
+    @Override
+    public AuditLog auditLog() {
+        return new AuditLogImpl(logger, clazz);
+    }
+
+    @Override
+    public MetricLog metricLog() {
+        return new MetricLogImpl(logger, clazz);
+    }
+
+    @Override
+    public ErrorLog errorLog() {
+        return new ErrorLogImpl(logger, clazz);
+    }
+
+    @Override
+    public DebugLog debugLog() {
+        return new DebugLogImpl(logger, clazz);
+    }
+
+    @Override
+    public EELFLoggerContext loggingContext() {
+        return new EELFLoggerContextImpl();
+    }
+
+    @Override
+    public String toString() {
+        return "EELF LOGBACK IMP";
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/ErrorLogImpl.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/ErrorLogImpl.java
new file mode 100644 (file)
index 0000000..5d8f272
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.ErrorLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+import org.slf4j.Logger;
+
+
+/**
+ * Error Log Logback Implementation
+ *
+ * @author Rajiv Singla
+ */
+public class ErrorLogImpl implements ErrorLog {
+
+    private final Logger logger;
+    private final Class<?> clazz;
+
+    public ErrorLogImpl(final Logger logger, final Class<?> clazz) {
+        this.logger = logger;
+        this.clazz = clazz;
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final ErrorLogSpec errorLogSpec,
+                    final OptionalLogSpec optionalLogSpec, final String... args) {
+
+        // if error log spec or log level category is null throw an exception
+        if (errorLogSpec == null || logLevelCategory == null) {
+            throw new IllegalArgumentException("Error Log Spec and Log level category must not be null");
+        }
+
+        // required fields
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOG_LEVEL_CATEGORY_KEY, logLevelCategory);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.ERROR_LOG_SPEC_KEY, errorLogSpec);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOGGER_CLASS_KEY, clazz);
+        // optional fields
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.OPTIONAL_LOG_SPEC_KEY, optionalLogSpec);
+
+        // log with normalized log level category
+        LogUtils.logWithLogLevel(logLevelCategory, logger, LogUtils.ERROR_LOG_MARKER, message, args);
+
+        // clean up
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOG_LEVEL_CATEGORY_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.ERROR_LOG_SPEC_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOGGER_CLASS_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.OPTIONAL_LOG_SPEC_KEY);
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final ErrorLogSpec errorLogSpec,
+                    final String... args) {
+        log(logLevelCategory, message, errorLogSpec, null, args);
+    }
+
+    @Override
+    public void error(final String message, final ErrorLogSpec errorLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        log(LogLevelCategory.ERROR, message, errorLogSpec, null, args);
+    }
+
+    @Override
+    public void error(final String message, final ErrorLogSpec errorLogSpec, final String... args) {
+        error(message, errorLogSpec, null, args);
+    }
+
+    @Override
+    public void warn(final String message, final ErrorLogSpec errorLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        log(LogLevelCategory.WARN, message, errorLogSpec, null, args);
+    }
+
+    @Override
+    public void warn(final String message, final ErrorLogSpec errorLogSpec, final String... args) {
+        warn(message, errorLogSpec, null, args);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/MetricLogImpl.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/log/MetricLogImpl.java
new file mode 100644 (file)
index 0000000..5857835
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.log.MetricLog;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.utils.LogUtils;
+import org.slf4j.Logger;
+
+/**
+ * Metric Log Logback Implementation
+ *
+ * @author Rajiv Singla
+ */
+public class MetricLogImpl implements MetricLog {
+
+    private final Logger logger;
+    private final Class<?> clazz;
+
+    public MetricLogImpl(final Logger logger, final Class<?> clazz) {
+        this.logger = logger;
+        this.clazz = clazz;
+    }
+
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final MetricLogSpec metricLogSpec,
+                    final OptionalLogSpec optionalLogSpec, final String... args) {
+
+        // if metric log spec or log level category is null throw an exception
+        if (metricLogSpec == null || logLevelCategory == null) {
+            throw new IllegalArgumentException("Metric Log Spec and Log level category must not be null");
+        }
+
+        // required fields
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOG_LEVEL_CATEGORY_KEY, logLevelCategory);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.METRIC_LOG_SPEC_KEY, metricLogSpec);
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.LOGGER_CLASS_KEY, clazz);
+        // optional fields
+        LogUtils.CUSTOM_MDC_MAP.put(LogUtils.OPTIONAL_LOG_SPEC_KEY, optionalLogSpec);
+
+        // log with normalized log level category
+        LogUtils.logWithLogLevel(logLevelCategory, logger, LogUtils.METRIC_LOG_MARKER, message, args);
+
+        // clean up
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOG_LEVEL_CATEGORY_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.METRIC_LOG_SPEC_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.LOGGER_CLASS_KEY);
+        LogUtils.CUSTOM_MDC_MAP.remove(LogUtils.OPTIONAL_LOG_SPEC_KEY);
+    }
+
+    @Override
+    public void log(final LogLevelCategory logLevelCategory, final String message, final MetricLogSpec metricLogSpec,
+                    final String... args) {
+        log(logLevelCategory, message, metricLogSpec, null, args);
+    }
+
+    @Override
+    public void info(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        log(LogLevelCategory.INFO, message, metricLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void info(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        log(LogLevelCategory.INFO, message, metricLogSpec, args);
+    }
+
+    @Override
+    public void warn(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                     final String... args) {
+        log(LogLevelCategory.WARN, message, metricLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void warn(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        warn(message, metricLogSpec, null, args);
+    }
+
+    @Override
+    public void error(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        log(LogLevelCategory.ERROR, message, metricLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void error(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        error(message, metricLogSpec, null, args);
+    }
+
+    @Override
+    public void fatal(final String message, final MetricLogSpec metricLogSpec, final OptionalLogSpec optionalLogSpec,
+                      final String... args) {
+        log(LogLevelCategory.FATAL, message, metricLogSpec, optionalLogSpec, args);
+    }
+
+    @Override
+    public void fatal(final String message, final MetricLogSpec metricLogSpec, final String... args) {
+        fatal(message, metricLogSpec, null, args);
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/CompositePropertyResolver.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/CompositePropertyResolver.java
new file mode 100644 (file)
index 0000000..e5f1bc1
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.resolver;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A composite property resolver can look under different resolvers in order of given property resolvers
+ *
+ * @author Rajiv Singla
+ */
+public class CompositePropertyResolver implements PropertyResolver {
+
+    private static final long serialVersionUID = 1L;
+
+    private final List<PropertyResolver> propertyResolvers;
+
+    public CompositePropertyResolver(PropertyResolver... propertyResolvers) {
+        this.propertyResolvers = Arrays.asList(propertyResolvers);
+    }
+
+    @Override
+    public String resolve(final List<String> propertyNames) {
+        // resolver property in given resolvers in the same order they are defined
+        for (PropertyResolver propertyResolver : propertyResolvers) {
+            final String propertyValue = propertyResolver.resolve(propertyNames);
+            if (propertyValue != null) {
+                return propertyValue;
+            }
+        }
+
+        return null;
+    }
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/EnvironmentPropertyResolver.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/EnvironmentPropertyResolver.java
new file mode 100644 (file)
index 0000000..8f3d59f
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.resolver;
+
+import java.util.List;
+
+/**
+ * Looks up Property values inside HOST environment variables
+ *
+ * @author Rajiv Singla
+ */
+public class EnvironmentPropertyResolver implements PropertyResolver {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public String resolve(final List<String> propertyNames) {
+
+        // check if system environment variables have property names set
+        for (final String propertyName : propertyNames) {
+            final String propertyValue = System.getenv(propertyName);
+            if (propertyValue != null) {
+                return propertyValue;
+            }
+        }
+
+        return null;
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/PropertyResolver.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/PropertyResolver.java
new file mode 100644 (file)
index 0000000..758de61
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.resolver;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * A resolver is used to resolve properties
+ *
+ * @author Rajiv Singla
+ */
+public interface PropertyResolver extends Serializable {
+
+    /**
+     * Returns resolved property value
+     *
+     * @param propertyNames names under which property can be found
+     *
+     * @return property value
+     */
+    String resolve(List<String> propertyNames);
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/SystemPropertyResolver.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/resolver/SystemPropertyResolver.java
new file mode 100644 (file)
index 0000000..674b00b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.resolver;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Resolve System Properties passed in by -DpropertyName=propertyValue when invoking
+ * via java command line arguments
+ *
+ * @author Rajiv Singla
+ */
+public class SystemPropertyResolver implements PropertyResolver {
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public String resolve(final List<String> propertyNames) {
+
+        // Get all system Properties
+        final Properties systemProperties = System.getProperties();
+
+        for (Map.Entry<Object, Object> systemEntries : systemProperties.entrySet()) {
+
+            if (systemEntries.getKey() instanceof String) {
+                final String systemKey = (String) systemEntries.getKey();
+
+                // if system properties contain any of the property names - ignoring case then return its value
+                for (String propertyName : propertyNames) {
+                    if (propertyName.equalsIgnoreCase(systemKey)) {
+                        return (String) systemEntries.getValue();
+                    }
+                }
+
+            }
+        }
+
+        return null;
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/utils/LogUtils.java b/eelf-logger/eelf-logger-logback-impl/src/main/java/org/onap/dcae/utils/eelf/logger/logback/utils/LogUtils.java
new file mode 100644 (file)
index 0000000..f5c558b
--- /dev/null
@@ -0,0 +1,590 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.utils;
+
+import ch.qos.logback.core.CoreConstants;
+import org.onap.dcae.utils.eelf.logger.api.info.AppLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.LogLevelCategory;
+import org.onap.dcae.utils.eelf.logger.api.info.NagiosAlertLevel;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestStatusCode;
+import org.onap.dcae.utils.eelf.logger.api.spec.AppLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.EELFLoggerDefaults;
+import org.onap.dcae.utils.eelf.logger.logback.resolver.CompositePropertyResolver;
+import org.onap.dcae.utils.eelf.logger.logback.resolver.EnvironmentPropertyResolver;
+import org.onap.dcae.utils.eelf.logger.logback.resolver.SystemPropertyResolver;
+import org.onap.dcae.utils.eelf.logger.model.info.AppLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.CodeLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.MessageLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestIdLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestTimingLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.AppLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.AuditLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.DebugLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.ErrorLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.MetricLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.OptionalLogSpecImpl;
+import org.slf4j.Logger;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.UUID;
+
+
+
+/**
+ * Contains various logging utility methods
+ *
+ * @author Rajiv Singla
+ */
+public abstract class LogUtils {
+
+    private static final String LOG_MESSAGE_DELIMITER = "|";
+    private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+    private static final String DATE_TIMEZONE = "UTC";
+    // property resolver which looks up system property and the environment properties
+    private static final CompositePropertyResolver COMPOSITE_PROPERTY_RESOLVER =
+            new CompositePropertyResolver(new SystemPropertyResolver(), new EnvironmentPropertyResolver());
+
+    // Custom MDC Map Keys
+    public static final String APP_LOG_SPEC_KEY = "APP_LOG_SPEC";
+    public static final String AUDIT_LOG_SPEC_KEY = "AUDIT_LOG_SPEC";
+    public static final String METRIC_LOG_SPEC_KEY = "METRIC_LOG_SPEC";
+    public static final String ERROR_LOG_SPEC_KEY = "ERROR_LOG_SPEC";
+    public static final String DEBUG_LOG_SPEC_KEY = "DEBUG_LOG_SPEC";
+    public static final String OPTIONAL_LOG_SPEC_KEY = "OPTIONAL_LOG_SPEC";
+    public static final String LOG_LEVEL_CATEGORY_KEY = "LOG_LEVEL_CATEGORY";
+    public static final String LOGGER_CLASS_KEY = "LOGGER_CLASS_KEY";
+
+    // markers
+    public static final Marker AUDIT_LOG_MARKER = MarkerFactory.getMarker("AUDIT_LOG");
+    public static final Marker METRIC_LOG_MARKER = MarkerFactory.getMarker("METRIC_LOG");
+    public static final Marker ERROR_LOG_MARKER = MarkerFactory.getMarker("ERROR_LOG");
+    public static final Marker DEBUG_LOG_MARKER = MarkerFactory.getMarker("DEBUG_LOG");
+
+
+    public static final Map<String, Object> CUSTOM_MDC_MAP = new ThreadLocal<Map<String, Object>>() {
+        @Override
+        protected Map<String, Object> initialValue() {
+            return new HashMap<>();
+        }
+    }.get();
+
+    public static final ThreadLocal<SimpleDateFormat> SIMPLE_DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
+        @Override
+        protected SimpleDateFormat initialValue() {
+            final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
+            simpleDateFormat.setTimeZone(TimeZone.getTimeZone(DATE_TIMEZONE));
+            return simpleDateFormat;
+        }
+    };
+
+
+    private LogUtils() {
+        // private constructor
+    }
+
+
+    /**
+     * Logs eomp message with normalized log level category
+     *
+     * @param logLevelCategory ecomp log level category
+     * @param logger logback logger
+     * @param marker logback marker
+     * @param message log message
+     * @param args log message arguments for interpolation
+     */
+    public static void logWithLogLevel(final LogLevelCategory logLevelCategory,
+                                       final Logger logger, final Marker marker,
+                                       final String message, final String... args) {
+        switch (logLevelCategory) {
+            case DEBUG:
+                logger.debug(marker, message, args);
+                break;
+            case INFO:
+                logger.info(marker, message, args);
+                break;
+            case WARN:
+                logger.warn(marker, message, args);
+                break;
+            default:
+                // fatal log level is treated as error also as logback does not have fatal level
+                logger.error(marker, message, args);
+        }
+    }
+
+
+    /**
+     * Returns value for {@link AppLogSpec}. If no {@link AppLogSpec} is defined a default app log spec is passed
+     *
+     * @return app log spec
+     */
+    public static AppLogSpec getAppLogSpec() {
+        final AppLogSpec appLogSpec = getCustomMapValue(APP_LOG_SPEC_KEY, AppLogSpec.class);
+        return appLogSpec == null ? new AppLogSpecImpl(EELFLoggerDefaults.DEFAULT_APP_LOG_INFO) : appLogSpec;
+    }
+
+    /**
+     * Populate default values of {@link OptionalLogSpec} if not present
+     *
+     * @param loggerClass logger class
+     * @param logLevelCategory log level category
+     *
+     * @return optional log spec with default values if not present
+     */
+    public static OptionalLogSpec getOptionalLogSpec(final Class<?> loggerClass, final LogLevelCategory
+            logLevelCategory) {
+
+        OptionalLogSpecImpl optionalLogSpec =
+                getCustomMapValue(OPTIONAL_LOG_SPEC_KEY, OptionalLogSpecImpl.class);
+
+        if (optionalLogSpec != null) {
+            // if message log info is empty populate default values
+            if (optionalLogSpec.getMessageLogInfo() == null ||
+                    optionalLogSpec.getCreationTimestamp() == null && optionalLogSpec.getAlertSeverity() == null &&
+                            optionalLogSpec.getStatusCode() == null) {
+                optionalLogSpec = optionalLogSpec.withMessageLogInfo(createDefaultMessageLogInfo(logLevelCategory));
+            }
+            // if code log info is empty populate default values
+            if (optionalLogSpec.getCodeLogInfo() == null ||
+                    optionalLogSpec.getClassName() == null && optionalLogSpec.getThreadId() == null) {
+                optionalLogSpec = optionalLogSpec.withCodeLogInfo(createDefaultCodeLogInfo(loggerClass));
+            }
+            // if custom fields log info is empty populate default values
+            if (optionalLogSpec.getCustomFieldsLogInfo() == null) {
+                optionalLogSpec =
+                        optionalLogSpec.withCustomFieldsLogInfo(EELFLoggerDefaults.DEFAULT_CUSTOM_FIELDS_LOG_INFO);
+            }
+            // if misc fields log info is empty populate default values
+            if (optionalLogSpec.getMiscLogInfo() == null) {
+                optionalLogSpec = optionalLogSpec.withMiscLogInfo(EELFLoggerDefaults.DEFAULT_MISC_LOG_INFO);
+            }
+        } else {
+            // optional log spec is null so create new optional log spec
+            optionalLogSpec = createDefaultOptionalLogSpec(loggerClass, logLevelCategory);
+        }
+
+        return optionalLogSpec;
+    }
+
+
+    /**
+     * Formats given date in ISO 8601 format
+     *
+     * @param date Date object
+     *
+     * @return formatted date string
+     */
+    public static String formatDate(final Date date) {
+        if (date == null) {
+            return "";
+        }
+        return SIMPLE_DATE_FORMAT.get().format(date);
+    }
+
+    /**
+     * Creates log message string
+     *
+     * @param logValues log message values
+     *
+     * @return log message string
+     */
+    public static String createLogMessageString(final String[] logValues) {
+        final StringBuffer stringBuffer = new StringBuffer(512);
+        for (int i = 0; i < logValues.length; i++) {
+            final String logValue = logValues[i];
+            stringBuffer.append(logValue != null ? logValue : "");
+            if (i != logValues.length - 1) {
+                stringBuffer.append(LOG_MESSAGE_DELIMITER);
+            }
+        }
+        stringBuffer.append(CoreConstants.LINE_SEPARATOR);
+        return stringBuffer.toString();
+    }
+
+    /**
+     * Gets custom MDC value from Custom MDC Map for give key. Returns null if no value can be found
+     *
+     * @param key MDC Map key
+     * @param clazz expected value class type
+     * @param <T> class type
+     *
+     * @return value inside Custom MDC Map
+     */
+    private static <T> T getCustomMapValue(final String key, final Class<T> clazz) {
+        final Object value = CUSTOM_MDC_MAP.get(key);
+        if (value != null) {
+            return clazz.cast(value);
+        }
+        return null;
+    }
+
+
+    /**
+     * Get current Metric log spec from the custom MDC map and populates default values if not present
+     *
+     * @return Metric log spec
+     */
+    public static MetricLogSpec getMetricLogSpec() {
+        MetricLogSpecImpl metricLogSpec = getCustomMapValue(METRIC_LOG_SPEC_KEY, MetricLogSpecImpl.class);
+
+        if (metricLogSpec != null) {
+            if (metricLogSpec.getRequestIdLogInfo() == null || metricLogSpec.getRequestId() == null) {
+                metricLogSpec = metricLogSpec.withRequestIdLogInfo(createNewRequestIdLogInfo());
+            }
+            if (metricLogSpec.getServiceLogInfo() == null) {
+                metricLogSpec = metricLogSpec.withServiceLogInfo(EELFLoggerDefaults.DEFAULT_SERVICE_LOG_INFO);
+            }
+            if (metricLogSpec.getRequestTimingLogInfo() == null || metricLogSpec.getBeginTimestamp() == null ||
+                    metricLogSpec.getEndTimestamp() == null) {
+                metricLogSpec =
+                        metricLogSpec.withRequestTimingLogInfo(EELFLoggerDefaults.DEFAULT_REQUEST_TIMING_LOG_INFO);
+            }
+            if (metricLogSpec.getResponseLogInfo() == null) {
+                metricLogSpec = metricLogSpec.withResponseLogInfo(EELFLoggerDefaults.DEFAULT_RESPONSE_LOG_INFO);
+            }
+            final Date beginTimestamp = metricLogSpec.getBeginTimestamp();
+            final Date endTimestamp = metricLogSpec.getEndTimestamp();
+            final Long elapsedTime = metricLogSpec.getElapsedTime();
+            if (endTimestamp != null && beginTimestamp != null && elapsedTime == null) {
+                final RequestTimingLogInfoImpl requestTimingLogInfo =
+                        new RequestTimingLogInfoImpl(beginTimestamp, endTimestamp,
+                                endTimestamp.getTime() - beginTimestamp.getTime());
+                metricLogSpec = metricLogSpec.withRequestTimingLogInfo(requestTimingLogInfo);
+            }
+            if (metricLogSpec.getTargetServiceLogInfo() == null) {
+                metricLogSpec =
+                        metricLogSpec.withTargetServiceLogInfo(EELFLoggerDefaults.DEFAULT_TARGET_SERVICE_LOG_INFO);
+            }
+        } else {
+            throw new IllegalArgumentException("Metric Log Spec must not be null");
+        }
+
+        return metricLogSpec;
+    }
+
+    /**
+     * Get current Debug log spec from the custom MDC map and populates default values if not present
+     *
+     * @return Debug log spec
+     */
+    public static DebugLogSpec getDebugLogSpec() {
+        final DebugLogSpecImpl debugLogSpec = getCustomMapValue(DEBUG_LOG_SPEC_KEY, DebugLogSpecImpl.class);
+        if (debugLogSpec == null || debugLogSpec.getRequestIdLogInfo() == null || debugLogSpec.getRequestId() == null) {
+            return new DebugLogSpecImpl(createNewRequestIdLogInfo());
+        }
+        return debugLogSpec;
+    }
+
+    /**
+     * Get current Error log spec from the custom MDC map and populates default values if not present
+     *
+     * @return Error log spec
+     */
+    public static ErrorLogSpec getErrorLogSpec() {
+        ErrorLogSpecImpl errorLogSpec = getCustomMapValue(ERROR_LOG_SPEC_KEY, ErrorLogSpecImpl.class);
+        if (errorLogSpec != null) {
+
+            if (errorLogSpec.getRequestIdLogInfo() == null || errorLogSpec.getRequestId() == null) {
+                errorLogSpec = errorLogSpec.withRequestIdLogInfo(createNewRequestIdLogInfo());
+            }
+            if (errorLogSpec.getServiceLogInfo() == null) {
+                errorLogSpec = errorLogSpec.withServiceLogInfo(EELFLoggerDefaults.DEFAULT_SERVICE_LOG_INFO);
+            }
+            if (errorLogSpec.getTargetServiceLogInfo() == null) {
+                errorLogSpec =
+                        errorLogSpec.withTargetServiceLogInfo(EELFLoggerDefaults.DEFAULT_TARGET_SERVICE_LOG_INFO);
+            }
+            if (errorLogSpec.getErrorLogInfo() == null) {
+                errorLogSpec = errorLogSpec.withErrorLogInfo(EELFLoggerDefaults.DEFAULT_ERROR_LOG_INFO);
+            }
+
+        } else {
+            throw new IllegalArgumentException("Error Log Spec cannot be null");
+        }
+        return errorLogSpec;
+    }
+
+
+    /**
+     * Get current Audit log spec from the custom MDC map and populates default values if not present
+     *
+     * @return Audit log spec
+     */
+    public static AuditLogSpec getAuditLogSpec() {
+        AuditLogSpecImpl auditLogSpec = getCustomMapValue(AUDIT_LOG_SPEC_KEY, AuditLogSpecImpl.class);
+        if (auditLogSpec != null) {
+            if (auditLogSpec.getServiceLogInfo() == null) {
+                auditLogSpec = auditLogSpec.withServiceLogInfo(EELFLoggerDefaults.DEFAULT_SERVICE_LOG_INFO);
+            }
+            if (auditLogSpec.getRequestIdLogInfo() == null || auditLogSpec.getRequestId() == null) {
+                auditLogSpec = auditLogSpec.withRequestIdLogInfo(createNewRequestIdLogInfo());
+            }
+            if (auditLogSpec.getResponseLogInfo() == null) {
+                auditLogSpec = auditLogSpec.withResponseLogInfo(EELFLoggerDefaults.DEFAULT_RESPONSE_LOG_INFO);
+            }
+
+            if (auditLogSpec.getRequestTimingLogInfo() == null || auditLogSpec.getBeginTimestamp() == null ||
+                    auditLogSpec.getEndTimestamp() == null) {
+                auditLogSpec =
+                        auditLogSpec.withRequestTimingLogInfo(EELFLoggerDefaults.DEFAULT_REQUEST_TIMING_LOG_INFO);
+            }
+            final Date beginTimestamp = auditLogSpec.getBeginTimestamp();
+            final Date endTimestamp = auditLogSpec.getEndTimestamp();
+            final Long elapsedTime = auditLogSpec.getElapsedTime();
+            if (endTimestamp != null && beginTimestamp != null && elapsedTime == null) {
+                final RequestTimingLogInfoImpl requestTimingLogInfo =
+                        new RequestTimingLogInfoImpl(beginTimestamp, endTimestamp,
+                                endTimestamp.getTime() - beginTimestamp.getTime());
+                auditLogSpec = auditLogSpec.withRequestTimingLogInfo(requestTimingLogInfo);
+            }
+
+        } else {
+            throw new IllegalArgumentException("Audit Log Spec cannot be null");
+        }
+
+        return auditLogSpec;
+    }
+
+
+    private static RequestIdLogInfo createNewRequestIdLogInfo() {
+        return new RequestIdLogInfoImpl(UUID.randomUUID().toString());
+    }
+
+    /**
+     * Return Log Level Category from MDC Map
+     *
+     * @return log level category
+     */
+    public static Class<?> getLoggerClass() {
+        final Class<?> loggerClass = getCustomMapValue(LOGGER_CLASS_KEY, Class.class);
+        // logger class must always be non null
+        if (loggerClass != null) {
+            return loggerClass;
+        }
+        return LogUtils.class.getClass();
+    }
+
+
+    /**
+     * Return Log Level Category from MDC Map
+     *
+     * @return log level category
+     */
+    public static LogLevelCategory getLogLevelCategory() {
+        final LogLevelCategory logLevelCategory = getCustomMapValue(LOG_LEVEL_CATEGORY_KEY, LogLevelCategory.class);
+        if (logLevelCategory != null) {
+            return logLevelCategory;
+        }
+        return LogLevelCategory.ERROR;
+    }
+
+    /**
+     * Creates Default Optional Log spec
+     *
+     * @param loggerClass logger class name
+     * @param logLevelCategory Log leve category
+     *
+     * @return default optional log spec
+     */
+    private static OptionalLogSpecImpl createDefaultOptionalLogSpec(final Class<?> loggerClass,
+                                                                    final LogLevelCategory logLevelCategory) {
+        return new OptionalLogSpecImpl(createDefaultMessageLogInfo(logLevelCategory),
+                createDefaultCodeLogInfo(loggerClass), EELFLoggerDefaults.DEFAULT_CUSTOM_FIELDS_LOG_INFO,
+                EELFLoggerDefaults.DEFAULT_MISC_LOG_INFO);
+    }
+
+
+    /**
+     * Creates Default Code Log Info
+     *
+     * @param loggerClass logger class name
+     *
+     * @return default code log info
+     */
+    private static CodeLogInfoImpl createDefaultCodeLogInfo(final Class<?> loggerClass) {
+        // thread id can be extracted from the framework
+        return new CodeLogInfoImpl(null, loggerClass != null ? loggerClass.getName() : "");
+    }
+
+
+    /**
+     * Creates Default Message Log Info
+     *
+     * @param logLevelCategory Log leve category
+     *
+     * @return default message log info
+     */
+    private static MessageLogInfoImpl createDefaultMessageLogInfo(final LogLevelCategory logLevelCategory) {
+        return new MessageLogInfoImpl(new Date(),
+                getStatusCode(logLevelCategory),
+                getNagiosAlertLevel(logLevelCategory));
+    }
+
+
+    /**
+     * Creates Default App Log Spec
+     *
+     * @return default APP log Spec
+     */
+    public static AppLogInfoImpl createDefaultAppLogInfo() {
+        final String serviceInstanceId =
+                resolveProperty(null, AppLogInfo.Defaults.DEFAULT_SERVICE_INSTANCE_ID,
+                        "SERVICE_NAME", "ServiceInstanceId", "SERVICE_INSTANCE_ID");
+        final String instanceUUID =
+                resolveProperty(null, AppLogInfo.Defaults.DEFAULT_INSTANCE_UUID,
+                        "InstanceUUID", "INSTANCE_UUID");
+        final String virtualServerName =
+                resolveProperty(null, AppLogInfo.Defaults.DEFAULT_VIRTUAL_SERVER_NAME,
+                        "VirtualServerName", "VIRTUAL_SERVER_NAME");
+        final String serverIPAddress = getHostIPAddress() != null ?
+                getHostIPAddress() : AppLogInfo.Defaults.DEFAULT_SERVER_IP_ADDRESS;
+        final String serverFQDN = getHostName() != null ? getHostName() : AppLogInfo.Defaults.DEFAULT_SERVER_FQDN;
+        return new AppLogInfoImpl(serviceInstanceId, instanceUUID, virtualServerName, serverIPAddress, serverFQDN);
+    }
+
+
+    /**
+     * Returns status code based on log level category
+     *
+     * @param logLevelCategory log level category
+     *
+     * @return request status code as string based on log level category
+     */
+    private static RequestStatusCode getStatusCode(final LogLevelCategory logLevelCategory) {
+        if (logLevelCategory == LogLevelCategory.DEBUG || logLevelCategory == LogLevelCategory.INFO ||
+                logLevelCategory == LogLevelCategory.WARN) {
+            return RequestStatusCode.COMPLETE;
+        } else {
+            return RequestStatusCode.ERROR;
+        }
+    }
+
+    /**
+     * Returns nagios Alert level based on log level category
+     *
+     * @param logLevelCategory log level category
+     *
+     * @return nagios alert level
+     */
+    private static NagiosAlertLevel getNagiosAlertLevel(final LogLevelCategory logLevelCategory) {
+        switch (logLevelCategory) {
+            case DEBUG:
+                return NagiosAlertLevel.OK;
+            case INFO:
+                return NagiosAlertLevel.OK;
+            case WARN:
+                return NagiosAlertLevel.WARNING;
+            case ERROR:
+                return NagiosAlertLevel.CRITICAL;
+            case FATAL:
+                return NagiosAlertLevel.CRITICAL;
+            default:
+                return NagiosAlertLevel.UNKNOWN;
+        }
+    }
+
+    /**
+     * Resolves property value if not present
+     *
+     * @param userPassedValue user passed property value
+     * @param defaultValue default value if no value is found after resolving the property
+     * @param propertyNames property names
+     *
+     * @return resolved property value
+     */
+    private static String resolveProperty(
+            final String userPassedValue, final String defaultValue, final String... propertyNames) {
+        // if user passed is present return that value
+        if (userPassedValue != null) {
+            return userPassedValue;
+        }
+        // resolve it using composite resolver
+        final String resolveProperty = resolveProperty(Arrays.asList(propertyNames));
+        return resolveProperty != null ? resolveProperty : defaultValue;
+    }
+
+    /**
+     * Resolves property values in different places
+     *
+     * @param propertyNames property Names
+     *
+     * @return property Value
+     */
+    private static String resolveProperty(final List<String> propertyNames) {
+        return COMPOSITE_PROPERTY_RESOLVER.resolve(propertyNames);
+    }
+
+
+    /**
+     * Determine host IP Address
+     *
+     * @return host ip address
+     */
+    private static String getHostIPAddress() {
+        final InetAddress inetAddress = getInetAddress();
+        if (inetAddress != null) {
+            return inetAddress.getHostAddress();
+        }
+        return null;
+    }
+
+    /**
+     * Determines fully qualified host name
+     *
+     * @return fully qualified host name
+     */
+    private static String getHostName() {
+        final InetAddress inetAddress = getInetAddress();
+        if (inetAddress != null) {
+            return inetAddress.getCanonicalHostName();
+        }
+        return null;
+    }
+
+    /**
+     * Fetches Inet Address
+     *
+     * @return Inet Address
+     */
+    private static InetAddress getInetAddress() {
+        try {
+            return InetAddress.getLocalHost();
+        } catch (UnknownHostException e) {
+            return null;
+        }
+    }
+
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/resources/META-INF/services/org.onap.dcae.utils.eelf.logger.api.log.EELFLogger b/eelf-logger/eelf-logger-logback-impl/src/main/resources/META-INF/services/org.onap.dcae.utils.eelf.logger.api.log.EELFLogger
new file mode 100644 (file)
index 0000000..d7d5c71
--- /dev/null
@@ -0,0 +1,20 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
+
+org.onap.dcae.utils.eelf.logger.logback.log.EELFLoggerImpl
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-async-appenders.xml b/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-async-appenders.xml
new file mode 100644 (file)
index 0000000..e2e93e4
--- /dev/null
@@ -0,0 +1,55 @@
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<included>
+
+    <!--
+        ASYNC APPENDERS CAN BE USED TO INCREASE THE PERFORMANCE OF ECOMP LOGGING, HOWEVER, ASYNC LOGGERS
+        CAN DROP MESSAGES IF QUEUE SIZE IF FULL AND DURING SHUT DOWN TIME.
+
+        SO INCREASED PERFORMANCE AT THE COST OF LESS RELIABLE LOGGING
+     -->
+
+    <appender name="asyncAuditLogAppender" class="ch.qos.logback.classic.AsyncAppender">
+        <queueSize>${queueSize}</queueSize>
+        <maxFlushTime>${maxFlushTime}</maxFlushTime>
+        <appender-ref ref="auditLogAppender"/>
+    </appender>
+
+    <appender name="asyncMetricLogAppender" class="ch.qos.logback.classic.AsyncAppender">
+        <queueSize>${queueSize}</queueSize>
+        <maxFlushTime>${maxFlushTime}</maxFlushTime>
+        <appender-ref ref="metricLogAppender"/>
+    </appender>
+
+    <appender name="asyncErrorLogAppender" class="ch.qos.logback.classic.AsyncAppender">
+        <queueSize>${queueSize}</queueSize>
+        <maxFlushTime>${maxFlushTime}</maxFlushTime>
+        <appender-ref ref="errorLogAppender"/>
+    </appender>
+
+    <appender name="asyncDebugLogAppender" class="ch.qos.logback.classic.AsyncAppender">
+        <queueSize>${queueSize}</queueSize>
+        <maxFlushTime>${maxFlushTime}</maxFlushTime>
+        <appender-ref ref="debugLogAppender"/>
+    </appender>
+
+</included>
+
+
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-defaults.xml b/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-defaults.xml
new file mode 100644 (file)
index 0000000..f9bb078
--- /dev/null
@@ -0,0 +1,51 @@
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<included>
+
+    <!-- LOG DIRECTORIES -->
+    <property scope="context" name="logDir" value="logs"/>
+    <property scope="context" name="debugDir" value="debug-logs"/>
+
+    <!-- SETUP LOG DIRECTORIES -->
+    <property scope="context" name="logDirectory" value="${logDir}/${componentName}"/>
+    <property scope="context" name="debugLogDirectory" value="${debugDir}/${componentName}"/>
+
+    <!--
+    MODIFY LOG DIR ON WINDOWS OS SO THAT TEST LOGS ARE UNDER TARGET DIR CAN BE CLEANED AFTER TESTS AUTOMATICALLY
+     -->
+    <property scope="context" name="modifyLogPathInWindows" value="true" />
+    <property scope="context" name="appendDirectory" value="target" />
+
+    <!-- LOG FILE NAMES -->
+    <property scope="context" name="metricLogName" value="metrics"/>
+    <property scope="context" name="auditLogName" value="audit"/>
+    <property scope="context" name="errorLogName" value="error"/>
+    <property scope="context" name="debugLogName" value="debug"/>
+
+    <!-- ROLLING FILE APPENDER DEFAULT SETTINGS -->
+    <property scope="context" name="minFileIndex" value="1"/>
+    <property scope="context" name="maxFileIndex" value="10"/>
+    <property scope="context" name="maxFileSize" value="2500KB"/>
+
+    <!-- ASYNC APPENDER DEFAULT SETTINGS -->
+    <property scope="context" name="queueSize" value="1024"/>
+    <property scope="context" name="maxFlushTime" value="5000"/>
+
+</included>
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-logback.xml b/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-logback.xml
new file mode 100644 (file)
index 0000000..7e08eb2
--- /dev/null
@@ -0,0 +1,45 @@
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<included>
+
+    <include resource="eelf-defaults.xml"/>
+
+    <!-- CUSTOM STARTUP LISTENER REQUIRED TO SETUP DEFAULT APP LOG INFO DURING STARTUP TIME-->
+    <contextListener class="org.onap.dcae.utils.eelf.logger.logback.listener.LogbackStartupListener"/>
+
+    <!-- ADD REQUIRED APPENDERS -->
+    <include resource="eelf-required-appenders.xml"/>
+
+    <!-- ADD OPTIONAL APPENDERS: NOT ADDED BY DEFAULT -->
+    <!--<include resource="eelf-optional-appenders.xml"/>-->
+
+
+    <root level="DEBUG">
+        <!-- required appenders -->
+        <appender-ref ref="auditLogAppender"/>
+        <appender-ref ref="metricLogAppender"/>
+        <appender-ref ref="errorLogAppender"/>
+
+        <!-- optional appenders: not added by default -->
+        <!--<appender-ref ref="debugLogAppender"/>-->
+        <!--<appender-ref ref="STDOUT"/>-->
+    </root>
+
+</included>
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-optional-appenders.xml b/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-optional-appenders.xml
new file mode 100644 (file)
index 0000000..fb7ec7f
--- /dev/null
@@ -0,0 +1,68 @@
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<included>
+
+    <!--
+     ============================= DEBUG LOG APPENDER ================================
+     -->
+    <appender name="debugLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+        <filter class="org.onap.dcae.utils.eelf.logger.logback.filter.MarkerFilter">
+            <markers>DEBUG_LOG</markers>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+
+        <file>${debugLogDirectory}/${debugLogName}.log</file>
+
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+            <fileNamePattern>${logDirectory}/${debugLogName}.%i.log.zip</fileNamePattern>
+            <minIndex>${minFileIndex}</minIndex>
+            <maxIndex>${maxFileIndex}</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+            <maxFileSize>${maxFileSize}</maxFileSize>
+        </triggeringPolicy>
+
+        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
+            <layout class="org.onap.dcae.utils.eelf.logger.logback.layout.DebugLogLayout"/>
+        </encoder>
+
+    </appender>
+
+
+    <!--
+      ============================= CONSOLE APPENDER ================================
+     -->
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+
+        <filter class="org.onap.dcae.utils.eelf.logger.logback.filter.MarkerFilter">
+            <markers>METRIC_LOG,AUDIT_LOG,ERROR_LOG,DEBUG_LOG</markers>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+
+        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
+            <layout class="org.onap.dcae.utils.eelf.logger.logback.layout.ConsoleLayout"/>
+        </encoder>
+    </appender>
+
+</included>
diff --git a/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-required-appenders.xml b/eelf-logger/eelf-logger-logback-impl/src/main/resources/eelf-required-appenders.xml
new file mode 100644 (file)
index 0000000..72f1a5d
--- /dev/null
@@ -0,0 +1,112 @@
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<included>
+
+    <!--
+     ============================= AUDIT LOG APPENDER ================================
+     -->
+    <appender name="auditLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+        <filter class="org.onap.dcae.utils.eelf.logger.logback.filter.MarkerFilter">
+            <markers>AUDIT_LOG</markers>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+
+        <file>${logDirectory}/${auditLogName}.log</file>
+
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+            <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip</fileNamePattern>
+            <minIndex>${minFileIndex}</minIndex>
+            <maxIndex>${maxFileIndex}</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+            <maxFileSize>${maxFileSize}</maxFileSize>
+        </triggeringPolicy>
+
+        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
+            <layout class="org.onap.dcae.utils.eelf.logger.logback.layout.AuditLogLayout"/>
+        </encoder>
+
+    </appender>
+
+
+    <!--
+     ============================= METRIC LOG APPENDER ================================
+     -->
+    <appender name="metricLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+        <filter class="org.onap.dcae.utils.eelf.logger.logback.filter.MarkerFilter">
+            <markers>METRIC_LOG</markers>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+
+        <file>${logDirectory}/${metricLogName}.log</file>
+
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+            <fileNamePattern>${logDirectory}/${metricLogName}.%i.log.zip</fileNamePattern>
+            <minIndex>${minFileIndex}</minIndex>
+            <maxIndex>${maxFileIndex}</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+            <maxFileSize>${maxFileSize}</maxFileSize>
+        </triggeringPolicy>
+
+        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
+            <layout class="org.onap.dcae.utils.eelf.logger.logback.layout.MetricLogLayout"/>
+        </encoder>
+
+    </appender>
+
+
+    <!--
+     ============================= ERROR LOG APPENDER ================================
+    -->
+    <appender name="errorLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+
+        <filter class="org.onap.dcae.utils.eelf.logger.logback.filter.MarkerFilter">
+            <markers>ERROR_LOG</markers>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+
+        <file>${logDirectory}/${errorLogName}.log</file>
+
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+            <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip</fileNamePattern>
+            <minIndex>${minFileIndex}</minIndex>
+            <maxIndex>${maxFileIndex}</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+            <maxFileSize>${maxFileSize}</maxFileSize>
+        </triggeringPolicy>
+
+        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
+            <layout class="org.onap.dcae.utils.eelf.logger.logback.layout.ErrorLogLayout"/>
+        </encoder>
+
+    </appender>
+
+
+</included>
diff --git a/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/BaseLogbackUnitTest.java b/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/BaseLogbackUnitTest.java
new file mode 100644 (file)
index 0000000..fda4355
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback;
+
+
+import org.onap.dcae.utils.eelf.logger.api.info.CodeLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.CustomFieldsLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ErrorLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.MessageLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.MiscLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.NagiosAlertLevel;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestStatusCode;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestTimingLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+import org.onap.dcae.utils.eelf.logger.model.info.CodeLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.CustomFieldsLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ErrorLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.MessageLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.MiscLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestIdLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.RequestTimingLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ResponseLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.ServiceLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.info.TargetServiceLogInfoImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.AuditLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.DebugLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.ErrorLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.MetricLogSpecImpl;
+import org.onap.dcae.utils.eelf.logger.model.spec.OptionalLogSpecImpl;
+
+import java.util.Date;
+
+/**
+ * Base Logback Unit Test.
+ *
+ * @author Rajiv Singla
+ */
+public abstract class BaseLogbackUnitTest {
+
+    protected static final String TEST_SERVICE_INSTANCE_ID = "testServiceInstanceID";
+    protected static final String TEST_INSTANCE_UUID = "";
+
+    static {
+        System.setProperty("ServiceInstanceId", TEST_SERVICE_INSTANCE_ID);
+        System.setProperty("InstanceUUID", TEST_INSTANCE_UUID);
+    }
+
+    protected static final String TEST_REQUEST_ID = "403cdad8-4de7-450d-b441-561001decdd6";
+    protected static final String TEST_SERVICE_NAME = "testServiceName";
+    protected static final String TEST_PARTNER_NAME = "testPartnerName";
+    protected static final String TEST_CLIENT_IP_ADDRESS = "";
+
+    protected static final Date START_DATE = new Date();
+    protected static final Date END_DATE = new Date(new Date().getTime() + 30_000);
+    protected static final Long ELAPSED_TIME = END_DATE.getTime() - START_DATE.getTime();
+
+    protected static final Integer RESPONSE_CODE = 200;
+    protected static final String RESPONSE_DESCRIPTION = "TEST RESPONSE DESCRIPTION";
+
+    protected static final String TEST_TARGET_ENTITY = "testTargetEntity";
+    protected static final String TEST_TARGET_SERVICE_NAME = "testTargetServiceName";
+    protected static final String TEST_TARGET_VIRTUAL_ENTITY = "testTargetVirtualEntity";
+
+
+    protected static final String TEST_THREAD_ID = "testThreadId";
+    protected static final String TEST_CLASS_NAME = "testClassName";
+
+    protected static final String TEST_CUSTOM_FIELD1 = "testCustomField1";
+    protected static final String TEST_CUSTOM_FIELD2 = "testCustomField2";
+    protected static final String TEST_CUSTOM_FIELD3 = "testCustomField3";
+    protected static final String TEST_CUSTOM_FIELD4 = "testCustomField4";
+
+    protected static final String TEST_PROCESS_KEY = "testProcessId";
+
+    protected static final Integer TEST_ERROR_CODE = 500;
+    protected static final String TEST_ERROR_CODE_DESCRIPTION = "TEST ERROR CODE DESCRIPTION";
+
+
+    protected static RequestIdLogInfo getTestRequestIdLogInfo() {
+        return new RequestIdLogInfoImpl(TEST_REQUEST_ID);
+    }
+
+    protected static ServiceLogInfo getTestServiceLogInfo() {
+        return new ServiceLogInfoImpl(TEST_SERVICE_NAME, TEST_PARTNER_NAME, TEST_CLIENT_IP_ADDRESS);
+    }
+
+    protected static RequestTimingLogInfo getTestRequestTimingInfo() {
+        return new RequestTimingLogInfoImpl(START_DATE, END_DATE, ELAPSED_TIME);
+    }
+
+    protected static ResponseLogInfo getTestResponseLogInfo() {
+        return new ResponseLogInfoImpl(RESPONSE_CODE, RESPONSE_DESCRIPTION);
+    }
+
+    protected static AuditLogSpec getTestAuditLogSpec() {
+        return new AuditLogSpecImpl(getTestRequestIdLogInfo(), getTestServiceLogInfo(),
+                getTestRequestTimingInfo(), getTestResponseLogInfo());
+    }
+
+    protected static DebugLogSpec getTestDebugLogSpec() {
+        return new DebugLogSpecImpl(getTestRequestIdLogInfo());
+    }
+
+    protected static TargetServiceLogInfo getTestTargetServiceLogInfo() {
+        return new TargetServiceLogInfoImpl(TEST_TARGET_ENTITY, TEST_TARGET_SERVICE_NAME, TEST_TARGET_VIRTUAL_ENTITY);
+    }
+
+    protected static MetricLogSpec getTestMetricLogSpec() {
+        return new MetricLogSpecImpl(getTestRequestIdLogInfo(), getTestServiceLogInfo(),
+                getTestRequestTimingInfo(), getTestResponseLogInfo(), getTestTargetServiceLogInfo());
+    }
+
+    protected static ErrorLogInfo getTestErrorLogInfo() {
+        return new ErrorLogInfoImpl(TEST_ERROR_CODE, TEST_ERROR_CODE_DESCRIPTION);
+    }
+
+    protected static ErrorLogSpec getTestErrorLogSpec() {
+        return new ErrorLogSpecImpl(getTestRequestIdLogInfo(), getTestServiceLogInfo(), getTestTargetServiceLogInfo()
+                , getTestErrorLogInfo());
+    }
+
+    protected static OptionalLogSpec getTestOptionalLogSpec() {
+        final MessageLogInfo messageLogInfo = new MessageLogInfoImpl(new Date(), RequestStatusCode.COMPLETE,
+                NagiosAlertLevel.OK);
+        final CodeLogInfo codeLogInfo = new CodeLogInfoImpl(TEST_THREAD_ID, TEST_CLASS_NAME);
+        final CustomFieldsLogInfo customFieldsLogInfo = new CustomFieldsLogInfoImpl(TEST_CUSTOM_FIELD1,
+                TEST_CUSTOM_FIELD2, TEST_CUSTOM_FIELD3, TEST_CUSTOM_FIELD4);
+        final MiscLogInfo miscLogInfo = new MiscLogInfoImpl(TEST_PROCESS_KEY, "");
+        return new OptionalLogSpecImpl(messageLogInfo, codeLogInfo, customFieldsLogInfo, miscLogInfo);
+    }
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/AuditLogImplTest.java b/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/AuditLogImplTest.java
new file mode 100644 (file)
index 0000000..e50f697
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+import org.junit.Test;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.BaseLogbackUnitTest;
+import org.onap.dcae.utils.eelf.logger.logback.EELFLoggerDefaults;
+import org.onap.dcae.utils.eelf.logger.model.spec.AuditLogSpecImpl;
+
+/**
+ * Tests for Audit log implementations.
+ *
+ * @author Rajiv Singla
+ */
+public class AuditLogImplTest extends BaseLogbackUnitTest {
+
+    private static final EELFLogger log = EELFLogFactory.getLogger(AuditLogImplTest.class);
+
+    @Test
+    public void auditLoggerTest() throws Exception {
+
+        log.auditLog().info("Test Audit info message: {}",
+                getTestAuditLogSpec(), getTestOptionalLogSpec(), "infoArg");
+
+        final AuditLogSpec emptyAuditLog = new AuditLogSpecImpl(null, null,
+                null, null);
+
+        log.auditLog().info("Test Empty Audit info message.", emptyAuditLog,
+                EELFLoggerDefaults.DEFAULT_OPTIONAL_LOG_SPEC);
+
+    }
+
+
+    @Test
+    public void auditLoggerTestWithWarnLogLevel() throws Exception {
+        log.auditLog().warn("Test Audit warn message: {}",
+                getTestAuditLogSpec(), getTestOptionalLogSpec(), "warnArg");
+    }
+
+    @Test
+    public void auditLoggerTestWithErrorLogLevel() throws Exception {
+        log.auditLog().error("Test Audit error message: {}",
+                getTestAuditLogSpec(), getTestOptionalLogSpec(), "errorArg");
+
+    }
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/DebugLogImplTest.java b/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/DebugLogImplTest.java
new file mode 100644 (file)
index 0000000..1bff007
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+import org.junit.Test;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.BaseLogbackUnitTest;
+import org.onap.dcae.utils.eelf.logger.logback.EELFLoggerDefaults;
+import org.onap.dcae.utils.eelf.logger.model.spec.DebugLogSpecImpl;
+
+
+/**
+ * Test for Debug log implementation.
+ *
+ * @author Rajiv Singla
+ */
+public class DebugLogImplTest extends BaseLogbackUnitTest {
+
+    private static final EELFLogger log = EELFLogFactory.getLogger(DebugLogImplTest.class);
+
+    @Test
+    public void debugLoggerTest() throws Exception {
+
+        log.debugLog().debug("Test DebugLog debug message: {}",
+                getTestDebugLogSpec(), getTestOptionalLogSpec(), "debugArg");
+
+        final DebugLogSpec emptyDebugLog = new DebugLogSpecImpl(null);
+
+        log.debugLog().debug("Test Empty DebugLog debug message.", emptyDebugLog,
+                EELFLoggerDefaults.DEFAULT_OPTIONAL_LOG_SPEC);
+
+    }
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/ErrorLogImplTest.java b/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/ErrorLogImplTest.java
new file mode 100644 (file)
index 0000000..529b7cb
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+import org.junit.Test;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.BaseLogbackUnitTest;
+import org.onap.dcae.utils.eelf.logger.logback.EELFLoggerDefaults;
+import org.onap.dcae.utils.eelf.logger.model.spec.ErrorLogSpecImpl;
+
+
+/**
+ * Tests for Error Log implementation.
+ *
+ * @author Rajiv Singla
+ */
+public class ErrorLogImplTest extends BaseLogbackUnitTest {
+
+    private static final EELFLogger log = EELFLogFactory.getLogger(ErrorLogImplTest.class);
+
+    @Test
+    public void errorLoggerTest() throws Exception {
+        log.errorLog().error("Test ErrorLog error message: {}",
+                getTestErrorLogSpec(), getTestOptionalLogSpec(), "errorArg");
+
+        final ErrorLogSpec emptyErrorLog = new ErrorLogSpecImpl(null, null,
+                null, null);
+
+        log.errorLog().error("Test Empty ErrorLog error message", emptyErrorLog,
+                EELFLoggerDefaults.DEFAULT_OPTIONAL_LOG_SPEC);
+
+    }
+
+    @Test
+    public void errorLoggerTestWithWarnLogLevel() throws Exception {
+        log.errorLog().warn("Test errorLog warn message: {}", getTestErrorLogSpec(), getTestOptionalLogSpec(),
+                "warnArg");
+
+    }
+
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/MetricLogImplTest.java b/eelf-logger/eelf-logger-logback-impl/src/test/java/org/onap/dcae/utils/eelf/logger/logback/log/MetricLogImplTest.java
new file mode 100644 (file)
index 0000000..54a1689
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.logback.log;
+
+import org.junit.Test;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogFactory;
+import org.onap.dcae.utils.eelf.logger.api.log.EELFLogger;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+import org.onap.dcae.utils.eelf.logger.logback.BaseLogbackUnitTest;
+import org.onap.dcae.utils.eelf.logger.logback.EELFLoggerDefaults;
+import org.onap.dcae.utils.eelf.logger.model.spec.MetricLogSpecImpl;
+
+
+/**
+ * Tests for Metric Log implementation.
+ *
+ * @author Rajiv Singla
+ */
+public class MetricLogImplTest extends BaseLogbackUnitTest {
+
+    private static final EELFLogger log = EELFLogFactory.getLogger(MetricLogImplTest.class);
+
+    @Test
+    public void metricLoggerTest() throws Exception {
+
+        log.metricLog().info("test Metric info message: {}", getTestMetricLogSpec(), getTestOptionalLogSpec(),
+                "infoArg");
+
+        final MetricLogSpec emptyMetricLog = new MetricLogSpecImpl(null, null, null, null, null);
+
+        log.metricLog().info("Test Empty Metric info message", emptyMetricLog,
+                EELFLoggerDefaults.DEFAULT_OPTIONAL_LOG_SPEC);
+    }
+
+    @Test
+    public void metricLoggerTestWithWarnLogLevel() throws Exception {
+        log.metricLog().warn("test Metric warn message: {}", getTestMetricLogSpec(), getTestOptionalLogSpec(),
+                "warnArg");
+
+    }
+
+    @Test
+    public void metricLoggerTestWithErrorLogLevel() throws Exception {
+        log.metricLog().warn("test Metric error message: {}", getTestMetricLogSpec(), getTestOptionalLogSpec(),
+                "errorArg");
+
+
+    }
+
+}
diff --git a/eelf-logger/eelf-logger-logback-impl/src/test/resources/logback.xml b/eelf-logger/eelf-logger-logback-impl/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..b1cffd6
--- /dev/null
@@ -0,0 +1,41 @@
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+<configuration>
+
+    <!-- SET EELF COMPONENT NAME -->
+    <property scope="context" name="componentName" value="test-eelf-logger"/>
+    <contextName>${componentName}</contextName>
+
+    <include resource="eelf-logback.xml"/>
+
+    <include resource="eelf-optional-appenders.xml"/>
+
+    <root level="DEBUG">
+        <!-- required appenders -->
+        <appender-ref ref="auditLogAppender"/>
+        <appender-ref ref="metricLogAppender"/>
+        <appender-ref ref="errorLogAppender"/>
+
+        <!-- optional appenders -->
+        <appender-ref ref="debugLogAppender"/>
+        <appender-ref ref="STDOUT"/>
+    </root>
+
+
+</configuration>
diff --git a/eelf-logger/eelf-logger-model/pom.xml b/eelf-logger/eelf-logger-model/pom.xml
new file mode 100644 (file)
index 0000000..74df39f
--- /dev/null
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+               <groupId>org.onap.dcaegen2.utils</groupId>
+        <artifactId>eelf-logger</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>eelf-logger-model</artifactId>
+    <packaging>jar</packaging>
+
+
+    <!-- EELF LOGGER MODELS CONTAINS IMMUTABLE MODEL OBJECTS FOR VARIOUS EELF LOGGER INTERFACES -->
+    <name>EELF Logger Model</name>
+    <description>Contains immutable model objects for various EELF Logger interfaces</description>
+
+    <properties>
+        <main.basedir>${project.parent.basedir}</main.basedir>
+        <!-- SONAR SETTINGS : EXCLUDE TEST COVERAGE AS MODEL ONLY CONTAINS POJOs AND NO BUSINESS LOGIC-->
+        <sonar.coverage.exclusions>**/model/**</sonar.coverage.exclusions>
+    </properties>
+
+    <!-- NOTE: THIS MODULE MUST NOT HAVE ANY DEPENDENCY BESIDES ECOMP LOGGER API IN COMPILE SCOPE -->
+    <dependencies>
+
+        <!-- ECOMP LOGGER API -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>eelf-logger-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- LOMBOK IS USED FOR CODE GENERATION IN PROVIDED SCOPE (NOT IN COMPILE SCOPE) -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <sourceDirectory>${project.build.directory}/generated-sources/delombok</sourceDirectory>
+        <plugins>
+            <plugin>
+                <groupId>org.projectlombok</groupId>
+                <artifactId>lombok-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+
+
+</project>
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/AppLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/AppLogInfoImpl.java
new file mode 100644 (file)
index 0000000..689915c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.AppLogInfo;
+
+/**
+ * Concrete model implementation for {@link AppLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class AppLogInfoImpl implements AppLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private String serviceInstanceID;
+
+    private String instanceUUID;
+
+    private String virtualServerName;
+
+    private String serverIPAddress;
+
+    private String serverFQDN;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/CodeLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/CodeLogInfoImpl.java
new file mode 100644 (file)
index 0000000..7f5eb2f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.CodeLogInfo;
+
+/**
+ * Concrete model implementation for {@link CodeLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class CodeLogInfoImpl implements CodeLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private String threadId;
+
+    private String className;
+
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/CustomFieldsLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/CustomFieldsLogInfoImpl.java
new file mode 100644 (file)
index 0000000..151900d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.CustomFieldsLogInfo;
+
+/**
+ * Concrete model implementation for {@link CustomFieldsLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class CustomFieldsLogInfoImpl implements CustomFieldsLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private String customField1;
+
+    private String customField2;
+
+    private String customField3;
+
+    private String customField4;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ErrorLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ErrorLogInfoImpl.java
new file mode 100644 (file)
index 0000000..18c2e95
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.ErrorLogInfo;
+
+/**
+ * Concrete model implementation for {@link ErrorLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class ErrorLogInfoImpl implements ErrorLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private Integer errorCode;
+
+    private String errorDescription;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/MessageLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/MessageLogInfoImpl.java
new file mode 100644 (file)
index 0000000..65e722a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.MessageLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.NagiosAlertLevel;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestStatusCode;
+
+
+import java.util.Date;
+
+/**
+ * Concrete model implementation for {@link MessageLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class MessageLogInfoImpl implements MessageLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private Date creationTimestamp;
+
+    private RequestStatusCode statusCode;
+
+    private NagiosAlertLevel alertSeverity;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/MiscLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/MiscLogInfoImpl.java
new file mode 100644 (file)
index 0000000..f7e648b
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.MiscLogInfo;
+
+/**
+ * Concrete model implementation for {@link MiscLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class MiscLogInfoImpl implements MiscLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private String processId;
+
+    private String unused;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/RequestIdLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/RequestIdLogInfoImpl.java
new file mode 100644 (file)
index 0000000..af939c4
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+
+/**
+ * Concrete model implementation for {@link RequestIdLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class RequestIdLogInfoImpl implements RequestIdLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private String requestId;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/RequestTimingLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/RequestTimingLogInfoImpl.java
new file mode 100644 (file)
index 0000000..19d860b
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestTimingLogInfo;
+
+import java.util.Date;
+
+/**
+ * Concrete model implementation for {@link RequestTimingLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class RequestTimingLogInfoImpl implements RequestTimingLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private Date beginTimestamp;
+
+    private Date endTimestamp;
+
+    private Long elapsedTime;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ResponseLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ResponseLogInfoImpl.java
new file mode 100644 (file)
index 0000000..1f0bfbf
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+
+/**
+ * Concrete model implementation for {@link ResponseLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class ResponseLogInfoImpl implements ResponseLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private Integer responseCode;
+
+    private String responseDescription;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ServiceLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/ServiceLogInfoImpl.java
new file mode 100644 (file)
index 0000000..68d1f41
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+
+/**
+ * Concrete model implementation for {@link ServiceLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class ServiceLogInfoImpl implements ServiceLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private String serviceName;
+
+    private String partnerName;
+
+    private String clientIPAddress;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/TargetServiceLogInfoImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/TargetServiceLogInfoImpl.java
new file mode 100644 (file)
index 0000000..4a41e73
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.info;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+
+/**
+ * Concrete model implementation for {@link TargetServiceLogInfo}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class TargetServiceLogInfoImpl implements TargetServiceLogInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    private String targetEntity;
+
+    private String targetServiceName;
+
+    private String targetVirtualEntity;
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/package-info.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/info/package-info.java
new file mode 100644 (file)
index 0000000..ce0966e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+/**
+ * Contains immutable implementations for EELF Logging Information interfaces
+ */
+package org.onap.dcae.utils.eelf.logger.model.info;
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/AppLogSpecImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/AppLogSpecImpl.java
new file mode 100644 (file)
index 0000000..d1e40ad
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.spec;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Delegate;
+import org.onap.dcae.utils.eelf.logger.api.info.AppLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.spec.AppLogSpec;
+
+
+/**
+ * Concrete model implementation for {@link AppLogSpec}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+public class AppLogSpecImpl implements AppLogSpec {
+
+    private static final long serialVersionUID = 1L;
+
+    @Delegate(types = AppLogSpec.class)
+    private AppLogInfo appLogInfo;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/AuditLogSpecImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/AuditLogSpecImpl.java
new file mode 100644 (file)
index 0000000..c217595
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.spec;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Delegate;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestTimingLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.spec.AuditLogSpec;
+
+
+/**
+ * Concrete model implementation for {@link AuditLogSpec}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class AuditLogSpecImpl implements AuditLogSpec {
+
+    private static final long serialVersionUID = 1L;
+
+    @Delegate(types = RequestIdLogInfo.class)
+    private RequestIdLogInfo requestIdLogInfo;
+
+    @Delegate(types = ServiceLogInfo.class)
+    private ServiceLogInfo serviceLogInfo;
+
+    @Delegate(types = RequestTimingLogInfo.class)
+    private RequestTimingLogInfo requestTimingLogInfo;
+
+    @Delegate(types = ResponseLogInfo.class)
+    private ResponseLogInfo responseLogInfo;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/DebugLogSpecImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/DebugLogSpecImpl.java
new file mode 100644 (file)
index 0000000..53a1070
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.spec;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Delegate;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.spec.DebugLogSpec;
+
+
+/**
+ * Concrete model implementation for {@link DebugLogSpec}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class DebugLogSpecImpl implements DebugLogSpec {
+
+    private static final long serialVersionUID = 1L;
+
+    @Delegate(types = RequestIdLogInfo.class)
+    private RequestIdLogInfo requestIdLogInfo;
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/ErrorLogSpecImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/ErrorLogSpecImpl.java
new file mode 100644 (file)
index 0000000..6e73fcf
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.spec;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Delegate;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.ErrorLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.spec.ErrorLogSpec;
+
+
+/**
+ * Concrete model implementation for {@link ErrorLogSpec}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class ErrorLogSpecImpl implements ErrorLogSpec {
+
+    private static final long serialVersionUID = 1L;
+
+    @Delegate(types = RequestIdLogInfo.class)
+    private RequestIdLogInfo requestIdLogInfo;
+
+    @Delegate(types = ServiceLogInfo.class)
+    private ServiceLogInfo serviceLogInfo;
+
+    @Delegate(types = TargetServiceLogInfo.class)
+    private TargetServiceLogInfo targetServiceLogInfo;
+
+    @Delegate(types = ErrorLogInfo.class)
+    private ErrorLogInfo errorLogInfo;
+
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/MetricLogSpecImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/MetricLogSpecImpl.java
new file mode 100644 (file)
index 0000000..d910bc2
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.spec;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Delegate;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestIdLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.RequestTimingLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ResponseLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.ServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.TargetServiceLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.spec.MetricLogSpec;
+
+
+/**
+ * Concrete model implementation for {@link MetricLogSpec}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class MetricLogSpecImpl implements MetricLogSpec {
+
+    private static final long serialVersionUID = 1L;
+
+    @Delegate(types = RequestIdLogInfo.class)
+    private RequestIdLogInfo requestIdLogInfo;
+
+    @Delegate(types = ServiceLogInfo.class)
+    private ServiceLogInfo serviceLogInfo;
+
+    @Delegate(types = RequestTimingLogInfo.class)
+    private RequestTimingLogInfo requestTimingLogInfo;
+
+    @Delegate(types = ResponseLogInfo.class)
+    private ResponseLogInfo responseLogInfo;
+
+    @Delegate(types = TargetServiceLogInfo.class)
+    private TargetServiceLogInfo targetServiceLogInfo;
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/OptionalLogSpecImpl.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/OptionalLogSpecImpl.java
new file mode 100644 (file)
index 0000000..755b4bf
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+package org.onap.dcae.utils.eelf.logger.model.spec;
+
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import lombok.experimental.Delegate;
+import lombok.experimental.Wither;
+import org.onap.dcae.utils.eelf.logger.api.info.CodeLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.CustomFieldsLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.MessageLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.info.MiscLogInfo;
+import org.onap.dcae.utils.eelf.logger.api.spec.OptionalLogSpec;
+
+
+/**
+ * Concrete model implementation for {@link OptionalLogSpec}
+ *
+ * @author Rajiv Singla
+ */
+@Getter
+@AllArgsConstructor
+@EqualsAndHashCode
+@ToString
+@Wither
+public class OptionalLogSpecImpl implements OptionalLogSpec {
+
+    private static final long serialVersionUID = 1L;
+
+    @Delegate(types = MessageLogInfo.class)
+    private MessageLogInfo messageLogInfo;
+
+    @Delegate(types = CodeLogInfo.class)
+    private CodeLogInfo codeLogInfo;
+
+    @Delegate(types = CustomFieldsLogInfo.class)
+    private CustomFieldsLogInfo customFieldsLogInfo;
+
+    @Delegate(types = MiscLogInfo.class)
+    private MiscLogInfo miscLogInfo;
+}
diff --git a/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/package-info.java b/eelf-logger/eelf-logger-model/src/main/java/org/onap/dcae/utils/eelf/logger/model/spec/package-info.java
new file mode 100644 (file)
index 0000000..73aec41
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * ================================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+
+/**
+ * Contains immutable implementations for EELF Logging specification interfaces
+ */
+package org.onap.dcae.utils.eelf.logger.model.spec;
diff --git a/eelf-logger/findbugs-exclude.xml b/eelf-logger/findbugs-exclude.xml
new file mode 100644 (file)
index 0000000..9eac36d
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<FindBugsFilter>
+
+    <Match>
+        <!-- MODEL OBJECTS ARE USING LOMBOK ANNOTATIONS SO SOME FINDBUGS ARE IGNORED-->
+        <Package name="~.*model.*"/>
+        <Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ, RC_REF_COMPARISON, EI_EXPOSE_REP, EI_EXPOSE_REP2"/>
+    </Match>
+
+</FindBugsFilter>
diff --git a/eelf-logger/pmd-exclude.properties b/eelf-logger/pmd-exclude.properties
new file mode 100644 (file)
index 0000000..2ca9be7
--- /dev/null
@@ -0,0 +1,22 @@
+#
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+#
+
+# List fully qualified names of classes that can be excluded for PMD (PROGRAMMING-MISTAKE-DETECTOR)
+
+# IGNORE TOO MANY STATIC IMPORTS
diff --git a/eelf-logger/pom.xml b/eelf-logger/pom.xml
new file mode 100644 (file)
index 0000000..30aad26
--- /dev/null
@@ -0,0 +1,478 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+       <parent>
+               <groupId>org.onap.dcaegen2</groupId>
+               <artifactId>tca-gen2</artifactId>
+               <version>3.0.0-SNAPSHOT</version>
+       </parent>
+
+       <groupId>org.onap.dcaegen2.utils</groupId>
+    <artifactId>eelf-logger</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+
+    <name>EELF Logger Parent</name>
+    <packaging>pom</packaging>
+    
+    <modules>
+        <module>eelf-logger-api</module>
+        <module>eelf-logger-model</module>
+        <module>eelf-logger-logback-impl</module>
+    </modules>
+
+
+
+    <properties>
+
+        <!-- PROJECT SETTINGS-->
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <main.basedir>${project.basedir}</main.basedir>
+
+        <!--TEST SETTINGS -->
+        <surefire.redirectTestOutputToFile>true</surefire.redirectTestOutputToFile>
+
+        <!-- PROJECT DEPENDENCIES -->
+        <slf4j.version>1.7.5</slf4j.version>
+        <logback.version>1.2.3</logback.version>
+        <lombok.version>1.16.10</lombok.version>
+
+
+        <!--TESTING DEPENDENCIES -->
+        <junit.version>4.12</junit.version>
+        <mockito.version>2.2.11</mockito.version>
+        <assertj-core.version>2.6.0</assertj-core.version>
+
+
+        <!-- PLUGINS VERSIONS -->
+        <compiler.plugin.version>3.3</compiler.plugin.version>
+        <surefire.plugin.version>2.19.1</surefire.plugin.version>
+        <failsafe.plugin.version>2.19.1</failsafe.plugin.version>
+        <findbugs.plugin.version>3.0.2</findbugs.plugin.version>
+
+        <pmd.plugin.version>3.5</pmd.plugin.version>
+        <javadoc.plugin.version>2.10.4</javadoc.plugin.version>
+        <source.plugin.version>2.4</source.plugin.version>
+        <jar.plugin.version>2.4</jar.plugin.version>
+        <deploy.plugin.version>2.8</deploy.plugin.version>
+        <lombok.plugin.version>1.16.10.0</lombok.plugin.version>
+        <maven.site.plugin>3.5.1</maven.site.plugin>
+
+        <!--PLUGIN SETTINGS -->
+        <compiler.source.version>1.7</compiler.source.version>
+        <compiler.target.version>1.7</compiler.target.version>
+        <unit.test.pattern>**/*Test.java</unit.test.pattern>
+        <skip.unit.tests>false</skip.unit.tests>
+        <integration.test.pattern>**/*IT.java</integration.test.pattern>
+        <skip.integration.tests>true</skip.integration.tests>
+        <pmd.violation.buildfail>true</pmd.violation.buildfail>
+        <findbugs.failOnError>true</findbugs.failOnError>
+
+    </properties>
+
+
+    <dependencyManagement>
+
+        <dependencies>
+
+            <!-- LOGGING -->
+            <dependency>
+                <groupId>org.slf4j</groupId>
+                <artifactId>slf4j-api</artifactId>
+                <version>${slf4j.version}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>ch.qos.logback</groupId>
+                <artifactId>logback-classic</artifactId>
+                <version>${logback.version}</version>
+            </dependency>
+
+            <!-- CODE GENERATION -->
+            <dependency>
+                <groupId>org.projectlombok</groupId>
+                <artifactId>lombok</artifactId>
+                <version>${lombok.version}</version>
+                <scope>provided</scope>
+            </dependency>
+
+
+            <!-- TEST DEPENDENCIES -->
+            <dependency>
+                <groupId>junit</groupId>
+                <artifactId>junit</artifactId>
+                <version>${junit.version}</version>
+                <scope>test</scope>
+            </dependency>
+
+            <dependency>
+                <groupId>org.mockito</groupId>
+                <artifactId>mockito-core</artifactId>
+                <version>${mockito.version}</version>
+                <scope>test</scope>
+            </dependency>
+
+            <dependency>
+                <groupId>org.assertj</groupId>
+                <artifactId>assertj-core</artifactId>
+                <version>${assertj-core.version}</version>
+                <scope>test</scope>
+            </dependency>
+
+        </dependencies>
+
+    </dependencyManagement>
+
+
+    <!-- COMMON DEPENDENCIES FOR ALL SUB-PROJECTS -->
+    <dependencies>
+        <!-- TEST DEPENDENCIES -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+
+        <pluginManagement>
+
+            <plugins>
+                <!-- COMPILER PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>${compiler.plugin.version}</version>
+                    <configuration>
+                        <source>${compiler.target.version}</source>
+                        <target>${compiler.source.version}</target>
+                    </configuration>
+                </plugin>
+
+                <!-- MAVEN SOURCE PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <version>${source.plugin.version}</version>
+                    <configuration>
+                        <excludeResources>true</excludeResources>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>attach-sources</id>
+                            <phase>verify</phase>
+                            <goals>
+                                <goal>jar-no-fork</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+
+                <!-- MAVEN JAVADOC PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-javadoc-plugin</artifactId>
+                    <version>${javadoc.plugin.version}</version>
+                    <configuration>
+                        <!-- minimize console output messages -->
+                        <quiet>true</quiet>
+                        <verbose>false</verbose>
+                        <useStandardDocletOptions>false</useStandardDocletOptions>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>aggregate</id>
+                            <phase>site</phase>
+                            <goals>
+                                <goal>aggregate</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>attach-javadoc</id>
+                            <goals>
+                                <goal>jar</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+
+                <!-- SUREFIRE TEST PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>${surefire.plugin.version}</version>
+                    <configuration>
+                        <skipTests>${skip.unit.tests}</skipTests>
+                        <argLine>-Xmx2048m -Djava.awt.headless=true -XX:+UseConcMarkSweepGC
+                            -XX:OnOutOfMemoryError="kill -9 %p" -XX:+HeapDumpOnOutOfMemoryError
+                        </argLine>
+                        <redirectTestOutputToFile>${surefire.redirectTestOutputToFile}</redirectTestOutputToFile>
+                        <parallel>methods</parallel>
+                        <threadCount>8</threadCount>
+                        <forkCount>8</forkCount>
+                        <reuseForks>true</reuseForks>
+                        <reportFormat>xml</reportFormat>
+                        <trimStackTrace>false</trimStackTrace>
+                        <systemPropertyVariables>
+                            <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+                            <logback.configurationFile>
+                                ${basedir}/src/test/resources/logback-test.xml
+                            </logback.configurationFile>
+                        </systemPropertyVariables>
+                        <includes>
+                            <include>${unit.test.pattern}</include>
+                        </includes>
+                        <excludes>
+                            <exclude>${integration.test.pattern}</exclude>
+                        </excludes>
+                        <!-- Sets the VM argument line used when unit tests are run. -->
+                        <argLine>${surefireArgLine}</argLine>
+                    </configuration>
+                    <dependencies>
+                        <dependency>
+                            <groupId>org.apache.maven.surefire</groupId>
+                            <artifactId>surefire-junit47</artifactId>
+                            <version>${surefire.plugin.version}</version>
+                        </dependency>
+                    </dependencies>
+                </plugin>
+
+                <!-- FAIL SAFE PLUGIN FOR INTEGRATION TEST -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-failsafe-plugin</artifactId>
+                    <version>${failsafe.plugin.version}</version>
+                    <executions>
+                        <execution>
+                            <id>integration-tests</id>
+                            <goals>
+                                <goal>integration-test</goal>
+                                <goal>verify</goal>
+                            </goals>
+                            <configuration>
+                                <skipTests>${skip.integration.tests}</skipTests>
+                                <!-- Sets the VM argument line used when integration tests are run. -->
+                                <!--suppress MavenModelInspection -->
+                                <argLine>${failsafeArgLine}</argLine>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+
+
+                <!-- FIND BUGS (STATIC CODE ANALYSIS) PLUGIN -->
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>findbugs-maven-plugin</artifactId>
+                    <version>${findbugs.plugin.version}</version>
+                    <configuration>
+                        <effort>Max</effort>
+                        <threshold>Low</threshold>
+                        <xmlOutput>true</xmlOutput>
+                        <!-- BUILD FAIL ON FINDBUGS ERRORS -->
+                        <failOnError>${findbugs.failOnError}</failOnError>
+                        <excludeFilterFile>${main.basedir}/findbugs-exclude.xml</excludeFilterFile>
+                        <outputDirectory>${project.reporting.outputDirectory}/findbugs</outputDirectory>
+                        <findbugsXmlOutputDirectory>${project.reporting.outputDirectory}/findbugs
+                        </findbugsXmlOutputDirectory>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>analyze-compile</id>
+                            <phase>compile</phase>
+                            <goals>
+                                <goal>check</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- PMD PLUGIN SETUP -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-pmd-plugin</artifactId>
+                    <version>${pmd.plugin.version}</version>
+                    <configuration>
+                        <sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
+                        <targetJdk>${compiler.target.version}</targetJdk>
+                        <linkXRef>false</linkXRef>
+                        <!-- BUILD FAIL ON PMD VIOLATION -->
+                        <failOnViolation>${pmd.violation.buildfail}</failOnViolation>
+                        <targetDirectory>${project.reporting.outputDirectory}/pmd</targetDirectory>
+                        <minimumTokens>200</minimumTokens>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>pmd-check</id>
+                            <goals>
+                                <goal>check</goal>
+                            </goals>
+                            <configuration>
+                                <printFailingErrors>true</printFailingErrors>
+                                <excludeFromFailureFile>${main.basedir}/pmd-exclude.properties</excludeFromFailureFile>
+                            </configuration>
+                        </execution>
+                        <execution>
+                            <id>cpd-check</id>
+                            <goals>
+                                <goal>cpd-check</goal>
+                            </goals>
+                            <configuration>
+                                <printFailingErrors>true</printFailingErrors>
+                                <excludeFromFailureFile>${main.basedir}/cpd-exclude.properties</excludeFromFailureFile>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+
+
+
+
+                <!-- LOMBOK PLUGIN -->
+                <plugin>
+                    <groupId>org.projectlombok</groupId>
+                    <artifactId>lombok-maven-plugin</artifactId>
+                    <version>${lombok.plugin.version}</version>
+                    <executions>
+                        <execution>
+                            <id>delombok</id>
+                            <phase>generate-sources</phase>
+                            <goals>
+                                <goal>delombok</goal>
+                            </goals>
+                            <configuration>
+                                <addOutputDirectory>false</addOutputDirectory>
+                                <sourceDirectory>src/main/java</sourceDirectory>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+
+                <!-- JAR PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>${jar.plugin.version}</version>
+                    <configuration>
+                        <archive>
+                            <manifest>
+                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+                            </manifest>
+                            <manifestEntries>
+                                <Implementation-Build-Version>${project.version}</Implementation-Build-Version>
+                            </manifestEntries>
+                        </archive>
+                    </configuration>
+                </plugin>
+
+                <!-- DEPLOY PLUGIN -->
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-deploy-plugin</artifactId>
+                    <version>${deploy.plugin.version}</version>
+                    <configuration>
+                        <deployAtEnd>true</deployAtEnd>
+                    </configuration>
+                </plugin>
+
+            </plugins>
+
+        </pluginManagement>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+            </plugin>
+
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+
+    </build>
+
+    <profiles>
+        <profile>
+            <id>disable-java8-doclint</id>
+            <activation>
+                <jdk>[1.8,)</jdk>
+            </activation>
+            <properties>
+                <additionalparam>-Xdoclint:none</additionalparam>
+            </properties>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/eelf-logger/version.properties b/eelf-logger/version.properties
new file mode 100644 (file)
index 0000000..2e2ac47
--- /dev/null
@@ -0,0 +1,23 @@
+# ================================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. 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.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+
+major=3
+minor=0
+patch=0
+base_version=${major}.${minor}.${patch}
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT
diff --git a/pom.xml b/pom.xml
new file mode 100644 (file)
index 0000000..42e05b8
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+  ~ ================================================================================
+  ~ Copyright (c) 2018 AT&T Intellectual Property. 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.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~ ============LICENSE_END=========================================================
+  ~
+  -->
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onap.oparent</groupId>
+        <artifactId>oparent</artifactId>
+        <version>1.1.1</version>
+    </parent>
+
+    <groupId>org.onap.dcaegen2</groupId>
+    <artifactId>tca-gen2</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+
+    <name>tca-gen2</name>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>eelf-logger</module>
+        <module>dcae-analytics</module>
+    </modules>
+
+
+</project>
diff --git a/version.properties b/version.properties
new file mode 100644 (file)
index 0000000..081a54a
--- /dev/null
@@ -0,0 +1,6 @@
+major=3
+minor=0
+patch=0
+base_version=${major}.${minor}.${patch}
+release_version=${base_version}
+snapshot_version=${base_version}-SNAPSHOT