aboutsummaryrefslogtreecommitdiffstats
path: root/dcae-analytics-common/src
diff options
context:
space:
mode:
authorlj1412 <lji@research.att.com>2017-02-14 15:10:48 +0000
committerlj1412 <lji@research.att.com>2017-02-14 15:10:50 +0000
commite27500a2d72e152490d6786d3a6d90f8d2ba973f (patch)
treef8088c05a15ec4404c7b707902bab083d5fe2671 /dcae-analytics-common/src
parent6348522233134b69dc455949d80b11e3bcd2fce7 (diff)
Init dcae.apod.analytics
Change-Id: Ie62128895a199633d0afa695749d40c940d804b2 Signed-off-by: lj1412 <lji@research.att.com>
Diffstat (limited to 'dcae-analytics-common/src')
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/AnalyticsConstants.java134
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPComponentsConstants.java196
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/CDAPMetricsConstants.java112
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/DCAEAnalyticsPreferences.java29
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppConfig.java47
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppPreferences.java31
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPAppSettings.java35
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/settings/CDAPBaseAppConfig.java62
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/cdap/validation/CDAPAppSettingsValidator.java52
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/CDAPSettingsException.java50
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/DCAEAnalyticsRuntimeException.java54
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/exception/MessageProcessingException.java51
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractMessageProcessor.java162
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/AbstractProcessorContext.java96
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessor.java63
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/GenericProcessorInfo.java55
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/MessageProcessor.java84
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessingState.java36
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorContext.java70
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/service/processor/ProcessorInfo.java49
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/HTTPUtils.java57
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/MessageProcessorUtils.java114
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/PersistenceUtils.java54
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/utils/ValidationUtils.java89
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/DCAEValidator.java29
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/GenericValidationResponse.java84
-rw-r--r--dcae-analytics-common/src/main/java/org/openecomp/dcae/analytics/common/validation/ValidationResponse.java90
-rw-r--r--dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/BaseAnalyticsCommonUnitTest.java48
-rw-r--r--dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/GenericMessageChainProcessorTest.java96
-rw-r--r--dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestEarlyTerminatingProcessor.java39
-rw-r--r--dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor1.java41
-rw-r--r--dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestMessageProcessor2.java41
-rw-r--r--dcae-analytics-common/src/test/java/org/openecomp/dcae/analytics/common/service/processor/TestProcessorContext.java84
-rw-r--r--dcae-analytics-common/src/test/resources/logback-test.xml54
34 files changed, 2388 insertions, 0 deletions
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
new file mode 100644
index 0000000..6c51069
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..50aad3c
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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.
+ *
+ * <p>
+ * 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:
+ * <ul>
+ * <li>Name of the DCAE sub module (e.g. TCA) to which variable is applicable</li>
+ * <li>Information about variable name:
+ * <ul>
+ * <li>FIXED - if variable value is fixed and cannot be changed</li>
+ * <li>DEFAULT - if variable name is default name and can be changed by cdap settings file
+ * when application is created</li>
+ * </ul>
+ * </li>
+ * <li>Actual Descriptive name about the CDAP component (may contain underscrores) </li>
+ * <li>CDAP component type e.g STREAM, DATASET, APP, FLOW, FLOWLET, OUTPUT</li>
+ * </ul>
+ *
+ * <p>e.g TCA_DEFAULT_DMAAP_INPUT_STREAM</p>
+ *
+ * <p><strong>RegEx Format (DCAE MODULE NAME)_(FIXED|DEFAULT)_(VARIABLE NAME)_(CDAP COMPONENT TYPE)</strong></p>
+ *
+ * @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
new file mode 100644
index 0000000..12df643
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common;
+
+/**
+ * Contains all metrics names used for DCAE CDAP modules
+ *
+ * <p>
+ * Format should be (ModuleName)_(Description of metrics)_METRIC e.g. TCA_WORKER_FAILED_ATTEMPTS_METRIC
+ * </p>
+ *
+ * @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
new file mode 100644
index 0000000..dc345f4
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..3fc6f22
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.cdap.settings;
+
+/**
+ *<p>
+ * Minimum Contract for all CDAP App Configs
+ *</p>
+ *
+ * @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
new file mode 100644
index 0000000..52ec1af
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.cdap.settings;
+
+/**
+ * <p>
+ * Marker Interface for all CDAP Preferences
+ * </p>
+ *
+ * @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
new file mode 100644
index 0000000..d59e6f4
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.cdap.settings;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * A marker interface for all CDAP Related App Settings.
+ * App Settings can either be preferences, cdap app settings etc.
+ * </p>
+ *
+ *
+ * @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
new file mode 100644
index 0000000..1360b20
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..df00eff
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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;
+
+/**
+ * <p>
+ * Validates CDAP Application Settings (AppConfig, Preferences etc)
+ * <p>
+ *
+ * @param <T> {@link CDAPAppSettings} DCAE Analytics App Settings (e.g. AppConfig, Preferences)
+ * @param <R> {@link ValidationResponse} Validator response implementations
+ *
+ * @author Rajiv Singla. Creation Date: 11/2/2016.
+ */
+public interface CDAPAppSettingsValidator<T extends CDAPAppSettings, R extends ValidationResponse<T>>
+ 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
new file mode 100644
index 0000000..f6859e2
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..cc00e33
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.exception;
+
+import org.slf4j.Logger;
+
+/**
+ * Runtime Exception for DCAE Analytics Exceptions. All DCAE Analytics
+ * runtime Exceptions must be wrapped inside this exception
+ * <p>
+ * @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
new file mode 100644
index 0000000..b40f604
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..e5b9afc
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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 <P> Processor Context sub classes
+ *
+ * @author Rajiv Singla. Creation Date: 11/8/2016.
+ */
+public abstract class AbstractMessageProcessor<P extends ProcessorContext> implements MessageProcessor<P> {
+
+ 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<String> 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
new file mode 100644
index 0000000..15145b5
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+import com.google.common.base.Objects;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * <p>
+ * An abstract implementation for {@link ProcessorContext} which other DCAE Analytics Modules
+ * can extend to add module specific functionality
+ * </p>
+ *
+ * @author Rajiv Singla. Creation Date: 11/7/2016.
+ */
+public abstract class AbstractProcessorContext implements ProcessorContext {
+
+ private final String message;
+ private List<? super MessageProcessor<? extends ProcessorContext>> 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<? super MessageProcessor<? extends ProcessorContext>> 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
new file mode 100644
index 0000000..b86d3ad
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+import org.openecomp.dcae.analytics.common.utils.MessageProcessorUtils;
+
+import java.util.List;
+
+/**
+ * <p>
+ * A Generic Message Processor which passes the {@link ProcessorContext} from first to second
+ * {@link MessageProcessor}
+ * </p>
+ *
+ * @param <P> Processor Context sub classes
+ *
+ * @author Rajiv Singla. Creation Date: 11/8/2016.
+ */
+public class GenericMessageChainProcessor<P extends ProcessorContext> {
+
+ private final List<? extends MessageProcessor<P>> messageProcessors;
+ private final P initialProcessorContext;
+
+ public GenericMessageChainProcessor(List<? extends MessageProcessor<P>> messageProcessors,
+ P initialProcessorContext) {
+ this.messageProcessors = messageProcessors;
+ this.initialProcessorContext = initialProcessorContext;
+ }
+
+ public P processChain() {
+
+ final MessageProcessorUtils.MessageProcessorFunction<P> messageProcessorFunction =
+ new MessageProcessorUtils.MessageProcessorFunction<P>() {
+ @Override
+ public <M extends MessageProcessor<P>> 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
new file mode 100644
index 0000000..665f787
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..3c09da9
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * A message processor can be used to process incoming messages.
+ * It uses implementations of {@link ProcessorContext} as input and output
+ * </p>
+ *
+ * @param <P> Message Processor Context implementations
+ *
+ * @author Rajiv Singla. Creation Date: 11/7/2016.
+ */
+public interface MessageProcessor<P extends ProcessorContext> extends Function<P, P>, 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<String> 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
new file mode 100644
index 0000000..c5090f7
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+/**
+ * <p>
+ * Processing state of a {@link MessageProcessor}
+ * </p>
+ * @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
new file mode 100644
index 0000000..74eabd7
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * <p>
+ * A Processor Context is used a an input and output to a {@link MessageProcessor}
+ * <br>
+ * DCAE Analytics sub projects should extend this interface and add specific fields
+ * required for input and output
+ * </p>
+ *
+ * @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<? super MessageProcessor<? extends ProcessorContext>> 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
new file mode 100644
index 0000000..e657ed7
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * Contains Information about a processor. For e.g. Processor name, processor description etc
+ * </p>
+ *
+ * @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
new file mode 100644
index 0000000..4c36cb3
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..10c8d7c
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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 <P> Sub classes of Processor Context
+ */
+ public interface MessageProcessorFunction<P extends ProcessorContext> {
+
+ /**
+ * 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 <M> Message processor sub classes
+ *
+ * @return processing context after computing the current Message Processor
+ */
+ <M extends MessageProcessor<P>> 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 <P> Sub classes for Processor Context
+ *
+ * @return processing context which results after computing the whole chain
+ */
+ public static <P extends ProcessorContext> P computeMessageProcessorChain(
+ final Iterable<? extends MessageProcessor<P>> messageProcessors,
+ final P initialProcessorContext,
+ final MessageProcessorFunction<P> messageProcessorFunction) {
+
+ // Get message processor iterator
+ final Iterator<? extends MessageProcessor<P>> 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<P> 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
new file mode 100644
index 0000000..e408171
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..694529f
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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 <T> Settings type e.g. AppConfig or AppPreferences
+ * @param <R> Validation Response type
+ * @param <V> Validator Type
+ */
+ public static <T extends CDAPAppSettings, R extends ValidationResponse<T>,
+ V extends CDAPAppSettingsValidator<T, R>> 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
new file mode 100644
index 0000000..065411f
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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
new file mode 100644
index 0000000..7015ffe
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.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 <T> Validation Entity Type
+ *
+ * @author Rajiv Singla. Creation Date: 10/24/2016.
+ */
+public class GenericValidationResponse<T> implements ValidationResponse<T> {
+
+ private LinkedHashMap<String, String> errorMessageMap = new LinkedHashMap<>();
+
+ @Override
+ public boolean hasErrors() {
+ return errorMessageMap.size() != 0;
+ }
+
+ @Override
+ public Set<String> getFieldNamesWithError() {
+ return errorMessageMap.keySet();
+ }
+
+ public Collection<String> getErrorMessageMap() {
+ return errorMessageMap.values();
+ }
+
+ @Override
+ public Map<String, String> 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
new file mode 100644
index 0000000..b1b7a16
--- /dev/null
+++ b/dcae-analytics-common/src/main/java/org/openecomp/dcae/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.analytics.common.validation;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Validation Response contract
+ *
+ * @param <T> Entity class type which is being validated
+ *
+ * @author Rajiv Singla. Creation Date: 10/24/2016.
+ */
+public interface ValidationResponse<T> {
+
+ /**
+ * Returns true if validation resulted in one or more errors
+ *
+ * @return true if validation has errors
+ */
+ boolean hasErrors();
+
+ /**
+ * Returns all field names which have error
+ *
+ * @return names of fields which have error
+ */
+ Set<String> getFieldNamesWithError();
+
+ /**
+ * Returns list of all error messages
+ *
+ * @return list of error messages
+ */
+ Collection<String> 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<String, String> 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
new file mode 100644
index 0000000..06b7e63
--- /dev/null
+++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/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.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
+ * <p>
+ * @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
new file mode 100644
index 0000000..2ab9d40
--- /dev/null
+++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/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.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<? extends MessageProcessor<TestProcessorContext>> testMessageChain =
+ ImmutableList.of(testMessageProcessor1, testMessageProcessor2);
+
+ final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true);
+
+ final GenericMessageChainProcessor<TestProcessorContext> 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<? extends MessageProcessor<TestProcessorContext>> testMessageChain =
+ ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2());
+ final TestProcessorContext testProcessorContext = new TestProcessorContext("Hello", true);
+
+ final GenericMessageChainProcessor<TestProcessorContext> 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<? extends MessageProcessor<TestProcessorContext>> testMessageChain =
+ ImmutableList.of(testEarlyTerminatingProcessor, getTestMessageProcessor2());
+ final TestProcessorContext testProcessorContext = null;
+
+ final GenericMessageChainProcessor<TestProcessorContext> 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
new file mode 100644
index 0000000..c5852de
--- /dev/null
+++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+/**
+ *
+ * @author Rajiv Singla. Creation Date: 11/8/2016.
+ */
+public class TestEarlyTerminatingProcessor extends AbstractMessageProcessor<TestProcessorContext> {
+
+ @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
new file mode 100644
index 0000000..6c56cb8
--- /dev/null
+++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+/**
+ *
+ * @author Rajiv Singla. Creation Date: 11/8/2016.
+ */
+public class TestMessageProcessor1 extends AbstractMessageProcessor<TestProcessorContext> {
+
+ @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
new file mode 100644
index 0000000..0ecbedf
--- /dev/null
+++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/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.analytics.common.service.processor;
+
+/**
+ *
+ * @author Rajiv Singla. Creation Date: 11/8/2016.
+ */
+public class TestMessageProcessor2 extends AbstractMessageProcessor<TestProcessorContext> {
+
+ @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
new file mode 100644
index 0000000..9d9342f
--- /dev/null
+++ b/dcae-analytics-common/src/test/java/org/openecomp/dcae/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.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<? super MessageProcessor<? extends ProcessorContext>> 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<? super MessageProcessor<? extends ProcessorContext>> 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/resources/logback-test.xml b/dcae-analytics-common/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..2a874be
--- /dev/null
+++ b/dcae-analytics-common/src/test/resources/logback-test.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============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=========================================================
+ -->
+<configuration>
+
+ <!--
+ Disabling some chatty loggers.
+ -->
+ <logger name="org.apache.commons.beanutils" level="ERROR"/>
+ <logger name="org.apache.zookeeper.server" level="ERROR"/>
+ <logger name="org.apache.zookeeper" level="ERROR"/>
+ <logger name="com.ning" level="WARN"/>
+ <logger name="org.apache.spark" level="WARN"/>
+ <logger name="org.spark-project" level="WARN"/>
+ <logger name="org.apache.hadoop" level="WARN"/>
+ <logger name="org.apache.hive" level="WARN"/>
+ <logger name="org.quartz.core" level="WARN"/>
+ <logger name="org.eclipse.jetty" level="WARN"/>
+ <logger name="io.netty.util.internal" level="WARN"/>
+
+ <logger name="org.apache.twill" level="WARN"/>
+ <logger name="co.cask.cdap" level="INFO"/>
+ <logger name="com.openecomp" level="DEBUG"/>
+
+ <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="ERROR">
+ <appender-ref ref="Console"/>
+ </root>
+
+
+</configuration>
+