1 2 49 package org.mr.core.stats.cmc; 50 51 import org.mr.MantaAgent; 52 import org.apache.commons.logging.Log; 53 import org.apache.commons.logging.LogFactory; 54 import org.mr.core.stats.StatManager; 55 56 import javax.management.*; 57 58 63 public class GetStatsJMX extends StandardMBean implements GetStatsJMXMBean { 64 public Log log; 65 66 public GetStatsJMX()throws NotCompliantMBeanException{ 67 super(GetStatsJMXMBean.class); 68 log=LogFactory.getLog("GetStatsJMX"); 69 } 70 71 72 76 public String [] getStatsString() { 77 StatManager manager = MantaAgent.getInstance().getSingletonRepository().getStatManager(); 78 CMCAgentStats stats = manager.getCurrentCMCStats(); 79 String [] result = { "last five minutes bytes = "+stats.getFiveMinBytes(), 80 "total bytes = "+stats.getTotalBytes(), 81 "last five minutes messages = "+stats.getFiveMinMessages(), 82 "total messages = "+stats.getTotalMessages(), 83 "free memory = "+stats.getFreeMem(), 84 "total memory = "+stats.getTotalMem()}; 85 return result; 86 } 87 88 protected String getDescription(MBeanInfo i_mBeanInfo) { 89 return "returns various stats of the peer (memory usage, message & byte count)"; 90 } 91 92 protected String getDescription(MBeanAttributeInfo i_mBeanAttributeInfo) { 93 if(i_mBeanAttributeInfo.getName().equals("StatsString")) 94 return "returns the current stats of the peer in a String."; 95 return "gets the current stats of the peer"; 96 } 97 98 } 99 100 101 | Popular Tags |