Update the dependencies to use project version
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / synchronizer / TaskProcessingStats.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.onap.aai.sparky.synchronizer;
24
25 import org.onap.aai.sparky.analytics.AbstractStatistics;
26 import org.onap.aai.sparky.synchronizer.config.TaskProcessorConfig;
27
28 /**
29  * The Class TaskProcessingStats.
30  */
31 public class TaskProcessingStats extends AbstractStatistics {
32
33   private static String TASK_AGE_STATS = "taskAgeStats";
34   private static String TASK_RESPONSE_STATS = "taskResponseStats";
35   private static String RESPONSE_SIZE_IN_BYTES = "taskResponseSizeInBytes";
36   // private static String QUEUE_ITEM_LENGTH = "queueItemLength";
37   private static String TPS = "transactionsPerSecond";
38
39   /**
40    * Instantiates a new task processing stats.
41    *
42    * @param config the config
43    */
44   public TaskProcessingStats(TaskProcessorConfig config) {
45
46     addHistogram(TASK_AGE_STATS, config.getTaskAgeHistogramLabel(),
47         config.getTaskAgeHistogramMaxYAxis(), config.getTaskAgeHistogramNumBins(),
48         config.getTaskAgeHistogramNumDecimalPoints());
49
50     addHistogram(TASK_RESPONSE_STATS, config.getResponseTimeHistogramLabel(),
51         config.getResponseTimeHistogramMaxYAxis(), config.getResponseTimeHistogramNumBins(),
52         config.getResponseTimeHistogramNumDecimalPoints());
53
54     addHistogram(RESPONSE_SIZE_IN_BYTES, config.getBytesHistogramLabel(),
55         config.getBytesHistogramMaxYAxis(), config.getBytesHistogramNumBins(),
56         config.getBytesHistogramNumDecimalPoints());
57
58     /*
59      * addHistogram(QUEUE_ITEM_LENGTH, config.getQueueLengthHistogramLabel(),
60      * config.getQueueLengthHistogramMaxYAxis(), config.getQueueLengthHistogramNumBins(),
61      * config.getQueueLengthHistogramNumDecimalPoints());
62      */
63
64     addHistogram(TPS, config.getTpsHistogramLabel(), config.getTpsHistogramMaxYAxis(),
65         config.getTpsHistogramNumBins(), config.getTpsHistogramNumDecimalPoints());
66
67   }
68
69   /*
70    * public void updateQueueItemLengthHistogram(long value) { updateHistogram(QUEUE_ITEM_LENGTH,
71    * value); }
72    */
73
74   /**
75    * Update task age stats histogram.
76    *
77    * @param value the value
78    */
79   public void updateTaskAgeStatsHistogram(long value) {
80     updateHistogram(TASK_AGE_STATS, value);
81   }
82
83   /**
84    * Update task response stats histogram.
85    *
86    * @param value the value
87    */
88   public void updateTaskResponseStatsHistogram(long value) {
89     updateHistogram(TASK_RESPONSE_STATS, value);
90   }
91
92   /**
93    * Update response size in bytes histogram.
94    *
95    * @param value the value
96    */
97   public void updateResponseSizeInBytesHistogram(long value) {
98     updateHistogram(RESPONSE_SIZE_IN_BYTES, value);
99   }
100
101   /**
102    * Update transactions per second histogram.
103    *
104    * @param value the value
105    */
106   public void updateTransactionsPerSecondHistogram(long value) {
107     updateHistogram(TPS, value);
108   }
109
110   /**
111    * Gets the statistics report.
112    *
113    * @param verboseEnabled the verbose enabled
114    * @param indentPadding the indent padding
115    * @return the statistics report
116    */
117   public String getStatisticsReport(boolean verboseEnabled, String indentPadding) {
118
119     StringBuilder sb = new StringBuilder();
120
121     sb.append("\n").append(getHistogramStats(TASK_AGE_STATS, verboseEnabled, indentPadding));
122     // sb.append("\n").append(getHistogramStats(QUEUE_ITEM_LENGTH, verboseEnabled, indentPadding));
123     sb.append("\n").append(getHistogramStats(TASK_RESPONSE_STATS, verboseEnabled, indentPadding));
124     sb.append("\n")
125         .append(getHistogramStats(RESPONSE_SIZE_IN_BYTES, verboseEnabled, indentPadding));
126     sb.append("\n").append(getHistogramStats(TPS, verboseEnabled, indentPadding));
127
128     return sb.toString();
129
130   }
131
132   /**
133    * @return the tASK_AGE_STATS
134    */
135   public static String getTASK_AGE_STATS() {
136     return TASK_AGE_STATS;
137   }
138
139   /**
140    * @param tASK_AGE_STATS the tASK_AGE_STATS to set
141    */
142   public static void setTASK_AGE_STATS(String tASK_AGE_STATS) {
143     TASK_AGE_STATS = tASK_AGE_STATS;
144   }
145
146   /**
147    * @return the tASK_RESPONSE_STATS
148    */
149   public static String getTASK_RESPONSE_STATS() {
150     return TASK_RESPONSE_STATS;
151   }
152
153   /**
154    * @param tASK_RESPONSE_STATS the tASK_RESPONSE_STATS to set
155    */
156   public static void setTASK_RESPONSE_STATS(String tASK_RESPONSE_STATS) {
157     TASK_RESPONSE_STATS = tASK_RESPONSE_STATS;
158   }
159
160   /**
161    * @return the rESPONSE_SIZE_IN_BYTES
162    */
163   public static String getRESPONSE_SIZE_IN_BYTES() {
164     return RESPONSE_SIZE_IN_BYTES;
165   }
166
167   /**
168    * @param rESPONSE_SIZE_IN_BYTES the rESPONSE_SIZE_IN_BYTES to set
169    */
170   public static void setRESPONSE_SIZE_IN_BYTES(String rESPONSE_SIZE_IN_BYTES) {
171     RESPONSE_SIZE_IN_BYTES = rESPONSE_SIZE_IN_BYTES;
172   }
173
174   /**
175    * @return the tPS
176    */
177   public static String getTPS() {
178     return TPS;
179   }
180
181   /**
182    * @param tPS the tPS to set
183    */
184   public static void setTPS(String tPS) {
185     TPS = tPS;
186   }
187
188
189 }