diff options
Diffstat (limited to 'dcae-analytics-tca/src/main')
-rw-r--r-- | dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyDomainFilter.java | 5 | ||||
-rw-r--r-- | dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyEventNameFilter.java (renamed from dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyFunctionalRoleFilter.java) | 22 | ||||
-rw-r--r-- | dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFPolicyThresholdsProcessor.java | 31 | ||||
-rw-r--r-- | dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/processor/TCACEFProcessorContext.java | 20 | ||||
-rw-r--r-- | dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/utils/TCAUtils.java | 259 |
5 files changed, 166 insertions, 171 deletions
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 index 40d6330..cd29ed1 100644 --- 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 @@ -20,6 +20,7 @@ package org.openecomp.dcae.apod.analytics.tca.processor; +import org.openecomp.dcae.apod.analytics.model.domain.cef.Domain; import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener; /** @@ -48,7 +49,7 @@ public class TCACEFPolicyDomainFilter extends AbstractTCAECEFPolicyProcessor { // event listener is indeed present final EventListener eventListener = processorContext.getCEFEventListener(); - String cefMessageDomain; + Domain cefMessageDomain; // Extract CEF domain as it is must be present as per CEF Schema if (eventListener.getEvent() != null && @@ -67,7 +68,7 @@ public class TCACEFPolicyDomainFilter extends AbstractTCAECEFPolicyProcessor { final String policyDomain = processorContext.getTCAPolicy().getDomain(); // If Policy domain matches CEF message domain then continue processing - if (cefMessageDomain.equals(policyDomain)) { + if (cefMessageDomain.toString().equalsIgnoreCase(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); 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/TCACEFPolicyEventNameFilter.java index 8a97299..689b06c 100644 --- 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/TCACEFPolicyEventNameFilter.java @@ -26,18 +26,18 @@ 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; +import static org.openecomp.dcae.apod.analytics.tca.utils.TCAUtils.getPolicyEventNamesSupplier; /** * <p> - * TCA Processor that acts like a filter to filter out messages which does not belong to TCA Policy Functional Roles + * TCA Processor that acts like a filter to filter out messages which does not belong to TCA Policy Event Name * <br> * Pre Conditions: CEF Event Listener must be present * </p> * * @author Rajiv Singla . Creation Date: 11/9/2016. */ -public class TCACEFPolicyFunctionalRoleFilter extends AbstractTCAECEFPolicyProcessor { +public class TCACEFPolicyEventNameFilter extends AbstractTCAECEFPolicyProcessor { private static final long serialVersionUID = 1L; @@ -53,36 +53,36 @@ public class TCACEFPolicyFunctionalRoleFilter extends AbstractTCAECEFPolicyProce // event listener is indeed present final EventListener eventListener = processorContext.getCEFEventListener(); - String cefMessageFunctionalRole; + String cefMessageEventName; if (eventListener.getEvent() != null && eventListener.getEvent().getCommonEventHeader() != null && - eventListener.getEvent().getCommonEventHeader().getFunctionalRole() != null) { - cefMessageFunctionalRole = eventListener.getEvent().getCommonEventHeader().getFunctionalRole(); + eventListener.getEvent().getCommonEventHeader().getEventName() != null) { + cefMessageEventName = eventListener.getEvent().getCommonEventHeader().getEventName(); } else { - String terminationMessage = "Invalid CEF Message.Common Event Header Functional Role not present."; + String terminationMessage = "Invalid CEF Message.Common Event Header Event Name not present."; setTerminatingProcessingMessage(terminationMessage, processorContext); return processorContext; } // Determine Policy Functional Roles final TCAPolicy tcaPolicy = processorContext.getTCAPolicy(); - final List<String> policyFunctionalRoles = getPolicyFunctionalRoleSupplier(tcaPolicy).get(); + final List<String> policyFunctionalRoles = getPolicyEventNamesSupplier(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)) { + if (policyFunctionalRoles.contains(cefMessageEventName)) { final String finishMessage = String.format( "Policy Functional Roles and CEF Message Functional match successful." + "Message Functional Role: %s, Policy Functional Roles: %s", - cefMessageFunctionalRole, policyFunctionalRolesString); + cefMessageEventName, 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); + cefMessageEventName, policyFunctionalRolesString); setTerminatingProcessingMessage(terminatingMessage, 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 index 4d49cbb..f02a4bb 100644 --- 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 @@ -23,8 +23,9 @@ 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.Domain; 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.MetricsPerEventName; 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; @@ -57,10 +58,10 @@ public class TCACEFPolicyThresholdsProcessor extends AbstractTCAECEFPolicyProces 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. " + + final Domain domain = eventListener.getEvent().getCommonEventHeader().getDomain(); + final String eventName = eventListener.getEvent().getCommonEventHeader().getEventName(); + if (domain == null || eventName == null) { + final String errorMessage = "CEF Event Listener domain or eventName not Present. " + "Invalid use of this Processor"; throw new MessageProcessingException(errorMessage, LOG, new IllegalArgumentException(errorMessage)); } @@ -78,17 +79,17 @@ public class TCACEFPolicyThresholdsProcessor extends AbstractTCAECEFPolicyProces final String cefMessage = processorContext.getMessage(); - // Determine domain and functional Role + // Determine domain and eventName final EventListener eventListener = processorContext.getCEFEventListener(); - final String functionalRole = eventListener.getEvent().getCommonEventHeader().getFunctionalRole(); + final String eventName = eventListener.getEvent().getCommonEventHeader().getEventName(); - // Get Table containing Functional Role and Thresholds Field Path + // Get Table containing event Name and Thresholds Field Path final TCAPolicy tcaPolicy = processorContext.getTCAPolicy(); - final Table<String, String, List<Threshold>> functionalRoleFieldPathsTable = - TCAUtils.getPolicyFRThresholdsTableSupplier(tcaPolicy).get(); + final Table<String, String, List<Threshold>> eventNameFieldPathsTable = + TCAUtils.getPolicyEventNameThresholdsTableSupplier(tcaPolicy).get(); - // Get Policy Field Paths for that functional Role - final Map<String, List<Threshold>> policyFieldPathsMap = functionalRoleFieldPathsTable.row(functionalRole); + // Get Policy Field Paths for that event Name + final Map<String, List<Threshold>> policyFieldPathsMap = eventNameFieldPathsTable.row(eventName); final Set<String> policyFieldPaths = policyFieldPathsMap.keySet(); // Get Json Values for Policy Fields @@ -119,10 +120,10 @@ public class TCACEFPolicyThresholdsProcessor extends AbstractTCAECEFPolicyProces // If there are policy violations then determine max priority violation final Threshold maxSeverityThresholdViolation = TCAUtils.prioritizeThresholdViolations(violatedThresholdsMap); - final MetricsPerFunctionalRole violatedMetrics = TCAUtils.createViolatedMetrics(tcaPolicy, - maxSeverityThresholdViolation, functionalRole); + final MetricsPerEventName violatedMetrics = TCAUtils.createViolatedMetrics(tcaPolicy, + maxSeverityThresholdViolation, eventName); // attach policy violation to processor Context - processorContext.setMetricsPerFunctionalRole(violatedMetrics); + processorContext.setMetricsPerEventName(violatedMetrics); final String finishMessage = String.format("Policy Threshold violation detected for threshold: %s", maxSeverityThresholdViolation); 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 index d2ba545..207d1e1 100644 --- 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 @@ -22,7 +22,7 @@ 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.MetricsPerEventName; import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy; /** @@ -36,7 +36,7 @@ public class TCACEFProcessorContext extends AbstractProcessorContext { private final TCAPolicy tcaPolicy; private EventListener eventListener; - private MetricsPerFunctionalRole metricsPerFunctionalRole; + private MetricsPerEventName metricsPerEventName; public TCACEFProcessorContext(final String message, boolean canProcessingContinue, final TCAPolicy tcaPolicy) { super(message, canProcessingContinue); @@ -44,7 +44,7 @@ public class TCACEFProcessorContext extends AbstractProcessorContext { // 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; + this.metricsPerEventName = null; } // Auxiliary Constructor which default canProcessingContinue Flag to true @@ -82,22 +82,22 @@ public class TCACEFProcessorContext extends AbstractProcessorContext { /** - * Returns TCA Policy {@link MetricsPerFunctionalRole} which was has violated Threshold for the CEF Message if + * Returns TCA Policy {@link MetricsPerEventName} which was has violated Threshold for the CEF Message if * present else null * * @return Violated Threshold */ - public MetricsPerFunctionalRole getMetricsPerFunctionalRole() { - return metricsPerFunctionalRole; + public MetricsPerEventName getMetricsPerEventName() { + return metricsPerEventName; } /** - * Assign new TCA Policy {@link MetricsPerFunctionalRole} which was has violated Threshold for the CEF Message + * Assign new TCA Policy {@link MetricsPerEventName} which was has violated Threshold for the CEF Message * - * @param metricsPerFunctionalRole new value for Metrics Per Functional Role with violated threshold + * @param metricsPerEventName new value for Metrics Per Functional Role with violated threshold */ - public void setMetricsPerFunctionalRole(MetricsPerFunctionalRole metricsPerFunctionalRole) { - this.metricsPerFunctionalRole = metricsPerFunctionalRole; + public void setMetricsPerEventName(MetricsPerEventName metricsPerEventName) { + this.metricsPerEventName = metricsPerEventName; } } diff --git a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/utils/TCAUtils.java b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/utils/TCAUtils.java index 2465fb4..cd61e65 100644 --- a/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/utils/TCAUtils.java +++ b/dcae-analytics-tca/src/main/java/org/openecomp/dcae/apod/analytics/tca/utils/TCAUtils.java @@ -51,8 +51,10 @@ import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener; import org.openecomp.dcae.apod.analytics.model.domain.cef.EventSeverity; import org.openecomp.dcae.apod.analytics.model.domain.cef.PerformanceCounter; import org.openecomp.dcae.apod.analytics.model.domain.cef.ThresholdCrossingAlertFields; +import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.ControlLoopEventStatus; +import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.ControlLoopSchemaType; import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Direction; -import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.MetricsPerFunctionalRole; +import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.MetricsPerEventName; 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.model.facade.tca.AAI; @@ -61,7 +63,7 @@ import org.openecomp.dcae.apod.analytics.model.util.AnalyticsModelIOUtils; import org.openecomp.dcae.apod.analytics.model.util.AnalyticsModelJsonUtils; import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFJsonProcessor; import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyDomainFilter; -import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyFunctionalRoleFilter; +import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyEventNameFilter; import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyThresholdsProcessor; import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFProcessorContext; import org.quartz.Job; @@ -121,85 +123,85 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { }; /** - * {@link Function} that extracts {@link TCAPolicy#getMetricsPerFunctionalRole()} from {@link TCAPolicy} + * {@link Function} that extracts {@link TCAPolicy#getMetricsPerEventName()} from {@link TCAPolicy} * - * @return TCA Policy Metrics Per Functional Roles List + * @return TCA Policy Metrics Per Event Name list */ - public static Function<TCAPolicy, List<MetricsPerFunctionalRole>> tcaPolicyMetricsExtractorFunction() { - return new Function<TCAPolicy, List<MetricsPerFunctionalRole>>() { + public static Function<TCAPolicy, List<MetricsPerEventName>> tcaPolicyMetricsExtractorFunction() { + return new Function<TCAPolicy, List<MetricsPerEventName>>() { @Nullable @Override - public List<MetricsPerFunctionalRole> apply(@Nonnull TCAPolicy tcaPolicy) { - return tcaPolicy.getMetricsPerFunctionalRole(); + public List<MetricsPerEventName> apply(@Nonnull TCAPolicy tcaPolicy) { + return tcaPolicy.getMetricsPerEventName(); } }; } /** - * {@link Function} that extracts {@link MetricsPerFunctionalRole#getFunctionalRole()} from - * {@link MetricsPerFunctionalRole} + * {@link Function} that extracts {@link MetricsPerEventName#getEventName()} from + * {@link MetricsPerEventName} * - * @return Functional role or a Metrics Per Functional Role object + * @return Event Names or a Metrics Per Event Name object */ - public static Function<MetricsPerFunctionalRole, String> tcaFunctionalRoleExtractorFunction() { - return new Function<MetricsPerFunctionalRole, String>() { + public static Function<MetricsPerEventName, String> tcaEventNameExtractorFunction() { + return new Function<MetricsPerEventName, String>() { @Override - public String apply(@Nonnull MetricsPerFunctionalRole metricsPerFunctionalRole) { - return metricsPerFunctionalRole.getFunctionalRole(); + public String apply(@Nonnull MetricsPerEventName metricsPerEventName) { + return metricsPerEventName.getEventName(); } }; } /** - * Extracts {@link TCAPolicy} Functional Roles + * Extracts {@link TCAPolicy} Event Names * * @param tcaPolicy TCA Policy - * @return List of functional Roles in the tca Policy + * @return List of event names in the TCA Policy */ - public static List<String> getPolicyFunctionalRoles(@Nonnull final TCAPolicy tcaPolicy) { - final List<MetricsPerFunctionalRole> metricsPerFunctionalRoles = + public static List<String> getPolicyEventNames(@Nonnull final TCAPolicy tcaPolicy) { + final List<MetricsPerEventName> metricsPerEventNames = tcaPolicyMetricsExtractorFunction().apply(tcaPolicy); - return Lists.transform(metricsPerFunctionalRoles, tcaFunctionalRoleExtractorFunction()); + return Lists.transform(metricsPerEventNames, tcaEventNameExtractorFunction()); } /** - * A {@link Supplier} which caches {@link TCAPolicy} Functional Roles as they are not expected to + * A {@link Supplier} which caches {@link TCAPolicy} Event names as they are not expected to * change during runtime * * @param tcaPolicy TCA Policy - * @return a Supplier that memoize the Functional roles + * @return a Supplier that memoize the TCA Policy event names */ - public static Supplier<List<String>> getPolicyFunctionalRoleSupplier(@Nonnull final TCAPolicy tcaPolicy) { + public static Supplier<List<String>> getPolicyEventNamesSupplier(@Nonnull final TCAPolicy tcaPolicy) { return Suppliers.memoize(new Supplier<List<String>>() { @Override public List<String> get() { - return getPolicyFunctionalRoles(tcaPolicy); + return getPolicyEventNames(tcaPolicy); } }); } /** - * Creates a Table to lookup thresholds of a {@link TCAPolicy} by its Functional Role and Threshold Field path + * Creates a Table to lookup thresholds of a {@link TCAPolicy} by its Event Name and Threshold Field path * * @param tcaPolicy TCA Policy - * @return A table with Keys of functional role and field path containing List of threshold as values + * @return A table with Keys of event name and field path containing List of threshold as values */ - public static Table<String, String, List<Threshold>> getPolicyFRThresholdsTable(final TCAPolicy tcaPolicy) { + public static Table<String, String, List<Threshold>> getPolicyEventNameThresholdsTable(final TCAPolicy tcaPolicy) { final Table<String, String, List<Threshold>> domainFRTable = HashBasedTable.create(); - for (MetricsPerFunctionalRole metricsPerFunctionalRole : tcaPolicy.getMetricsPerFunctionalRole()) { - final String functionalRole = metricsPerFunctionalRole.getFunctionalRole(); - final List<Threshold> thresholds = metricsPerFunctionalRole.getThresholds(); + for (MetricsPerEventName metricsPerEventName : tcaPolicy.getMetricsPerEventName()) { + final String eventName = metricsPerEventName.getEventName(); + final List<Threshold> thresholds = metricsPerEventName.getThresholds(); for (Threshold threshold : thresholds) { - final List<Threshold> existingThresholds = domainFRTable.get(functionalRole, threshold.getFieldPath()); + final List<Threshold> existingThresholds = domainFRTable.get(eventName, threshold.getFieldPath()); if (existingThresholds == null) { final LinkedList<Threshold> newThresholdList = new LinkedList<>(); newThresholdList.add(threshold); - domainFRTable.put(functionalRole, threshold.getFieldPath(), newThresholdList); + domainFRTable.put(eventName, threshold.getFieldPath(), newThresholdList); } else { - domainFRTable.get(functionalRole, threshold.getFieldPath()).add(threshold); + domainFRTable.get(eventName, threshold.getFieldPath()).add(threshold); } } } @@ -208,17 +210,17 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { /** - * A {@link Supplier} which caches Policy Functional Role and Threshold Field Path Thresholds lookup table + * A {@link Supplier} which caches Policy Event Name and Threshold Field Path Thresholds lookup table * * @param tcaPolicy TCA Policy - * @return Cached Supplier for table with Keys of functional role and field path containing thresholds as values + * @return Cached Supplier for table with Keys of event Name and field path containing thresholds as values */ - public static Supplier<Table<String, String, List<Threshold>>> getPolicyFRThresholdsTableSupplier + public static Supplier<Table<String, String, List<Threshold>>> getPolicyEventNameThresholdsTableSupplier (final TCAPolicy tcaPolicy) { return Suppliers.memoize(new Supplier<Table<String, String, List<Threshold>>>() { @Override public Table<String, String, List<Threshold>> get() { - return getPolicyFRThresholdsTable(tcaPolicy); + return getPolicyEventNameThresholdsTable(tcaPolicy); } }); } @@ -226,8 +228,8 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { /** * Creates a {@link GenericMessageChainProcessor} of {@link TCACEFJsonProcessor}, - * {@link TCACEFPolicyDomainFilter} and {@link TCACEFPolicyFunctionalRoleFilter}s to - * filter out messages which does not match policy domain or functional role + * {@link TCACEFPolicyDomainFilter} and {@link TCACEFPolicyEventNameFilter}s to + * filter out messages which does not match policy domain or event Name * * @param cefMessage CEF Message * @param tcaPolicy TCA Policy @@ -238,10 +240,10 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { final TCACEFJsonProcessor jsonProcessor = new TCACEFJsonProcessor(); final TCACEFPolicyDomainFilter domainFilter = new TCACEFPolicyDomainFilter(); - final TCACEFPolicyFunctionalRoleFilter functionalRoleFilter = new TCACEFPolicyFunctionalRoleFilter(); + final TCACEFPolicyEventNameFilter eventNameFilter = new TCACEFPolicyEventNameFilter(); // Create a list of message processors final ImmutableList<AbstractMessageProcessor<TCACEFProcessorContext>> messageProcessors = - ImmutableList.of(jsonProcessor, domainFilter, functionalRoleFilter); + ImmutableList.of(jsonProcessor, domainFilter, eventNameFilter); final TCACEFProcessorContext processorContext = new TCACEFProcessorContext(cefMessage, tcaPolicy); // Create a message processors chain final GenericMessageChainProcessor<TCACEFProcessorContext> tcaProcessingChain = @@ -331,33 +333,33 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { /** - * Creates {@link MetricsPerFunctionalRole} object which contains violated thresholds + * Creates {@link MetricsPerEventName} object which contains violated thresholds * * @param tcaPolicy TCA Policy * @param violatedThreshold Violated thresholds - * @param functionalRole Functional Role + * @param eventName Event Name * - * @return MetricsPerFunctionalRole object containing one highest severity violated threshold + * @return MetricsPerEventName object containing one highest severity violated threshold */ - public static MetricsPerFunctionalRole createViolatedMetrics(@Nonnull final TCAPolicy tcaPolicy, - @Nonnull final Threshold violatedThreshold, - @Nonnull final String functionalRole) { + public static MetricsPerEventName createViolatedMetrics(@Nonnull final TCAPolicy tcaPolicy, + @Nonnull final Threshold violatedThreshold, + @Nonnull final String eventName) { - final ArrayList<MetricsPerFunctionalRole> metricsPerFunctionalRoles = newArrayList( - Iterables.filter(tcaPolicy.getMetricsPerFunctionalRole(), new Predicate<MetricsPerFunctionalRole>() { + final ArrayList<MetricsPerEventName> metricsPerEventNames = newArrayList( + Iterables.filter(tcaPolicy.getMetricsPerEventName(), new Predicate<MetricsPerEventName>() { @Override - public boolean apply(@Nonnull MetricsPerFunctionalRole metricsPerFunctionalRole) { - return metricsPerFunctionalRole.getFunctionalRole().equals(functionalRole); + public boolean apply(@Nonnull MetricsPerEventName metricsPerEventName) { + return metricsPerEventName.getEventName().equals(eventName); } })); - // TCA policy must have only one metrics role per functional role - if (metricsPerFunctionalRoles.size() == 1) { - final MetricsPerFunctionalRole violatedMetrics = - MetricsPerFunctionalRole.copy(metricsPerFunctionalRoles.get(0)); + // TCA policy must have only one metrics per event Name + if (metricsPerEventNames.size() == 1) { + final MetricsPerEventName violatedMetrics = + MetricsPerEventName.copy(metricsPerEventNames.get(0)); violatedMetrics.setThresholds(ImmutableList.of(Threshold.copy(violatedThreshold))); return violatedMetrics; } else { - final String errorMessage = String.format("TCA Policy must contain functional Role: %s", functionalRole); + final String errorMessage = String.format("TCA Policy must contain eventName: %s", eventName); throw new MessageProcessingException(errorMessage, LOG, new IllegalStateException(errorMessage)); } } @@ -413,16 +415,16 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { public static EventListener addThresholdViolationFields( final TCACEFProcessorContext processorContextWithViolations) { - final MetricsPerFunctionalRole metricsPerFunctionalRole = - processorContextWithViolations.getMetricsPerFunctionalRole(); + final MetricsPerEventName metricsPerEventName = + processorContextWithViolations.getMetricsPerEventName(); // confirm violations are indeed present - if (metricsPerFunctionalRole == null) { + if (metricsPerEventName == null) { final String errorMessage = "No violations metrics. Unable to add Threshold Violation Fields"; throw new MessageProcessingException(errorMessage, LOG, new IllegalArgumentException(errorMessage)); } // get violated threshold - final Threshold violatedThreshold = metricsPerFunctionalRole.getThresholds().get(0); + final Threshold violatedThreshold = metricsPerEventName.getThresholds().get(0); final EventListener eventListener = processorContextWithViolations.getCEFEventListener(); final CommonEventHeader commonEventHeader = eventListener.getEvent().getCommonEventHeader(); @@ -435,7 +437,7 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { thresholdCrossingAlertFields.setAlertType(AlertType.INTERFACE_ANOMALY); thresholdCrossingAlertFields.setAlertDescription(violatedThreshold.getDirection().toString()); thresholdCrossingAlertFields.setInterfaceName(commonEventHeader.getReportingEntityName()); - thresholdCrossingAlertFields.setElementType(commonEventHeader.getFunctionalRole()); + thresholdCrossingAlertFields.setElementType(commonEventHeader.getEventName()); // create new performance count final PerformanceCounter performanceCounter = new PerformanceCounter(); @@ -482,15 +484,14 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { public static TCAVESResponse createNewTCAVESResponse(final TCACEFProcessorContext processorContext, final String tcaAppName) { - final MetricsPerFunctionalRole metricsPerFunctionalRole = processorContext.getMetricsPerFunctionalRole(); + final MetricsPerEventName metricsPerEventName = processorContext.getMetricsPerEventName(); // confirm violations are indeed present - if (metricsPerFunctionalRole == null) { + if (metricsPerEventName == null) { final String errorMessage = "No violations metrics. Unable to create VES Response"; throw new MessageProcessingException(errorMessage, LOG, new IllegalArgumentException(errorMessage)); } - final String functionalRole = metricsPerFunctionalRole.getFunctionalRole(); - final Threshold violatedThreshold = metricsPerFunctionalRole.getThresholds().get(0); + final Threshold violatedThreshold = metricsPerEventName.getThresholds().get(0); final EventListener eventListener = processorContext.getCEFEventListener(); final CommonEventHeader commonEventHeader = eventListener.getEvent().getCommonEventHeader(); @@ -510,18 +511,19 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { final AAI aai = new AAI(); tcavesResponse.setAai(aai); - // vLoadBalancer specific settings - if (isFunctionalRoleVLoadBalancer(functionalRole)) { + // VM specific settings + if (metricsPerEventName.getControlLoopSchemaType() == ControlLoopSchemaType.VM) { // Hard Coded - "VM" - tcavesResponse.setTargetType(AnalyticsConstants.LOAD_BALANCER_TCA_VES_RESPONSE_TARGET_TYPE); + tcavesResponse.setTargetType(AnalyticsConstants.TCA_VES_RESPONSE_VM_TARGET_TYPE); // Hard Coded - "vserver.vserver-name" - tcavesResponse.setTarget(AnalyticsConstants.LOAD_BALANCER_TCA_VES_RESPONSE_TARGET); + tcavesResponse.setTarget(AnalyticsConstants.TCA_VES_RESPONSE_VM_TARGET); aai.setGenericServerId(commonEventHeader.getReportingEntityName()); } else { + // VNF specific settings // Hard Coded - "VNF" - tcavesResponse.setTargetType(AnalyticsConstants.TCA_VES_RESPONSE_TARGET_TYPE); + tcavesResponse.setTargetType(AnalyticsConstants.TCA_VES_RESPONSE_VNF_TARGET_TYPE); // Hard Coded - "generic-vnf.vnf-id" - tcavesResponse.setTarget(AnalyticsConstants.TCA_VES_RESPONSE_TARGET); + tcavesResponse.setTarget(AnalyticsConstants.TCA_VES_RESPONSE_VNF_TARGET); // commonEventHeader.reportingEntityName from the received VES measurementsForVfScaling message (value for // the data element used in A&AI) aai.setGenericVNFId(commonEventHeader.getReportingEntityName()); @@ -530,40 +532,29 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { // Hard Coded - "DCAE" tcavesResponse.setFrom(AnalyticsConstants.TCA_VES_RESPONSE_FROM); // policyScope included in the DCAE configuration Policy - tcavesResponse.setPolicyScope(metricsPerFunctionalRole.getPolicyScope()); + tcavesResponse.setPolicyScope(metricsPerEventName.getPolicyScope()); // policyName included in the DCAE configuration Policy - tcavesResponse.setPolicyName(metricsPerFunctionalRole.getPolicyName()); + tcavesResponse.setPolicyName(metricsPerEventName.getPolicyName()); // policyVersion included in the DCAE configuration Policy - tcavesResponse.setPolicyVersion(metricsPerFunctionalRole.getPolicyVersion()); - // Hard Coded - "ONSET" - tcavesResponse.setClosedLoopEventStatus(AnalyticsConstants.TCA_VES_RESPONSE_CLOSED_LOOP_EVENT_STATUS); + tcavesResponse.setPolicyVersion(metricsPerEventName.getPolicyVersion()); + // Extracted from violated threshold + tcavesResponse.setClosedLoopEventStatus(violatedThreshold.getClosedLoopEventStatus().name()); return tcavesResponse; } - /** - * Determines if Functional Role is vLoadBalancer - * - * @param functionalRole functional Role to check - * - * @return return true if functional role is for vLoadBalancer - */ - private static boolean isFunctionalRoleVLoadBalancer(final String functionalRole) { - return functionalRole.equals(AnalyticsConstants.LOAD_BALANCER_FUNCTIONAL_ROLE); - } - /** - * Extract Domain and functional Role from processor context if present + * Extract Domain and Event Name from processor context if present * * @param processorContext processor context - * @return Tuple of domain and functional role + * @return Tuple of domain and event Name */ - public static Pair<String, String> getDomainAndFunctionalRole(@Nullable final TCACEFProcessorContext - processorContext) { + public static Pair<String, String> getDomainAndEventName( + @Nullable final TCACEFProcessorContext processorContext) { String domain = null; - String functionalRole = null; + String eventName = null; if (processorContext != null && processorContext.getCEFEventListener() != null && @@ -573,42 +564,42 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { .getCommonEventHeader(); if (commonEventHeader.getDomain() != null) { - domain = commonEventHeader.getDomain(); + domain = commonEventHeader.getDomain().name(); } - if (commonEventHeader.getFunctionalRole() != null) { - functionalRole = commonEventHeader.getFunctionalRole(); + if (commonEventHeader.getEventName() != null) { + eventName = commonEventHeader.getEventName(); } } - return new ImmutablePair<>(domain, functionalRole); + return new ImmutablePair<>(domain, eventName); } /** - * Creates {@link TCAPolicy} Metrics per Functional Role list + * Creates {@link TCAPolicy} Metrics per Event Name list * - * @param functionalRolesMap Map containing functional Roles as key and corresponding values + * @param eventNamesMap Map containing event Name as key and corresponding values * - * @return List of {@link MetricsPerFunctionalRole} + * @return List of {@link MetricsPerEventName} */ - public static List<MetricsPerFunctionalRole> createTCAPolicyMetricsPerFunctionalRoleList( - final Map<String, Map<String, String>> functionalRolesMap) { + public static List<MetricsPerEventName> createTCAPolicyMetricsPerEventNameList( + final Map<String, Map<String, String>> eventNamesMap) { - // create a new metrics per functional role list - final List<MetricsPerFunctionalRole> metricsPerFunctionalRoles = new LinkedList<>(); + // create a new metrics per event Name list + final List<MetricsPerEventName> metricsPerEventNames = new LinkedList<>(); - for (Map.Entry<String, Map<String, String>> functionalRolesEntry : functionalRolesMap.entrySet()) { + for (Map.Entry<String, Map<String, String>> eventNamesEntry : eventNamesMap.entrySet()) { - // create new metrics per functional role instance - final MetricsPerFunctionalRole newMetricsPerFunctionalRole = - createNewMetricsPerFunctionalRole(functionalRolesEntry); - metricsPerFunctionalRoles.add(newMetricsPerFunctionalRole); + // create new metrics per event Name instance + final MetricsPerEventName newMetricsPerEventName = + createNewMetricsPerEventName(eventNamesEntry); + metricsPerEventNames.add(newMetricsPerEventName); // determine all threshold related values final Map<String, String> thresholdsValuesMaps = - filterMapByKeyNamePrefix(functionalRolesEntry.getValue(), + filterMapByKeyNamePrefix(eventNamesEntry.getValue(), AnalyticsConstants.TCA_POLICY_THRESHOLDS_PATH_POSTFIX); // create a map of all threshold values @@ -616,14 +607,14 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { extractSubTree(thresholdsValuesMaps, 1, 2, AnalyticsConstants.TCA_POLICY_DELIMITER); - // add thresholds to nmetrics per functional roles threshold list + // add thresholds to nmetrics per event Names threshold list for (Map<String, String> thresholdMap : thresholdsMap.values()) { - newMetricsPerFunctionalRole.getThresholds().add(createNewThreshold(thresholdMap)); + newMetricsPerEventName.getThresholds().add(createNewThreshold(thresholdMap)); } } - return metricsPerFunctionalRoles; + return metricsPerEventNames; } /** @@ -641,32 +632,36 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { threshold.setDirection(Direction.valueOf(thresholdMap.get("policy.direction"))); threshold.setSeverity(EventSeverity.valueOf(thresholdMap.get("policy.severity"))); threshold.setThresholdValue(Long.valueOf(thresholdMap.get("policy.thresholdValue"))); + threshold.setClosedLoopEventStatus( + ControlLoopEventStatus.valueOf(thresholdMap.get("policy.closedLoopEventStatus"))); return threshold; } /** - * Create new {@link MetricsPerFunctionalRole} instance with policy Name, policy Version and policy Scope - * extracted from given functionalRolesEntry + * Create new {@link MetricsPerEventName} instance with policy Name, policy Version and policy Scope + * extracted from given eventNamesEntry * - * @param functionalRolesEntry Functional Role Entry + * @param eventNamesEntry Event Names Entry * - * @return new instance of MetricsPerFunctionalRole + * @return new instance of MetricsPerEventName */ - public static MetricsPerFunctionalRole createNewMetricsPerFunctionalRole( - final Map.Entry<String, Map<String, String>> functionalRolesEntry) { - // determine functional Role - final String functionalRole = functionalRolesEntry.getKey(); - // determine functional Role thresholds - final Map<String, String> metricsPerFunctionalRoleThresholdsMap = functionalRolesEntry.getValue(); - final MetricsPerFunctionalRole metricsPerFunctionalRole = new MetricsPerFunctionalRole(); + public static MetricsPerEventName createNewMetricsPerEventName( + final Map.Entry<String, Map<String, String>> eventNamesEntry) { + // determine event Name + final String eventName = eventNamesEntry.getKey(); + // determine event Name thresholds + final Map<String, String> metricsPerEventNameThresholdsMap = eventNamesEntry.getValue(); + final MetricsPerEventName metricsPerEventName = new MetricsPerEventName(); final List<Threshold> thresholds = new LinkedList<>(); - metricsPerFunctionalRole.setThresholds(thresholds); - metricsPerFunctionalRole.setFunctionalRole(functionalRole); - // bind policyName, policyVersion and policyScope - metricsPerFunctionalRole.setPolicyName(metricsPerFunctionalRoleThresholdsMap.get("policyName")); - metricsPerFunctionalRole.setPolicyVersion(metricsPerFunctionalRoleThresholdsMap.get("policyVersion")); - metricsPerFunctionalRole.setPolicyScope(metricsPerFunctionalRoleThresholdsMap.get("policyScope")); - return metricsPerFunctionalRole; + metricsPerEventName.setThresholds(thresholds); + metricsPerEventName.setEventName(eventName); + // bind policyName, policyVersion, policyScope and closedLoopControlName + metricsPerEventName.setPolicyName(metricsPerEventNameThresholdsMap.get("policyName")); + metricsPerEventName.setPolicyVersion(metricsPerEventNameThresholdsMap.get("policyVersion")); + metricsPerEventName.setPolicyScope(metricsPerEventNameThresholdsMap.get("policyScope")); + metricsPerEventName.setControlLoopSchemaType(ControlLoopSchemaType.valueOf( + metricsPerEventNameThresholdsMap.get("closedLoopControlName"))); + return metricsPerEventName; } /** @@ -751,7 +746,7 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { * @param <T> An implementation of Quartz {@link Job} interface * @return Configured Quartz Scheduler * - * @throws SchedulerException expection if unable to create to Quartz Scheduler + * @throws SchedulerException exception if unable to create to Quartz Scheduler */ public static <T extends Job> Scheduler createQuartzScheduler(final Integer pollingIntervalMS, final StdSchedulerFactory stdSchedulerFactory, final String quartzPublisherPropertiesFileName, @@ -786,6 +781,4 @@ public abstract class TCAUtils extends AnalyticsModelJsonUtils { return scheduler; } - - } |