Search in sources :

Example 11 with DistributedRegionMXBean

use of org.apache.geode.management.DistributedRegionMXBean in project geode by apache.

the class CreateAlterDestroyRegionCommands method verifyDistributedRegionMbean.

public boolean verifyDistributedRegionMbean(InternalCache cache, String regionName) {
    int federationInterval = cache.getInternalDistributedSystem().getConfig().getJmxManagerUpdateRate();
    long timeEnd = System.currentTimeMillis() + federationInterval + 50;
    for (; System.currentTimeMillis() <= timeEnd; ) {
        try {
            DistributedRegionMXBean bean = ManagementService.getManagementService(cache).getDistributedRegionMXBean(regionName);
            if (bean == null) {
                bean = ManagementService.getManagementService(cache).getDistributedRegionMXBean(Region.SEPARATOR + regionName);
            }
            if (bean != null) {
                return true;
            } else {
                Thread.sleep(2);
            }
        } catch (Exception ignored) {
        }
    }
    return false;
}
Also used : DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) ConverterHint(org.apache.geode.management.cli.ConverterHint) CommandResultException(org.apache.geode.management.internal.cli.result.CommandResultException) MalformedObjectNameException(javax.management.MalformedObjectNameException)

Example 12 with DistributedRegionMXBean

use of org.apache.geode.management.DistributedRegionMXBean in project geode by apache.

the class CreateAlterDestroyRegionCommands method validateRegionFunctionArgs.

