use of org.apache.geode.management.DistributedSystemMXBean in project geode by apache.
the class AbstractCommandsController method getManagingMemberMXBean.
/**
* Lookup operation for the MemberMXBean representing the Manager in the GemFire cluster. This
* method gets an instance fo the Platform MBeanServer for this JVM process and uses it to lookup
* the MemberMXBean for the GemFire Manager based on the ObjectName declared in the
* DistributedSystemMXBean.getManagerObjectName() operation.
*
* @return a proxy instance to the MemberMXBean of the GemFire Manager.
* @see #getMBeanServer()
* @see #createMemberMXBeanForManagerUsingProxy(javax.management.MBeanServer,
* javax.management.ObjectName)
* @see org.apache.geode.management.DistributedSystemMXBean
* @see org.apache.geode.management.MemberMXBean
*/
protected synchronized MemberMXBean getManagingMemberMXBean() {
if (managingMemberMXBeanProxy == null) {
SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(getCache());
MBeanServer mbs = getMBeanServer();
final DistributedSystemMXBean distributedSystemMXBean = JMX.newMXBeanProxy(mbs, MBeanJMXAdapter.getDistributedSystemName(), DistributedSystemMXBean.class);
managingMemberMXBeanProxy = createMemberMXBeanForManagerUsingProxy(mbs, distributedSystemMXBean.getMemberObjectName());
}
return managingMemberMXBeanProxy;
}
use of org.apache.geode.management.DistributedSystemMXBean in project geode by apache.
the class AbstractCommandsController method getMemberObjectName.
protected synchronized ObjectName getMemberObjectName() {
final MBeanServer platformMBeanServer = getMBeanServer();
final DistributedSystemMXBean distributedSystemMXBean = JMX.newMXBeanProxy(platformMBeanServer, MBeanJMXAdapter.getDistributedSystemName(), DistributedSystemMXBean.class);
return distributedSystemMXBean.getMemberObjectName();
}
use of org.apache.geode.management.DistributedSystemMXBean in project geode by apache.
the class WanCommands method listGateway.
@CliCommand(value = CliStrings.LIST_GATEWAY, help = CliStrings.LIST_GATEWAY__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_WAN)
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result listGateway(@CliOption(key = CliStrings.LIST_GATEWAY__MEMBER, optionContext = ConverterHint.MEMBERIDNAME, help = CliStrings.LIST_GATEWAY__MEMBER__HELP) String[] onMember, @CliOption(key = CliStrings.LIST_GATEWAY__GROUP, optionContext = ConverterHint.MEMBERGROUP, help = CliStrings.LIST_GATEWAY__GROUP__HELP) String[] onGroup) {
Result result = null;
InternalCache cache = getCache();
try {
SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
Set<DistributedMember> dsMembers = CliUtil.findMembers(onGroup, onMember);
if (dsMembers.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
}
Map<String, Map<String, GatewaySenderMXBean>> gatewaySenderBeans = new TreeMap<String, Map<String, GatewaySenderMXBean>>();
Map<String, GatewayReceiverMXBean> gatewayReceiverBeans = new TreeMap<String, GatewayReceiverMXBean>();
DistributedSystemMXBean dsMXBean = service.getDistributedSystemMXBean();
for (DistributedMember member : dsMembers) {
String memberName = member.getName();
String memberNameOrId = (memberName != null && !memberName.isEmpty()) ? memberName : member.getId();
ObjectName[] gatewaySenderObjectNames = dsMXBean.listGatewaySenderObjectNames(memberNameOrId);
// on it
if (gatewaySenderObjectNames != null) {
for (ObjectName name : gatewaySenderObjectNames) {
GatewaySenderMXBean senderBean = service.getMBeanProxy(name, GatewaySenderMXBean.class);
if (senderBean != null) {
if (gatewaySenderBeans.containsKey(senderBean.getSenderId())) {
Map<String, GatewaySenderMXBean> memberToBeanMap = gatewaySenderBeans.get(senderBean.getSenderId());
memberToBeanMap.put(member.getId(), senderBean);
} else {
Map<String, GatewaySenderMXBean> memberToBeanMap = new TreeMap<String, GatewaySenderMXBean>();
memberToBeanMap.put(member.getId(), senderBean);
gatewaySenderBeans.put(senderBean.getSenderId(), memberToBeanMap);
}
}
}
}
// gateway receivers : a member can have only one gateway receiver
ObjectName gatewayReceiverObjectName = MBeanJMXAdapter.getGatewayReceiverMBeanName(member);
if (gatewayReceiverObjectName != null) {
GatewayReceiverMXBean receieverBean = null;
receieverBean = service.getMBeanProxy(gatewayReceiverObjectName, GatewayReceiverMXBean.class);
if (receieverBean != null) {
gatewayReceiverBeans.put(member.getId(), receieverBean);
}
}
}
if (gatewaySenderBeans.isEmpty() && gatewayReceiverBeans.isEmpty()) {
return ResultBuilder.createUserErrorResult(CliStrings.GATEWAYS_ARE_NOT_AVAILABLE_IN_CLUSTER);
}
CompositeResultData crd = ResultBuilder.createCompositeResultData();
crd.setHeader(CliStrings.HEADER_GATEWAYS);
accumulateListGatewayResult(crd, gatewaySenderBeans, gatewayReceiverBeans);
result = ResultBuilder.buildResult(crd);
} catch (Exception e) {
LogWrapper.getInstance().warning(CliStrings.GATEWAY_ERROR + CliUtil.stackTraceAsString(e));
result = ResultBuilder.createGemFireErrorResult(CliStrings.GATEWAY_ERROR + e.getMessage());
}
return result;
}
use of org.apache.geode.management.DistributedSystemMXBean in project geode by apache.
the class TestRemoteClusterDUnitTest method checkRemoteClusterStatus.
/**
* Checks Proxy GatewaySender
*
* @param vm reference to VM
*/
@SuppressWarnings("serial")
protected void checkRemoteClusterStatus(final VM vm, final DistributedMember senderMember) {
SerializableRunnable checkProxySender = new SerializableRunnable("DS Map Size") {
public void run() {
Cache cache = GemFireCacheImpl.getInstance();
final WaitCriterion waitCriteria2 = new WaitCriterion() {
@Override
public boolean done() {
Cache cache = GemFireCacheImpl.getInstance();
final ManagementService service = ManagementService.getManagementService(cache);
final DistributedSystemMXBean dsBean = service.getDistributedSystemMXBean();
if (dsBean != null) {
return true;
}
return false;
}
@Override
public String description() {
return "wait for getDistributedSystemMXBean to complete and get results";
}
};
Wait.waitForCriterion(waitCriteria2, 2 * 60 * 1000, 5000, true);
ManagementService service = ManagementService.getManagementService(cache);
final DistributedSystemMXBean dsBean = service.getDistributedSystemMXBean();
assertNotNull(dsBean);
Map<String, Boolean> dsMap = dsBean.viewRemoteClusterStatus();
LogWriterUtils.getLogWriter().info("Ds Map is: " + dsMap.size());
assertNotNull(dsMap);
assertEquals(true, dsMap.size() > 0 ? true : false);
}
};
vm.invoke(checkProxySender);
}
use of org.apache.geode.management.DistributedSystemMXBean in project geode by apache.
the class DistributedSystemStatsDUnitTest method testDistributedSystemStats.
@Test
public void testDistributedSystemStats() throws Exception {
this.managerVM.invoke("verifyMBeans", () -> {
DistributedSystemMXBean distributedSystemMXBean = awaitDistributedSystemMXBean();
// next block awaits all memberMXBeanName to refresh (getLastUpdateTime)
SystemManagementService service = this.managementTestRule.getSystemManagementService();
Set<DistributedMember> otherMemberSet = this.managementTestRule.getOtherNormalMembers();
assertEquals(3, otherMemberSet.size());
for (DistributedMember member : otherMemberSet) {
MemberMXBean memberMXBean = awaitMemberMXBeanProxy(member);
ObjectName memberMXBeanName = service.getMemberMBeanName(member);
long lastRefreshTime = service.getLastUpdateTime(memberMXBeanName);
await().until(() -> assertTrue(service.getLastUpdateTime(memberMXBeanName) > lastRefreshTime));
}
// TODO: add assertions for distributedSystemMXBean stats?
});
}
Aggregations