/** * Returns a Set of DistributedMember for members that have the specified <code>region</code>. * <code>returnAll</code> indicates whether to return all members or only the first member we find. * * @param region region path for which members that have this region are required * @param cache Cache instance to use to find members * @param returnAll whether to return all members or only the first member we find. Returns all when <code>true</code> * @return a Set of DistributedMember for members that have the specified <code>region</code>. */ public static Set<DistributedMember> getRegionAssociatedMembers(final String region, final Cache cache, boolean returnAll) { if (region == null || region.isEmpty()) { return null; } ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean distributedSystemMXBean = managementService.getDistributedSystemMXBean(); Set<DistributedMember> matchedMembers = new HashSet<DistributedMember>(); Set<DistributedMember> allClusterMembers = new HashSet<DistributedMember>(); allClusterMembers.addAll(cache.getMembers()); allClusterMembers.add(cache.getDistributedSystem().getDistributedMember()); for (DistributedMember member : allClusterMembers) { try { if (distributedSystemMXBean.fetchRegionObjectName(CliUtil.getMemberNameOrId(member), region) != null) { matchedMembers.add(member); } } catch (Exception e) { //ignore for now } } return matchedMembers; }
PARTITIONED_REGION_PATH); waitForProxy(expectedName, RegionMXBean.class); actualName = bean.fetchRegionObjectName(memberId, PARTITIONED_REGION_PATH); REGION_PATH); waitForProxy(expectedName, RegionMXBean.class); actualName = bean.fetchRegionObjectName(memberId, REGION_PATH);
/** * Returns a Set of DistributedMember for members that have the specified <code>region</code>. * <code>returnAll</code> indicates whether to return all members or only the first member we find. * * @param region region path for which members that have this region are required * @param cache Cache instance to use to find members * @param returnAll whether to return all members or only the first member we find. Returns all when <code>true</code> * @return a Set of DistributedMember for members that have the specified <code>region</code>. */ public static Set<DistributedMember> getRegionAssociatedMembers(final String region, final Cache cache, boolean returnAll) { if (region == null || region.isEmpty()) { return null; } ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean distributedSystemMXBean = managementService.getDistributedSystemMXBean(); Set<DistributedMember> matchedMembers = new HashSet<DistributedMember>(); Set<DistributedMember> allClusterMembers = new HashSet<DistributedMember>(); allClusterMembers.addAll(cache.getMembers()); allClusterMembers.add(cache.getDistributedSystem().getDistributedMember()); for (DistributedMember member : allClusterMembers) { try { if (distributedSystemMXBean.fetchRegionObjectName(CliUtil.getMemberNameOrId(member), region) != null) { matchedMembers.add(member); } } catch (Exception e) { //ignore for now } } return matchedMembers; }
private static boolean isClusterwideSameConfig(Cache cache, String regionPath) { ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean(); Set<DistributedMember> allMembers = CliUtil.getAllNormalMembers(cache); RegionAttributesData regionAttributesToValidateAgainst = null; for (DistributedMember distributedMember : allMembers) { ObjectName regionObjectName; try { regionObjectName = dsMXBean.fetchRegionObjectName(CliUtil.getMemberNameOrId(distributedMember), regionPath); RegionMXBean regionMBean = managementService.getMBeanInstance(regionObjectName, RegionMXBean.class); RegionAttributesData regionAttributes = regionMBean.listRegionAttributes(); if (regionAttributesToValidateAgainst == null) { regionAttributesToValidateAgainst = regionAttributes; } else if ( !(regionAttributesToValidateAgainst.getScope().equals(regionAttributes.getScope()) || regionAttributesToValidateAgainst.getDataPolicy().equals(regionAttributes.getDataPolicy())) ) { return false; } } catch (Exception e) { //ignore } } return true; }
private static boolean isClusterwideSameConfig(Cache cache, String regionPath) { ManagementService managementService = ManagementService.getExistingManagementService(cache); DistributedSystemMXBean dsMXBean = managementService.getDistributedSystemMXBean(); Set<DistributedMember> allMembers = CliUtil.getAllNormalMembers(cache); RegionAttributesData regionAttributesToValidateAgainst = null; for (DistributedMember distributedMember : allMembers) { ObjectName regionObjectName; try { regionObjectName = dsMXBean.fetchRegionObjectName(CliUtil.getMemberNameOrId(distributedMember), regionPath); RegionMXBean regionMBean = managementService.getMBeanInstance(regionObjectName, RegionMXBean.class); RegionAttributesData regionAttributes = regionMBean.listRegionAttributes(); if (regionAttributesToValidateAgainst == null) { regionAttributesToValidateAgainst = regionAttributes; } else if ( !(regionAttributesToValidateAgainst.getScope().equals(regionAttributes.getScope()) || regionAttributesToValidateAgainst.getDataPolicy().equals(regionAttributes.getDataPolicy())) ) { return false; } } catch (Exception e) { //ignore } } return true; }