OshiPlatformCache { public OperatingSystem getOperatingSystem() { OperatingSystem ret; wLock.lock(); try { if (!sysInfoCache.containsKey(PlatformResourceType.OPERATING_SYSTEM)) { HashMap<String, OperatingSystem> cache = new HashMap<>(1); OperatingSystem os = sysInfo.getOperatingSystem(); cache.put(PlatformResourceType.OPERATING_SYSTEM.getResourceTypeId().getIDString(), os); sysInfoCache.put(PlatformResourceType.OPERATING_SYSTEM, cache); } } finally { rLock.lock(); try { wLock.unlock(); ret = (OperatingSystem) sysInfoCache.get(PlatformResourceType.OPERATING_SYSTEM) .get(PlatformResourceType.OPERATING_SYSTEM.getResourceTypeId().getIDString()); } finally { rLock.unlock(); } } return ret; } OshiPlatformCache(String feedId, String machineId, String containerId); void refresh(); OperatingSystem getOperatingSystem(); @SuppressWarnings("unchecked") Map<String, OSFileStore> getFileStores(); GlobalMemory getMemory(); CentralProcessor getProcessor(); @SuppressWarnings("unchecked") Map<String, PowerSource> getPowerSources(); Double getPowerSourceMetric(String powerSourceName, ID metricToCollect); Double getProcessorMetric(String processorNumber, ID metricToCollect); Double getFileStoreMetric(String fileStoreNameName, ID metricToCollect); Double getMemoryMetric(ID metricToCollect); Double getOperatingSystemMetric(ID metricId); Double getMetric(PlatformResourceType type, String name, ID metricToCollect); String getMachineId(); String getContainerId();  }
@Test public void getOperatingSystemInfo() { OshiPlatformCache oshi = newOshiPlatformCache(); OperatingSystem os = oshi.getOperatingSystem(); Assert.assertNotNull(os); String family = os.getFamily(); String manu = os.getManufacturer(); OperatingSystemVersion version = os.getVersion(); Assert.assertNotNull(family); Assert.assertNotNull(manu); Assert.assertNotNull(version); print("===OPERATION SYSTEM=="); print(" Family=[%s]", family); print(" Manufacturer=[%s]", manu); print(" Version=[%s](%s)", version, version.getClass()); print(" toString=[%s]", os.toString()); }