private void validateRegionFunctionArgs(InternalCache cache, RegionFunctionArgs regionFunctionArgs) {
    if (regionFunctionArgs.getRegionPath() == null) {
        throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH);
    }
    ManagementService managementService = ManagementService.getExistingManagementService(cache);
    DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean();
    String useAttributesFrom = regionFunctionArgs.getUseAttributesFrom();
    if (useAttributesFrom != null && !useAttributesFrom.isEmpty() && regionExists(cache, useAttributesFrom)) {
        if (!regionExists(cache, useAttributesFrom)) {
            // check already done in createRegion !!!
            throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND, new Object[] { CliStrings.CREATE_REGION__USEATTRIBUTESFROM, useAttributesFrom }));
        }
        if (!regionFunctionArgs.isSetUseAttributesFrom() || regionFunctionArgs.getRegionAttributes() == null) {
            throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__COULD_NOT_RETRIEVE_REGION_ATTRS_FOR_PATH_0_VERIFY_REGION_EXISTS, useAttributesFrom));
        }
    }
    if (regionFunctionArgs.hasPartitionAttributes()) {
        RegionFunctionArgs.PartitionArgs partitionArgs = regionFunctionArgs.getPartitionArgs();
        String colocatedWith = partitionArgs.getPrColocatedWith();
        if (colocatedWith != null && !colocatedWith.isEmpty()) {
            String[] listAllRegionPaths = dsMBean.listAllRegionPaths();
            String foundRegionPath = null;
            for (String regionPath : listAllRegionPaths) {
                if (regionPath.equals(colocatedWith)) {
                    foundRegionPath = regionPath;
                    break;
                }
            }
            if (foundRegionPath == null) {
                throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_REGION_PATH_FOR_0_REGIONPATH_1_NOT_FOUND, new Object[] { CliStrings.CREATE_REGION__COLOCATEDWITH, colocatedWith }));
            }
            ManagementService mgmtService = ManagementService.getExistingManagementService(cache);
            DistributedRegionMXBean distributedRegionMXBean = mgmtService.getDistributedRegionMXBean(foundRegionPath);
            String regionType = distributedRegionMXBean.getRegionType();
            if (!(DataPolicy.PARTITION.toString().equals(regionType) || DataPolicy.PERSISTENT_PARTITION.toString().equals(regionType))) {
                throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__COLOCATEDWITH_REGION_0_IS_NOT_PARTITIONEDREGION, new Object[] { colocatedWith }));
            }
        }
        if (partitionArgs.isSetPRLocalMaxMemory()) {
            int prLocalMaxMemory = partitionArgs.getPrLocalMaxMemory();
            if (prLocalMaxMemory < 0) {
                throw new IllegalArgumentException(LocalizedStrings.AttributesFactory_PARTITIONATTRIBUTES_LOCALMAXMEMORY_MUST_NOT_BE_NEGATIVE.toLocalizedString());
            }
        }
        if (partitionArgs.isSetPRTotalMaxMemory()) {
            long prTotalMaxMemory = partitionArgs.getPrTotalMaxMemory();
            if (prTotalMaxMemory <= 0) {
                throw new IllegalArgumentException(LocalizedStrings.AttributesFactory_TOTAL_SIZE_OF_PARTITION_REGION_MUST_BE_0.toLocalizedString());
            }
        }
        if (partitionArgs.isSetPRRedundantCopies()) {
            int prRedundantCopies = partitionArgs.getPrRedundantCopies();
            switch(prRedundantCopies) {
                case 0:
                case 1:
                case 2:
                case 3:
                    break;
                default:
                    throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__REDUNDANT_COPIES_SHOULD_BE_ONE_OF_0123, new Object[] { prRedundantCopies }));
            }
        }
    }
    String keyConstraint = regionFunctionArgs.getKeyConstraint();
    if (keyConstraint != null && !isClassNameValid(keyConstraint)) {
        throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_KEYCONSTRAINT_0_IS_INVALID, new Object[] { keyConstraint }));
    }
    String valueConstraint = regionFunctionArgs.getValueConstraint();
    if (valueConstraint != null && !isClassNameValid(valueConstraint)) {
        throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_VALUECONSTRAINT_0_IS_INVALID, new Object[] { valueConstraint }));
    }
    Set<String> cacheListeners = regionFunctionArgs.getCacheListeners();
    if (cacheListeners != null && !cacheListeners.isEmpty()) {
        for (String cacheListener : cacheListeners) {
            if (!isClassNameValid(cacheListener)) {
                throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELISTENER_0_IS_INVALID, new Object[] { cacheListener }));
            }
        }
    }
    String cacheLoader = regionFunctionArgs.getCacheLoader();
    if (cacheLoader != null && !isClassNameValid(cacheLoader)) {
        throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHELOADER_0_IS_INVALID, new Object[] { cacheLoader }));
    }
    String cacheWriter = regionFunctionArgs.getCacheWriter();
    if (cacheWriter != null && !isClassNameValid(cacheWriter)) {
        throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_CLASSNAME_FOR_CACHEWRITER_0_IS_INVALID, new Object[] { cacheWriter }));
    }
    Set<String> gatewaySenderIds = regionFunctionArgs.getGatewaySenderIds();
    if (gatewaySenderIds != null && !gatewaySenderIds.isEmpty()) {
        String[] gatewaySenders = dsMBean.listGatewaySenders();
        if (gatewaySenders.length == 0) {
            throw new IllegalArgumentException(CliStrings.CREATE_REGION__MSG__NO_GATEWAYSENDERS_IN_THE_SYSTEM);
        } else {
            List<String> gatewaySendersList = new ArrayList<>(Arrays.asList(gatewaySenders));
            gatewaySenderIds = new HashSet<>(gatewaySenderIds);
            gatewaySenderIds.removeAll(gatewaySendersList);
            if (!gatewaySenderIds.isEmpty()) {
                throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_GATEWAYSENDER_ID_UNKNOWN_0, new Object[] { gatewaySenderIds }));
            }
        }
    }
    if (regionFunctionArgs.isSetConcurrencyLevel()) {
        int concurrencyLevel = regionFunctionArgs.getConcurrencyLevel();
        if (concurrencyLevel < 0) {
            throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_POSITIVE_INT_FOR_CONCURRENCYLEVEL_0_IS_NOT_VALID, new Object[] { concurrencyLevel }));
        }
    }
    String diskStore = regionFunctionArgs.getDiskStore();
    if (diskStore != null) {
        RegionShortcut regionShortcut = regionFunctionArgs.getRegionShortcut();
        if (regionShortcut != null && !PERSISTENT_OVERFLOW_SHORTCUTS.contains(regionShortcut)) {
            String subMessage = LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString();
            String message = subMessage + ". " + CliStrings.format(CliStrings.CREATE_REGION__MSG__USE_ONE_OF_THESE_SHORTCUTS_0, new Object[] { String.valueOf(PERSISTENT_OVERFLOW_SHORTCUTS) });
            throw new IllegalArgumentException(message);
        }
        RegionAttributes<?, ?> regionAttributes = regionFunctionArgs.getRegionAttributes();
        if (regionAttributes != null && !regionAttributes.getDataPolicy().withPersistence()) {
            String subMessage = LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString();
            String message = subMessage + ". " + CliStrings.format(CliStrings.CREATE_REGION__MSG__USE_ATTRIBUTES_FROM_REGION_0_IS_NOT_WITH_PERSISTENCE, new Object[] { String.valueOf(regionFunctionArgs.getUseAttributesFrom()) });
            throw new IllegalArgumentException(message);
        }
        if (!diskStoreExists(cache, diskStore)) {
            throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_DISKSTORE_UNKNOWN_DISKSTORE_0, new Object[] { diskStore }));
        }
    }
    RegionFunctionArgs.ExpirationAttrs entryExpirationIdleTime = regionFunctionArgs.getEntryExpirationIdleTime();
    RegionFunctionArgs.ExpirationAttrs entryExpirationTTL = regionFunctionArgs.getEntryExpirationTTL();
    RegionFunctionArgs.ExpirationAttrs regionExpirationIdleTime = regionFunctionArgs.getRegionExpirationIdleTime();
    RegionFunctionArgs.ExpirationAttrs regionExpirationTTL = regionFunctionArgs.getRegionExpirationTTL();
    if ((!regionFunctionArgs.isSetStatisticsEnabled() || !regionFunctionArgs.isStatisticsEnabled()) && (entryExpirationIdleTime != null || entryExpirationTTL != null || regionExpirationIdleTime != null || regionExpirationTTL != null)) {
        String message = LocalizedStrings.AttributesFactory_STATISTICS_MUST_BE_ENABLED_FOR_EXPIRATION.toLocalizedString();
        throw new IllegalArgumentException(message + ".");
    }
    boolean compressorFailure = false;
    if (regionFunctionArgs.isSetCompressor()) {
        String compressorClassName = regionFunctionArgs.getCompressor();
        Object compressor = null;
        try {
            Class<?> compressorClass = ClassPathLoader.getLatest().forName(compressorClassName);
            compressor = compressorClass.newInstance();
        } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
            compressorFailure = true;
        }
        if (compressorFailure || !(compressor instanceof Compressor)) {
            throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__INVALID_COMPRESSOR, new Object[] { regionFunctionArgs.getCompressor() }));
        }
    }
    if (regionFunctionArgs.hasPartitionAttributes()) {
        if (regionFunctionArgs.isPartitionResolverSet()) {
            String partitionResolverClassName = regionFunctionArgs.getPartitionResolver();
            try {
                Class<PartitionResolver> resolverClass = (Class<PartitionResolver>) ClassPathLoader.getLatest().forName(partitionResolverClassName);
                PartitionResolver partitionResolver = resolverClass.newInstance();
            } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
                throw new IllegalArgumentException(CliStrings.format(CliStrings.CREATE_REGION__MSG__INVALID_PARTITION_RESOLVER, new Object[] { regionFunctionArgs.getCompressor() }), e);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) RegionShortcut(org.apache.geode.cache.RegionShortcut) ManagementService(org.apache.geode.management.ManagementService) RegionFunctionArgs(org.apache.geode.management.internal.cli.functions.RegionFunctionArgs) Compressor(org.apache.geode.compression.Compressor) PartitionResolver(org.apache.geode.cache.PartitionResolver) DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) ConverterHint(org.apache.geode.management.cli.ConverterHint) DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean)

