blob: c7ffe69daf2ec3921273a36154cafe859205b4d2 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/*
slowr577f3222017-08-28 10:49:08 -07002 * Copyright 2015-present Open Networking Foundation
slowr13fa5b02017-08-08 16:32:31 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.xran.entities;
18
slowr577f3222017-08-28 10:49:08 -070019import com.fasterxml.jackson.annotation.JsonCreator;
20import com.fasterxml.jackson.annotation.JsonIgnore;
21import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
22import com.fasterxml.jackson.annotation.JsonProperty;
23import com.fasterxml.jackson.annotation.JsonPropertyOrder;
slowr13fa5b02017-08-08 16:32:31 -070024import com.fasterxml.jackson.databind.JsonNode;
25import org.onosproject.net.DeviceId;
slowrc153ad92017-08-16 19:47:52 -070026import org.onosproject.store.service.WallClockTimestamp;
slowr13fa5b02017-08-08 16:32:31 -070027import org.onosproject.xran.codecs.api.ECGI;
slowr13fa5b02017-08-08 16:32:31 -070028import org.onosproject.xran.codecs.api.PRBUsage;
slowr73b4eae2017-08-17 16:09:09 -070029import org.onosproject.xran.codecs.api.XICICPA;
slowrc153ad92017-08-16 19:47:52 -070030import org.onosproject.xran.codecs.ber.BerByteArrayOutputStream;
slowr73b4eae2017-08-17 16:09:09 -070031import org.onosproject.xran.codecs.ber.types.BerBitString;
slowrc153ad92017-08-16 19:47:52 -070032import org.onosproject.xran.codecs.ber.types.BerInteger;
slowr13fa5b02017-08-08 16:32:31 -070033import org.onosproject.xran.codecs.pdu.CellConfigReport;
34import org.onosproject.xran.codecs.pdu.L2MeasConfig;
35import org.onosproject.xran.codecs.pdu.RRMConfig;
36import org.onosproject.xran.codecs.pdu.SchedMeasReportPerCell;
slowr13fa5b02017-08-08 16:32:31 -070037
38import javax.xml.bind.DatatypeConverter;
39import java.io.ByteArrayInputStream;
40import java.io.IOException;
41import java.io.InputStream;
42import java.net.URI;
43import java.net.URISyntaxException;
slowr67d05e42017-08-11 20:37:22 -070044import java.util.List;
slowr8ddc2b12017-08-14 14:13:38 -070045import java.util.stream.Collectors;
46import java.util.stream.Stream;
slowr13fa5b02017-08-08 16:32:31 -070047
slowr60d4d102017-08-16 18:33:58 -070048
slowr577f3222017-08-28 10:49:08 -070049/**
50 * R-NIB Cell and its properties.
51 */
slowr60d4d102017-08-16 18:33:58 -070052@JsonPropertyOrder({
53 "ECGI",
54 "Configuration",
55 "PRB-Usage",
56 "QCI",
57 "RRMConfiguration",
58 "MeasurementConfiguration"
59})
60@JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -070061public class RnibCell {
slowr60d4d102017-08-16 18:33:58 -070062 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070063 private static final String SCHEME = "xran";
64
slowr60d4d102017-08-16 18:33:58 -070065 @JsonProperty("ECGI")
slowr13fa5b02017-08-08 16:32:31 -070066 private ECGI ecgi;
slowr60d4d102017-08-16 18:33:58 -070067 @JsonProperty("Configuration")
slowr13fa5b02017-08-08 16:32:31 -070068 private CellConfigReport conf;
slowr60d4d102017-08-16 18:33:58 -070069 @JsonProperty("PRB-Usage")
slowr13fa5b02017-08-08 16:32:31 -070070 private PrbUsageContainer prbUsage;
slowr60d4d102017-08-16 18:33:58 -070071 @JsonProperty("QCI")
slowr13fa5b02017-08-08 16:32:31 -070072 private SchedMeasReportPerCell.QciVals qci;
slowr60d4d102017-08-16 18:33:58 -070073 @JsonProperty("RRMConfiguration")
slowr13fa5b02017-08-08 16:32:31 -070074 private RRMConfig rrmConfig;
slowr60d4d102017-08-16 18:33:58 -070075 @JsonProperty("MeasurementConfiguration")
slowr13fa5b02017-08-08 16:32:31 -070076 private L2MeasConfig measConfig;
77
slowr60d4d102017-08-16 18:33:58 -070078 @JsonIgnore
slowr8ddc2b12017-08-14 14:13:38 -070079 private String version;
80
slowr13fa5b02017-08-08 16:32:31 -070081 public RnibCell() {
slowr8ddc2b12017-08-14 14:13:38 -070082 version = "3";
slowr89c2ac12017-08-15 16:20:06 -070083
84 rrmConfig = new RRMConfig();
85 rrmConfig.setEcgi(ecgi);
slowr13fa5b02017-08-08 16:32:31 -070086 }
87
slowr577f3222017-08-28 10:49:08 -070088 /**
89 * Encode ECGI and obtain its URI.
90 *
91 * @param ecgi ECGI
92 * @return URI
93 */
slowr13fa5b02017-08-08 16:32:31 -070094 public static URI uri(ECGI ecgi) {
95 if (ecgi != null) {
96 try {
97 BerByteArrayOutputStream os = new BerByteArrayOutputStream(4096);
98 ecgi.encode(os);
99 String message = DatatypeConverter.printHexBinary(os.getArray());
100 return new URI(SCHEME, message, null);
101 } catch (URISyntaxException | IOException e) {
102 return null;
103 }
104 }
105 return null;
106 }
107
slowr577f3222017-08-28 10:49:08 -0700108 /**
109 * Obtain ECGI from the device ID.
110 *
111 * @param deviceId ID of the device
112 * @return ECGI
113 * @throws IOException I0 Exception for ByteArrayInputStream
114 */
slowr13fa5b02017-08-08 16:32:31 -0700115 public static ECGI decodeDeviceId(DeviceId deviceId) throws IOException {
116 String uri = deviceId.toString();
117 String hexEcgi = uri.substring(uri.lastIndexOf("xran:") + 5);
118
119 ECGI ecgi = new ECGI();
120 byte[] bytearray = DatatypeConverter.parseHexBinary(hexEcgi);
121 InputStream inputStream = new ByteArrayInputStream(bytearray);
122
123 ecgi.decode(inputStream);
124 return ecgi;
125 }
126
slowr577f3222017-08-28 10:49:08 -0700127 /**
128 * Get version ID.
129 *
130 * @return version ID
131 */
slowred74ec72017-08-17 11:25:01 -0700132 public int getVersion() {
133 return Integer.parseInt(version);
slowr8ddc2b12017-08-14 14:13:38 -0700134 }
135
slowr577f3222017-08-28 10:49:08 -0700136 /**
137 * Set version ID.
138 *
139 * @param version version ID
140 */
slowr8ddc2b12017-08-14 14:13:38 -0700141 public void setVersion(String version) {
142 this.version = version;
143 }
144
slowr577f3222017-08-28 10:49:08 -0700145 /**
146 * Get RRMConfig.
147 *
148 * @return RRMConfig
149 */
slowr60d4d102017-08-16 18:33:58 -0700150 @JsonProperty("RRMConfiguration")
slowr67d05e42017-08-11 20:37:22 -0700151 public RRMConfig getRrmConfig() {
152 return rrmConfig;
153 }
154
slowr577f3222017-08-28 10:49:08 -0700155 /**
156 * Set RRMConfig properties.
157 *
158 * @param rrmConfig RRMConfig
159 */
slowr60d4d102017-08-16 18:33:58 -0700160 @JsonProperty("RRMConfiguration")
slowr67d05e42017-08-11 20:37:22 -0700161 public void setRrmConfig(RRMConfig rrmConfig) {
162 this.rrmConfig = rrmConfig;
163 }
164
slowr577f3222017-08-28 10:49:08 -0700165 /**
166 * Get PRB Usage.
167 * @return prb usage
168 */
slowr60d4d102017-08-16 18:33:58 -0700169 @JsonProperty("PRB-Usage")
slowr67d05e42017-08-11 20:37:22 -0700170 public PrbUsageContainer getPrbUsage() {
171 return prbUsage;
172 }
173
slowr577f3222017-08-28 10:49:08 -0700174 /**
175 * Set PRB Usage.
176 *
177 * @param prbUsage prb Usage
178 */
slowr60d4d102017-08-16 18:33:58 -0700179 @JsonProperty("PRB-Usage")
slowr67d05e42017-08-11 20:37:22 -0700180 public void setPrbUsage(PrbUsageContainer prbUsage) {
181 this.prbUsage = prbUsage;
182 }
183
slowr577f3222017-08-28 10:49:08 -0700184 /**
185 * Get ECGI.
186 *
187 * @return ECGI
188 */
slowr60d4d102017-08-16 18:33:58 -0700189 @JsonProperty("ECGI")
slowr13fa5b02017-08-08 16:32:31 -0700190 public ECGI getEcgi() {
191 return ecgi;
192 }
193
slowr577f3222017-08-28 10:49:08 -0700194 /**
195 * Set ECGI.
196 *
197 * @param ecgi ECGI
198 */
slowr60d4d102017-08-16 18:33:58 -0700199 @JsonProperty("ECGI")
slowr13fa5b02017-08-08 16:32:31 -0700200 public void setEcgi(ECGI ecgi) {
201 this.ecgi = ecgi;
202 }
203
slowr577f3222017-08-28 10:49:08 -0700204 /**
205 * Get cell config report.
206 *
207 * @return CellConfig Report
208 */
slowr60d4d102017-08-16 18:33:58 -0700209 @JsonProperty("Configuration")
slowr13fa5b02017-08-08 16:32:31 -0700210 public CellConfigReport getConf() {
211 return conf;
212 }
213
slowr577f3222017-08-28 10:49:08 -0700214 /**
215 * Set cell config report.
216 *
217 * @param conf Cell config report
218 */
slowr60d4d102017-08-16 18:33:58 -0700219 @JsonProperty("Configuration")
slowr13fa5b02017-08-08 16:32:31 -0700220 public void setConf(CellConfigReport conf) {
221 this.conf = conf;
222 }
223
slowr577f3222017-08-28 10:49:08 -0700224 /**
225 * Modify the RRM Config parameters of cell.
226 *
227 * @param rrmConfigNode RRMConfig parameters to modify obtained from REST call
228 * @param ueList List of all UEs
229 * @throws Exception p_a size not equal to UE size
230 */
slowr73b4eae2017-08-17 16:09:09 -0700231 public void modifyRrmConfig(JsonNode rrmConfigNode, List<RnibUe> ueList) throws Exception {
slowr67d05e42017-08-11 20:37:22 -0700232 RRMConfig.Crnti crnti = new RRMConfig.Crnti();
slowrc86750e2017-08-22 17:26:47 -0700233 ueList.forEach(ue -> crnti.addCRNTI(ue.getCrnti()));
slowr13fa5b02017-08-08 16:32:31 -0700234
slowr577f3222017-08-28 10:49:08 -0700235 JsonNode pA = rrmConfigNode.path("p_a");
236 if (!pA.isMissingNode()) {
slowr73b4eae2017-08-17 16:09:09 -0700237 RRMConfig.Pa pa = new RRMConfig.Pa();
slowr577f3222017-08-28 10:49:08 -0700238 if (pA.isArray()) {
239 if (ueList.size() == pA.size()) {
240 List<XICICPA> collect = Stream.of(pA)
slowr73b4eae2017-08-17 16:09:09 -0700241 .map(val -> new XICICPA(val.asInt()))
242 .collect(Collectors.toList());
243 pa.setXICICPA(collect);
244 } else {
245 throw new Exception("p_a size is not the same as UE size");
246 }
247 }
248 rrmConfig.setPa(pa);
249 }
slowr73b4eae2017-08-17 16:09:09 -0700250
slowr577f3222017-08-28 10:49:08 -0700251 JsonNode startPrbDl1 = rrmConfigNode.path("start_prb_dl");
252 if (!startPrbDl1.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700253 RRMConfig.StartPrbDl startPrbDl = new RRMConfig.StartPrbDl();
slowr577f3222017-08-28 10:49:08 -0700254 if (startPrbDl1.isArray()) {
255 if (ueList.size() == startPrbDl1.size()) {
256 List<BerInteger> collect = Stream.of(startPrbDl1)
slowr8ddc2b12017-08-14 14:13:38 -0700257 .map(val -> new BerInteger(val.asInt()))
258 .collect(Collectors.toList());
259 startPrbDl.setSeqOf(collect);
slowr73b4eae2017-08-17 16:09:09 -0700260 } else {
261 throw new Exception("start_prb_dl size is not the same as UE size");
slowr8ddc2b12017-08-14 14:13:38 -0700262 }
263 }
264 rrmConfig.setStartPrbDl(startPrbDl);
slowr67d05e42017-08-11 20:37:22 -0700265 }
slowr67d05e42017-08-11 20:37:22 -0700266
slowr577f3222017-08-28 10:49:08 -0700267 JsonNode endPrbDl1 = rrmConfigNode.path("end_prb_dl");
268 if (!endPrbDl1.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700269 RRMConfig.EndPrbDl endPrbDl = new RRMConfig.EndPrbDl();
slowr577f3222017-08-28 10:49:08 -0700270 if (endPrbDl1.isArray()) {
271 if (ueList.size() == endPrbDl1.size()) {
272 List<BerInteger> collect = Stream.of(endPrbDl1)
slowr8ddc2b12017-08-14 14:13:38 -0700273 .map(val -> new BerInteger(val.asInt()))
274 .collect(Collectors.toList());
275 endPrbDl.setSeqOf(collect);
slowr73b4eae2017-08-17 16:09:09 -0700276 } else {
277 throw new Exception("end_prb_dl size is not the same as UE size");
slowr8ddc2b12017-08-14 14:13:38 -0700278 }
279 }
280 rrmConfig.setEndPrbDl(endPrbDl);
281 }
slowr8ddc2b12017-08-14 14:13:38 -0700282
slowr577f3222017-08-28 10:49:08 -0700283 JsonNode frameBitmaskDl = rrmConfigNode.path("sub_frame_bitmask_dl");
284 if (!frameBitmaskDl.isMissingNode()) {
slowr73b4eae2017-08-17 16:09:09 -0700285 RRMConfig.SubframeBitmaskDl subframeBitmaskDl = new RRMConfig.SubframeBitmaskDl();
slowr577f3222017-08-28 10:49:08 -0700286 if (frameBitmaskDl.isArray()) {
287 List<BerBitString> collect = Stream.of(frameBitmaskDl)
slowr73b4eae2017-08-17 16:09:09 -0700288 .map(val -> new BerBitString(DatatypeConverter.parseHexBinary(val.asText()), 10))
289 .collect(Collectors.toList());
290
291 subframeBitmaskDl.setSeqOf(collect);
292 } else {
293 throw new Exception("sub_frame_bitmask_dl size is not the same as UE size");
294 }
295 rrmConfig.setSubframeBitmaskDl(subframeBitmaskDl);
296 }
slowr73b4eae2017-08-17 16:09:09 -0700297
slowr577f3222017-08-28 10:49:08 -0700298 JsonNode startPrbUl1 = rrmConfigNode.path("start_prb_ul");
299 if (!startPrbUl1.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700300 RRMConfig.StartPrbUl startPrbUl = new RRMConfig.StartPrbUl();
slowr577f3222017-08-28 10:49:08 -0700301 if (startPrbUl1.isArray()) {
302 if (ueList.size() == startPrbUl1.size()) {
303 List<BerInteger> collect = Stream.of(startPrbUl1)
slowr8ddc2b12017-08-14 14:13:38 -0700304 .map(val -> new BerInteger(val.asInt()))
305 .collect(Collectors.toList());
306 startPrbUl.setSeqOf(collect);
slowr73b4eae2017-08-17 16:09:09 -0700307 } else {
308 throw new Exception("start_prb_ul size is not the same as UE size");
slowr8ddc2b12017-08-14 14:13:38 -0700309 }
310 }
311 rrmConfig.setStartPrbUl(startPrbUl);
312 }
slowr8ddc2b12017-08-14 14:13:38 -0700313
slowr577f3222017-08-28 10:49:08 -0700314 JsonNode endPrbUl1 = rrmConfigNode.path("end_prb_ul");
315 if (!endPrbUl1.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700316 RRMConfig.EndPrbUl endPrbUl = new RRMConfig.EndPrbUl();
slowr577f3222017-08-28 10:49:08 -0700317 if (endPrbUl1.isArray()) {
318 if (ueList.size() == endPrbUl1.size()) {
319 List<BerInteger> collect = Stream.of(endPrbUl1)
slowr8ddc2b12017-08-14 14:13:38 -0700320 .map(val -> new BerInteger(val.asInt()))
321 .collect(Collectors.toList());
322 endPrbUl.setSeqOf(collect);
slowr73b4eae2017-08-17 16:09:09 -0700323 } else {
324 throw new Exception("end_prb_ul size is not the same as UE size");
slowr8ddc2b12017-08-14 14:13:38 -0700325 }
326 }
327 rrmConfig.setEndPrbUl(endPrbUl);
328 }
slowr8ddc2b12017-08-14 14:13:38 -0700329
slowr577f3222017-08-28 10:49:08 -0700330 JsonNode uePusch = rrmConfigNode.path("p0_ue_pusch");
331 if (!uePusch.isMissingNode()) {
slowr73b4eae2017-08-17 16:09:09 -0700332 RRMConfig.P0UePusch p0UePusch = new RRMConfig.P0UePusch();
slowr577f3222017-08-28 10:49:08 -0700333 if (uePusch.isArray()) {
334 if (ueList.size() == uePusch.size()) {
335 List<BerInteger> collect = Stream.of(uePusch)
slowr73b4eae2017-08-17 16:09:09 -0700336 .map(val -> new BerInteger(val.asInt()))
337 .collect(Collectors.toList());
338 p0UePusch.setSeqOf(collect);
339 } else {
340 throw new Exception("p0_ue_pusch size is not the same as UE size");
341 }
342 }
343 rrmConfig.setP0UePusch(p0UePusch);
344 }
slowr73b4eae2017-08-17 16:09:09 -0700345
slowr577f3222017-08-28 10:49:08 -0700346 JsonNode frameBitmaskUl = rrmConfigNode.path("sub_frame_bitmask_ul");
347 if (!frameBitmaskUl.isMissingNode()) {
slowr73b4eae2017-08-17 16:09:09 -0700348 RRMConfig.SubframeBitmaskUl subframeBitmaskUl = new RRMConfig.SubframeBitmaskUl();
slowr577f3222017-08-28 10:49:08 -0700349 if (frameBitmaskUl.isArray()) {
350 List<BerBitString> collect = Stream.of(frameBitmaskUl)
slowr73b4eae2017-08-17 16:09:09 -0700351 .map(val -> new BerBitString(DatatypeConverter.parseHexBinary(val.asText()), 10))
352 .collect(Collectors.toList());
353
354 subframeBitmaskUl.setSeqOf(collect);
355 } else {
356 throw new Exception("sub_frame_bitmask_ul size is not the same as UE size");
357 }
358 rrmConfig.setSubframeBitmaskUl(subframeBitmaskUl);
359 }
slowr73b4eae2017-08-17 16:09:09 -0700360
slowr8ddc2b12017-08-14 14:13:38 -0700361 rrmConfig.setCrnti(crnti);
slowr13fa5b02017-08-08 16:32:31 -0700362 }
363
slowr577f3222017-08-28 10:49:08 -0700364 /**
365 * Get QCI values.
366 *
367 * @return QCI values
368 */
slowr60d4d102017-08-16 18:33:58 -0700369 @JsonProperty("QCI")
slowr13fa5b02017-08-08 16:32:31 -0700370 public SchedMeasReportPerCell.QciVals getQci() {
371 return qci;
372 }
373
slowr577f3222017-08-28 10:49:08 -0700374 /**
375 * Set QCI values.
376 *
377 * @param qci QCI
378 */
slowr60d4d102017-08-16 18:33:58 -0700379 @JsonProperty("QCI")
slowr13fa5b02017-08-08 16:32:31 -0700380 public void setQci(SchedMeasReportPerCell.QciVals qci) {
381 this.qci = qci;
382 }
383
slowr577f3222017-08-28 10:49:08 -0700384 /**
385 * Get L2 measurement config.
386 *
387 * @return L2MeasConfig
388 */
slowr60d4d102017-08-16 18:33:58 -0700389 @JsonProperty("MeasurementConfiguration")
slowr13fa5b02017-08-08 16:32:31 -0700390 public L2MeasConfig getMeasConfig() {
391 return measConfig;
392 }
393
slowr577f3222017-08-28 10:49:08 -0700394 /**
395 * Set L2 measurement config.
396 *
397 * @param measConfig l2MeasConfig
398 */
slowr60d4d102017-08-16 18:33:58 -0700399 @JsonProperty("MeasurementConfiguration")
slowr13fa5b02017-08-08 16:32:31 -0700400 public void setMeasConfig(L2MeasConfig measConfig) {
401 this.measConfig = measConfig;
402 }
403
404 @Override
405 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700406 return "RnibCell{" +
407 "ecgi=" + ecgi +
408 ", conf=" + conf +
409 ", prbUsage=" + prbUsage +
410 ", qci=" + qci +
411 ", rrmConfig=" + rrmConfig +
412 ", measConfig=" + measConfig +
413 ", version='" + version + '\'' +
414 '}';
slowr13fa5b02017-08-08 16:32:31 -0700415 }
416
slowr577f3222017-08-28 10:49:08 -0700417 /*
418 * (non-Javadoc)
419 *
420 * @see java.lang.Object#equals()
421 */
slowr13fa5b02017-08-08 16:32:31 -0700422 @Override
423 public boolean equals(Object o) {
slowr577f3222017-08-28 10:49:08 -0700424 if (this == o) {
425 return true;
426 }
427 if (o == null || getClass() != o.getClass()) {
428 return false;
429 }
slowr13fa5b02017-08-08 16:32:31 -0700430
431 RnibCell rnibCell = (RnibCell) o;
432
433 return ecgi.equals(rnibCell.ecgi);
434 }
435
slowr577f3222017-08-28 10:49:08 -0700436 /*
437 * (non-Javadoc)
438 *
439 * @see java.lang.Object#hashCode()
440 */
slowr13fa5b02017-08-08 16:32:31 -0700441 @Override
442 public int hashCode() {
443 return ecgi.hashCode();
444 }
445
slowr577f3222017-08-28 10:49:08 -0700446 /**
447 * Container class for PRBUsage.
448 */
slowr60d4d102017-08-16 18:33:58 -0700449 @JsonPropertyOrder({
450 "primary",
slowrc153ad92017-08-16 19:47:52 -0700451 "secondary",
452 "timesincelastupdate"
slowr60d4d102017-08-16 18:33:58 -0700453 })
454 @JsonIgnoreProperties(ignoreUnknown = true)
slowrc153ad92017-08-16 19:47:52 -0700455 public static class PrbUsageContainer {
slowr13fa5b02017-08-08 16:32:31 -0700456 PRBUsage primary;
457 PRBUsage secondary;
slowrc153ad92017-08-16 19:47:52 -0700458 WallClockTimestamp timesincelastupdate;
459
460 @JsonCreator
slowr577f3222017-08-28 10:49:08 -0700461 public PrbUsageContainer(@JsonProperty("primary") PRBUsage primary,
462 @JsonProperty("secondary") PRBUsage secondary) {
slowrc153ad92017-08-16 19:47:52 -0700463 this.primary = primary;
464 this.secondary = secondary;
465 this.timesincelastupdate = new WallClockTimestamp();
466 }
slowr13fa5b02017-08-08 16:32:31 -0700467
slowr577f3222017-08-28 10:49:08 -0700468 /**
469 * Get primary PRBUsage.
470 *
471 * @return PRBUsage
472 */
slowr60d4d102017-08-16 18:33:58 -0700473 public PRBUsage getPrimary() {
474 return primary;
475 }
476
slowr577f3222017-08-28 10:49:08 -0700477 /**
478 * Set secondary PRBUsage.
479 *
480 * @param primary PRBUsage
481 */
slowr60d4d102017-08-16 18:33:58 -0700482 public void setPrimary(PRBUsage primary) {
483 this.primary = primary;
484 }
485
slowr577f3222017-08-28 10:49:08 -0700486 /**
487 * Get secondary PRBUsage.
488 *
489 * @return PRBUsage
490 */
slowr60d4d102017-08-16 18:33:58 -0700491 public PRBUsage getSecondary() {
492 return secondary;
493 }
494
slowr577f3222017-08-28 10:49:08 -0700495 /**
496 * Set secondary PRBUsage.
497 *
498 * @param secondary PRBUsage
499 */
slowr60d4d102017-08-16 18:33:58 -0700500 public void setSecondary(PRBUsage secondary) {
501 this.secondary = secondary;
502 }
503
slowr577f3222017-08-28 10:49:08 -0700504 /**
505 * Get time since last update.
506 *
507 * @return long Time
508 */
509 public long getTimeSinceLastUpdate() {
slowr7bebd7b2017-08-17 11:46:11 -0700510 return new WallClockTimestamp().unixTimestamp() - timesincelastupdate.unixTimestamp();
slowrc153ad92017-08-16 19:47:52 -0700511 }
slowr7bebd7b2017-08-17 11:46:11 -0700512
slowr577f3222017-08-28 10:49:08 -0700513
514 /**
515 * Set time since last update.
516 *
517 * @param timesincelastupdate time since last update
518 */
519 public void setTimeSinceLastUpdate(WallClockTimestamp timesincelastupdate) {
slowrc153ad92017-08-16 19:47:52 -0700520 this.timesincelastupdate = timesincelastupdate;
521 }
522
slowr13fa5b02017-08-08 16:32:31 -0700523 @Override
524 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700525 return "PrbUsageContainer{" +
526 "primary=" + primary +
527 ", secondary=" + secondary +
slowr577f3222017-08-28 10:49:08 -0700528 ", timesincelastupdate=" + (new WallClockTimestamp().unixTimestamp() -
529 timesincelastupdate.unixTimestamp()) +
slowr60d4d102017-08-16 18:33:58 -0700530 '}';
slowr13fa5b02017-08-08 16:32:31 -0700531 }
532 }
533}