diff options
Diffstat (limited to 'dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service')
11 files changed, 651 insertions, 0 deletions
diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java new file mode 100644 index 0000000..6a208d2 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java @@ -0,0 +1,48 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; + +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; + +/** + * @author Rajiv Singla + */ +@Builder +@Getter +@EqualsAndHashCode +@ToString +public class GenericTcaExecutionContext implements TcaExecutionContext { + + private final String requestId; + private final String transactionId; + private final int messageIndex; + private final String cefMessage; + private final TcaPolicy tcaPolicy; + private final TcaProcessingContext tcaProcessingContext; + private final TcaResultContext tcaResultContext; + private final TcaAbatementContext tcaAbatementContext; + private final TcaAaiEnrichmentContext tcaAaiEnrichmentContext; + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaProcessingContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaProcessingContext.java new file mode 100644 index 0000000..aceb4be --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaProcessingContext.java @@ -0,0 +1,41 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + + +import lombok.Data; + +import org.onap.dcae.analytics.model.cef.EventListener; + +/** + * A Generic implementation for {@link TcaProcessingContext} + * + * @author Rajiv Singla + */ + +@Data +public class GenericTcaProcessingContext implements TcaProcessingContext { + + private EventListener eventListener; + private boolean continueProcessing = true; + private String earlyTerminationMessage; + private String errorMessage; + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaResultContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaResultContext.java new file mode 100644 index 0000000..ee8ef86 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaResultContext.java @@ -0,0 +1,41 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import lombok.Data; + +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; +import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName; + +/** + * @author Rajiv Singla + */ +@Data +public class GenericTcaResultContext implements TcaResultContext { + + private MetricsPerEventName violatedMetricsPerEventName; + private TcaAlert tcaAlert; + private String previousRequestId; + + @Override + public boolean isThresholdViolationsPresent() { + return getViolatedMetricsPerEventName() != null; + } +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentContext.java new file mode 100644 index 0000000..292905e --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentContext.java @@ -0,0 +1,33 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +/** + * Provides abstractions for TCA AAI Enrichment + * + * @author Rajiv Singla + */ +public interface TcaAaiEnrichmentContext { + + boolean isAaiEnrichmentEnabled(); + + TcaAaiEnrichmentService getAaiEnrichmentService(); + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentService.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentService.java new file mode 100644 index 0000000..f2d140c --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAaiEnrichmentService.java @@ -0,0 +1,39 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; + +/** + * TCA AAI Enrichment Service enriches {@link TcaAlert#getAai()} + * + * @author Rajiv Singla + */ +@FunctionalInterface +public interface TcaAaiEnrichmentService { + + /** + * @param tcaExecutionContext tca execution context + * + * @return tca alert with AAI enrichment + */ + TcaAlert doAaiEnrichment(TcaExecutionContext tcaExecutionContext); + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementContext.java new file mode 100644 index 0000000..9ec4192 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementContext.java @@ -0,0 +1,57 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +/** + * Provides abstractions for TCA Abatement processing calculations + * + * @author Rajiv Singla + */ +public interface TcaAbatementContext { + + /** + * Returns true if TCA Abatement calculations are enabled + * + * @return true if TCA Abatement calculations are enabled + */ + boolean isAbatementEnabled(); + + + /** + * Provides abstractions for Tca Abatement Persistence + * + * @return abstractions for Tca Abatement Persistence + */ + TcaAbatementRepository getTcaAbatementRepository(); + + + /** + * Creates new instance of TCA Abatement persistence Entity + * + * @param lookupKey lookup key + * @param requestId request id + * @param isAbatementAlertSent true if abatement alert was already sent + * + * @return new instance of TCA Abatement Persistence Entity + */ + TcaAbatementEntity create(String lookupKey, String requestId, boolean isAbatementAlertSent); + + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementEntity.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementEntity.java new file mode 100644 index 0000000..fe0ac5e --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementEntity.java @@ -0,0 +1,61 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import java.util.Date; + +/** + * TCA Abatement Persistence Entity + * + * @author Rajiv Singla + */ +public interface TcaAbatementEntity { + + /** + * Last Modified Date when entity was modified + * + * @return last modified date + */ + Date getLastModificationDate(); + + /** + * Lookup Key + * + * @return provides Lookup Key + */ + String getLookupKey(); + + + /** + * Provides Request Id + * + * @return request id + */ + String getRequestId(); + + + /** + * Return true if alert was already sent for this Entity else false + * + * @return true if alert was already sent for this Entity else false + */ + boolean isAbatementAlertSent(); + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementRepository.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementRepository.java new file mode 100644 index 0000000..c1d3a78 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaAbatementRepository.java @@ -0,0 +1,49 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import java.util.List; + +/** + * Provides abstractions for Tca Abatement Persistence + * + * @author Rajiv Singla + */ +public interface TcaAbatementRepository { + + /** + * Saves new Tca Abatement Entity to some persistent store + * + * @param tcaAbatementEntity Tca Abatement Entity that need to be stored + */ + void save(TcaAbatementEntity tcaAbatementEntity); + + + /** + * Provides any saved Tca Abatement Entities which same look up key + * + * @param lookUpKey look up key for abatement persistence entity + * + * @return list of previously saved tca abatement persistence entities has given lookup key + */ + List<TcaAbatementEntity> findByLookupKey(String lookUpKey); + + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java new file mode 100644 index 0000000..9a55151 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java @@ -0,0 +1,102 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; + +/** + * TCA Execution context captures various fields required to calculate a TCA threshold violation calculation execution + * + * @author Rajiv Singla + */ +public interface TcaExecutionContext { + + /** + * Provides request id associated with execution context + * + * @return request id associated with execution context + */ + String getRequestId(); + + + /** + * Provides transaction id associated with execution context + * + * @return transaction id associated with execution context + */ + String getTransactionId(); + + + /** + * Provides message order number inside a execution batch + * + * @return message order number inside a execution batch + */ + int getMessageIndex(); + + + /** + * Provides common event format message as JSON string that is being analyzed + * + * @return common event format message as JSON string that is being analyzed + */ + String getCefMessage(); + + + /** + * Provides TCA Policy associated with the processing context + * + * @return TCA Policy associated with processing context + */ + TcaPolicy getTcaPolicy(); + + + /** + * Provides TCA Processing Context captures various mutable fields that are computed during TCA execution + * + * @return TCA Processing Context captures various mutable fields that are computed during TCA execution + */ + TcaProcessingContext getTcaProcessingContext(); + + + /** + * Provides TCA Processing Result Context which captures outputs of TCA execution + * + * @return TCA Processing Result Context which captures outputs of TCA execution + */ + TcaResultContext getTcaResultContext(); + + + /** + * Provides TCA Abatement context containing abstractions for TCA Abatement processing calculations + * + * @return TCA abatement context containing abstractions for TCA Abatement processing calculations + */ + TcaAbatementContext getTcaAbatementContext(); + + + /** + * Provides TCA AAI Enrichment Context + * + * @return TCA AAI enrichment context + */ + TcaAaiEnrichmentContext getTcaAaiEnrichmentContext(); + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaProcessingContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaProcessingContext.java new file mode 100644 index 0000000..69a5ab0 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaProcessingContext.java @@ -0,0 +1,92 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import org.onap.dcae.analytics.model.cef.EventListener; + +/** + * TCA Processing Context captures various mutable fields that are computed during TCA execution + * + * @author Rajiv Singla + */ +public interface TcaProcessingContext { + + + /** + * Provides common event format message as JAVA object that is being analyzed + * + * @return common event format message as JAVA object that is being analyzed + */ + EventListener getEventListener(); + + + /** + * Sets new values for common event format message as JAVA object that is being analyzed + * + * @param eventListener new values for common event format message as JAVA object that is being analyzed + */ + void setEventListener(EventListener eventListener); + + + /** + * Provides flag which is false if TCA processing cannot continue to next stage due to some prior condition + * + * @return false if TCA processing cannot continue to next stage due to some condition + */ + boolean isContinueProcessing(); + + /** + * Sets TCA processing continue flag + * + * @param isContinueProcessing - TCA processing continue flag + */ + void setContinueProcessing(boolean isContinueProcessing); + + + /** + * Provides early termination message message if present or null + * + * @return early termination message if present or null + */ + String getEarlyTerminationMessage(); + + /** + * Sets early termination message + * + * @param earlyTerminationMessage sets a new value for early termination message + */ + void setEarlyTerminationMessage(String earlyTerminationMessage); + + + /** + * Returns error message if present or null + * + * @return error message if present or null + */ + String getErrorMessage(); + + /** + * Sets new value for error message + * + * @param errorMessage new value for error message + */ + void setErrorMessage(final String errorMessage); + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaResultContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaResultContext.java new file mode 100644 index 0000000..b166a5f --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaResultContext.java @@ -0,0 +1,88 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.core.service; + +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; +import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName; + +/** + * TCA Processing Result Context which captures outputs of TCA Execution + * + * @author Rajiv Singla + */ +public interface TcaResultContext { + + /** + * Returns true if Threshold violations are present + * + * @return true if Threshold violations are present + */ + boolean isThresholdViolationsPresent(); + + + /** + * Returns TCA policy's violated metrics per event name that was violated by the incoming message + * + * @return TCA policy's violated metrics per event name that was violated by the incoming message + */ + MetricsPerEventName getViolatedMetricsPerEventName(); + + + /** + * Sets new value for violated metrics per event name that was violated by the incoming message + * + * @param violatedMetricsPerEventName new value for violated metrics per event name that was violated by the + * incoming message + */ + void setViolatedMetricsPerEventName(MetricsPerEventName violatedMetricsPerEventName); + + + /** + * Provides TCA Alert message that is generated if there is any TCA policy's threshold violation + * + * @return TCA Alert message that is generated if there is any TCA policy's threshold violation + */ + TcaAlert getTcaAlert(); + + + /** + * Sets new value for TCA Alert + * + * @param tcaAlert new value for TCA Alert + */ + void setTcaAlert(TcaAlert tcaAlert); + + /** + * Provides previous request id for abated threshold violations if present or null + * + * @return previous request id for abated threshold violations if present or null + */ + String getPreviousRequestId(); + + + /** + * Sets previous request id for abated threshold violations + * + * @param previousRequestId new value of request id for abated threshold violations + */ + void setPreviousRequestId(String previousRequestId); + + +} |