blob: ccddd85dc32f3433c285edf9e5a33855c2839416 [file] [log] [blame]
nitinanandf14dccd2018-05-31 15:11:04 +05301/*
2 * Copyright 2016-present Open Networking Foundation
3 *
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 */
16package org.onosproject.net.behaviour;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
21
22/**
23 * A representation of system stats of device.
24 */
25public class DeviceSystemStats {
26
27 private final DeviceMemoryStats memory;
28 private final DeviceCpuStats cpu;
29
30 /**
31 * Creates deviceSystemStats object.
32 *
33 * @param memoryStats memory statisics of the device
34 * @param cpuStats cpu statistics of the device
35 */
36 public DeviceSystemStats(DeviceMemoryStats memoryStats, DeviceCpuStats cpuStats) {
37 this.memory = memoryStats;
38 this.cpu = cpuStats;
39 }
40
41 /**
42 * Get memory usage statistics.
43 *
44 * @return deviceMemoryStats, device memory usage stats in KB
45 */
46 public DeviceMemoryStats getMemory() {
47 return this.memory;
48 }
49
50 /**
51 * Get cpu usage statistics.
52 *
53 * @return deviceCpuStats, device cpu usage stats
54 */
55 public DeviceCpuStats getCpu() {
56 return this.cpu;
57 }
58
59 @Override
60 public String toString() {
61 return MoreObjects.toStringHelper(getClass())
62 .add("memory", memory)
63 .add("cpu", cpu)
64 .toString();
65 }
66
67 @Override
68 public boolean equals(Object o) {
69 if (this == o) {
70 return true;
71 }
72 if (o == null || getClass() != o.getClass()) {
73 return false;
74 }
75 DeviceSystemStats that = (DeviceSystemStats) o;
76 return Objects.equals(memory, that.memory) &&
77 Objects.equals(cpu, that.cpu);
78 }
79
80 @Override
81 public int hashCode() {
82 return Objects.hash(memory, cpu);
83 }
84}
85
86