List of usage examples for java.lang.management ManagementFactory getOperatingSystemMXBean
public static OperatingSystemMXBean getOperatingSystemMXBean()
From source file:com.ah.be.common.NmsUtil.java
public static long getSysTotalMemory() { OperatingSystemMXBean osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); return osmb.getTotalPhysicalMemorySize() / 1024 / 1024; }
From source file:org.apache.accumulo.tserver.TabletServer.java
public TabletServerStatus getStats(Map<String, MapCounter<ScanRunState>> scanCounts) { TabletServerStatus result = new TabletServerStatus(); Map<KeyExtent, Tablet> onlineTabletsCopy; synchronized (this.onlineTablets) { onlineTabletsCopy = new HashMap<KeyExtent, Tablet>(this.onlineTablets); }/*w w w . ja v a 2 s. c om*/ Map<String, TableInfo> tables = new HashMap<String, TableInfo>(); for (Entry<KeyExtent, Tablet> entry : onlineTabletsCopy.entrySet()) { String tableId = entry.getKey().getTableId(); TableInfo table = tables.get(tableId); if (table == null) { table = new TableInfo(); table.minors = new Compacting(); table.majors = new Compacting(); tables.put(tableId, table); } Tablet tablet = entry.getValue(); long recs = tablet.getNumEntries(); table.tablets++; table.onlineTablets++; table.recs += recs; table.queryRate += tablet.queryRate(); table.queryByteRate += tablet.queryByteRate(); table.ingestRate += tablet.ingestRate(); table.ingestByteRate += tablet.ingestByteRate(); table.scanRate += tablet.scanRate(); long recsInMemory = tablet.getNumEntriesInMemory(); table.recsInMemory += recsInMemory; if (tablet.isMinorCompactionRunning()) table.minors.running++; if (tablet.isMinorCompactionQueued()) table.minors.queued++; if (tablet.isMajorCompactionRunning()) table.majors.running++; if (tablet.isMajorCompactionQueued()) table.majors.queued++; } for (Entry<String, MapCounter<ScanRunState>> entry : scanCounts.entrySet()) { TableInfo table = tables.get(entry.getKey()); if (table == null) { table = new TableInfo(); tables.put(entry.getKey(), table); } if (table.scans == null) table.scans = new Compacting(); table.scans.queued += entry.getValue().get(ScanRunState.QUEUED); table.scans.running += entry.getValue().get(ScanRunState.RUNNING); } ArrayList<KeyExtent> offlineTabletsCopy = new ArrayList<KeyExtent>(); synchronized (this.unopenedTablets) { synchronized (this.openingTablets) { offlineTabletsCopy.addAll(this.unopenedTablets); offlineTabletsCopy.addAll(this.openingTablets); } } for (KeyExtent extent : offlineTabletsCopy) { String tableId = extent.getTableId(); TableInfo table = tables.get(tableId); if (table == null) { table = new TableInfo(); tables.put(tableId, table); } table.tablets++; } result.lastContact = RelativeTime.currentTimeMillis(); result.tableMap = tables; result.osLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); result.name = getClientAddressString(); result.holdTime = resourceManager.holdTime(); result.lookups = seekCount.get(); result.indexCacheHits = resourceManager.getIndexCache().getStats().getHitCount(); result.indexCacheRequest = resourceManager.getIndexCache().getStats().getRequestCount(); result.dataCacheHits = resourceManager.getDataCache().getStats().getHitCount(); result.dataCacheRequest = resourceManager.getDataCache().getStats().getRequestCount(); result.logSorts = logSorter.getLogSorts(); result.flushs = flushCounter.get(); result.syncs = syncCounter.get(); result.bulkImports = new ArrayList<>(); result.bulkImports.addAll(clientHandler.getBulkLoadStatus()); result.bulkImports.addAll(bulkImportStatus.getBulkLoadStatus()); return result; }
From source file:org.apache.accumulo.server.tabletserver.ScanRunState.java
public TabletServerStatus getStats(Map<String, MapCounter<ScanRunState>> scanCounts) { TabletServerStatus result = new TabletServerStatus(); Map<KeyExtent, Tablet> onlineTabletsCopy; synchronized (this.onlineTablets) { onlineTabletsCopy = new HashMap<KeyExtent, Tablet>(this.onlineTablets); }/* w ww . jav a2 s. c o m*/ Map<String, TableInfo> tables = new HashMap<String, TableInfo>(); for (Entry<KeyExtent, Tablet> entry : onlineTabletsCopy.entrySet()) { String tableId = entry.getKey().getTableId().toString(); TableInfo table = tables.get(tableId); if (table == null) { table = new TableInfo(); table.minors = new Compacting(); table.majors = new Compacting(); tables.put(tableId, table); } Tablet tablet = entry.getValue(); long recs = tablet.getNumEntries(); table.tablets++; table.onlineTablets++; table.recs += recs; table.queryRate += tablet.queryRate(); table.queryByteRate += tablet.queryByteRate(); table.ingestRate += tablet.ingestRate(); table.ingestByteRate += tablet.ingestByteRate(); table.scanRate += tablet.scanRate(); long recsInMemory = tablet.getNumEntriesInMemory(); table.recsInMemory += recsInMemory; if (tablet.minorCompactionRunning()) table.minors.running++; if (tablet.minorCompactionQueued()) table.minors.queued++; if (tablet.majorCompactionRunning()) table.majors.running++; if (tablet.majorCompactionQueued()) table.majors.queued++; } for (Entry<String, MapCounter<ScanRunState>> entry : scanCounts.entrySet()) { TableInfo table = tables.get(entry.getKey()); if (table == null) { table = new TableInfo(); tables.put(entry.getKey(), table); } if (table.scans == null) table.scans = new Compacting(); table.scans.queued += entry.getValue().get(ScanRunState.QUEUED); table.scans.running += entry.getValue().get(ScanRunState.RUNNING); } ArrayList<KeyExtent> offlineTabletsCopy = new ArrayList<KeyExtent>(); synchronized (this.unopenedTablets) { synchronized (this.openingTablets) { offlineTabletsCopy.addAll(this.unopenedTablets); offlineTabletsCopy.addAll(this.openingTablets); } } for (KeyExtent extent : offlineTabletsCopy) { String tableId = extent.getTableId().toString(); TableInfo table = tables.get(tableId); if (table == null) { table = new TableInfo(); tables.put(tableId, table); } table.tablets++; } result.lastContact = RelativeTime.currentTimeMillis(); result.tableMap = tables; result.osLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); result.name = getClientAddressString(); result.holdTime = resourceManager.holdTime(); result.lookups = seekCount.get(); result.indexCacheHits = resourceManager.getIndexCache().getStats().getHitCount(); result.indexCacheRequest = resourceManager.getIndexCache().getStats().getRequestCount(); result.dataCacheHits = resourceManager.getDataCache().getStats().getHitCount(); result.dataCacheRequest = resourceManager.getDataCache().getStats().getRequestCount(); result.logSorts = logSorter.getLogSorts(); return result; }