Example 13 with DistributedRegionMXBean

use of org.apache.geode.management.DistributedRegionMXBean in project geode by apache.

the class DataCommands method getMemberRegionList.

private List<MemberPRInfo> getMemberRegionList(InternalCache cache, List<String> listExcludedRegion) {
    List<MemberPRInfo> listMemberPRInfo = new ArrayList<>();
    String[] listDSRegions = ManagementService.getManagementService(cache).getDistributedSystemMXBean().listRegions();
    final Set<DistributedMember> dsMembers = CliUtil.getAllMembers(cache);
    for (String regionName : listDSRegions) {
        // check for excluded regions
        boolean excludedRegionMatch = false;
        for (String aListExcludedRegion : listExcludedRegion) {
            // this is needed since region name may start with / or without it
            // also
            String excludedRegion = aListExcludedRegion.trim();
            if (regionName.startsWith("/")) {
                if (!excludedRegion.startsWith("/")) {
                    excludedRegion = "/" + excludedRegion;
                }
            }
            if (excludedRegion.startsWith("/")) {
                if (!regionName.startsWith("/")) {
                    regionName = "/" + regionName;
                }
            }
            if (excludedRegion.equals(regionName)) {
                excludedRegionMatch = true;
                break;
            }
        }
        if (excludedRegionMatch) {
            // ignore this region
            continue;
        }
        if (!regionName.startsWith("/")) {
            regionName = Region.SEPARATOR + regionName;
        }
        // remove this prefix /
        DistributedRegionMXBean bean = ManagementService.getManagementService(cache).getDistributedRegionMXBean(regionName);
        if (bean != null) {
            if (bean.getRegionType().equals(DataPolicy.PARTITION.toString()) || bean.getRegionType().equals(DataPolicy.PERSISTENT_PARTITION.toString())) {
                String[] memberNames = bean.getMembers();
                for (DistributedMember dsmember : dsMembers) {
                    for (String memberName : memberNames) {
                        if (MBeanJMXAdapter.getMemberNameOrId(dsmember).equals(memberName)) {
                            MemberPRInfo memberAndItsPRRegions = new MemberPRInfo();
                            memberAndItsPRRegions.region = regionName;
                            memberAndItsPRRegions.dsMemberList.add(dsmember);
                            if (listMemberPRInfo.contains(memberAndItsPRRegions)) {
                                // add member for appropriate region
                                int index = listMemberPRInfo.indexOf(memberAndItsPRRegions);
                                MemberPRInfo listMember = listMemberPRInfo.get(index);
                                listMember.dsMemberList.add(dsmember);
                            } else {
                                listMemberPRInfo.add(memberAndItsPRRegions);
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
    return listMemberPRInfo;
}
Also used : ArrayList(java.util.ArrayList) DistributedMember(org.apache.geode.distributed.DistributedMember) DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) ConverterHint(org.apache.geode.management.cli.ConverterHint)

Example 14 with DistributedRegionMXBean

use of org.apache.geode.management.DistributedRegionMXBean in project geode by apache.

the class DistributedRegionBridge method listSubRegionPaths.

/**
   * Lists the sub regions of the GemFire {@link Region} represented by this
   * {@link DistributedRegionMXBean}. If <code>recursive</code> is <code>true</code>, will return
   * sub-regions by traversing recursively.
   * 
   * @param recursive if <code>true</code>, recursively traverses to find sub regions.
   * @return String array of sub region paths
   */
public String[] listSubRegionPaths(boolean recursive) {
    String[] subRegionPathsArr = new String[0];
    Collection<RegionMXBean> proxies = mapOfProxy.values();
    // Need to go through all proxies as different proxies could have different sub-regions
    if (proxies != null && !proxies.isEmpty()) {
        SortedSet<String> subRegionPaths = new TreeSet<String>();
        for (RegionMXBean regionMXBean : proxies) {
            String[] listSubRegionPaths = regionMXBean.listSubregionPaths(recursive);
            // Little cosly, but how can it be
            subRegionPaths.addAll(Arrays.asList(listSubRegionPaths));
        // avoided?
        }
        subRegionPathsArr = subRegionPaths.toArray(subRegionPathsArr);
    }
    return subRegionPathsArr;
}
Also used : RegionMXBean(org.apache.geode.management.RegionMXBean) DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) TreeSet(java.util.TreeSet)

Example 15 with DistributedRegionMXBean

use of org.apache.geode.management.DistributedRegionMXBean in project geode by apache.

the class GemfireDataCommandsDUnitTest method setupForGetPutRemoveLocateEntry.

void setupForGetPutRemoveLocateEntry(String testName) {
    final VM vm1 = Host.getHost(0).getVM(1);
    final VM vm2 = Host.getHost(0).getVM(2);
    Properties props = new Properties();
    props.setProperty(NAME, testName + "Manager");
    HeadlessGfsh gfsh = setUpJmxManagerOnVm0ThenConnect(props);
    assertNotNull(gfsh);
    assertEquals(true, gfsh.isConnectedAndReady());
    vm1.invoke(new SerializableRunnable() {

        public void run() {
            InternalCache cache = getCache();
            RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
            Region dataRegion = regionFactory.create(DATA_REGION_NAME);
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            dataRegion = dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1, dataRegion.getAttributes());
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            dataRegion = dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1_2, dataRegion.getAttributes());
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            dataRegion = regionFactory.create(DATA_REGION_NAME_VM1);
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            PartitionAttributes partitionAttrs = new PartitionAttributesFactory().setRedundantCopies(2).create();
            RegionFactory<Object, Object> partitionRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
            partitionRegionFactory.setPartitionAttributes(partitionAttrs);
            Region dataParRegion = partitionRegionFactory.create(DATA_PAR_REGION_NAME);
            assertNotNull(dataParRegion);
            getLogWriter().info("Created Region " + dataParRegion);
            dataParRegion = partitionRegionFactory.create(DATA_PAR_REGION_NAME_VM1);
            assertNotNull(dataParRegion);
            getLogWriter().info("Created Region " + dataParRegion);
        }
    });
    vm2.invoke(new SerializableRunnable() {

        public void run() {
            InternalCache cache = getCache();
            RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE);
            Region dataRegion = regionFactory.create(DATA_REGION_NAME);
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            dataRegion = dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1, dataRegion.getAttributes());
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            dataRegion = dataRegion.createSubregion(DATA_REGION_NAME_CHILD_1_2, dataRegion.getAttributes());
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            dataRegion = regionFactory.create(DATA_REGION_NAME_VM2);
            assertNotNull(dataRegion);
            getLogWriter().info("Created Region " + dataRegion);
            PartitionAttributes partitionAttrs = new PartitionAttributesFactory().setRedundantCopies(2).create();
            RegionFactory<Object, Object> partitionRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
            partitionRegionFactory.setPartitionAttributes(partitionAttrs);
            Region dataParRegion = partitionRegionFactory.create(DATA_PAR_REGION_NAME);
            assertNotNull(dataParRegion);
            getLogWriter().info("Created Region " + dataParRegion);
            dataParRegion = partitionRegionFactory.create(DATA_PAR_REGION_NAME_VM2);
            assertNotNull(dataParRegion);
            getLogWriter().info("Created Region " + dataParRegion);
        }
    });
    final String vm1MemberId = vm1.invoke(() -> getMemberId());
    final String vm2MemberId = vm2.invoke(() -> getMemberId());
    getLogWriter().info("Vm1 ID : " + vm1MemberId);
    getLogWriter().info("Vm2 ID : " + vm2MemberId);
    final VM manager = Host.getHost(0).getVM(0);
    SerializableRunnable checkRegionMBeans = new SerializableRunnable() {

        @Override
        public void run() {
            InternalCache cache = getCache();
            final ManagementService service = ManagementService.getManagementService(cache);
            final WaitCriterion waitForMaangerMBean = new WaitCriterion() {

                @Override
                public boolean done() {
                    ManagerMXBean bean1 = service.getManagerMXBean();
                    DistributedRegionMXBean bean2 = service.getDistributedRegionMXBean(DATA_REGION_NAME_PATH);
                    if (bean1 == null) {
                        getLogWriter().info("Still probing for ManagerMBean");
                        return false;
                    } else {
                        getLogWriter().info("Still probing for DistributedRegionMXBean=" + bean2);
                        return (bean2 != null);
                    }
                }

                @Override
                public String description() {
                    return "Probing for ManagerMBean";
                }
            };
            waitForCriterion(waitForMaangerMBean, 30000, 2000, true);
            assertNotNull(service.getMemberMXBean());
            assertNotNull(service.getManagerMXBean());
            DistributedRegionMXBean bean = service.getDistributedRegionMXBean(DATA_REGION_NAME_PATH);
            assertNotNull(bean);
            WaitCriterion waitForRegionMBeans = new WaitCriterion() {

                @Override
                public boolean done() {
                    DistributedRegionMXBean[] beans = new DistributedRegionMXBean[6];
                    beans[0] = service.getDistributedRegionMXBean(DATA_REGION_NAME_PATH);
                    beans[1] = service.getDistributedRegionMXBean(DATA_REGION_NAME_VM1_PATH);
                    beans[2] = service.getDistributedRegionMXBean(DATA_REGION_NAME_VM2_PATH);
                    beans[3] = service.getDistributedRegionMXBean(DATA_PAR_REGION_NAME_PATH);
                    beans[4] = service.getDistributedRegionMXBean(DATA_PAR_REGION_NAME_VM1_PATH);
                    beans[5] = service.getDistributedRegionMXBean(DATA_PAR_REGION_NAME_VM2_PATH);
                    // SubRegion Bug : Proxy creation has some issues.
                    // beans[6] = service.getDistributedRegionMXBean(DATA_REGION_NAME_CHILD_1_PATH);
                    // beans[7] = service.getDistributedRegionMXBean(DATA_REGION_NAME_CHILD_1_2_PATH);
                    boolean flag = true;
                    for (DistributedRegionMXBean b : beans) {
                        if (b == null) {
                            flag = false;
                            break;
                        }
                    }
                    if (!flag) {
                        getLogWriter().info("Still probing for regionMbeans " + DATA_REGION_NAME_PATH + "=" + beans[0] + " " + DATA_REGION_NAME_VM1_PATH + "=" + beans[1] + " " + DATA_REGION_NAME_VM2_PATH + "=" + beans[2] + " " + DATA_PAR_REGION_NAME_PATH + "=" + beans[3] + " " + DATA_PAR_REGION_NAME_VM1_PATH + "=" + beans[4] + " " + DATA_PAR_REGION_NAME_VM2_PATH + "=" + beans[5] + " ");
                        return false;
                    } else {
                        getLogWriter().info("Probing complete for regionMbeans " + DATA_REGION_NAME_PATH + "=" + beans[0] + " " + DATA_REGION_NAME_VM1_PATH + "=" + beans[1] + " " + DATA_REGION_NAME_VM2_PATH + "=" + beans[2] + " " + DATA_PAR_REGION_NAME_PATH + "=" + beans[3] + " " + DATA_PAR_REGION_NAME_VM1_PATH + "=" + beans[4] + " " + DATA_PAR_REGION_NAME_VM2_PATH + "=" + beans[5] + " ");
                        // bean1.getMemberCount()==1)
                        return true;
                    // else{
                    // getLogWriter().info("Still probing for regionMbeans for aggregation bean1=" +
                    // bean1.getMemberCount() + " bean2="+ bean2.getMemberCount() + " bean3" +
                    // bean3.getMemberCount());
                    // return false;
                    // }
                    }
                }

                @Override
                public String description() {
                    return "Probing for regionMbeans";
                }
            };
            waitForCriterion(waitForRegionMBeans, 30000, 2000, true);
            String[] regions = { DATA_REGION_NAME_PATH, DATA_REGION_NAME_VM1_PATH, DATA_REGION_NAME_VM2_PATH, DATA_PAR_REGION_NAME_PATH, DATA_PAR_REGION_NAME_VM1_PATH, DATA_PAR_REGION_NAME_VM2_PATH };
            for (String region : regions) {
                bean = service.getDistributedRegionMXBean(region);
                assertNotNull(bean);
                String[] membersName = bean.getMembers();
                getLogWriter().info("Members Array for region " + region + " : " + StringUtils.objectToString(membersName, true, 10));
                if (bean.getMemberCount() < 1)
                    fail("Even after waiting mbean reports number of member hosting region " + DATA_REGION_NAME_VM1_PATH + " is less than one");
            // assertIndexDetailsEquals(1, membersName.length); //exists in one members vm1
            }
        }
    };
    manager.invoke(checkRegionMBeans);
}
Also used : HeadlessGfsh(org.apache.geode.management.internal.cli.HeadlessGfsh) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) InternalCache(org.apache.geode.internal.cache.InternalCache) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) ManagementService(org.apache.geode.management.ManagementService) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) RegionFactory(org.apache.geode.cache.RegionFactory) VM(org.apache.geode.test.dunit.VM) Region(org.apache.geode.cache.Region) ManagerMXBean(org.apache.geode.management.ManagerMXBean)

Aggregations

DistributedRegionMXBean (org.apache.geode.management.DistributedRegionMXBean)15 InternalCache (org.apache.geode.internal.cache.InternalCache)7 DistributedMember (org.apache.geode.distributed.DistributedMember)5 ManagementService (org.apache.geode.management.ManagementService)5 VM (org.apache.geode.test.dunit.VM)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 Cache (org.apache.geode.cache.Cache)3 ConverterHint (org.apache.geode.management.cli.ConverterHint)3 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)3 ManagerMXBean (org.apache.geode.management.ManagerMXBean)2 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)2 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)2 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)2 ErrorResultData (org.apache.geode.management.internal.cli.result.ErrorResultData)2 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)2 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)2