From e37de6e66c5cc554384a1f27f68f4d27962fe15d Mon Sep 17 00:00:00 2001 From: Lisa Revel Date: Mon, 20 Feb 2017 19:15:19 +0000 Subject: Re-add source from correct branch Change-Id: I515f8378ea1d2baf0aa2434ec46272f1b5bdb229 Signed-off-by: Lisa Revel --- dcae-analytics-common/pom.xml | 6 +- .../dcae/analytics/common/AnalyticsConstants.java | 134 -------------- .../analytics/common/CDAPComponentsConstants.java | 196 --------------------- .../analytics/common/CDAPMetricsConstants.java | 112 ------------ .../analytics/common/DCAEAnalyticsPreferences.java | 29 --- .../common/cdap/settings/CDAPAppConfig.java | 47 ----- .../common/cdap/settings/CDAPAppPreferences.java | 31 ---- .../common/cdap/settings/CDAPAppSettings.java | 35 ---- .../common/cdap/settings/CDAPBaseAppConfig.java | 62 ------- .../cdap/validation/CDAPAppSettingsValidator.java | 52 ------ .../common/exception/CDAPSettingsException.java | 50 ------ .../exception/DCAEAnalyticsRuntimeException.java | 54 ------ .../exception/MessageProcessingException.java | 51 ------ .../processor/AbstractMessageProcessor.java | 162 ----------------- .../processor/AbstractProcessorContext.java | 96 ---------- .../processor/GenericMessageChainProcessor.java | 63 ------- .../service/processor/GenericProcessorInfo.java | 55 ------ .../common/service/processor/MessageProcessor.java | 84 --------- .../common/service/processor/ProcessingState.java | 36 ---- .../common/service/processor/ProcessorContext.java | 70 -------- .../common/service/processor/ProcessorInfo.java | 49 ------ .../dcae/analytics/common/utils/HTTPUtils.java | 57 ------ .../common/utils/MessageProcessorUtils.java | 114 ------------ .../analytics/common/utils/PersistenceUtils.java | 54 ------ .../analytics/common/utils/ValidationUtils.java | 89 ---------- .../analytics/common/validation/DCAEValidator.java | 29 --- .../validation/GenericValidationResponse.java | 84 --------- .../common/validation/ValidationResponse.java | 90 ---------- .../apod/analytics/common/AnalyticsConstants.java | 134 ++++++++++++++ .../analytics/common/CDAPComponentsConstants.java | 196 +++++++++++++++++++++ .../analytics/common/CDAPMetricsConstants.java | 112 ++++++++++++ .../analytics/common/DCAEAnalyticsPreferences.java | 29 +++ .../common/cdap/settings/CDAPAppConfig.java | 47 +++++ .../common/cdap/settings/CDAPAppPreferences.java | 31 ++++ .../common/cdap/settings/CDAPAppSettings.java | 35 ++++ .../common/cdap/settings/CDAPBaseAppConfig.java | 62 +++++++ .../cdap/validation/CDAPAppSettingsValidator.java | 52 ++++++ .../common/exception/CDAPSettingsException.java | 50 ++++++ .../exception/DCAEAnalyticsRuntimeException.java | 54 ++++++ .../exception/MessageProcessingException.java | 51 ++++++ .../processor/AbstractMessageProcessor.java | 162 +++++++++++++++++ .../processor/AbstractProcessorContext.java | 96 ++++++++++ .../processor/GenericMessageChainProcessor.java | 63 +++++++ .../service/processor/GenericProcessorInfo.java | 55 ++++++ .../common/service/processor/MessageProcessor.java | 84 +++++++++ .../common/service/processor/ProcessingState.java | 36 ++++ .../common/service/processor/ProcessorContext.java | 70 ++++++++ .../common/service/processor/ProcessorInfo.java | 49 ++++++ .../apod/analytics/common/utils/HTTPUtils.java | 57 ++++++ .../common/utils/MessageProcessorUtils.java | 114 ++++++++++++ .../analytics/common/utils/PersistenceUtils.java | 54 ++++++ .../analytics/common/utils/ValidationUtils.java | 89 ++++++++++ .../analytics/common/validation/DCAEValidator.java | 29 +++ .../validation/GenericValidationResponse.java | 84 +++++++++ .../common/validation/ValidationResponse.java | 90 ++++++++++ .../common/BaseAnalyticsCommonUnitTest.java | 48 ----- .../GenericMessageChainProcessorTest.java | 96 ---------- .../processor/TestEarlyTerminatingProcessor.java | 39 ---- .../service/processor/TestMessageProcessor1.java | 41 ----- .../service/processor/TestMessageProcessor2.java | 41 ----- .../service/processor/TestProcessorContext.java | 84 --------- .../common/BaseAnalyticsCommonUnitTest.java | 48 +++++ .../GenericMessageChainProcessorTest.java | 96 ++++++++++ .../processor/TestEarlyTerminatingProcessor.java | 39 ++++ .../service/processor/TestMessageProcessor1.java | 41 +++++ .../service/processor/TestMessageProcessor2.java | 41 +++++ .../service/processor/TestProcessorContext.java | 84 +++++++++ 67 files changed, 2337 insertions(+), 2337 deletions(-) delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/AnalyticsConstants.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPComponentsConstants.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPMetricsConstants.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/DCAEAnalyticsPreferences.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppConfig.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppPreferences.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppSettings.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPBaseAppConfig.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/validation/CDAPAppSettingsValidator.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/CDAPSettingsException.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/DCAEAnalyticsRuntimeException.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/MessageProcessingException.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractMessageProcessor.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractProcessorContext.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessor.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericProcessorInfo.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/MessageProcessor.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessingState.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorContext.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorInfo.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/HTTPUtils.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/MessageProcessorUtils.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/PersistenceUtils.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/ValidationUtils.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/DCAEValidator.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/GenericValidationResponse.java delete mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/ValidationResponse.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/AnalyticsConstants.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPComponentsConstants.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPMetricsConstants.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/DCAEAnalyticsPreferences.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppConfig.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppPreferences.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppSettings.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPBaseAppConfig.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/validation/CDAPAppSettingsValidator.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/CDAPSettingsException.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/DCAEAnalyticsRuntimeException.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/MessageProcessingException.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractMessageProcessor.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractProcessorContext.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessor.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericProcessorInfo.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/MessageProcessor.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessingState.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorContext.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorInfo.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/HTTPUtils.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/MessageProcessorUtils.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/PersistenceUtils.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/ValidationUtils.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/DCAEValidator.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/GenericValidationResponse.java create mode 100644 dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/ValidationResponse.java delete mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/BaseAnalyticsCommonUnitTest.java delete mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessorTest.java delete mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestEarlyTerminatingProcessor.java delete mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor1.java delete mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor2.java delete mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestProcessorContext.java create mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java create mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java create mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java create mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java create mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java create mode 100644 dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestProcessorContext.java (limited to 'dcae-analytics-common') diff --git a/dcae-analytics-common/pom.xml b/dcae-analytics-common/pom.xml index 1c58693..7da767f 100644 --- a/dcae-analytics-common/pom.xml +++ b/dcae-analytics-common/pom.xml @@ -27,7 +27,7 @@ 4.0.0 - org.openecomp.dcae.analytics + org.openecomp.dcae.apod.analytics dcae-analytics 1.0-SNAPSHOT ../pom.xml @@ -49,7 +49,7 @@ - org.openecomp.dcae.analytics + org.openecomp.dcae.apod.analytics dcae-analytics-model 1.0-SNAPSHOT @@ -108,7 +108,7 @@ - org.openecomp.dcae.analytics + org.openecomp.dcae.apod.analytics dcae-analytics-test 1.0-SNAPSHOT test diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/AnalyticsConstants.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/AnalyticsConstants.java deleted file mode 100644 index 6c51069..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/AnalyticsConstants.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common; - -/** - * Contains static variable for all DCAE Components. - * - * @author Rajiv Singla. Creation Date: 10/21/2016. - */ -public abstract class AnalyticsConstants { - - - // =============== Common Constants for all DCAE Analytics Modules ==================== // - - - // =============== DMaaP Constants for all DCAE Analytics Modules ==================== // - - public static final String DMAAP_URI_PATH_PREFIX = "/events/"; - public static final String DMAAP_GROUP_PREFIX = "OpenDCAE-"; - - // ================== DMaaP MR Constants ============================== // - // Publisher Constants - public static final int DEFAULT_PUBLISHER_MAX_BATCH_SIZE = 100; - public static final int DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE = 100000; - public static final int PUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE = 5; - public static final int PUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE = 5000; - // Subscriber Constants - public static final int DEFAULT_SUBSCRIBER_TIMEOUT_MS = -1; - public static final int DEFAULT_SUBSCRIBER_MESSAGE_LIMIT = -1; - public static final String DEFAULT_SUBSCRIBER_GROUP_PREFIX = DMAAP_GROUP_PREFIX + "DMaaPSub-"; - public static final String SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME = "timeout"; - public static final String SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME = "limit"; - - - // ================== TCA Constants ============================== // - - // Default subscriber polling interval - public static final Integer TCA_DEFAULT_SUBSCRIBER_POLLING_INTERVAL_MS = 30000; - - // Default publisher polling interval - public static final Integer TCA_DEFAULT_PUBLISHER_POLLING_INTERVAL_MS = 30000; - - // Default publisher max batch queue size determines the minimum number of messages that need to be published in - // batch mode - public static final Integer TCA_DEFAULT_PUBLISHER_MAX_BATCH_QUEUE_SIZE = 10; - - // Default publisher max recovery queue size determines max number of messages can be cached in memory - // in case publisher is not responding - public static final Integer TCA_DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE = 100000; - - // Default interval during which TCA DMaaP Worker checks if scheduler is shut down - public static final Integer TCA_DEFAULT_WORKER_SHUTDOWN_CHECK_INTERVAL_MS = 10000; - - // ***** TCA Quartz Scheduler Settings ******// - - public static final String TCA_QUARTZ_SUBSCRIBER_PROPERTIES_FILE_NAME = "quartz-subscriber.properties"; - - public static final String TCA_QUARTZ_PUBLISHER_PROPERTIES_FILE_NAME = "quartz-publisher.properties"; - - // TCA Quartz Group Settings - public static final String TCA_QUARTZ_GROUP_NAME = "TCAQuartzGroup"; - // TCA Quartz Trigger Settings - public static final String TCA_DMAAP_SUBSCRIBER_QUARTZ_TRIGGER_NAME = "TCADMaaPSubscriberTrigger"; - public static final String TCA_DMAAP_PUBLISHER_QUARTZ_TRIGGER_NAME = "TCADMaaPPublisherTrigger"; - - // TCA Quartz DMaaP Subscriber Job Settings - public static final String TCA_DMAAP_SUBSCRIBER_QUARTZ_JOB_NAME = "TCADMaaPSubscriberJob"; - public static final String TCA_DMAAP_PUBLISHER_QUARTZ_JOB_NAME = "TCADMaaPPublisherJob"; - - // TCA Quartz Publisher and Subscriber Job Parameters - // Common Job parameters for both Publisher and Subscriber - public static final String WORKER_CONTEXT_VARIABLE_NAME = "WORKER_CONTEXT"; - public static final String DMAAP_METRICS_VARIABLE_NAME = "DMAAP_METRICS"; - // TCA Quartz DMaaP Subscriber Job Parameter Settings - public static final String CDAP_STREAM_VARIABLE_NAME = "CDAP_STREAM_NAME"; - public static final String DMAAP_SUBSCRIBER_VARIABLE_NAME = "DMAAP_SUBSCRIBER"; - // TCA Quartz DMaaP Publisher Job Parameter Settings - public static final String CDAP_ALERTS_TABLE_VARIABLE_NAME = "CDAP_TCA_ALERTS_TABLE_NAME"; - public static final String DMAAP_PUBLISHER_VARIABLE_NAME = "DMAAP_PUBLISHER"; - - // TCA VES Response Constants - public static final String TCA_VES_RESPONSE_TARGET_TYPE = "VNF"; - public static final String TCA_VES_RESPONSE_TARGET = "generic-vnf.vnf-id"; - public static final String TCA_VES_RESPONSE_FROM = "DCAE"; - public static final String TCA_VES_RESPONSE_CLOSED_LOOP_EVENT_STATUS = "ONSET"; - - // TCA VES Response Constants for vLoadBalancer - public static final String LOAD_BALANCER_FUNCTIONAL_ROLE = "vLoadBalancer"; - public static final String LOAD_BALANCER_TCA_VES_RESPONSE_TARGET_TYPE = "VM"; - public static final String LOAD_BALANCER_TCA_VES_RESPONSE_TARGET = "vserver.vserver-name"; - - // TCA VES Message Router Partition Key - public static final String TCA_VES_MESSAGE_ROUTER_PARTITION_KEY = "VESMessageHash"; - - /** - * Default Number of instances for Threshold violation calculator flowlet - */ - public static final Integer TCA_DEFAULT_THRESHOLD_CALCULATOR_FLOWLET_INSTANCES = 2; - - /** - * Default TTL for TCA VES Message status table which contain status of all messages processed by TCA - */ - public static final Integer TCA_DEFAULT_VES_MESSAGE_STATUS_TTL_TABLE = 60 * 60 * 24 * 10; // 10 Days - - /** - * Default TTL for TCA VES Alerts table which contains alerts that can be send to downstream systems - */ - public static final Integer TCA_DEFAULT_VES_ALERTS_TTL_TABLE = 60 * 60 * 24 * 20; // 20 Days - - - // TCA Policy Runtime Argument Paths - public static final String TCA_POLICY_DELIMITER = "."; - public static final String TCA_POLICY_DOMAIN_PATH = "domain"; - public static final String TCA_POLICY_METRICS_PER_FUNCTIONAL_ROLE_PATH = "configuration.metricsPerFunctionalRole"; - public static final String TCA_POLICY_THRESHOLDS_PATH_POSTFIX = "thresholds"; -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPComponentsConstants.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPComponentsConstants.java deleted file mode 100644 index 50aad3c..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPComponentsConstants.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common; - -/** - * Contains static constant variable names and values of all DCAE CDAP Components for - * e.g. app names, app descriptions, streams, datasets, flows, flowlets, workers, outputs etc. - * - *

- * A strict naming convention must be followed for variable names for CDAP Components names for proper - * identification of CDAP Component variable purpose and function. A custom configuration settings can be - * generated for app - * deployment purposes based on variable naming conventions. - * - * The variable names should have 4 parts separated by an underscore: - *

    - *
  • Name of the DCAE sub module (e.g. TCA) to which variable is applicable
  • - *
  • Information about variable name: - *
      - *
    • FIXED - if variable value is fixed and cannot be changed
    • - *
    • DEFAULT - if variable name is default name and can be changed by cdap settings file - * when application is created
    • - *
    - *
  • - *
  • Actual Descriptive name about the CDAP component (may contain underscrores)
  • - *
  • CDAP component type e.g STREAM, DATASET, APP, FLOW, FLOWLET, OUTPUT
  • - *
- * - *

e.g TCA_DEFAULT_DMAAP_INPUT_STREAM

- * - *

RegEx Format (DCAE MODULE NAME)_(FIXED|DEFAULT)_(VARIABLE NAME)_(CDAP COMPONENT TYPE)

- * - * @author Rajiv Singla. Creation Date: 10/24/2016. - */ -public abstract class CDAPComponentsConstants { - - // =============== Common Module Constants ==================== // - - /** - * Default DCAE App Name. It should be overriden by sub modules - */ - public static final String COMMON_DEFAULT_DCAE_CDAP_NAME_APP = "DCAE_ANALYTICS_GENERIC_APP"; - - /** - * Default DCAE App Description. It should be overriden by sub modules - */ - public static final String COMMON_DEFAULT_DCAE_CDAP_DESCRIPTION_APP = "DCAE ANALYTICS GENERIC APP DESCRIPTION"; - - // =============== TCA Module Constants ==================== // - - /** - * Default TCA application name if application name is not provided from startup configuration - */ - public static final String TCA_DEFAULT_NAME_APP = "dcae-tca"; - - /** - * Default TCA application description if not provided from startup configuration - */ - public static final String TCA_DEFAULT_DESCRIPTION_APP = "DCAE Analytics Threshold Crossing Alert Application"; - - /** - * Default TCA DMaaP Subscriber output stream name if not provided from startup configuration - */ - public static final String TCA_DEFAULT_SUBSCRIBER_OUTPUT_NAME_STREAM = "TCASubscriberOutputStream"; - - - /** - * Fixed TCA DMaaP Subscriber output stream description - */ - public static final String TCA_FIXED_SUBSCRIBER_OUTPUT_DESCRIPTION_STREAM = - "Stream which contains all message from VES Collector DMaaP MR topic"; - - - /** - * Fixed Name of TCA DMaaP Subscriber Worker - which will be fetching DMaaP Messages posting them to CDAP stream - */ - public static final String TCA_FIXED_DMAAP_SUBSCRIBER_WORKER = "TCADMaaPMRSubscriberWorker"; - - /** - * Fixed Description of TCA DMaaP Subscriber Worker - */ - public static final String TCA_FIXED_DMAAP_SUBSCRIBER_DESCRIPTION_WORKER = - "Fetches messages from DMaaP MR Topic at frequent intervals and writes them to a CDAP stream"; - - /** - * Fixed Name of TCA DMaaP Publisher Worker - which will be publishing messages to DMaaP MR - */ - public static final String TCA_FIXED_DMAAP_PUBLISHER_WORKER = "TCADMaaPMRPublisherWorker"; - - /** - * Fixed Description of TCA DMaaP Publisher Worker - */ - public static final String TCA_FIXED_DMAAP_PUBLISHER_DESCRIPTION_WORKER = - "Polls TCA Alerts Table at frequent intervals for new alerts and publishes them to DMaaP MR Topic"; - - /** - * Fixed name for TCA VES Collector Messages Processing Flow - */ - public static final String TCA_FIXED_VES_COLLECTOR_NAME_FLOW = "TCAVESCollectorFlow"; - - - /** - * Fixed description for TCA VES Collector Messages Processing Flow - */ - public static final String TCA_FIXED_VES_COLLECTOR_DESCRIPTION_FLOW = "Flow performs TCA on VES Collector Messages"; - - - /** - * Fixed Name for TCA VES Message Router Flowlet - */ - public static final String TCA_FIXED_VES_MESSAGE_ROUTER_NAME_FLOWLET = "TCAVESMessageRouterFlowlet"; - - /** - * Fixed Description for TCA VES Message Router Flowlet - */ - public static final String TCA_FIXED_VES_MESSAGE_ROUTER_DESCRIPTION_FLOWLET = - "Routes message received from TCA VES Collector to TCA Threshold Calculator Flowlet instances"; - - /** - * Fixed TCA VES Message Router Flowlet Output - */ - public static final String TCA_FIXED_VES_MESSAGE_ROUTER_OUTPUT = "TCAVESMessageRouterFlowlet"; - - /** - * Fixed Name for TCA VES Message Policy Violated Threshold Calculator Flowlet - */ - public static final String TCA_FIXED_VES_THRESHOLD_VIOLATION_CALCULATOR_NAME_FLOWLET = - "TCAVESThresholdViolationCalculatorFlowlet"; - - /** - * Fixed Description for TCA VES Message Policy Violated Threshold Calculator Flowlet - */ - public static final String TCA_FIXED_VES_THRESHOLD_VIOLATION_CALCULATOR_DESCRIPTION_FLOWLET = - "Applies TCA Policy Thresholds to VES Message and determined if any message violated TCA Policy thresholds"; - - /** - * Fixed Name for TCA VES Message Policy Violated Threshold Calculator Output - */ - public static final String TCA_FIXED_VES_TCA_CALCULATOR_NAME_OUTPUT = "TCAThresholdViolationCalculatorOutput"; - - - /** - * Fixed Name for TCA VES Alerts Sink Flowlet - */ - public static final String TCA_FIXED_VES_ALERTS_SINK_NAME_FLOWLET = "TCAVESAlertsSinkFlowlet"; - - /** - * Fixed Description for TCA VES Alerts Sink Flowlet - */ - public static final String TCA_FIXED_VES_ALERTS_SINK_DESCRIPTION_FLOWLET = - "Saves messages which violated TCA Policy in a data set"; - - - /** - * Default Name for TCA VES Message status table which contain status of all messages processed by TCA - */ - public static final String TCA_DEFAULT_VES_MESSAGE_STATUS_NAME_TABLE = "TCAVESMessageStatusTable"; - - - /** - * Fixed Description for TCA VES Message status table which contain status of all messages processed by TCA - */ - public static final String TCA_FIXED_VES_MESSAGE_STATUS_DESCRIPTION_TABLE = - "Store processing information about all incoming TCA VES Messages"; - - /** - * Default Name for TCA VES Alerts table which contains alerts that can be send to downstream systems - */ - public static final String TCA_DEFAULT_VES_ALERTS_NAME_TABLE = "TCAVESAlertsTable"; - - /** - * Fixed Description for TCA VES Alerts table which contains alerts that can be send to downstream systems - */ - public static final String TCA_DEFAULT_VES_ALERTS_DESCRIPTION_TABLE = - "Stores alert messages that need to be DMaaP"; - - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPMetricsConstants.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPMetricsConstants.java deleted file mode 100644 index 12df643..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPMetricsConstants.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common; - -/** - * Contains all metrics names used for DCAE CDAP modules - * - *

- * Format should be (ModuleName)_(Description of metrics)_METRIC e.g. TCA_WORKER_FAILED_ATTEMPTS_METRIC - *

- * - * @author Rajiv Singla. Creation Date: 10/25/2016. - */ -public abstract class CDAPMetricsConstants { - - /** - * Metric captures count of all responses received from DMaaP MR Subscriber Topic - */ - public static final String TCA_SUBSCRIBER_ALL_RESPONSES_COUNT_METRIC = "tca.subscriber.fetch.all_responses"; - - /** - * Metric captures count of responses from DMaaP MR Subscriber Topic which does not have 200 HTTP Response code. - * This can be due to DMaaP topic being down or any internal server errors etc. - */ - public static final String TCA_SUBSCRIBER_UNSUCCESSFUL_RESPONSES_METRIC = "tca.subscriber.fetch.unsuccessful"; - - /** - * Metric that counts the number of successful (200 HTTP Response Code) calls to DMaaP which did not had empty - * messages - */ - public static final String TCA_SUBSCRIBER_RESPONSES_WITH_NO_MESSAGES_METRIC = "tca.subscriber.fetch.no_message"; - - /** - * Metric to count total number of VES Collector message processed by tca subscriber - */ - public static final String TCA_SUBSCRIBER_TOTAL_MESSAGES_PROCESSED_METRIC = "tca.subscriber.message.count"; - - - /** - * Metric to record time taken in ms by subscriber in its most recent call to fetch DMaaP MR messages - */ - public static final String TCA_SUBSCRIBER_RESPONSE_TIME_MS_METRIC = "tca.subscriber.fetch.response_time"; - - /** - * Metric captures the count of number of times DMaaP MR Subscriber was unable to write to DMaaP Stream due - * some CDAP error while writing to stream. This should ideally never happen assuming we have enough space - * on CDAP machine and CDAP process is functioning normally - */ - public static final String TCA_SUBSCRIBER_FAILURE_TO_WRITE_TO_STREAM_METRIC = "tca.subscriber.stream.writing.error"; - - - /** - * Metric captures number of VES messages that are not applicable as per TCA Policy - */ - public static final String TCA_VES_INAPPLICABLE_MESSAGES_METRIC = "tca.ves.calculator.inapplicable"; - - /** - * Metric captures number of VES messages that are applicable as per TCA Policy but don't violate any thresholds - */ - public static final String TCA_VES_COMPLIANT_MESSAGES_METRIC = "tca.ves.calculator.compliant"; - - /** - * Metrics captures number of VES messages that are applicable as per TCA Policy and does violate thresholds and - * will likely cause an alert - */ - public static final String TCA_VES_NON_COMPLIANT_MESSAGES_METRIC = "tca.ves.calculator.non_compliant"; - - - /** - * Metric that counts the number of publisher look ups in alerts table which resulted in 0 new alerts - */ - public static final String TCA_PUBLISHER_NO_NEW_ALERTS_LOOKUP_METRIC = "tca.publisher.lookup.no_message"; - - /** - * Metric that counts the number of new alerts found by the publisher in alerts table - */ - public static final String TCA_PUBLISHER_NEW_ALERTS_METRIC = "tca.publisher.lookup.new_messages"; - - /** - * Metric that counts the number of alerts deleted by publisher in alerts table - */ - public static final String TCA_PUBLISHER_DELETED_ALERTS_METRIC = "tca.publisher.deleted.alerts"; - - /** - * Metric that counts the number of publisher calls to DMaaP which resulted in successful response code - */ - public static final String TCA_PUBLISHER_SUCCESSFUL_DMAAP_RESPONSE_METRIC = "tca.publisher.publish.successful"; - - /** - * Metric that counts the number of publisher calls to DMaaP which resulted in unsuccessful response code - */ - public static final String TCA_PUBLISHER_UNSUCCESSFUL_DMAAP_RESPONSE_METRIC = "tca.publisher.publish.unsuccessful"; - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/DCAEAnalyticsPreferences.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/DCAEAnalyticsPreferences.java deleted file mode 100644 index dc345f4..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/DCAEAnalyticsPreferences.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common; - -/** - * A Marker Interface for all DCAE Analytics Preferences - * - * @author Rajiv Singla. Creation Date: 10/26/2016. - */ -public interface DCAEAnalyticsPreferences { -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppConfig.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppConfig.java deleted file mode 100644 index 3fc6f22..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppConfig.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.cdap.settings; - -/** - *

- * Minimum Contract for all CDAP App Configs - *

- * - * @author Rajiv Singla. Creation Date: 11/2/2016. - */ -public interface CDAPAppConfig extends CDAPAppSettings { - - /** - * CDAP Application Name - * - * @return cdap app name - */ - String getAppName(); - - - /** - * CDAP Application Description - * - * @return cdap app description - */ - String getAppDescription(); - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppPreferences.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppPreferences.java deleted file mode 100644 index 52ec1af..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppPreferences.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.cdap.settings; - -/** - *

- * Marker Interface for all CDAP Preferences - *

- * - * @author Rajiv Singla. Creation Date: 11/2/2016. - */ -public interface CDAPAppPreferences extends CDAPAppSettings { -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppSettings.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppSettings.java deleted file mode 100644 index d59e6f4..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppSettings.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.cdap.settings; - -import java.io.Serializable; - -/** - *

- * A marker interface for all CDAP Related App Settings. - * App Settings can either be preferences, cdap app settings etc. - *

- * - * - * @author Rajiv Singla. Creation Date: 11/2/2016. - */ -public interface CDAPAppSettings extends Serializable { -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPBaseAppConfig.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPBaseAppConfig.java deleted file mode 100644 index 1360b20..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPBaseAppConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.cdap.settings; - -import co.cask.cdap.api.Config; -import org.openecomp.dcae.analytics.common.CDAPComponentsConstants; - -/** - * Base class for all DACE Analytics Application Configurations - * - * @author Rajiv Singla. Creation Date: 10/4/2016. - */ -public abstract class CDAPBaseAppConfig extends Config implements CDAPAppConfig { - - - /** - * DCAE Analytics App Name - */ - protected String appName = CDAPComponentsConstants.COMMON_DEFAULT_DCAE_CDAP_NAME_APP; - - /** - * DCAE Analytics App Description - */ - protected String appDescription = CDAPComponentsConstants.COMMON_DEFAULT_DCAE_CDAP_DESCRIPTION_APP; - - - /** - * Returns DCAE Analytics CDAP Application name - * - * @return CDAP application name - */ - public String getAppName() { - return appName; - } - - /** - * Returns DCAE Analytics CDAP Application descrption - * - * @return CDAP application description - */ - public String getAppDescription() { - return appDescription; - } -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/validation/CDAPAppSettingsValidator.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/validation/CDAPAppSettingsValidator.java deleted file mode 100644 index df00eff..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/validation/CDAPAppSettingsValidator.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.cdap.validation; - -import org.openecomp.dcae.analytics.common.cdap.settings.CDAPAppSettings; -import org.openecomp.dcae.analytics.common.validation.DCAEValidator; -import org.openecomp.dcae.analytics.common.validation.ValidationResponse; - -/** - *

- * Validates CDAP Application Settings (AppConfig, Preferences etc) - *

- * - * @param {@link CDAPAppSettings} DCAE Analytics App Settings (e.g. AppConfig, Preferences) - * @param {@link ValidationResponse} Validator response implementations - * - * @author Rajiv Singla. Creation Date: 11/2/2016. - */ -public interface CDAPAppSettingsValidator> - extends DCAEValidator { - - /** - * Validates DCAE Analytics App Settings and return Validation response which can be - * checked for any app setting issues - * - * @param appSettings DCAE CDAP Application Settings (e.g. AppConfig, Preferences etc.) - * @return validation response - */ - R validateAppSettings(T appSettings); - - -} - - diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/CDAPSettingsException.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/CDAPSettingsException.java deleted file mode 100644 index f6859e2..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/CDAPSettingsException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.exception; - -import org.slf4j.Logger; - -/** - * Runtime exception which signals that DCAE CDAP App settings (e.g. app config, preferences) validation failed - * - * @author Rajiv Singla. Creation Date: 10/24/2016. - */ -public class CDAPSettingsException extends DCAEAnalyticsRuntimeException { - - /** - * @param message - Error Message for Exception - * @param cause - Actual Exception which caused {@link DCAEAnalyticsRuntimeException} - */ - public CDAPSettingsException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Creates and logs the DCAE App Config Exception to given logger - * - * @param message - Error Message for Exception and logging - * @param logger - Logger used for logging exception - * @param cause - Actual exception which caused - */ - public CDAPSettingsException(String message, Logger logger, Throwable cause) { - super(message, logger, cause); - } -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/DCAEAnalyticsRuntimeException.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/DCAEAnalyticsRuntimeException.java deleted file mode 100644 index cc00e33..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/DCAEAnalyticsRuntimeException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.exception; - -import org.slf4j.Logger; - -/** - * Runtime Exception for DCAE Analytics Exceptions. All DCAE Analytics - * runtime Exceptions must be wrapped inside this exception - *

- * @author Rajiv Singla. Creation Date: 10/5/2016. - */ -public class DCAEAnalyticsRuntimeException extends RuntimeException { - - - /** - * @param message - Error Message for Exception - * @param cause - Actual Exception which caused {@link DCAEAnalyticsRuntimeException} - */ - public DCAEAnalyticsRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Creates and logs the DCAE Runtime Exception to given logger - * - * @param message - Error Message for Exception and logging - * @param logger - Logger used for logging exception - * @param cause - Actual exception which caused {@link DCAEAnalyticsRuntimeException} - */ - public DCAEAnalyticsRuntimeException(String message, Logger logger, Throwable cause) { - super(message, cause); - logger.error(message); - } - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/MessageProcessingException.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/MessageProcessingException.java deleted file mode 100644 index b40f604..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/MessageProcessingException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.exception; - -import org.openecomp.dcae.analytics.common.service.processor.MessageProcessor; -import org.slf4j.Logger; - -/** - * Runtime Exception caused due to {@link MessageProcessor} failure while processing a message. - * - * @author Rajiv Singla. Creation Date: 11/7/2016. - */ -public class MessageProcessingException extends DCAEAnalyticsRuntimeException { - - /** - * @param message - Error Message for Exception - * @param cause - Actual Exception which caused {@link DCAEAnalyticsRuntimeException} - */ - public MessageProcessingException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Creates and logs the DCAE Runtime Exception to given logger - * - * @param message - Error Message for Exception and logging - * @param logger - Logger used for logging exception - * @param cause - Actual exception which caused {@link DCAEAnalyticsRuntimeException} - */ - public MessageProcessingException(String message, Logger logger, Throwable cause) { - super(message, logger, cause); - } -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractMessageProcessor.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractMessageProcessor.java deleted file mode 100644 index e5b9afc..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractMessageProcessor.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import com.google.common.base.Optional; -import org.openecomp.dcae.analytics.common.exception.MessageProcessingException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nonnull; - -import static java.lang.String.format; - -/** - * An abstract Message Processor which can be extended by {@link MessageProcessor} implementations - * to get default behavior for Message Processors - * - * @param

Processor Context sub classes - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public abstract class AbstractMessageProcessor

implements MessageProcessor

{ - - private static final Logger LOG = LoggerFactory.getLogger(AbstractMessageProcessor.class); - - /** - * By Default there is no processing message - */ - private String processingMessage = null; - - /** - * By Default Processing State is set to not required - subclasses must - * set processing state to {@link ProcessingState#PROCESSING_FINISHED_SUCCESSFULLY} on successful processing - * or {@link ProcessingState#PROCESSING_TERMINATED_EARLY} if processing fails - */ - protected ProcessingState processingState = ProcessingState.PROCESSING_NOT_REQUIRED; - - /** - * Sub classes must provide a description of a processor - * - * @return description of processor - * - */ - public abstract String getProcessorDescription(); - - - /** - * Sub classes must provide implementation to process Message - * - * @param processorContext incoming {@link ProcessorContext} - * @return outgoing {@link ProcessorContext} - */ - public abstract P processMessage(P processorContext); - - @Override - public ProcessorInfo getProcessorInfo() { - // by default the class of the Processor is assigned as Processor Name - final String processorClassName = getClass().getSimpleName(); - return new GenericProcessorInfo(processorClassName, getProcessorDescription()); - } - - @Override - public P preProcessor(P processorContext) { - LOG.debug("Processing Started for Processor: {}", getProcessorInfo().getProcessorName()); - // by default check to see if continue processing Flag is not false - final boolean okToContinue = processorContext.canProcessingContinue(); - if (!okToContinue) { - final String errorMessage = - format("Processor: %s. Processing Context flag okToContinue is false. Unable to proceed...", - getProcessorInfo().getProcessorName()); - throw new MessageProcessingException(errorMessage, LOG, new IllegalStateException(errorMessage)); - } - processingState = ProcessingState.PROCESSING_STARTED; - return processorContext; - } - - @Override - public ProcessingState getProcessingState() { - return processingState; - } - - @Override - public Optional getProcessingMessage() { - return Optional.fromNullable(processingMessage); - } - - @Override - public P postProcessor(P processorContext) { - // Default implementation updates the post processing flag if processing did not - // completed successfully - if (processingState != ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY) { - LOG.debug("Processor: {}, Update Process Context State to stop Processing.", - getProcessorInfo().getProcessorName()); - processorContext.setProcessingContinueFlag(false); - } - // attaches itself to message processor context - processorContext.getMessageProcessors().add(this); - LOG.debug("Processing Completed for Processor: {}", getProcessorInfo()); - return processorContext; - } - - - @Override - public final P apply(@Nonnull P processorContext) { - final P preProcessedProcessorContext = preProcessor(processorContext); - final P processedProcessorContext = processMessage(preProcessedProcessorContext); - return postProcessor(processedProcessorContext); - } - - - /** - * Helper method that updates processing state in case of early termination, logs the processing - * termination reason, updates Processor processing state as Terminated and sets it processing message - * - * @param terminatingMessage error Message - * @param processorContext message processor context - */ - protected void setTerminatingProcessingMessage(final String terminatingMessage, - final P processorContext) { - - final String message = processorContext.getMessage(); - this.processingState = ProcessingState.PROCESSING_TERMINATED_EARLY; - this.processingMessage = terminatingMessage; - LOG.debug("Processor: {}, Early Terminating Message: {}, Incoming Message: {}", - getProcessorInfo().getProcessorName(), terminatingMessage, message); - } - - /** - * Helper method that updates Processing state and logs completion message - * passed - * - * @param processorPassingMessage Processor passing message - * @param processorContext message processor context - */ - protected void setFinishedProcessingMessage(final String processorPassingMessage, P processorContext) { - final String message = processorContext.getMessage(); - processingState = ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY; - this.processingMessage = processorPassingMessage; - LOG.debug("Processor: {}, Successful Completion Message: {}, Incoming Message: {}", - getProcessorInfo().getProcessorName(), processorPassingMessage, message); - } - - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractProcessorContext.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractProcessorContext.java deleted file mode 100644 index 15145b5..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractProcessorContext.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import com.google.common.base.Objects; - -import java.util.LinkedList; -import java.util.List; - -/** - *

- * An abstract implementation for {@link ProcessorContext} which other DCAE Analytics Modules - * can extend to add module specific functionality - *

- * - * @author Rajiv Singla. Creation Date: 11/7/2016. - */ -public abstract class AbstractProcessorContext implements ProcessorContext { - - private final String message; - private List> messageProcessors; - private boolean canProcessingContinue; - - public AbstractProcessorContext(final String message, - boolean canProcessingContinue) { - this.message = message; - this.canProcessingContinue = canProcessingContinue; - this.messageProcessors = new LinkedList<>(); - } - - /** - * Returns JSON String of incoming CEF Message that needs to be processed - * - * @return incoming CEF message that needs to be processed - */ - @Override - public String getMessage() { - return message; - } - - /** - * Sets if it is ok to continue processing normally - * - * @return boolean which determines if it is ok to continue processing normally - */ - @Override - public boolean canProcessingContinue() { - return canProcessingContinue; - } - - - /** - * Set if it is ok to continue processing normally - * - * @param canProcessingContinue sets boolean which determines if it is ok to continue processing normally - */ - @Override - public void setProcessingContinueFlag(boolean canProcessingContinue) { - this.canProcessingContinue = canProcessingContinue; - } - - /** - * Provides List of message processors which were used in processing CEF message - * - * @return List of message processors which were used in processing CEF message - */ - @Override - public List> getMessageProcessors() { - return messageProcessors; - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("canProcessingContinue", canProcessingContinue) - .toString(); - } -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessor.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessor.java deleted file mode 100644 index b86d3ad..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessor.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import org.openecomp.dcae.analytics.common.utils.MessageProcessorUtils; - -import java.util.List; - -/** - *

- * A Generic Message Processor which passes the {@link ProcessorContext} from first to second - * {@link MessageProcessor} - *

- * - * @param

Processor Context sub classes - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public class GenericMessageChainProcessor

{ - - private final List> messageProcessors; - private final P initialProcessorContext; - - public GenericMessageChainProcessor(List> messageProcessors, - P initialProcessorContext) { - this.messageProcessors = messageProcessors; - this.initialProcessorContext = initialProcessorContext; - } - - public P processChain() { - - final MessageProcessorUtils.MessageProcessorFunction

messageProcessorFunction = - new MessageProcessorUtils.MessageProcessorFunction

() { - @Override - public > P apply(P context, M processor) { - return processor.apply(context); - } - }; - - return MessageProcessorUtils.computeMessageProcessorChain(messageProcessors, initialProcessorContext, - messageProcessorFunction); - - } - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericProcessorInfo.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericProcessorInfo.java deleted file mode 100644 index 665f787..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericProcessorInfo.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import javax.annotation.Nonnull; - -/** - * A Generic Implementation of {@link ProcessorInfo} - * - * @author Rajiv Singla. Creation Date: 11/7/2016. - */ -public class GenericProcessorInfo implements ProcessorInfo { - - private static final long serialVersionUID = -2840512323233649809L; - - private final String processorName; - private final String processorDescription; - - public GenericProcessorInfo(@Nonnull String processorName, @Nonnull String processorDescription) { - this.processorName = processorName; - this.processorDescription = processorDescription; - } - - public String getProcessorName() { - return processorName; - } - - public String getProcessorDescription() { - return processorDescription; - } - - - @Override - public String toString() { - return processorName; - } -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/MessageProcessor.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/MessageProcessor.java deleted file mode 100644 index 3c09da9..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/MessageProcessor.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import com.google.common.base.Function; -import com.google.common.base.Optional; - -import java.io.Serializable; - -/** - *

- * A message processor can be used to process incoming messages. - * It uses implementations of {@link ProcessorContext} as input and output - *

- * - * @param

Message Processor Context implementations - * - * @author Rajiv Singla. Creation Date: 11/7/2016. - */ -public interface MessageProcessor

extends Function, Serializable { - - /** - * Returns processor information - * - * @return processor Information - */ - ProcessorInfo getProcessorInfo(); - - - /** - * Does pre-processing of {@link ProcessorContext} e.g. validate input conditions and return - * pre processed context - * - * @param processorContext incoming Processor Context - * @return Pre processed Processor Context - */ - P preProcessor(P processorContext); - - - /** - * Return processing state of a processor - * - * @return Processing State - */ - ProcessingState getProcessingState(); - - - /** - * May return a message from a processor which indicates the reason for {@link ProcessingState} especially if - * there was some failure in processing - * - * @return processing Message - */ - Optional getProcessingMessage(); - - - /** - * Does post-processing of {@link ProcessorContext} - * - * @param processorContext incoming Processor Context - * @return processor Context after post processing is finished - */ - P postProcessor(P processorContext); - - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessingState.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessingState.java deleted file mode 100644 index c5090f7..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessingState.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -/** - *

- * Processing state of a {@link MessageProcessor} - *

- * @author Rajiv Singla. Creation Date: 11/5/2016. - */ -public enum ProcessingState { - - PROCESSING_STARTED, - PROCESSING_FINISHED_SUCCESSFULLY, - PROCESSING_TERMINATED_EARLY, - PROCESSING_NOT_REQUIRED; - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorContext.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorContext.java deleted file mode 100644 index 74eabd7..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorContext.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import java.io.Serializable; -import java.util.List; - -/** - *

- * A Processor Context is used a an input and output to a {@link MessageProcessor} - *
- * DCAE Analytics sub projects should extend this interface and add specific fields - * required for input and output - *

- * - * @author Rajiv Singla. Creation Date: 11/7/2016. - */ -public interface ProcessorContext extends Serializable { - - /** - * Returns Processor Context message that will be processed by Chain of Processors - * - * @return message that need to be processed by processors - */ - String getMessage(); - - /** - * Processing Context flag which determines if Processing can continue in a processing - * chain - * - * @return true if ok to continue processing normally - */ - boolean canProcessingContinue(); - - - /** - * Sets new value for ProcessingContinue flag which will cause early termination of processing in chain if - * set to false - * - * @param canProcessingContinue set new value for canProcessing Continue flag - */ - void setProcessingContinueFlag(boolean canProcessingContinue); - - - /** - * Provides a List of previous processors which have completed processing - * - * @return list of previous processors - */ - List> getMessageProcessors(); - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorInfo.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorInfo.java deleted file mode 100644 index e657ed7..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorInfo.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import java.io.Serializable; - -/** - *

- * Contains Information about a processor. For e.g. Processor name, processor description etc - *

- * - * @author Rajiv Singla. Creation Date: 11/7/2016. - */ -public interface ProcessorInfo extends Serializable { - - /** - * Returns a name which should uniquely identify a particular {@link MessageProcessor} - * - * @return processor name - */ - String getProcessorName(); - - - /** - * Returns description of a {@link MessageProcessor} - * - * @return processor description - */ - String getProcessorDescription(); - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/HTTPUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/HTTPUtils.java deleted file mode 100644 index 4c36cb3..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/HTTPUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.utils; - -/** - * Contains common utils to check HTTP Related Utils - * - * @author Rajiv Singla. Creation Date: 11/2/2016. - */ -public abstract class HTTPUtils { - - /** - * HTTP Status code for successful HTTP call - */ - public static final Integer HTTP_SUCCESS_STATUS_CODE = 200; - - /** - * HTTP Response code when request has been accepted for processing, but the processing has not been completed - */ - public static final Integer HTTP_ACCEPTED_RESPONSE_CODE = 202; - - /** - * HTTP Response code when there is no content - */ - public static final Integer HTTP_NO_CONTENT_RESPONSE_CODE = 204; - - - public static final String JSON_APPLICATION_TYPE = "application/json"; - - /** - * Checks if HTTP Status code is less than or equal to 200 but less then 300 - * - * @param statusCode http status code - * @return true if response code between 200 and 300 - */ - public static boolean isSuccessfulResponseCode(Integer statusCode) { - return statusCode >= 200 && statusCode < 300; - } -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/MessageProcessorUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/MessageProcessorUtils.java deleted file mode 100644 index 10c8d7c..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/MessageProcessorUtils.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.utils; - -import org.openecomp.dcae.analytics.common.exception.MessageProcessingException; -import org.openecomp.dcae.analytics.common.service.processor.MessageProcessor; -import org.openecomp.dcae.analytics.common.service.processor.ProcessorContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Iterator; - - -/** - * Contains utility methods for {@link MessageProcessor} - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public abstract class MessageProcessorUtils { - - private static final Logger LOG = LoggerFactory.getLogger(MessageProcessorUtils.class); - - /** - * Provides an abstraction how to apply {@link ProcessorContext} to next {@link MessageProcessor} - * in the message processor chain - * - * @param

Sub classes of Processor Context - */ - public interface MessageProcessorFunction

{ - - /** - * Method which provides accumulated {@link ProcessorContext} from previous processors and a reference - * to next processor in the chain - * - * @param p accumulated {@link ProcessorContext} from previous processors - * @param m current {@link MessageProcessor} in the chain - * @param Message processor sub classes - * - * @return processing context after computing the current Message Processor - */ - > P apply(P p, M m); - } - - - /** - * Provides an abstraction to compute a chain of {@link MessageProcessor} - * - * @param messageProcessors An iterable containing one or more {@link MessageProcessor}s - * @param initialProcessorContext An initial processing Context - * @param messageProcessorFunction messageProcessor Function - * @param

Sub classes for Processor Context - * - * @return processing context which results after computing the whole chain - */ - public static

P computeMessageProcessorChain( - final Iterable> messageProcessors, - final P initialProcessorContext, - final MessageProcessorFunction

messageProcessorFunction) { - - // Get message processor iterator - final Iterator> processorIterator = messageProcessors.iterator(); - - // If no next message processor - return initial processor context - if (!processorIterator.hasNext()) { - return initialProcessorContext; - } - - // An accumulator for processor Context - P processorContextAccumulator = initialProcessorContext; - - while (processorIterator.hasNext()) { - - final MessageProcessor

nextProcessor = processorIterator.next(); - - // If Initial Processor Context is null - if (processorContextAccumulator == null) { - final String errorMessage = - String.format("Processor Context must not be null for Message Process: %s", - nextProcessor.getProcessorInfo().getProcessorName()); - throw new MessageProcessingException(errorMessage, LOG, new IllegalStateException(errorMessage)); - } - - - if (!processorContextAccumulator.canProcessingContinue()) { - LOG.debug("Triggering Early Termination, before Message Processor: {}, Incoming Message: {}", - nextProcessor.getProcessorInfo().getProcessorName(), processorContextAccumulator.getMessage()); - break; - } - processorContextAccumulator = messageProcessorFunction.apply(processorContextAccumulator, nextProcessor); - } - - return processorContextAccumulator; - } - - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/PersistenceUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/PersistenceUtils.java deleted file mode 100644 index e408171..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/PersistenceUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.utils; - -import java.util.Date; - -/** - * Contains Utility methods for creating persistence row keys etc. - * - * @author Rajiv Singla. Creation Date: 11/16/2016. - */ -public abstract class PersistenceUtils { - - - /** - * Name of the column which will contain Table Key - */ - public static final String TABLE_ROW_KEY_COLUMN_NAME = "key"; - - /** - * Delimited to be used when creating a row key with multiple fields - */ - public static final String ROW_KEY_DELIMITER = "-"; - - /** - * Creates a decreasing number using current timestamp. Handy when you want to keep records most recent records - * close to the top of column table like HBase - * - * @return decreasing number - */ - public static String getCurrentTimeReverseSubKey() { - final long timeReverseLong = Long.MAX_VALUE - new Date().getTime(); - return String.format("%025d", timeReverseLong); - } - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/ValidationUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/ValidationUtils.java deleted file mode 100644 index 694529f..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/ValidationUtils.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.utils; - -import org.openecomp.dcae.analytics.common.cdap.settings.CDAPAppSettings; -import org.openecomp.dcae.analytics.common.cdap.validation.CDAPAppSettingsValidator; -import org.openecomp.dcae.analytics.common.exception.CDAPSettingsException; -import org.openecomp.dcae.analytics.common.validation.ValidationResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Contains utility methods to validate null checks, empty string etc - * - * @author Rajiv Singla. Creation Date: 10/24/2016. - */ -public abstract class ValidationUtils { - - private static final Logger LOG = LoggerFactory.getLogger(ValidationUtils.class); - - /** - * 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(final @Nullable String stringValue) { - return stringValue == null || stringValue.isEmpty() || stringValue.trim().isEmpty(); - } - - - /** - * Provides common functionality to Validates CDAP App Settings. Throws Runtime exception if validation fails - * - * @param appSettings app Settings e.g. App Config, App Preferences etc - * @param appSettingsValidator app Settings validator - * - * @param Settings type e.g. AppConfig or AppPreferences - * @param Validation Response type - * @param Validator Type - */ - public static , - V extends CDAPAppSettingsValidator> void validateSettings(final @Nonnull T appSettings, - final @Nonnull V appSettingsValidator) { - checkNotNull(appSettings, "App Settings must not be null"); - checkNotNull(appSettingsValidator, "App Settings validator must not be null"); - - final String appSettingsClassName = appSettings.getClass().getSimpleName(); - final String appSettingsClassValidator = appSettingsValidator.getClass().getSimpleName(); - - LOG.debug("Validating App Settings for: {}, with App Settings Validator: {} ", - appSettingsClassName, appSettingsClassValidator); - - final R validationResponse = appSettingsValidator.validateAppSettings(appSettings); - - // If setting validation fails throw an exception - if (validationResponse.hasErrors()) { - throw new CDAPSettingsException( - validationResponse.getAllErrorMessage(), LOG, new IllegalArgumentException()); - } - - LOG.debug("App Settings Validation Successful for app Settings: {} with validator: {}", appSettingsClassName, - appSettingsClassValidator); - } - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/DCAEValidator.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/DCAEValidator.java deleted file mode 100644 index 065411f..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/DCAEValidator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.validation; - -/** - * Marker interface for all DCAE Validators - * - * @author Rajiv Singla. Creation Date: 10/24/2016. - */ -public interface DCAEValidator { -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/GenericValidationResponse.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/GenericValidationResponse.java deleted file mode 100644 index 7015ffe..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/GenericValidationResponse.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.validation; - -import com.google.common.base.Joiner; -import com.google.common.base.Objects; - -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -/** - * A generic implementation of Validation Response - * - * @param Validation Entity Type - * - * @author Rajiv Singla. Creation Date: 10/24/2016. - */ -public class GenericValidationResponse implements ValidationResponse { - - private LinkedHashMap errorMessageMap = new LinkedHashMap<>(); - - @Override - public boolean hasErrors() { - return errorMessageMap.size() != 0; - } - - @Override - public Set getFieldNamesWithError() { - return errorMessageMap.keySet(); - } - - public Collection getErrorMessageMap() { - return errorMessageMap.values(); - } - - @Override - public Map getValidationResultsAsMap() { - return errorMessageMap; - } - - - @Override - public String getAllErrorMessage() { - return getAllErrorMessage(","); - } - - @Override - public String getAllErrorMessage(String delimiter) { - return Joiner.on(delimiter).join(errorMessageMap.values()); - } - - @Override - public void addErrorMessage(String fieldName, String filedErrorMessage) { - errorMessageMap.put(fieldName, filedErrorMessage); - } - - @Override - public String toString() { - return Objects.toStringHelper(this) - .add("hasErrors", hasErrors()) - .add("errorMessageMap", errorMessageMap) - .toString(); - } -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/ValidationResponse.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/ValidationResponse.java deleted file mode 100644 index b1b7a16..0000000 --- a/dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/ValidationResponse.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.validation; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -/** - * Validation Response contract - * - * @param Entity class type which is being validated - * - * @author Rajiv Singla. Creation Date: 10/24/2016. - */ -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 getFieldNamesWithError(); - - /** - * Returns list of all error messages - * - * @return list of error messages - */ - Collection getErrorMessageMap(); - - - /** - * 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 getValidationResultsAsMap(); - -} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/AnalyticsConstants.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/AnalyticsConstants.java new file mode 100644 index 0000000..4294d6a --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/AnalyticsConstants.java @@ -0,0 +1,134 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common; + +/** + * Contains static variable for all DCAE Components. + * + * @author Rajiv Singla. Creation Date: 10/21/2016. + */ +public abstract class AnalyticsConstants { + + + // =============== Common Constants for all DCAE Analytics Modules ==================== // + + + // =============== DMaaP Constants for all DCAE Analytics Modules ==================== // + + public static final String DMAAP_URI_PATH_PREFIX = "/events/"; + public static final String DMAAP_GROUP_PREFIX = "OpenDCAE-"; + + // ================== DMaaP MR Constants ============================== // + // Publisher Constants + public static final int DEFAULT_PUBLISHER_MAX_BATCH_SIZE = 100; + public static final int DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE = 100000; + public static final int PUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE = 5; + public static final int PUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE = 5000; + // Subscriber Constants + public static final int DEFAULT_SUBSCRIBER_TIMEOUT_MS = -1; + public static final int DEFAULT_SUBSCRIBER_MESSAGE_LIMIT = -1; + public static final String DEFAULT_SUBSCRIBER_GROUP_PREFIX = DMAAP_GROUP_PREFIX + "DMaaPSub-"; + public static final String SUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME = "timeout"; + public static final String SUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME = "limit"; + + + // ================== TCA Constants ============================== // + + // Default subscriber polling interval + public static final Integer TCA_DEFAULT_SUBSCRIBER_POLLING_INTERVAL_MS = 30000; + + // Default publisher polling interval + public static final Integer TCA_DEFAULT_PUBLISHER_POLLING_INTERVAL_MS = 30000; + + // Default publisher max batch queue size determines the minimum number of messages that need to be published in + // batch mode + public static final Integer TCA_DEFAULT_PUBLISHER_MAX_BATCH_QUEUE_SIZE = 10; + + // Default publisher max recovery queue size determines max number of messages can be cached in memory + // in case publisher is not responding + public static final Integer TCA_DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE = 100000; + + // Default interval during which TCA DMaaP Worker checks if scheduler is shut down + public static final Integer TCA_DEFAULT_WORKER_SHUTDOWN_CHECK_INTERVAL_MS = 10000; + + // ***** TCA Quartz Scheduler Settings ******// + + public static final String TCA_QUARTZ_SUBSCRIBER_PROPERTIES_FILE_NAME = "quartz-subscriber.properties"; + + public static final String TCA_QUARTZ_PUBLISHER_PROPERTIES_FILE_NAME = "quartz-publisher.properties"; + + // TCA Quartz Group Settings + public static final String TCA_QUARTZ_GROUP_NAME = "TCAQuartzGroup"; + // TCA Quartz Trigger Settings + public static final String TCA_DMAAP_SUBSCRIBER_QUARTZ_TRIGGER_NAME = "TCADMaaPSubscriberTrigger"; + public static final String TCA_DMAAP_PUBLISHER_QUARTZ_TRIGGER_NAME = "TCADMaaPPublisherTrigger"; + + // TCA Quartz DMaaP Subscriber Job Settings + public static final String TCA_DMAAP_SUBSCRIBER_QUARTZ_JOB_NAME = "TCADMaaPSubscriberJob"; + public static final String TCA_DMAAP_PUBLISHER_QUARTZ_JOB_NAME = "TCADMaaPPublisherJob"; + + // TCA Quartz Publisher and Subscriber Job Parameters + // Common Job parameters for both Publisher and Subscriber + public static final String WORKER_CONTEXT_VARIABLE_NAME = "WORKER_CONTEXT"; + public static final String DMAAP_METRICS_VARIABLE_NAME = "DMAAP_METRICS"; + // TCA Quartz DMaaP Subscriber Job Parameter Settings + public static final String CDAP_STREAM_VARIABLE_NAME = "CDAP_STREAM_NAME"; + public static final String DMAAP_SUBSCRIBER_VARIABLE_NAME = "DMAAP_SUBSCRIBER"; + // TCA Quartz DMaaP Publisher Job Parameter Settings + public static final String CDAP_ALERTS_TABLE_VARIABLE_NAME = "CDAP_TCA_ALERTS_TABLE_NAME"; + public static final String DMAAP_PUBLISHER_VARIABLE_NAME = "DMAAP_PUBLISHER"; + + // TCA VES Response Constants + public static final String TCA_VES_RESPONSE_TARGET_TYPE = "VNF"; + public static final String TCA_VES_RESPONSE_TARGET = "generic-vnf.vnf-id"; + public static final String TCA_VES_RESPONSE_FROM = "DCAE"; + public static final String TCA_VES_RESPONSE_CLOSED_LOOP_EVENT_STATUS = "ONSET"; + + // TCA VES Response Constants for vLoadBalancer + public static final String LOAD_BALANCER_FUNCTIONAL_ROLE = "vLoadBalancer"; + public static final String LOAD_BALANCER_TCA_VES_RESPONSE_TARGET_TYPE = "VM"; + public static final String LOAD_BALANCER_TCA_VES_RESPONSE_TARGET = "vserver.vserver-name"; + + // TCA VES Message Router Partition Key + public static final String TCA_VES_MESSAGE_ROUTER_PARTITION_KEY = "VESMessageHash"; + + /** + * Default Number of instances for Threshold violation calculator flowlet + */ + public static final Integer TCA_DEFAULT_THRESHOLD_CALCULATOR_FLOWLET_INSTANCES = 2; + + /** + * Default TTL for TCA VES Message status table which contain status of all messages processed by TCA + */ + public static final Integer TCA_DEFAULT_VES_MESSAGE_STATUS_TTL_TABLE = 60 * 60 * 24 * 10; // 10 Days + + /** + * Default TTL for TCA VES Alerts table which contains alerts that can be send to downstream systems + */ + public static final Integer TCA_DEFAULT_VES_ALERTS_TTL_TABLE = 60 * 60 * 24 * 20; // 20 Days + + + // TCA Policy Runtime Argument Paths + public static final String TCA_POLICY_DELIMITER = "."; + public static final String TCA_POLICY_DOMAIN_PATH = "domain"; + public static final String TCA_POLICY_METRICS_PER_FUNCTIONAL_ROLE_PATH = "configuration.metricsPerFunctionalRole"; + public static final String TCA_POLICY_THRESHOLDS_PATH_POSTFIX = "thresholds"; +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPComponentsConstants.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPComponentsConstants.java new file mode 100644 index 0000000..ab39ee9 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPComponentsConstants.java @@ -0,0 +1,196 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common; + +/** + * Contains static constant variable names and values of all DCAE CDAP Components for + * e.g. app names, app descriptions, streams, datasets, flows, flowlets, workers, outputs etc. + * + *

+ * A strict naming convention must be followed for variable names for CDAP Components names for proper + * identification of CDAP Component variable purpose and function. A custom configuration settings can be + * generated for app + * deployment purposes based on variable naming conventions. + * + * The variable names should have 4 parts separated by an underscore: + *

    + *
  • Name of the DCAE sub module (e.g. TCA) to which variable is applicable
  • + *
  • Information about variable name: + *
      + *
    • FIXED - if variable value is fixed and cannot be changed
    • + *
    • DEFAULT - if variable name is default name and can be changed by cdap settings file + * when application is created
    • + *
    + *
  • + *
  • Actual Descriptive name about the CDAP component (may contain underscrores)
  • + *
  • CDAP component type e.g STREAM, DATASET, APP, FLOW, FLOWLET, OUTPUT
  • + *
+ * + *

e.g TCA_DEFAULT_DMAAP_INPUT_STREAM

+ * + *

RegEx Format (DCAE MODULE NAME)_(FIXED|DEFAULT)_(VARIABLE NAME)_(CDAP COMPONENT TYPE)

+ * + * @author Rajiv Singla. Creation Date: 10/24/2016. + */ +public abstract class CDAPComponentsConstants { + + // =============== Common Module Constants ==================== // + + /** + * Default DCAE App Name. It should be overriden by sub modules + */ + public static final String COMMON_DEFAULT_DCAE_CDAP_NAME_APP = "DCAE_ANALYTICS_GENERIC_APP"; + + /** + * Default DCAE App Description. It should be overriden by sub modules + */ + public static final String COMMON_DEFAULT_DCAE_CDAP_DESCRIPTION_APP = "DCAE ANALYTICS GENERIC APP DESCRIPTION"; + + // =============== TCA Module Constants ==================== // + + /** + * Default TCA application name if application name is not provided from startup configuration + */ + public static final String TCA_DEFAULT_NAME_APP = "dcae-tca"; + + /** + * Default TCA application description if not provided from startup configuration + */ + public static final String TCA_DEFAULT_DESCRIPTION_APP = "DCAE Analytics Threshold Crossing Alert Application"; + + /** + * Default TCA DMaaP Subscriber output stream name if not provided from startup configuration + */ + public static final String TCA_DEFAULT_SUBSCRIBER_OUTPUT_NAME_STREAM = "TCASubscriberOutputStream"; + + + /** + * Fixed TCA DMaaP Subscriber output stream description + */ + public static final String TCA_FIXED_SUBSCRIBER_OUTPUT_DESCRIPTION_STREAM = + "Stream which contains all message from VES Collector DMaaP MR topic"; + + + /** + * Fixed Name of TCA DMaaP Subscriber Worker - which will be fetching DMaaP Messages posting them to CDAP stream + */ + public static final String TCA_FIXED_DMAAP_SUBSCRIBER_WORKER = "TCADMaaPMRSubscriberWorker"; + + /** + * Fixed Description of TCA DMaaP Subscriber Worker + */ + public static final String TCA_FIXED_DMAAP_SUBSCRIBER_DESCRIPTION_WORKER = + "Fetches messages from DMaaP MR Topic at frequent intervals and writes them to a CDAP stream"; + + /** + * Fixed Name of TCA DMaaP Publisher Worker - which will be publishing messages to DMaaP MR + */ + public static final String TCA_FIXED_DMAAP_PUBLISHER_WORKER = "TCADMaaPMRPublisherWorker"; + + /** + * Fixed Description of TCA DMaaP Publisher Worker + */ + public static final String TCA_FIXED_DMAAP_PUBLISHER_DESCRIPTION_WORKER = + "Polls TCA Alerts Table at frequent intervals for new alerts and publishes them to DMaaP MR Topic"; + + /** + * Fixed name for TCA VES Collector Messages Processing Flow + */ + public static final String TCA_FIXED_VES_COLLECTOR_NAME_FLOW = "TCAVESCollectorFlow"; + + + /** + * Fixed description for TCA VES Collector Messages Processing Flow + */ + public static final String TCA_FIXED_VES_COLLECTOR_DESCRIPTION_FLOW = "Flow performs TCA on VES Collector Messages"; + + + /** + * Fixed Name for TCA VES Message Router Flowlet + */ + public static final String TCA_FIXED_VES_MESSAGE_ROUTER_NAME_FLOWLET = "TCAVESMessageRouterFlowlet"; + + /** + * Fixed Description for TCA VES Message Router Flowlet + */ + public static final String TCA_FIXED_VES_MESSAGE_ROUTER_DESCRIPTION_FLOWLET = + "Routes message received from TCA VES Collector to TCA Threshold Calculator Flowlet instances"; + + /** + * Fixed TCA VES Message Router Flowlet Output + */ + public static final String TCA_FIXED_VES_MESSAGE_ROUTER_OUTPUT = "TCAVESMessageRouterFlowlet"; + + /** + * Fixed Name for TCA VES Message Policy Violated Threshold Calculator Flowlet + */ + public static final String TCA_FIXED_VES_THRESHOLD_VIOLATION_CALCULATOR_NAME_FLOWLET = + "TCAVESThresholdViolationCalculatorFlowlet"; + + /** + * Fixed Description for TCA VES Message Policy Violated Threshold Calculator Flowlet + */ + public static final String TCA_FIXED_VES_THRESHOLD_VIOLATION_CALCULATOR_DESCRIPTION_FLOWLET = + "Applies TCA Policy Thresholds to VES Message and determined if any message violated TCA Policy thresholds"; + + /** + * Fixed Name for TCA VES Message Policy Violated Threshold Calculator Output + */ + public static final String TCA_FIXED_VES_TCA_CALCULATOR_NAME_OUTPUT = "TCAThresholdViolationCalculatorOutput"; + + + /** + * Fixed Name for TCA VES Alerts Sink Flowlet + */ + public static final String TCA_FIXED_VES_ALERTS_SINK_NAME_FLOWLET = "TCAVESAlertsSinkFlowlet"; + + /** + * Fixed Description for TCA VES Alerts Sink Flowlet + */ + public static final String TCA_FIXED_VES_ALERTS_SINK_DESCRIPTION_FLOWLET = + "Saves messages which violated TCA Policy in a data set"; + + + /** + * Default Name for TCA VES Message status table which contain status of all messages processed by TCA + */ + public static final String TCA_DEFAULT_VES_MESSAGE_STATUS_NAME_TABLE = "TCAVESMessageStatusTable"; + + + /** + * Fixed Description for TCA VES Message status table which contain status of all messages processed by TCA + */ + public static final String TCA_FIXED_VES_MESSAGE_STATUS_DESCRIPTION_TABLE = + "Store processing information about all incoming TCA VES Messages"; + + /** + * Default Name for TCA VES Alerts table which contains alerts that can be send to downstream systems + */ + public static final String TCA_DEFAULT_VES_ALERTS_NAME_TABLE = "TCAVESAlertsTable"; + + /** + * Fixed Description for TCA VES Alerts table which contains alerts that can be send to downstream systems + */ + public static final String TCA_DEFAULT_VES_ALERTS_DESCRIPTION_TABLE = + "Stores alert messages that need to be DMaaP"; + + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPMetricsConstants.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPMetricsConstants.java new file mode 100644 index 0000000..63ac7e0 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/CDAPMetricsConstants.java @@ -0,0 +1,112 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common; + +/** + * Contains all metrics names used for DCAE CDAP modules + * + *

+ * Format should be (ModuleName)_(Description of metrics)_METRIC e.g. TCA_WORKER_FAILED_ATTEMPTS_METRIC + *

+ * + * @author Rajiv Singla. Creation Date: 10/25/2016. + */ +public abstract class CDAPMetricsConstants { + + /** + * Metric captures count of all responses received from DMaaP MR Subscriber Topic + */ + public static final String TCA_SUBSCRIBER_ALL_RESPONSES_COUNT_METRIC = "tca.subscriber.fetch.all_responses"; + + /** + * Metric captures count of responses from DMaaP MR Subscriber Topic which does not have 200 HTTP Response code. + * This can be due to DMaaP topic being down or any internal server errors etc. + */ + public static final String TCA_SUBSCRIBER_UNSUCCESSFUL_RESPONSES_METRIC = "tca.subscriber.fetch.unsuccessful"; + + /** + * Metric that counts the number of successful (200 HTTP Response Code) calls to DMaaP which did not had empty + * messages + */ + public static final String TCA_SUBSCRIBER_RESPONSES_WITH_NO_MESSAGES_METRIC = "tca.subscriber.fetch.no_message"; + + /** + * Metric to count total number of VES Collector message processed by tca subscriber + */ + public static final String TCA_SUBSCRIBER_TOTAL_MESSAGES_PROCESSED_METRIC = "tca.subscriber.message.count"; + + + /** + * Metric to record time taken in ms by subscriber in its most recent call to fetch DMaaP MR messages + */ + public static final String TCA_SUBSCRIBER_RESPONSE_TIME_MS_METRIC = "tca.subscriber.fetch.response_time"; + + /** + * Metric captures the count of number of times DMaaP MR Subscriber was unable to write to DMaaP Stream due + * some CDAP error while writing to stream. This should ideally never happen assuming we have enough space + * on CDAP machine and CDAP process is functioning normally + */ + public static final String TCA_SUBSCRIBER_FAILURE_TO_WRITE_TO_STREAM_METRIC = "tca.subscriber.stream.writing.error"; + + + /** + * Metric captures number of VES messages that are not applicable as per TCA Policy + */ + public static final String TCA_VES_INAPPLICABLE_MESSAGES_METRIC = "tca.ves.calculator.inapplicable"; + + /** + * Metric captures number of VES messages that are applicable as per TCA Policy but don't violate any thresholds + */ + public static final String TCA_VES_COMPLIANT_MESSAGES_METRIC = "tca.ves.calculator.compliant"; + + /** + * Metrics captures number of VES messages that are applicable as per TCA Policy and does violate thresholds and + * will likely cause an alert + */ + public static final String TCA_VES_NON_COMPLIANT_MESSAGES_METRIC = "tca.ves.calculator.non_compliant"; + + + /** + * Metric that counts the number of publisher look ups in alerts table which resulted in 0 new alerts + */ + public static final String TCA_PUBLISHER_NO_NEW_ALERTS_LOOKUP_METRIC = "tca.publisher.lookup.no_message"; + + /** + * Metric that counts the number of new alerts found by the publisher in alerts table + */ + public static final String TCA_PUBLISHER_NEW_ALERTS_METRIC = "tca.publisher.lookup.new_messages"; + + /** + * Metric that counts the number of alerts deleted by publisher in alerts table + */ + public static final String TCA_PUBLISHER_DELETED_ALERTS_METRIC = "tca.publisher.deleted.alerts"; + + /** + * Metric that counts the number of publisher calls to DMaaP which resulted in successful response code + */ + public static final String TCA_PUBLISHER_SUCCESSFUL_DMAAP_RESPONSE_METRIC = "tca.publisher.publish.successful"; + + /** + * Metric that counts the number of publisher calls to DMaaP which resulted in unsuccessful response code + */ + public static final String TCA_PUBLISHER_UNSUCCESSFUL_DMAAP_RESPONSE_METRIC = "tca.publisher.publish.unsuccessful"; + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/DCAEAnalyticsPreferences.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/DCAEAnalyticsPreferences.java new file mode 100644 index 0000000..c912179 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/DCAEAnalyticsPreferences.java @@ -0,0 +1,29 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common; + +/** + * A Marker Interface for all DCAE Analytics Preferences + * + * @author Rajiv Singla. Creation Date: 10/26/2016. + */ +public interface DCAEAnalyticsPreferences { +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppConfig.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppConfig.java new file mode 100644 index 0000000..a47170f --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppConfig.java @@ -0,0 +1,47 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.cdap.settings; + +/** + *

+ * Minimum Contract for all CDAP App Configs + *

+ * + * @author Rajiv Singla. Creation Date: 11/2/2016. + */ +public interface CDAPAppConfig extends CDAPAppSettings { + + /** + * CDAP Application Name + * + * @return cdap app name + */ + String getAppName(); + + + /** + * CDAP Application Description + * + * @return cdap app description + */ + String getAppDescription(); + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppPreferences.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppPreferences.java new file mode 100644 index 0000000..67fbfc1 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppPreferences.java @@ -0,0 +1,31 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.cdap.settings; + +/** + *

+ * Marker Interface for all CDAP Preferences + *

+ * + * @author Rajiv Singla. Creation Date: 11/2/2016. + */ +public interface CDAPAppPreferences extends CDAPAppSettings { +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppSettings.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppSettings.java new file mode 100644 index 0000000..9e96cfe --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPAppSettings.java @@ -0,0 +1,35 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.cdap.settings; + +import java.io.Serializable; + +/** + *

+ * A marker interface for all CDAP Related App Settings. + * App Settings can either be preferences, cdap app settings etc. + *

+ * + * + * @author Rajiv Singla. Creation Date: 11/2/2016. + */ +public interface CDAPAppSettings extends Serializable { +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPBaseAppConfig.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPBaseAppConfig.java new file mode 100644 index 0000000..38c882f --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/settings/CDAPBaseAppConfig.java @@ -0,0 +1,62 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.cdap.settings; + +import co.cask.cdap.api.Config; +import org.openecomp.dcae.apod.analytics.common.CDAPComponentsConstants; + +/** + * Base class for all DACE Analytics Application Configurations + * + * @author Rajiv Singla. Creation Date: 10/4/2016. + */ +public abstract class CDAPBaseAppConfig extends Config implements CDAPAppConfig { + + + /** + * DCAE Analytics App Name + */ + protected String appName = CDAPComponentsConstants.COMMON_DEFAULT_DCAE_CDAP_NAME_APP; + + /** + * DCAE Analytics App Description + */ + protected String appDescription = CDAPComponentsConstants.COMMON_DEFAULT_DCAE_CDAP_DESCRIPTION_APP; + + + /** + * Returns DCAE Analytics CDAP Application name + * + * @return CDAP application name + */ + public String getAppName() { + return appName; + } + + /** + * Returns DCAE Analytics CDAP Application descrption + * + * @return CDAP application description + */ + public String getAppDescription() { + return appDescription; + } +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/validation/CDAPAppSettingsValidator.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/validation/CDAPAppSettingsValidator.java new file mode 100644 index 0000000..7ebe8e3 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/cdap/validation/CDAPAppSettingsValidator.java @@ -0,0 +1,52 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.cdap.validation; + +import org.openecomp.dcae.apod.analytics.common.cdap.settings.CDAPAppSettings; +import org.openecomp.dcae.apod.analytics.common.validation.DCAEValidator; +import org.openecomp.dcae.apod.analytics.common.validation.ValidationResponse; + +/** + *

+ * Validates CDAP Application Settings (AppConfig, Preferences etc) + *

+ * + * @param {@link CDAPAppSettings} DCAE Analytics App Settings (e.g. AppConfig, Preferences) + * @param {@link ValidationResponse} Validator response implementations + * + * @author Rajiv Singla. Creation Date: 11/2/2016. + */ +public interface CDAPAppSettingsValidator> + extends DCAEValidator { + + /** + * Validates DCAE Analytics App Settings and return Validation response which can be + * checked for any app setting issues + * + * @param appSettings DCAE CDAP Application Settings (e.g. AppConfig, Preferences etc.) + * @return validation response + */ + R validateAppSettings(T appSettings); + + +} + + diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/CDAPSettingsException.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/CDAPSettingsException.java new file mode 100644 index 0000000..f5a8037 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/CDAPSettingsException.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.exception; + +import org.slf4j.Logger; + +/** + * Runtime exception which signals that DCAE CDAP App settings (e.g. app config, preferences) validation failed + * + * @author Rajiv Singla. Creation Date: 10/24/2016. + */ +public class CDAPSettingsException extends DCAEAnalyticsRuntimeException { + + /** + * @param message - Error Message for Exception + * @param cause - Actual Exception which caused {@link DCAEAnalyticsRuntimeException} + */ + public CDAPSettingsException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Creates and logs the DCAE App Config Exception to given logger + * + * @param message - Error Message for Exception and logging + * @param logger - Logger used for logging exception + * @param cause - Actual exception which caused + */ + public CDAPSettingsException(String message, Logger logger, Throwable cause) { + super(message, logger, cause); + } +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/DCAEAnalyticsRuntimeException.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/DCAEAnalyticsRuntimeException.java new file mode 100644 index 0000000..559e6ae --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/DCAEAnalyticsRuntimeException.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.exception; + +import org.slf4j.Logger; + +/** + * Runtime Exception for DCAE Analytics Exceptions. All DCAE Analytics + * runtime Exceptions must be wrapped inside this exception + *

+ * @author Rajiv Singla. Creation Date: 10/5/2016. + */ +public class DCAEAnalyticsRuntimeException extends RuntimeException { + + + /** + * @param message - Error Message for Exception + * @param cause - Actual Exception which caused {@link DCAEAnalyticsRuntimeException} + */ + public DCAEAnalyticsRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Creates and logs the DCAE Runtime Exception to given logger + * + * @param message - Error Message for Exception and logging + * @param logger - Logger used for logging exception + * @param cause - Actual exception which caused {@link DCAEAnalyticsRuntimeException} + */ + public DCAEAnalyticsRuntimeException(String message, Logger logger, Throwable cause) { + super(message, cause); + logger.error(message); + } + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/MessageProcessingException.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/MessageProcessingException.java new file mode 100644 index 0000000..44ef147 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/exception/MessageProcessingException.java @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.exception; + +import org.openecomp.dcae.apod.analytics.common.service.processor.MessageProcessor; +import org.slf4j.Logger; + +/** + * Runtime Exception caused due to {@link MessageProcessor} failure while processing a message. + * + * @author Rajiv Singla. Creation Date: 11/7/2016. + */ +public class MessageProcessingException extends DCAEAnalyticsRuntimeException { + + /** + * @param message - Error Message for Exception + * @param cause - Actual Exception which caused {@link DCAEAnalyticsRuntimeException} + */ + public MessageProcessingException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Creates and logs the DCAE Runtime Exception to given logger + * + * @param message - Error Message for Exception and logging + * @param logger - Logger used for logging exception + * @param cause - Actual exception which caused {@link DCAEAnalyticsRuntimeException} + */ + public MessageProcessingException(String message, Logger logger, Throwable cause) { + super(message, logger, cause); + } +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractMessageProcessor.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractMessageProcessor.java new file mode 100644 index 0000000..c90858a --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractMessageProcessor.java @@ -0,0 +1,162 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import com.google.common.base.Optional; +import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; + +import static java.lang.String.format; + +/** + * An abstract Message Processor which can be extended by {@link MessageProcessor} implementations + * to get default behavior for Message Processors + * + * @param

Processor Context sub classes + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public abstract class AbstractMessageProcessor

implements MessageProcessor

{ + + private static final Logger LOG = LoggerFactory.getLogger(AbstractMessageProcessor.class); + + /** + * By Default there is no processing message + */ + private String processingMessage = null; + + /** + * By Default Processing State is set to not required - subclasses must + * set processing state to {@link ProcessingState#PROCESSING_FINISHED_SUCCESSFULLY} on successful processing + * or {@link ProcessingState#PROCESSING_TERMINATED_EARLY} if processing fails + */ + protected ProcessingState processingState = ProcessingState.PROCESSING_NOT_REQUIRED; + + /** + * Sub classes must provide a description of a processor + * + * @return description of processor + * + */ + public abstract String getProcessorDescription(); + + + /** + * Sub classes must provide implementation to process Message + * + * @param processorContext incoming {@link ProcessorContext} + * @return outgoing {@link ProcessorContext} + */ + public abstract P processMessage(P processorContext); + + @Override + public ProcessorInfo getProcessorInfo() { + // by default the class of the Processor is assigned as Processor Name + final String processorClassName = getClass().getSimpleName(); + return new GenericProcessorInfo(processorClassName, getProcessorDescription()); + } + + @Override + public P preProcessor(P processorContext) { + LOG.debug("Processing Started for Processor: {}", getProcessorInfo().getProcessorName()); + // by default check to see if continue processing Flag is not false + final boolean okToContinue = processorContext.canProcessingContinue(); + if (!okToContinue) { + final String errorMessage = + format("Processor: %s. Processing Context flag okToContinue is false. Unable to proceed...", + getProcessorInfo().getProcessorName()); + throw new MessageProcessingException(errorMessage, LOG, new IllegalStateException(errorMessage)); + } + processingState = ProcessingState.PROCESSING_STARTED; + return processorContext; + } + + @Override + public ProcessingState getProcessingState() { + return processingState; + } + + @Override + public Optional getProcessingMessage() { + return Optional.fromNullable(processingMessage); + } + + @Override + public P postProcessor(P processorContext) { + // Default implementation updates the post processing flag if processing did not + // completed successfully + if (processingState != ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY) { + LOG.debug("Processor: {}, Update Process Context State to stop Processing.", + getProcessorInfo().getProcessorName()); + processorContext.setProcessingContinueFlag(false); + } + // attaches itself to message processor context + processorContext.getMessageProcessors().add(this); + LOG.debug("Processing Completed for Processor: {}", getProcessorInfo()); + return processorContext; + } + + + @Override + public final P apply(@Nonnull P processorContext) { + final P preProcessedProcessorContext = preProcessor(processorContext); + final P processedProcessorContext = processMessage(preProcessedProcessorContext); + return postProcessor(processedProcessorContext); + } + + + /** + * Helper method that updates processing state in case of early termination, logs the processing + * termination reason, updates Processor processing state as Terminated and sets it processing message + * + * @param terminatingMessage error Message + * @param processorContext message processor context + */ + protected void setTerminatingProcessingMessage(final String terminatingMessage, + final P processorContext) { + + final String message = processorContext.getMessage(); + this.processingState = ProcessingState.PROCESSING_TERMINATED_EARLY; + this.processingMessage = terminatingMessage; + LOG.debug("Processor: {}, Early Terminating Message: {}, Incoming Message: {}", + getProcessorInfo().getProcessorName(), terminatingMessage, message); + } + + /** + * Helper method that updates Processing state and logs completion message + * passed + * + * @param processorPassingMessage Processor passing message + * @param processorContext message processor context + */ + protected void setFinishedProcessingMessage(final String processorPassingMessage, P processorContext) { + final String message = processorContext.getMessage(); + processingState = ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY; + this.processingMessage = processorPassingMessage; + LOG.debug("Processor: {}, Successful Completion Message: {}, Incoming Message: {}", + getProcessorInfo().getProcessorName(), processorPassingMessage, message); + } + + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractProcessorContext.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractProcessorContext.java new file mode 100644 index 0000000..2274f0e --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/AbstractProcessorContext.java @@ -0,0 +1,96 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import com.google.common.base.Objects; + +import java.util.LinkedList; +import java.util.List; + +/** + *

+ * An abstract implementation for {@link ProcessorContext} which other DCAE Analytics Modules + * can extend to add module specific functionality + *

+ * + * @author Rajiv Singla. Creation Date: 11/7/2016. + */ +public abstract class AbstractProcessorContext implements ProcessorContext { + + private final String message; + private List> messageProcessors; + private boolean canProcessingContinue; + + public AbstractProcessorContext(final String message, + boolean canProcessingContinue) { + this.message = message; + this.canProcessingContinue = canProcessingContinue; + this.messageProcessors = new LinkedList<>(); + } + + /** + * Returns JSON String of incoming CEF Message that needs to be processed + * + * @return incoming CEF message that needs to be processed + */ + @Override + public String getMessage() { + return message; + } + + /** + * Sets if it is ok to continue processing normally + * + * @return boolean which determines if it is ok to continue processing normally + */ + @Override + public boolean canProcessingContinue() { + return canProcessingContinue; + } + + + /** + * Set if it is ok to continue processing normally + * + * @param canProcessingContinue sets boolean which determines if it is ok to continue processing normally + */ + @Override + public void setProcessingContinueFlag(boolean canProcessingContinue) { + this.canProcessingContinue = canProcessingContinue; + } + + /** + * Provides List of message processors which were used in processing CEF message + * + * @return List of message processors which were used in processing CEF message + */ + @Override + public List> getMessageProcessors() { + return messageProcessors; + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("canProcessingContinue", canProcessingContinue) + .toString(); + } +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessor.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessor.java new file mode 100644 index 0000000..b289a32 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessor.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import org.openecomp.dcae.apod.analytics.common.utils.MessageProcessorUtils; + +import java.util.List; + +/** + *

+ * A Generic Message Processor which passes the {@link ProcessorContext} from first to second + * {@link MessageProcessor} + *

+ * + * @param

Processor Context sub classes + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public class GenericMessageChainProcessor

{ + + private final List> messageProcessors; + private final P initialProcessorContext; + + public GenericMessageChainProcessor(List> messageProcessors, + P initialProcessorContext) { + this.messageProcessors = messageProcessors; + this.initialProcessorContext = initialProcessorContext; + } + + public P processChain() { + + final MessageProcessorUtils.MessageProcessorFunction

messageProcessorFunction = + new MessageProcessorUtils.MessageProcessorFunction

() { + @Override + public > P apply(P context, M processor) { + return processor.apply(context); + } + }; + + return MessageProcessorUtils.computeMessageProcessorChain(messageProcessors, initialProcessorContext, + messageProcessorFunction); + + } + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericProcessorInfo.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericProcessorInfo.java new file mode 100644 index 0000000..681bb4d --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericProcessorInfo.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import javax.annotation.Nonnull; + +/** + * A Generic Implementation of {@link ProcessorInfo} + * + * @author Rajiv Singla. Creation Date: 11/7/2016. + */ +public class GenericProcessorInfo implements ProcessorInfo { + + private static final long serialVersionUID = -2840512323233649809L; + + private final String processorName; + private final String processorDescription; + + public GenericProcessorInfo(@Nonnull String processorName, @Nonnull String processorDescription) { + this.processorName = processorName; + this.processorDescription = processorDescription; + } + + public String getProcessorName() { + return processorName; + } + + public String getProcessorDescription() { + return processorDescription; + } + + + @Override + public String toString() { + return processorName; + } +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/MessageProcessor.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/MessageProcessor.java new file mode 100644 index 0000000..73414db --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/MessageProcessor.java @@ -0,0 +1,84 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import com.google.common.base.Function; +import com.google.common.base.Optional; + +import java.io.Serializable; + +/** + *

+ * A message processor can be used to process incoming messages. + * It uses implementations of {@link ProcessorContext} as input and output + *

+ * + * @param

Message Processor Context implementations + * + * @author Rajiv Singla. Creation Date: 11/7/2016. + */ +public interface MessageProcessor

extends Function, Serializable { + + /** + * Returns processor information + * + * @return processor Information + */ + ProcessorInfo getProcessorInfo(); + + + /** + * Does pre-processing of {@link ProcessorContext} e.g. validate input conditions and return + * pre processed context + * + * @param processorContext incoming Processor Context + * @return Pre processed Processor Context + */ + P preProcessor(P processorContext); + + + /** + * Return processing state of a processor + * + * @return Processing State + */ + ProcessingState getProcessingState(); + + + /** + * May return a message from a processor which indicates the reason for {@link ProcessingState} especially if + * there was some failure in processing + * + * @return processing Message + */ + Optional getProcessingMessage(); + + + /** + * Does post-processing of {@link ProcessorContext} + * + * @param processorContext incoming Processor Context + * @return processor Context after post processing is finished + */ + P postProcessor(P processorContext); + + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessingState.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessingState.java new file mode 100644 index 0000000..8f97d63 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessingState.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +/** + *

+ * Processing state of a {@link MessageProcessor} + *

+ * @author Rajiv Singla. Creation Date: 11/5/2016. + */ +public enum ProcessingState { + + PROCESSING_STARTED, + PROCESSING_FINISHED_SUCCESSFULLY, + PROCESSING_TERMINATED_EARLY, + PROCESSING_NOT_REQUIRED; + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorContext.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorContext.java new file mode 100644 index 0000000..3c70919 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorContext.java @@ -0,0 +1,70 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * A Processor Context is used a an input and output to a {@link MessageProcessor} + *
+ * DCAE Analytics sub projects should extend this interface and add specific fields + * required for input and output + *

+ * + * @author Rajiv Singla. Creation Date: 11/7/2016. + */ +public interface ProcessorContext extends Serializable { + + /** + * Returns Processor Context message that will be processed by Chain of Processors + * + * @return message that need to be processed by processors + */ + String getMessage(); + + /** + * Processing Context flag which determines if Processing can continue in a processing + * chain + * + * @return true if ok to continue processing normally + */ + boolean canProcessingContinue(); + + + /** + * Sets new value for ProcessingContinue flag which will cause early termination of processing in chain if + * set to false + * + * @param canProcessingContinue set new value for canProcessing Continue flag + */ + void setProcessingContinueFlag(boolean canProcessingContinue); + + + /** + * Provides a List of previous processors which have completed processing + * + * @return list of previous processors + */ + List> getMessageProcessors(); + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorInfo.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorInfo.java new file mode 100644 index 0000000..6bb74b0 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/service/processor/ProcessorInfo.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import java.io.Serializable; + +/** + *

+ * Contains Information about a processor. For e.g. Processor name, processor description etc + *

+ * + * @author Rajiv Singla. Creation Date: 11/7/2016. + */ +public interface ProcessorInfo extends Serializable { + + /** + * Returns a name which should uniquely identify a particular {@link MessageProcessor} + * + * @return processor name + */ + String getProcessorName(); + + + /** + * Returns description of a {@link MessageProcessor} + * + * @return processor description + */ + String getProcessorDescription(); + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/HTTPUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/HTTPUtils.java new file mode 100644 index 0000000..c10935f --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/HTTPUtils.java @@ -0,0 +1,57 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.utils; + +/** + * Contains common utils to check HTTP Related Utils + * + * @author Rajiv Singla. Creation Date: 11/2/2016. + */ +public abstract class HTTPUtils { + + /** + * HTTP Status code for successful HTTP call + */ + public static final Integer HTTP_SUCCESS_STATUS_CODE = 200; + + /** + * HTTP Response code when request has been accepted for processing, but the processing has not been completed + */ + public static final Integer HTTP_ACCEPTED_RESPONSE_CODE = 202; + + /** + * HTTP Response code when there is no content + */ + public static final Integer HTTP_NO_CONTENT_RESPONSE_CODE = 204; + + + public static final String JSON_APPLICATION_TYPE = "application/json"; + + /** + * Checks if HTTP Status code is less than or equal to 200 but less then 300 + * + * @param statusCode http status code + * @return true if response code between 200 and 300 + */ + public static boolean isSuccessfulResponseCode(Integer statusCode) { + return statusCode >= 200 && statusCode < 300; + } +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/MessageProcessorUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/MessageProcessorUtils.java new file mode 100644 index 0000000..20deb72 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/MessageProcessorUtils.java @@ -0,0 +1,114 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.utils; + +import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException; +import org.openecomp.dcae.apod.analytics.common.service.processor.MessageProcessor; +import org.openecomp.dcae.apod.analytics.common.service.processor.ProcessorContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Iterator; + + +/** + * Contains utility methods for {@link MessageProcessor} + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public abstract class MessageProcessorUtils { + + private static final Logger LOG = LoggerFactory.getLogger(MessageProcessorUtils.class); + + /** + * Provides an abstraction how to apply {@link ProcessorContext} to next {@link MessageProcessor} + * in the message processor chain + * + * @param

Sub classes of Processor Context + */ + public interface MessageProcessorFunction

{ + + /** + * Method which provides accumulated {@link ProcessorContext} from previous processors and a reference + * to next processor in the chain + * + * @param p accumulated {@link ProcessorContext} from previous processors + * @param m current {@link MessageProcessor} in the chain + * @param Message processor sub classes + * + * @return processing context after computing the current Message Processor + */ + > P apply(P p, M m); + } + + + /** + * Provides an abstraction to compute a chain of {@link MessageProcessor} + * + * @param messageProcessors An iterable containing one or more {@link MessageProcessor}s + * @param initialProcessorContext An initial processing Context + * @param messageProcessorFunction messageProcessor Function + * @param

Sub classes for Processor Context + * + * @return processing context which results after computing the whole chain + */ + public static

P computeMessageProcessorChain( + final Iterable> messageProcessors, + final P initialProcessorContext, + final MessageProcessorFunction

messageProcessorFunction) { + + // Get message processor iterator + final Iterator> processorIterator = messageProcessors.iterator(); + + // If no next message processor - return initial processor context + if (!processorIterator.hasNext()) { + return initialProcessorContext; + } + + // An accumulator for processor Context + P processorContextAccumulator = initialProcessorContext; + + while (processorIterator.hasNext()) { + + final MessageProcessor

nextProcessor = processorIterator.next(); + + // If Initial Processor Context is null + if (processorContextAccumulator == null) { + final String errorMessage = + String.format("Processor Context must not be null for Message Process: %s", + nextProcessor.getProcessorInfo().getProcessorName()); + throw new MessageProcessingException(errorMessage, LOG, new IllegalStateException(errorMessage)); + } + + + if (!processorContextAccumulator.canProcessingContinue()) { + LOG.debug("Triggering Early Termination, before Message Processor: {}, Incoming Message: {}", + nextProcessor.getProcessorInfo().getProcessorName(), processorContextAccumulator.getMessage()); + break; + } + processorContextAccumulator = messageProcessorFunction.apply(processorContextAccumulator, nextProcessor); + } + + return processorContextAccumulator; + } + + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/PersistenceUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/PersistenceUtils.java new file mode 100644 index 0000000..a10280f --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/PersistenceUtils.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.utils; + +import java.util.Date; + +/** + * Contains Utility methods for creating persistence row keys etc. + * + * @author Rajiv Singla. Creation Date: 11/16/2016. + */ +public abstract class PersistenceUtils { + + + /** + * Name of the column which will contain Table Key + */ + public static final String TABLE_ROW_KEY_COLUMN_NAME = "key"; + + /** + * Delimited to be used when creating a row key with multiple fields + */ + public static final String ROW_KEY_DELIMITER = "-"; + + /** + * Creates a decreasing number using current timestamp. Handy when you want to keep records most recent records + * close to the top of column table like HBase + * + * @return decreasing number + */ + public static String getCurrentTimeReverseSubKey() { + final long timeReverseLong = Long.MAX_VALUE - new Date().getTime(); + return String.format("%025d", timeReverseLong); + } + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/ValidationUtils.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/ValidationUtils.java new file mode 100644 index 0000000..f4f50a7 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/utils/ValidationUtils.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.utils; + +import org.openecomp.dcae.apod.analytics.common.cdap.settings.CDAPAppSettings; +import org.openecomp.dcae.apod.analytics.common.cdap.validation.CDAPAppSettingsValidator; +import org.openecomp.dcae.apod.analytics.common.exception.CDAPSettingsException; +import org.openecomp.dcae.apod.analytics.common.validation.ValidationResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Contains utility methods to validate null checks, empty string etc + * + * @author Rajiv Singla. Creation Date: 10/24/2016. + */ +public abstract class ValidationUtils { + + private static final Logger LOG = LoggerFactory.getLogger(ValidationUtils.class); + + /** + * 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(final @Nullable String stringValue) { + return stringValue == null || stringValue.isEmpty() || stringValue.trim().isEmpty(); + } + + + /** + * Provides common functionality to Validates CDAP App Settings. Throws Runtime exception if validation fails + * + * @param appSettings app Settings e.g. App Config, App Preferences etc + * @param appSettingsValidator app Settings validator + * + * @param Settings type e.g. AppConfig or AppPreferences + * @param Validation Response type + * @param Validator Type + */ + public static , + V extends CDAPAppSettingsValidator> void validateSettings(final @Nonnull T appSettings, + final @Nonnull V appSettingsValidator) { + checkNotNull(appSettings, "App Settings must not be null"); + checkNotNull(appSettingsValidator, "App Settings validator must not be null"); + + final String appSettingsClassName = appSettings.getClass().getSimpleName(); + final String appSettingsClassValidator = appSettingsValidator.getClass().getSimpleName(); + + LOG.debug("Validating App Settings for: {}, with App Settings Validator: {} ", + appSettingsClassName, appSettingsClassValidator); + + final R validationResponse = appSettingsValidator.validateAppSettings(appSettings); + + // If setting validation fails throw an exception + if (validationResponse.hasErrors()) { + throw new CDAPSettingsException( + validationResponse.getAllErrorMessage(), LOG, new IllegalArgumentException()); + } + + LOG.debug("App Settings Validation Successful for app Settings: {} with validator: {}", appSettingsClassName, + appSettingsClassValidator); + } + +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/DCAEValidator.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/DCAEValidator.java new file mode 100644 index 0000000..a42b53a --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/DCAEValidator.java @@ -0,0 +1,29 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.validation; + +/** + * Marker interface for all DCAE Validators + * + * @author Rajiv Singla. Creation Date: 10/24/2016. + */ +public interface DCAEValidator { +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/GenericValidationResponse.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/GenericValidationResponse.java new file mode 100644 index 0000000..3acb0c8 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/GenericValidationResponse.java @@ -0,0 +1,84 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.validation; + +import com.google.common.base.Joiner; +import com.google.common.base.Objects; + +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +/** + * A generic implementation of Validation Response + * + * @param Validation Entity Type + * + * @author Rajiv Singla. Creation Date: 10/24/2016. + */ +public class GenericValidationResponse implements ValidationResponse { + + private LinkedHashMap errorMessageMap = new LinkedHashMap<>(); + + @Override + public boolean hasErrors() { + return errorMessageMap.size() != 0; + } + + @Override + public Set getFieldNamesWithError() { + return errorMessageMap.keySet(); + } + + public Collection getErrorMessageMap() { + return errorMessageMap.values(); + } + + @Override + public Map getValidationResultsAsMap() { + return errorMessageMap; + } + + + @Override + public String getAllErrorMessage() { + return getAllErrorMessage(","); + } + + @Override + public String getAllErrorMessage(String delimiter) { + return Joiner.on(delimiter).join(errorMessageMap.values()); + } + + @Override + public void addErrorMessage(String fieldName, String filedErrorMessage) { + errorMessageMap.put(fieldName, filedErrorMessage); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("hasErrors", hasErrors()) + .add("errorMessageMap", errorMessageMap) + .toString(); + } +} diff --git a/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/ValidationResponse.java b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/ValidationResponse.java new file mode 100644 index 0000000..11591a3 --- /dev/null +++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/apod/analytics/common/validation/ValidationResponse.java @@ -0,0 +1,90 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.validation; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +/** + * Validation Response contract + * + * @param Entity class type which is being validated + * + * @author Rajiv Singla. Creation Date: 10/24/2016. + */ +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 getFieldNamesWithError(); + + /** + * Returns list of all error messages + * + * @return list of error messages + */ + Collection getErrorMessageMap(); + + + /** + * 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 getValidationResultsAsMap(); + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/BaseAnalyticsCommonUnitTest.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/BaseAnalyticsCommonUnitTest.java deleted file mode 100644 index 06b7e63..0000000 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/BaseAnalyticsCommonUnitTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common; - -import org.openecomp.dcae.analytics.common.service.processor.TestEarlyTerminatingProcessor; -import org.openecomp.dcae.analytics.common.service.processor.TestMessageProcessor1; -import org.openecomp.dcae.analytics.common.service.processor.TestMessageProcessor2; -import org.openecomp.dcae.analytics.common.service.processor.TestProcessorContext; -import org.openecomp.dcae.analytics.test.BaseDCAEAnalyticsUnitTest; - -/** - * Base class from all DCEA Analytics Common Module Unit Tests - *

- * @author Rajiv Singla. Creation Date: 10/6/2016. - */ -public abstract class BaseAnalyticsCommonUnitTest extends BaseDCAEAnalyticsUnitTest { - - - protected TestProcessorContext testProcessorContext = new TestProcessorContext("", true); - - protected TestMessageProcessor1 getTestMessageProcessor1() { - return new TestMessageProcessor1(); - } - protected TestMessageProcessor2 getTestMessageProcessor2() { - return new TestMessageProcessor2(); - } - protected TestEarlyTerminatingProcessor getTestEarlyTerminationProcessor() { - return new TestEarlyTerminatingProcessor(); - } -} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessorTest.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessorTest.java deleted file mode 100644 index 2ab9d40..0000000 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessorTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import com.google.common.collect.ImmutableList; -import org.junit.Test; -import org.openecomp.dcae.analytics.common.BaseAnalyticsCommonUnitTest; -import org.openecomp.dcae.analytics.common.exception.MessageProcessingException; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; - - -/** - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public class GenericMessageChainProcessorTest extends BaseAnalyticsCommonUnitTest { - - - @Test - public void testProcessChainWhenProcessChainHasNoEarlyTermination() throws Exception { - - final TestMessageProcessor1 testMessageProcessor1 = getTestMessageProcessor1(); - final TestMessageProcessor2 testMessageProcessor2 = getTestMessageProcessor2(); - final ImmutableList> testMessageChain = - ImmutableList.of(testMessageProcessor1, testMessageProcessor2); - - final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true); - - final GenericMessageChainProcessor genericMessageChainProcessor = - new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); - - final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain(); - - final String result = finalProcessorContext.getResult(); - assertThat("Final Result must be Hello World! Again", result, is("Hello World! Again")); - assertThat("TestProcessor1 state is correct", testMessageProcessor1.getProcessingState(), - is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY)); - assertThat("TestProcessor2 state is correct", testMessageProcessor2.getProcessingState(), - is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY)); - } - - - @Test - public void testProcessChainWhenProcessChainEarlyTermination() throws Exception { - - final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor(); - final ImmutableList> testMessageChain = - ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2()); - final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true); - - final GenericMessageChainProcessor genericMessageChainProcessor = - new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); - - final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain(); - final String result = finalProcessorContext.getResult(); - assertNull("Final Result must be null", result); - assertThat("TestEarlyTerminatingProcessor state is correct", - testEarlyTerminatingProcessor.getProcessingState(), is(ProcessingState.PROCESSING_TERMINATED_EARLY)); - } - - @Test(expected = MessageProcessingException.class) - public void testProcessChainWhenIncomingMessageContextIsNull() throws Exception { - - final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor(); - final ImmutableList> testMessageChain = - ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2()); - final TestProcessorContext testProcessorContext = null; - - final GenericMessageChainProcessor genericMessageChainProcessor = - new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); - - genericMessageChainProcessor.processChain(); - } - -} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestEarlyTerminatingProcessor.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestEarlyTerminatingProcessor.java deleted file mode 100644 index c5852de..0000000 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestEarlyTerminatingProcessor.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -/** - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public class TestEarlyTerminatingProcessor extends AbstractMessageProcessor { - - @Override - public String getProcessorDescription() { - return "Terminates the chain early"; - } - - @Override - public TestProcessorContext processMessage(TestProcessorContext processorContext) { - setTerminatingProcessingMessage("Terminating early", processorContext); - return processorContext; - } -} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor1.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor1.java deleted file mode 100644 index 6c56cb8..0000000 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor1.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -/** - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public class TestMessageProcessor1 extends AbstractMessageProcessor { - - @Override - public String getProcessorDescription() { - return "Appends \" World!\" to the message string and set it to result string"; - } - - @Override - public TestProcessorContext processMessage(TestProcessorContext processorContext) { - final String message = processorContext.getMessage(); - processorContext.setResult(message + " World!"); - setFinishedProcessingMessage("Finished Appending world", processorContext); - return processorContext; - } -} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor2.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor2.java deleted file mode 100644 index 0ecbedf..0000000 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor2.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -/** - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public class TestMessageProcessor2 extends AbstractMessageProcessor { - - @Override - public String getProcessorDescription() { - return "Appends \" Again\" to the result string"; - } - - @Override - public TestProcessorContext processMessage(TestProcessorContext processorContext) { - final String result = processorContext.getResult(); - processorContext.setResult(result + " Again"); - setFinishedProcessingMessage("Finished Appending again to result", processorContext); - return processorContext; - } -} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestProcessorContext.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestProcessorContext.java deleted file mode 100644 index 9d9342f..0000000 --- a/dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestProcessorContext.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * ============LICENSE_START========================================================= - * dcae-analytics - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.dcae.analytics.common.service.processor; - -import java.util.LinkedList; -import java.util.List; - -/** - * - * @author Rajiv Singla. Creation Date: 11/8/2016. - */ -public class TestProcessorContext implements ProcessorContext { - - private String message; - private boolean continueProcessingFlag; - private String result; - private List> messageProcessors; - - public TestProcessorContext(String message, boolean continueProcessingFlag) { - this.message = message; - this.continueProcessingFlag = continueProcessingFlag; - this.messageProcessors = new LinkedList<>(); - } - - @Override - public String getMessage() { - return message; - } - - @Override - public boolean canProcessingContinue() { - return continueProcessingFlag; - } - - @Override - public void setProcessingContinueFlag(boolean canProcessingContinue) { - this.continueProcessingFlag = canProcessingContinue; - } - - @Override - public List> getMessageProcessors() { - return messageProcessors; - } - - - public void setMessage(String message) { - this.message = message; - } - - public boolean isContinueProcessingFlag() { - return continueProcessingFlag; - } - - public void setContinueProcessingFlag(boolean continueProcessingFlag) { - this.continueProcessingFlag = continueProcessingFlag; - } - - public String getResult() { - return result; - } - - public void setResult(String result) { - this.result = result; - } - -} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java new file mode 100644 index 0000000..bd38168 --- /dev/null +++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/BaseAnalyticsCommonUnitTest.java @@ -0,0 +1,48 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common; + +import org.openecomp.dcae.apod.analytics.common.service.processor.TestEarlyTerminatingProcessor; +import org.openecomp.dcae.apod.analytics.common.service.processor.TestMessageProcessor1; +import org.openecomp.dcae.apod.analytics.common.service.processor.TestMessageProcessor2; +import org.openecomp.dcae.apod.analytics.common.service.processor.TestProcessorContext; +import org.openecomp.dcae.apod.analytics.test.BaseDCAEAnalyticsUnitTest; + +/** + * Base class from all DCEA Analytics Common Module Unit Tests + *

+ * @author Rajiv Singla. Creation Date: 10/6/2016. + */ +public abstract class BaseAnalyticsCommonUnitTest extends BaseDCAEAnalyticsUnitTest { + + + protected TestProcessorContext testProcessorContext = new TestProcessorContext("", true); + + protected TestMessageProcessor1 getTestMessageProcessor1() { + return new TestMessageProcessor1(); + } + protected TestMessageProcessor2 getTestMessageProcessor2() { + return new TestMessageProcessor2(); + } + protected TestEarlyTerminatingProcessor getTestEarlyTerminationProcessor() { + return new TestEarlyTerminatingProcessor(); + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java new file mode 100644 index 0000000..2ed82b6 --- /dev/null +++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/GenericMessageChainProcessorTest.java @@ -0,0 +1,96 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import com.google.common.collect.ImmutableList; +import org.junit.Test; +import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest; +import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; + + +/** + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public class GenericMessageChainProcessorTest extends BaseAnalyticsCommonUnitTest { + + + @Test + public void testProcessChainWhenProcessChainHasNoEarlyTermination() throws Exception { + + final TestMessageProcessor1 testMessageProcessor1 = getTestMessageProcessor1(); + final TestMessageProcessor2 testMessageProcessor2 = getTestMessageProcessor2(); + final ImmutableList> testMessageChain = + ImmutableList.of(testMessageProcessor1, testMessageProcessor2); + + final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true); + + final GenericMessageChainProcessor genericMessageChainProcessor = + new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); + + final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain(); + + final String result = finalProcessorContext.getResult(); + assertThat("Final Result must be Hello World! Again", result, is("Hello World! Again")); + assertThat("TestProcessor1 state is correct", testMessageProcessor1.getProcessingState(), + is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY)); + assertThat("TestProcessor2 state is correct", testMessageProcessor2.getProcessingState(), + is(ProcessingState.PROCESSING_FINISHED_SUCCESSFULLY)); + } + + + @Test + public void testProcessChainWhenProcessChainEarlyTermination() throws Exception { + + final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor(); + final ImmutableList> testMessageChain = + ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2()); + final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true); + + final GenericMessageChainProcessor genericMessageChainProcessor = + new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); + + final TestProcessorContext finalProcessorContext = genericMessageChainProcessor.processChain(); + final String result = finalProcessorContext.getResult(); + assertNull("Final Result must be null", result); + assertThat("TestEarlyTerminatingProcessor state is correct", + testEarlyTerminatingProcessor.getProcessingState(), is(ProcessingState.PROCESSING_TERMINATED_EARLY)); + } + + @Test(expected = MessageProcessingException.class) + public void testProcessChainWhenIncomingMessageContextIsNull() throws Exception { + + final TestEarlyTerminatingProcessor testEarlyTerminatingProcessor = getTestEarlyTerminationProcessor(); + final ImmutableList> testMessageChain = + ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2()); + final TestProcessorContext testProcessorContext = null; + + final GenericMessageChainProcessor genericMessageChainProcessor = + new GenericMessageChainProcessor<>(testMessageChain, testProcessorContext); + + genericMessageChainProcessor.processChain(); + } + +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java new file mode 100644 index 0000000..a015677 --- /dev/null +++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestEarlyTerminatingProcessor.java @@ -0,0 +1,39 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +/** + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public class TestEarlyTerminatingProcessor extends AbstractMessageProcessor { + + @Override + public String getProcessorDescription() { + return "Terminates the chain early"; + } + + @Override + public TestProcessorContext processMessage(TestProcessorContext processorContext) { + setTerminatingProcessingMessage("Terminating early", processorContext); + return processorContext; + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java new file mode 100644 index 0000000..ac29080 --- /dev/null +++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor1.java @@ -0,0 +1,41 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +/** + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public class TestMessageProcessor1 extends AbstractMessageProcessor { + + @Override + public String getProcessorDescription() { + return "Appends \" World!\" to the message string and set it to result string"; + } + + @Override + public TestProcessorContext processMessage(TestProcessorContext processorContext) { + final String message = processorContext.getMessage(); + processorContext.setResult(message + " World!"); + setFinishedProcessingMessage("Finished Appending world", processorContext); + return processorContext; + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java new file mode 100644 index 0000000..a0704db --- /dev/null +++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestMessageProcessor2.java @@ -0,0 +1,41 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +/** + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public class TestMessageProcessor2 extends AbstractMessageProcessor { + + @Override + public String getProcessorDescription() { + return "Appends \" Again\" to the result string"; + } + + @Override + public TestProcessorContext processMessage(TestProcessorContext processorContext) { + final String result = processorContext.getResult(); + processorContext.setResult(result + " Again"); + setFinishedProcessingMessage("Finished Appending again to result", processorContext); + return processorContext; + } +} diff --git a/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestProcessorContext.java b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestProcessorContext.java new file mode 100644 index 0000000..85e8c74 --- /dev/null +++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/apod/analytics/common/service/processor/TestProcessorContext.java @@ -0,0 +1,84 @@ +/* + * ============LICENSE_START========================================================= + * dcae-analytics + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.dcae.apod.analytics.common.service.processor; + +import java.util.LinkedList; +import java.util.List; + +/** + * + * @author Rajiv Singla. Creation Date: 11/8/2016. + */ +public class TestProcessorContext implements ProcessorContext { + + private String message; + private boolean continueProcessingFlag; + private String result; + private List> messageProcessors; + + public TestProcessorContext(String message, boolean continueProcessingFlag) { + this.message = message; + this.continueProcessingFlag = continueProcessingFlag; + this.messageProcessors = new LinkedList<>(); + } + + @Override + public String getMessage() { + return message; + } + + @Override + public boolean canProcessingContinue() { + return continueProcessingFlag; + } + + @Override + public void setProcessingContinueFlag(boolean canProcessingContinue) { + this.continueProcessingFlag = canProcessingContinue; + } + + @Override + public List> getMessageProcessors() { + return messageProcessors; + } + + + public void setMessage(String message) { + this.message = message; + } + + public boolean isContinueProcessingFlag() { + return continueProcessingFlag; + } + + public void setContinueProcessingFlag(boolean continueProcessingFlag) { + this.continueProcessingFlag = continueProcessingFlag; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + +} -- cgit 1.2.3-korg