Refactor SystemInfo, and store SystemInfo into singleton instance
- Implement Bill Pugh singleton for ControlMetricsFactory and
SystemInfo class
Change-Id: Ia97538d9f1be9ea900b0e87371bf50877eaf6483
diff --git a/apps/cpman/api/src/main/java/org/onosproject/cpman/SystemInfo.java b/apps/cpman/api/src/main/java/org/onosproject/cpman/SystemInfo.java
new file mode 100644
index 0000000..d8820f3
--- /dev/null
+++ b/apps/cpman/api/src/main/java/org/onosproject/cpman/SystemInfo.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cpman;
+
+/**
+ * System information interface.
+ */
+public interface SystemInfo {
+
+ /**
+ * Returns number of CPU cores.
+ *
+ * @return number of CPU cores
+ */
+ int coreCount();
+
+ /**
+ * Returns number of CPUs.
+ *
+ * @return number of CPUs
+ */
+ int cpuCount();
+
+ /**
+ * Returns CPU speed in MHz.
+ *
+ * @return CPU speed
+ */
+ int cpuSpeed();
+
+ /**
+ * Returns the total amount of memory in Mega Bytes.
+ *
+ * @return memory size
+ */
+ int totalMemory();
+
+ /**
+ * A builder of SystemInfo.
+ */
+ interface Builder {
+
+ /**
+ * Sets number of CPU cores.
+ *
+ * @param numOfCores number of CPU cores
+ * @return Builder object
+ */
+ Builder numOfCores(int numOfCores);
+
+ /**
+ * Sets number of CPUs.
+ * @param numOfCpus number of CPUs
+ * @return Builder object
+ */
+ Builder numOfCpus(int numOfCpus);
+
+ /**
+ * Sets CPU speed.
+ *
+ * @param cpuSpeedMhz CPU speed in Mhz
+ * @return Builder object
+ */
+ Builder cpuSpeed(int cpuSpeedMhz);
+
+ /**
+ * Sets total amount of memory.
+ *
+ * @param totalMemoryMbytes memory size in Mega Bytes
+ * @return Builder object
+ */
+ Builder totalMemory(int totalMemoryMbytes);
+
+ /**
+ * Builds a SystemInfo object.
+ *
+ * @return SystemInfo object
+ */
+ SystemInfo build();
+ }
+}