OshiPlatformCache { @SuppressWarnings("unchecked") public Map<String, OSFileStore> getFileStores() { Map<String, OSFileStore> ret; wLock.lock(); try { if (!sysInfoCache.containsKey(PlatformResourceType.FILE_STORE)) { HashMap<String, OSFileStore> cache = new HashMap<>(); OSFileStore[] arr = sysInfo.getOperatingSystem().getFileSystem().getFileStores(); if (arr != null) { for (OSFileStore item : arr) { cache.put(item.getName(), item); } } sysInfoCache.put(PlatformResourceType.FILE_STORE, cache); } } finally { rLock.lock(); try { wLock.unlock(); ret = (Map<String, OSFileStore>) sysInfoCache.get(PlatformResourceType.FILE_STORE); } 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 getFileStores() { OshiPlatformCache oshi = newOshiPlatformCache(); Map<String, OSFileStore> filestores = oshi.getFileStores(); Assert.assertNotNull(filestores); int i = 0; for (OSFileStore filestore : filestores.values()) { String name = filestore.getName(); String description = filestore.getDescription(); long usableSpace = filestore.getUsableSpace(); long totalSpace = filestore.getTotalSpace(); Assert.assertNotNull(name); Assert.assertNotNull(description); Assert.assertTrue(usableSpace > -1L); Assert.assertTrue(totalSpace > -1L); print("===FILE STORE #%d ===", ++i); print(" Name=[%s]", name); print(" Description=[%s]", description); print(" UsableSpace=[%s] (%d)", FormatUtil.formatBytes(usableSpace), usableSpace); print(" TotalSpace=[%s] (%d)", FormatUtil.formatBytes(totalSpace), totalSpace); print(" toString=[%s]", filestore.toString()); } }