Search in sources :

Example 1 with RegionAttributesData

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

the class RegionMBeanCompositeDataFactory method getRegionAttributesData.

public static RegionAttributesData getRegionAttributesData(RegionAttributes regAttrs) {
    String cacheLoaderClassName = null;
    if (regAttrs.getCacheLoader() != null) {
        cacheLoaderClassName = regAttrs.getCacheLoader().getClass().getCanonicalName();
    }
    String cacheWriteClassName = null;
    if (regAttrs.getCacheWriter() != null) {
        cacheWriteClassName = regAttrs.getCacheWriter().getClass().getCanonicalName();
    }
    String keyConstraintClassName = null;
    if (regAttrs.getKeyConstraint() != null) {
        keyConstraintClassName = regAttrs.getKeyConstraint().getName();
    }
    String valueContstraintClassName = null;
    if (regAttrs.getValueConstraint() != null) {
        valueContstraintClassName = regAttrs.getValueConstraint().getName();
    }
    CacheListener[] listeners = regAttrs.getCacheListeners();
    String[] cacheListeners = null;
    if (listeners != null && listeners.length > 0) {
        cacheListeners = new String[listeners.length];
        int j = 0;
        for (CacheListener l : listeners) {
            cacheListeners[j] = l.getClass().getName();
            j++;
        }
    } else {
        cacheListeners = ManagementConstants.NO_DATA_STRING;
    }
    int regionTimeToLive = regAttrs.getRegionTimeToLive().getTimeout();
    int regionIdleTimeout = regAttrs.getRegionIdleTimeout().getTimeout();
    int entryTimeToLive = regAttrs.getEntryTimeToLive().getTimeout();
    int entryIdleTimeout = regAttrs.getEntryIdleTimeout().getTimeout();
    String customEntryTimeToLive = null;
    Object o1 = regAttrs.getCustomEntryTimeToLive();
    if (o1 != null) {
        customEntryTimeToLive = o1.toString();
    }
    String customEntryIdleTimeout = null;
    Object o2 = regAttrs.getCustomEntryIdleTimeout();
    if (o2 != null) {
        customEntryIdleTimeout = o2.toString();
    }
    boolean ignoreJTA = regAttrs.getIgnoreJTA();
    String dataPolicy = regAttrs.getDataPolicy().toString();
    String scope = regAttrs.getScope().toString();
    int initialCapacity = regAttrs.getInitialCapacity();
    float loadFactor = regAttrs.getLoadFactor();
    boolean lockGrantor = regAttrs.isLockGrantor();
    boolean multicastEnabled = regAttrs.getMulticastEnabled();
    int concurrencyLevel = regAttrs.getConcurrencyLevel();
    boolean indexMaintenanceSynchronous = regAttrs.getIndexMaintenanceSynchronous();
    boolean statisticsEnabled = regAttrs.getStatisticsEnabled();
    boolean subsciptionConflationEnabled = regAttrs.getEnableSubscriptionConflation();
    boolean asyncConflationEnabled = regAttrs.getEnableAsyncConflation();
    String poolName = regAttrs.getPoolName();
    boolean isCloningEnabled = regAttrs.getCloningEnabled();
    String diskStoreName = regAttrs.getDiskStoreName();
    String interestPolicy = null;
    if (regAttrs.getSubscriptionAttributes() != null) {
        interestPolicy = regAttrs.getSubscriptionAttributes().getInterestPolicy().toString();
    }
    String compressorClassName = null;
    if (regAttrs.getCompressor() != null) {
        compressorClassName = regAttrs.getCompressor().getClass().getCanonicalName();
    }
    boolean diskSynchronus = regAttrs.isDiskSynchronous();
    boolean offheap = regAttrs.getOffHeap();
    RegionAttributesData regionAttributesData = new RegionAttributesData(cacheLoaderClassName, cacheWriteClassName, keyConstraintClassName, valueContstraintClassName, regionTimeToLive, regionIdleTimeout, entryTimeToLive, entryIdleTimeout, customEntryTimeToLive, customEntryIdleTimeout, ignoreJTA, dataPolicy, scope, initialCapacity, loadFactor, lockGrantor, multicastEnabled, concurrencyLevel, indexMaintenanceSynchronous, statisticsEnabled, subsciptionConflationEnabled, asyncConflationEnabled, poolName, isCloningEnabled, diskStoreName, interestPolicy, diskSynchronus, cacheListeners, compressorClassName, offheap);
    return regionAttributesData;
}
Also used : RegionAttributesData(org.apache.geode.management.RegionAttributesData) CacheListener(org.apache.geode.cache.CacheListener)

