aboutsummaryrefslogtreecommitdiffstats
path: root/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor
diff options
context:
space:
mode:
Diffstat (limited to 'dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor')
-rw-r--r--dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/AbstractTCAECEFPolicyProcessor.java61
-rw-r--r--dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFJsonProcessor.java98
-rw-r--r--dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyDomainFilter.java83
-rw-r--r--dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyFunctionalRoleFilter.java91
-rw-r--r--dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyThresholdsProcessor.java135
-rw-r--r--dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFProcessorContext.java103
6 files changed, 571 insertions, 0 deletions
diff --git a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/AbstractTCAECEFPolicyProcessor.java b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/AbstractTCAECEFPolicyProcessor.java
new file mode 100644
index 0000000..6cb8e7f
--- /dev/null
+++ b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/AbstractTCAECEFPolicyProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * ===============================LICENSE_START======================================
+ * dcae-analytics
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================LICENSE_END===========================================
+ */
+
+package org.openecomp.dcae.apod.analytics.tca.processor;
+
+import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException;
+import org.openecomp.dcae.apod.analytics.common.service.processor.AbstractMessageProcessor;
+import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+
+/**
+ * <p>
+ * Encapsulates common functionality for all TCA CEF Policy Processors
+ * </p>
+ *
+ * @author Rajiv Singla . Creation Date: 11/9/2016.
+ */
+public abstract class AbstractTCAECEFPolicyProcessor extends AbstractMessageProcessor<TCACEFProcessorContext> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractTCAECEFPolicyProcessor.class);
+
+ /**
+ * For all TCA Policy Processor the pre processor ensures that {@link EventListener} object is
+ * present
+ *
+ * @param processorContext incoming Processor Context
+ * @return Pre processed Processor Context
+ */
+ @Override
+ public TCACEFProcessorContext preProcessor(@Nonnull TCACEFProcessorContext processorContext) {
+ // validates CEF Event Listener is Present
+ final EventListener cefEventListener = processorContext.getCEFEventListener();
+ if (cefEventListener == null) {
+ final String errorMessage = String.format(
+ "CEF Event Listener is not Present.Invalid use of Processor: %s. CEF Message: %s",
+ getProcessorInfo().getProcessorName(), processorContext.getMessage());
+ throw new MessageProcessingException(errorMessage, LOG, new IllegalArgumentException(errorMessage));
+ }
+ return super.preProcessor(processorContext);
+ }
+}
diff --git a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFJsonProcessor.java b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFJsonProcessor.java
new file mode 100644
index 0000000..944eba6
--- /dev/null
+++ b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFJsonProcessor.java
@@ -0,0 +1,98 @@
+/*
+ * ===============================LICENSE_START======================================
+ * dcae-analytics
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================LICENSE_END===========================================
+ */
+
+package org.openecomp.dcae.apod.analytics.tca.processor;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException;
+import org.openecomp.dcae.apod.analytics.common.service.processor.AbstractMessageProcessor;
+import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
+import org.openecomp.dcae.apod.analytics.tca.utils.TCAUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+/**
+ *<p>
+ * Processor that converts incoming presumed JSON string CEF message to {@link EventListener} object
+ * <br>
+ * Pre Conditions: None
+ *</p>
+ *
+ * @author Rajiv Singla . Creation Date: 11/5/2016.
+ */
+public class TCACEFJsonProcessor extends AbstractMessageProcessor<TCACEFProcessorContext> {
+
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(TCACEFJsonProcessor.class);
+
+
+ @Override
+ public String getProcessorDescription() {
+ return "Converts incoming TCA CEF Message to Event Listener object";
+ }
+
+ @Override
+ public TCACEFProcessorContext processMessage(TCACEFProcessorContext processorContext) {
+
+ final String cefMessage = processorContext.getMessage();
+
+ // If CEF Message is null then processor should stop processing
+ if (cefMessage == null) {
+ String errorMessage = "Null CEF message cannot be converted to CEF Event Listener Object";
+ throw new MessageProcessingException(errorMessage, LOG, new IllegalArgumentException(errorMessage));
+ }
+
+ // If CEF Message is blank then processor stop processing
+ if (StringUtils.isBlank(cefMessage)) {
+ setTerminatingProcessingMessage("Blank CEF message cannot be converted to CEF Event Listener Object",
+ processorContext);
+ return processorContext;
+ }
+
+ // trim cef message
+ final String trimmedCEFMessage = cefMessage.trim();
+
+ // if message does not start with curly brace and ends with curly brace, it is not a valid cef message
+ // processor will stop processing
+ if (!(trimmedCEFMessage.startsWith("{") && trimmedCEFMessage.endsWith("}"))) {
+ setTerminatingProcessingMessage("CEF Message must start with curly brace and must end with curly brace",
+ processorContext);
+ return processorContext;
+ }
+
+ // try parsing the cef message
+ try {
+ final EventListener eventListener = TCAUtils.readValue(trimmedCEFMessage, EventListener.class);
+ setFinishedProcessingMessage("CEF JSON to Event Listener Conversion Successful", processorContext);
+ // set new Event Listener in the Processor Context
+ processorContext.setCEFEventListener(eventListener);
+ return processorContext;
+ } catch (IOException e) {
+ final String errorMessage = String.format("Parsing Failed for CEF Message: %s, Error: %s", cefMessage, e);
+ // If parsing fails throw an exception
+ throw new MessageProcessingException(errorMessage, LOG, e);
+ }
+
+ }
+}
diff --git a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyDomainFilter.java b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyDomainFilter.java
new file mode 100644
index 0000000..40d6330
--- /dev/null
+++ b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyDomainFilter.java
@@ -0,0 +1,83 @@
+/*
+ * ===============================LICENSE_START======================================
+ * dcae-analytics
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================LICENSE_END===========================================
+ */
+
+package org.openecomp.dcae.apod.analytics.tca.processor;
+
+import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
+
+/**
+ * <p>
+ * TCA Processor which acts like a filter to filter out messages which does not belong to TCA Policy Domain
+ * <br>
+ * Pre Conditions: CEF Event Listener must be present
+ * </p>
+ *
+ * @author Rajiv Singla . Creation Date: 11/7/2016.
+ */
+public class TCACEFPolicyDomainFilter extends AbstractTCAECEFPolicyProcessor {
+
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getProcessorDescription() {
+ return "Filters out CEF Messages which does not match TCAPolicy Domain";
+ }
+
+ @Override
+ public TCACEFProcessorContext processMessage(TCACEFProcessorContext processorContext) {
+
+ // Safe to get event Listener here without null check as pre processor will validate if
+ // event listener is indeed present
+ final EventListener eventListener = processorContext.getCEFEventListener();
+
+ String cefMessageDomain;
+
+ // Extract CEF domain as it is must be present as per CEF Schema
+ if (eventListener.getEvent() != null &&
+ eventListener.getEvent().getCommonEventHeader() != null &&
+ eventListener.getEvent().getCommonEventHeader().getDomain() != null) {
+ cefMessageDomain = eventListener.getEvent().getCommonEventHeader().getDomain();
+
+ } else {
+ final String terminatingMessage = "Invalid CEF Message.Common Event Header Domain not present.";
+ setTerminatingProcessingMessage(terminatingMessage, processorContext);
+ return processorContext;
+ }
+
+ // Get Policy Domain. TCA Policy Validation must ensure that Domain is indeed present
+ // no null check will be required here
+ final String policyDomain = processorContext.getTCAPolicy().getDomain();
+
+ // If Policy domain matches CEF message domain then continue processing
+ if (cefMessageDomain.equals(policyDomain)) {
+ final String finishMessage = String.format("Policy Domain and CEF Message Domain match successful." +
+ " Message Domain: %s, Policy Domain: %s", cefMessageDomain, policyDomain);
+ setFinishedProcessingMessage(finishMessage, processorContext);
+ } else {
+ // If policy domain does not match with CEF message terminate processing chain
+ final String terminatingMessage = String.format("Policy Domain and CEF Message Domain match unsuccessful." +
+ " Message Domain: %s, Policy Domain: %s", cefMessageDomain, policyDomain);
+ setTerminatingProcessingMessage(terminatingMessage, processorContext);
+ }
+
+ return processorContext;
+ }
+}
diff --git a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyFunctionalRoleFilter.java b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyFunctionalRoleFilter.java
new file mode 100644
index 0000000..8a97299
--- /dev/null
+++ b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyFunctionalRoleFilter.java
@@ -0,0 +1,91 @@
+/*
+ * ===============================LICENSE_START======================================
+ * dcae-analytics
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================LICENSE_END===========================================
+ */
+
+package org.openecomp.dcae.apod.analytics.tca.processor;
+
+import com.google.common.base.Joiner;
+import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
+import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
+
+import java.util.List;
+
+import static org.openecomp.dcae.apod.analytics.tca.utils.TCAUtils.getPolicyFunctionalRoleSupplier;
+
+/**
+ * <p>
+ * TCA Processor that acts like a filter to filter out messages which does not belong to TCA Policy Functional Roles
+ * <br>
+ * Pre Conditions: CEF Event Listener must be present
+ * </p>
+ *
+ * @author Rajiv Singla . Creation Date: 11/9/2016.
+ */
+public class TCACEFPolicyFunctionalRoleFilter extends AbstractTCAECEFPolicyProcessor {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getProcessorDescription() {
+ return "Filters out CEF Messages which does not match Policy Functional Roles";
+ }
+
+ @Override
+ public TCACEFProcessorContext processMessage(TCACEFProcessorContext processorContext) {
+
+ // Safe to get event Listener here without null check as pre processor will validate if
+ // event listener is indeed present
+ final EventListener eventListener = processorContext.getCEFEventListener();
+
+ String cefMessageFunctionalRole;
+
+ if (eventListener.getEvent() != null &&
+ eventListener.getEvent().getCommonEventHeader() != null &&
+ eventListener.getEvent().getCommonEventHeader().getFunctionalRole() != null) {
+ cefMessageFunctionalRole = eventListener.getEvent().getCommonEventHeader().getFunctionalRole();
+ } else {
+ String terminationMessage = "Invalid CEF Message.Common Event Header Functional Role not present.";
+ setTerminatingProcessingMessage(terminationMessage, processorContext);
+ return processorContext;
+ }
+
+ // Determine Policy Functional Roles
+ final TCAPolicy tcaPolicy = processorContext.getTCAPolicy();
+ final List<String> policyFunctionalRoles = getPolicyFunctionalRoleSupplier(tcaPolicy).get();
+ final String policyFunctionalRolesString = Joiner.on(",").join(policyFunctionalRoles);
+
+ // If Policy functional Roles contains CEF message Functional Role then continue processing
+ if (policyFunctionalRoles.contains(cefMessageFunctionalRole)) {
+ final String finishMessage = String.format(
+ "Policy Functional Roles and CEF Message Functional match successful." +
+ "Message Functional Role: %s, Policy Functional Roles: %s",
+ cefMessageFunctionalRole, policyFunctionalRolesString);
+ setFinishedProcessingMessage(finishMessage, processorContext);
+ } else {
+ // If Policy functional Roles does not contain CEF message Functiona Role then terminate processing
+ final String terminatingMessage = String.format(
+ "Policy Domain and CEF Message Domain match unsuccessful." +
+ "Message Functional Role: %s, Policy Functional Roles: %s",
+ cefMessageFunctionalRole, policyFunctionalRolesString);
+ setTerminatingProcessingMessage(terminatingMessage, processorContext);
+ }
+
+ return processorContext;
+ }
+}
diff --git a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyThresholdsProcessor.java b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyThresholdsProcessor.java
new file mode 100644
index 0000000..4d49cbb
--- /dev/null
+++ b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyThresholdsProcessor.java
@@ -0,0 +1,135 @@
+/*
+ * ===============================LICENSE_START======================================
+ * dcae-analytics
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================LICENSE_END===========================================
+ */
+
+package org.openecomp.dcae.apod.analytics.tca.processor;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Table;
+import org.openecomp.dcae.apod.analytics.common.exception.MessageProcessingException;
+import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
+import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.MetricsPerFunctionalRole;
+import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
+import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Threshold;
+import org.openecomp.dcae.apod.analytics.tca.utils.TCAUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Nonnull;
+
+/**
+ *<p>
+ * TCA CEF Policy Threshold processor
+ * <br>
+ * Pre Conditions: Domain and Functional Role must be present in CEF Event Listener Object
+ *</p>
+ *
+ * @author Rajiv Singla . Creation Date: 11/9/2016.
+ */
+public class TCACEFPolicyThresholdsProcessor extends AbstractTCAECEFPolicyProcessor {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger LOG = LoggerFactory.getLogger(TCACEFPolicyThresholdsProcessor.class);
+
+ @Override
+ public TCACEFProcessorContext preProcessor(@Nonnull TCACEFProcessorContext processorContext) {
+ // validates Domain and Functional Role are present
+ final EventListener eventListener = processorContext.getCEFEventListener();
+ final String domain = eventListener.getEvent().getCommonEventHeader().getDomain();
+ final String functionalRole = eventListener.getEvent().getCommonEventHeader().getFunctionalRole();
+ if (domain == null || functionalRole == null) {
+ final String errorMessage = "CEF Event Listener domain or functional role not Present. " +
+ "Invalid use of this Processor";
+ throw new MessageProcessingException(errorMessage, LOG, new IllegalArgumentException(errorMessage));
+ }
+ return super.preProcessor(processorContext);
+ }
+
+ @Override
+ public String getProcessorDescription() {
+ return "Applies TCA Policy rules to incoming CEF message. If any thresholds are violated attaches max " +
+ "Severity violated threshold to TCA Processor Context";
+ }
+
+ @Override
+ public TCACEFProcessorContext processMessage(TCACEFProcessorContext processorContext) {
+
+ final String cefMessage = processorContext.getMessage();
+
+ // Determine domain and functional Role
+ final EventListener eventListener = processorContext.getCEFEventListener();
+ final String functionalRole = eventListener.getEvent().getCommonEventHeader().getFunctionalRole();
+
+ // Get Table containing Functional Role and Thresholds Field Path
+ final TCAPolicy tcaPolicy = processorContext.getTCAPolicy();
+ final Table<String, String, List<Threshold>> functionalRoleFieldPathsTable =
+ TCAUtils.getPolicyFRThresholdsTableSupplier(tcaPolicy).get();
+
+ // Get Policy Field Paths for that functional Role
+ final Map<String, List<Threshold>> policyFieldPathsMap = functionalRoleFieldPathsTable.row(functionalRole);
+ final Set<String> policyFieldPaths = policyFieldPathsMap.keySet();
+
+ // Get Json Values for Policy Fields
+ final Map<String, List<Long>> messageFieldValuesMap = TCAUtils.getJsonPathValue(cefMessage, policyFieldPaths);
+
+ // Determine all violated thresholds per message field Path
+ final Map<String, Threshold> violatedThresholdsMap = new HashMap<>();
+ for (Map.Entry<String, List<Long>> messageFieldValuesMapEntry : messageFieldValuesMap.entrySet()) {
+ final String messageFieldPath = messageFieldValuesMapEntry.getKey();
+ final List<Threshold> messageFieldAssociatedPolicyThresholds = policyFieldPathsMap.get(messageFieldPath);
+ if (messageFieldAssociatedPolicyThresholds != null) {
+ final Optional<Threshold> thresholdOptional = TCAUtils.thresholdCalculator(
+ messageFieldValuesMapEntry.getValue(), messageFieldAssociatedPolicyThresholds);
+ if (thresholdOptional.isPresent()) {
+ violatedThresholdsMap.put(messageFieldPath, thresholdOptional.get());
+ }
+ }
+ }
+
+ // No threshold were violated
+ if (violatedThresholdsMap.isEmpty()) {
+
+ final String terminationMessage = "No Policy Threshold violated by the VES CEF Message.";
+ setTerminatingProcessingMessage(terminationMessage, processorContext);
+
+ } else {
+
+ // If there are policy violations then determine max priority violation
+ final Threshold maxSeverityThresholdViolation =
+ TCAUtils.prioritizeThresholdViolations(violatedThresholdsMap);
+ final MetricsPerFunctionalRole violatedMetrics = TCAUtils.createViolatedMetrics(tcaPolicy,
+ maxSeverityThresholdViolation, functionalRole);
+ // attach policy violation to processor Context
+ processorContext.setMetricsPerFunctionalRole(violatedMetrics);
+
+ final String finishMessage = String.format("Policy Threshold violation detected for threshold: %s",
+ maxSeverityThresholdViolation);
+ setFinishedProcessingMessage(finishMessage, processorContext);
+
+ }
+
+ return processorContext;
+ }
+}
diff --git a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFProcessorContext.java b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFProcessorContext.java
new file mode 100644
index 0000000..d2ba545
--- /dev/null
+++ b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFProcessorContext.java
@@ -0,0 +1,103 @@
+/*
+ * ===============================LICENSE_START======================================
+ * dcae-analytics
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============================LICENSE_END===========================================
+ */
+
+package org.openecomp.dcae.apod.analytics.tca.processor;
+
+import org.openecomp.dcae.apod.analytics.common.service.processor.AbstractProcessorContext;
+import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
+import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.MetricsPerFunctionalRole;
+import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
+
+/**
+ * TCA CEF Policy Processor Context
+ *
+ * @author Rajiv Singla . Creation Date: 11/7/2016.
+ */
+public class TCACEFProcessorContext extends AbstractProcessorContext {
+
+ private static final long serialVersionUID = 1L;
+
+ private final TCAPolicy tcaPolicy;
+ private EventListener eventListener;
+ private MetricsPerFunctionalRole metricsPerFunctionalRole;
+
+ public TCACEFProcessorContext(final String message, boolean canProcessingContinue, final TCAPolicy tcaPolicy) {
+ super(message, canProcessingContinue);
+ this.tcaPolicy = tcaPolicy;
+ // present only if cef incoming message can be parsed successfully to Event Listener Object
+ this.eventListener = null;
+ // present only if there are any threshold violations are detected
+ this.metricsPerFunctionalRole = null;
+ }
+
+ // Auxiliary Constructor which default canProcessingContinue Flag to true
+ public TCACEFProcessorContext(final String message, final TCAPolicy tcaPolicy) {
+ this(message, true, tcaPolicy);
+ }
+
+ /**
+ * Returns {@link TCAPolicy} Object
+ *
+ * @return TCA Policy
+ */
+ public TCAPolicy getTCAPolicy() {
+ return tcaPolicy;
+ }
+
+ /**
+ * Returns Common Event Format {@link EventListener} if present else null
+ *
+ * @return CEF Event Listener
+ */
+ public EventListener getCEFEventListener() {
+ return eventListener;
+ }
+
+
+ /**
+ * Sets new {@link EventListener}
+ *
+ * @param eventListener set new value for CEF event listener
+ */
+ public void setCEFEventListener(final EventListener eventListener) {
+ this.eventListener = eventListener;
+ }
+
+
+ /**
+ * Returns TCA Policy {@link MetricsPerFunctionalRole} which was has violated Threshold for the CEF Message if
+ * present else null
+ *
+ * @return Violated Threshold
+ */
+ public MetricsPerFunctionalRole getMetricsPerFunctionalRole() {
+ return metricsPerFunctionalRole;
+ }
+
+ /**
+ * Assign new TCA Policy {@link MetricsPerFunctionalRole} which was has violated Threshold for the CEF Message
+ *
+ * @param metricsPerFunctionalRole new value for Metrics Per Functional Role with violated threshold
+ */
+ public void setMetricsPerFunctionalRole(MetricsPerFunctionalRole metricsPerFunctionalRole) {
+ this.metricsPerFunctionalRole = metricsPerFunctionalRole;
+ }
+
+}