1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.types;
20 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
21 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.LinkIdentifyingObject;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
23 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
24 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.OtnHistoryDataG;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 import com.fasterxml.jackson.annotation.JsonGetter;
29 import com.fasterxml.jackson.annotation.JsonIgnore;
31 public class EsHistoricalPerformanceBase extends EsObject {
33 private static final Logger LOG = LoggerFactory.getLogger(EsHistoricalPerformanceBase.class);
34 private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
36 @JsonIgnore private final String nodeName;
37 @JsonIgnore private final String uuidInterface;
38 @JsonIgnore private final String layerProtocolName;
40 @JsonIgnore private String radioSignalId = null; //Meaning of connection Id
41 @JsonIgnore private String timeStamp = null;
42 @JsonIgnore private Boolean suspectIntervalFlag = null;
43 @JsonIgnore private String granularityPeriod = null; //Representation of GranularityPeriodType
44 @JsonIgnore private String scannerId = null;
45 @JsonIgnore private Object performanceData = null;
48 public EsHistoricalPerformanceBase(String nodeName, Lp actualInterface) {
49 this.nodeName = nodeName;
50 this.uuidInterface = actualInterface.getUuid().getValue();
51 this.layerProtocolName = actualInterface.getLayerProtocolName().getValue();
55 protected <T extends OtnHistoryDataG> void set(T record) {
57 LOG.warn("PM Record: null record. Can not handle");
61 if (LOG.isTraceEnabled()) {
62 LOG.trace("PM Record: class {} '{}' ", record.getClass().getSimpleName(), record);
65 timeStamp = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(record.getPeriodEndTime().getValue());
66 suspectIntervalFlag = record.isSuspectIntervalFlag();
67 granularityPeriod = getYangGranularityPeriodString( record.getGranularityPeriod() );
68 scannerId = record.getHistoryDataId();
70 if (record instanceof LinkIdentifyingObject) {
71 radioSignalId = ((LinkIdentifyingObject) record).getSignalId();
74 performanceData = new EsPerformanceData(record);
75 setEsId(genSpecificEsId(record.getPeriodEndTime().getValue()));
79 @JsonGetter("node-name")
80 public String getNodeName() {
84 @JsonGetter("uuid-interface")
85 public String getUuidInterface() {
89 @JsonGetter("layer-protocol-name")
90 public String getLayerProtocolName() {
91 return layerProtocolName;
94 @JsonGetter("radio-signal-id")
95 public String getRadioSignalId() {
99 @JsonGetter("time-stamp")
100 public String getTimeStamp() {
104 @JsonGetter("suspect-interval-flag")
105 public Boolean getSuspect() {
106 return suspectIntervalFlag;
109 @JsonGetter("granularity-period")
110 public String getGranularityPeriod() {
111 return granularityPeriod;
114 @JsonGetter("scanner-id")
115 public String getScannerId() {
119 @JsonGetter("performance-data")
120 public Object getData() {
121 return performanceData;
127 //@JsonGetter("granularityPeriod")
129 private static String getYangGranularityPeriodString(org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType yangGanularityPeriod) {
130 switch(yangGanularityPeriod == null ? org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.rev170320.GranularityPeriodType.Unknown : yangGanularityPeriod) {
132 return "PERIOD_15MIN";
134 return "PERIOD_24HOURS";
136 return "PERIOD_UNKOWN";
141 * Create a specific ES id for the current log.
142 * @param time is the input.
143 * @return a string with the generated ES Id
145 protected String genSpecificEsId(String time) {
147 StringBuffer strBuf = new StringBuffer();
148 strBuf.append(nodeName);
150 strBuf.append(uuidInterface);
152 strBuf.append(time == null || time.isEmpty() ? "Empty" : time);
154 return strBuf.toString();
158 public String toString() {
159 return "EsHistoricalPerformanceBase [nodeName=" + nodeName + ", uuidInterface=" + uuidInterface
160 + ", layerProtocolName=" + layerProtocolName + ", radioSignalId=" + radioSignalId + ", timeStamp="
161 + timeStamp + ", suspectIntervalFlag=" + suspectIntervalFlag + ", granularityPeriod="
162 + granularityPeriod + ", scannerId=" + scannerId + ", performanceData=" + performanceData + "]";