Example 2 with RegionAttributesData

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

the class CreateAlterDestroyRegionCommands method isClusterWideSameConfig.

private static boolean isClusterWideSameConfig(InternalCache 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;
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) ManagementService(org.apache.geode.management.ManagementService) RegionAttributesData(org.apache.geode.management.RegionAttributesData) DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) RegionMXBean(org.apache.geode.management.RegionMXBean) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) CommandResultException(org.apache.geode.management.internal.cli.result.CommandResultException) MalformedObjectNameException(javax.management.MalformedObjectNameException) ObjectName(javax.management.ObjectName)

Example 3 with RegionAttributesData

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

the class CreateAlterDestroyRegionCommands method findMembersForRegion.

private Set<DistributedMember> findMembersForRegion(InternalCache cache, ManagementService managementService, String regionPath) {
    Set<DistributedMember> membersList = new HashSet<>();
    Set<String> regionMemberIds = new HashSet<>();
    MBeanServer mbeanServer = MBeanJMXAdapter.mbeanServer;
    // needs to be escaped with quotes if it contains a hyphen
    if (regionPath.contains("-")) {
        regionPath = "\"" + regionPath + "\"";
    }
    String queryExp = MessageFormat.format(MBeanJMXAdapter.OBJECTNAME__REGION_MXBEAN, regionPath, "*");
    try {
        ObjectName queryExpON = new ObjectName(queryExp);
        Set<ObjectName> queryNames = mbeanServer.queryNames(null, queryExpON);
        if (queryNames == null || queryNames.isEmpty()) {
            // protects against null pointer exception below
            return membersList;
        }
        boolean addedOneRemote = false;
        for (ObjectName regionMBeanObjectName : queryNames) {
            try {
                RegionMXBean regionMXBean = managementService.getMBeanInstance(regionMBeanObjectName, RegionMXBean.class);
                if (regionMXBean != null) {
                    RegionAttributesData regionAttributes = regionMXBean.listRegionAttributes();
                    String scope = regionAttributes.getScope();
                    // propagated.
                    if (Scope.LOCAL.equals(Scope.fromString(scope))) {
                        regionMemberIds.add(regionMXBean.getMember());
                    } else {
                        if (!addedOneRemote) {
                            regionMemberIds.add(regionMXBean.getMember());
                            addedOneRemote = true;
                        }
                    }
                }
            } catch (ClassCastException e) {
                LogWriter logger = cache.getLogger();
                if (logger.finerEnabled()) {
                    logger.finer(regionMBeanObjectName + " is not a " + RegionMXBean.class.getSimpleName(), e);
                }
            }
        }
        if (!regionMemberIds.isEmpty()) {
            membersList = getMembersByIds(cache, regionMemberIds);
        }
    } catch (MalformedObjectNameException | NullPointerException e) {
        LogWrapper.getInstance().info(e.getMessage(), e);
    }
    return membersList;
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) RegionMXBean(org.apache.geode.management.RegionMXBean) RegionAttributesData(org.apache.geode.management.RegionAttributesData) ObjectName(javax.management.ObjectName) LogWriter(org.apache.geode.LogWriter) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) HashSet(java.util.HashSet) MBeanServer(javax.management.MBeanServer)

Aggregations

RegionAttributesData (org.apache.geode.management.RegionAttributesData)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 ObjectName (javax.management.ObjectName)2 DistributedMember (org.apache.geode.distributed.DistributedMember)2 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)2 DistributedRegionMXBean (org.apache.geode.management.DistributedRegionMXBean)2 RegionMXBean (org.apache.geode.management.RegionMXBean)2 HashSet (java.util.HashSet)1 MBeanServer (javax.management.MBeanServer)1 LogWriter (org.apache.geode.LogWriter)1 CacheListener (org.apache.geode.cache.CacheListener)1 DistributedSystemMXBean (org.apache.geode.management.DistributedSystemMXBean)1 ManagementService (org.apache.geode.management.ManagementService)1 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)1