Adding interfaces in documentation
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / sync / TaskProcessingStats.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.onap.aai.sparky.sync;
26
27 import org.onap.aai.sparky.analytics.AbstractStatistics;
28 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
29
30 /**
31  * The Class TaskProcessingStats.
32  */
33 public class TaskProcessingStats extends AbstractStatistics {
34
35   private static String TASK_AGE_STATS = "taskAgeStats";
36   private static String TASK_RESPONSE_STATS = "taskResponseStats";
37   private static String RESPONSE_SIZE_IN_BYTES = "taskResponseSizeInBytes";
38   // private static String QUEUE_ITEM_LENGTH = "queueItemLength";
39   private static String TPS = "transactionsPerSecond";
40
41   /**
42    * Instantiates a new task processing stats.
43    *
44    * @param config the config
45    */
46   public TaskProcessingStats(NetworkStatisticsConfig config) {
47
48     addHistogram(TASK_AGE_STATS, config.getTaskAgeHistogramLabel(),
49         config.getTaskAgeHistogramMaxYAxis(), config.getTaskAgeHistogramNumBins(),
50         config.getTaskAgeHistogramNumDecimalPoints());
51
52     addHistogram(TASK_RESPONSE_STATS, config.getResponseTimeHistogramLabel(),
53         config.getResponseTimeHistogramMaxYAxis(), config.getResponseTimeHistogramNumBins(),
54         config.getResponseTimeHistogramNumDecimalPoints());
55
56     addHistogram(RESPONSE_SIZE_IN_BYTES, config.getBytesHistogramLabel(),
57         config.getBytesHistogramMaxYAxis(), config.getBytesHistogramNumBins(),
58         config.getBytesHistogramNumDecimalPoints());
59
60     /*
61      * addHistogram(QUEUE_ITEM_LENGTH, config.getQueueLengthHistogramLabel(),
62      * config.getQueueLengthHistogramMaxYAxis(), config.getQueueLengthHistogramNumBins(),
63      * config.getQueueLengthHistogramNumDecimalPoints());
64      */
65
66     addHistogram(TPS, config.getTpsHistogramLabel(), config.getTpsHistogramMaxYAxis(),
67         config.getTpsHistogramNumBins(), config.getTpsHistogramNumDecimalPoints());
68
69   }
70
71   /*
72    * public void updateQueueItemLengthHistogram(long value) { updateHistogram(QUEUE_ITEM_LENGTH,
73    * value); }
74    */
75
76   /**
77    * Update task age stats histogram.
78    *
79    * @param value the value
80    */
81   public void updateTaskAgeStatsHistogram(long value) {
82     updateHistogram(TASK_AGE_STATS, value);
83   }
84
85   /**
86    * Update task response stats histogram.
87    *
88    * @param value the value
89    */
90   public void updateTaskResponseStatsHistogram(long value) {
91     updateHistogram(TASK_RESPONSE_STATS, value);
92   }
93
94   /**
95    * Update response size in bytes histogram.
96    *
97    * @param value the value
98    */
99   public void updateResponseSizeInBytesHistogram(long value) {
100     updateHistogram(RESPONSE_SIZE_IN_BYTES, value);
101   }
102
103   /**
104    * Update transactions per second histogram.
105    *
106    * @param value the value
107    */
108   public void updateTransactionsPerSecondHistogram(long value) {
109     updateHistogram(TPS, value);
110   }
111
112   /**
113    * Gets the statistics report.
114    *
115    * @param verboseEnabled the verbose enabled
116    * @param indentPadding the indent padding
117    * @return the statistics report
118    */
119   public String getStatisticsReport(boolean verboseEnabled, String indentPadding) {
120
121     StringBuilder sb = new StringBuilder();
122
123     sb.append("\n").append(getHistogramStats(TASK_AGE_STATS, verboseEnabled, indentPadding));
124     // sb.append("\n").append(getHistogramStats(QUEUE_ITEM_LENGTH, verboseEnabled, indentPadding));
125     sb.append("\n").append(getHistogramStats(TASK_RESPONSE_STATS, verboseEnabled, indentPadding));
126     sb.append("\n")
127         .append(getHistogramStats(RESPONSE_SIZE_IN_BYTES, verboseEnabled, indentPadding));
128     sb.append("\n").append(getHistogramStats(TPS, verboseEnabled, indentPadding));
129
130     return sb.toString();
131
132   }
133
134
135 }