1 49 package org.mr.kernel.world.cmc; 50 51 import java.util.*; 52 53 import javax.management.MBeanAttributeInfo ; 54 import javax.management.MBeanInfo ; 55 import javax.management.NotCompliantMBeanException ; 56 import javax.management.StandardMBean ; 57 58 import org.apache.commons.logging.Log; 59 import org.apache.commons.logging.LogFactory; 60 import org.mr.MantaAgent; 61 import org.mr.kernel.world.WorldModeler; 62 import org.mr.kernel.services.MantaService; 63 import org.mr.kernel.services.ServiceConsumer; 64 65 70 public class GetServiceParticipationJMX extends StandardMBean implements GetServiceParticipationJMXMBean{ 71 public Log log; 72 73 public GetServiceParticipationJMX()throws NotCompliantMBeanException { 74 super(GetServiceParticipationJMXMBean.class); 75 log=LogFactory.getLog("GetServiceParticipationJMX"); 76 } 77 78 82 public Set getProduced(){ 83 WorldModeler modeler = MantaAgent.getInstance(). 84 getSingletonRepository().getWorldModeler(); 85 Set setProduced = modeler.getMyProducedServices(); 86 Iterator i; 87 i=setProduced.iterator(); 88 Set stringsSetProduced = new HashSet(); 89 while (i.hasNext()) { 90 stringsSetProduced.add(i.next().toString()); 91 } 92 return stringsSetProduced; 93 } 95 99 public Set getConsumed(){ 100 WorldModeler modeler = MantaAgent.getInstance(). 101 getSingletonRepository().getWorldModeler(); 102 Set setConsumed = modeler.getMyConsumedServices(); 103 Iterator i; 104 i=setConsumed.iterator(); 105 Set stringsSetConsumed = new HashSet(); 106 while (i.hasNext()) { 107 stringsSetConsumed.add(i.next().toString()); 108 } return stringsSetConsumed; 110 } 112 116 public Set getDurablyConsumed(){ 117 WorldModeler modeler = MantaAgent.getInstance(). 118 getSingletonRepository().getWorldModeler(); 119 Set setConsumed = modeler.getMyConsumedServices(); 120 Iterator i; 121 i=setConsumed.iterator(); 122 Set stringsSetDurablyConsumed = new HashSet(); 123 while (i.hasNext()) { 124 MantaService service=(MantaService)i.next(); 125 if(service.getServiceType()==MantaService.SERVICE_TYPE_TOPIC){ 126 ArrayList serviceConsumers =service.getConsumersByAgentId(MantaAgent.getInstance().getAgentName()); 127 for(int j=0; j<serviceConsumers.size(); j++){ 128 ServiceConsumer consumer=(ServiceConsumer) serviceConsumers.get(j); 129 if(consumer.isDurable()) 130 stringsSetDurablyConsumed.add(service.toString()); 131 } 132 } 133 } return stringsSetDurablyConsumed; 135 } 136 137 141 public Set getCoordinated(){ 142 WorldModeler modeler = MantaAgent.getInstance(). 143 getSingletonRepository().getWorldModeler(); 144 Set setCoordinated = modeler.getMyCoordinatedServices(); 145 Iterator i; 146 i=setCoordinated.iterator(); 147 Set stringSetCoordinated = new HashSet(); 148 while (i.hasNext()) { 149 stringSetCoordinated.add(i.next().toString()); 150 } 151 return stringSetCoordinated; 152 } 153 154 protected String getDescription(MBeanInfo i_mBeanInfo) { 155 return "returns information regarding this peer's service participation"; 156 } 157 158 protected String getDescription(MBeanAttributeInfo i_mBeanAttributeInfo) { 159 if(i_mBeanAttributeInfo.getName().equals("Consumed")) 160 return "returns details about the services this layer is a consumer of"; 161 if(i_mBeanAttributeInfo.getName().equals("Produced")) 162 return "returns details about the services this layer is a producer of"; 163 if(i_mBeanAttributeInfo.getName().equals("Coordinated")) 164 return "returns details about the Queue services this layer is a coordinator of"; 165 return "managed string"; 166 } 167 168 } | Popular Tags |