Search in sources :

Example 1 with InterestPolicy

use of org.apache.geode.cache.InterestPolicy in project geode by apache.

the class NotificationForwarder method collectAllRegionsDetails.

/**
   * Collects all the region details from the RegionSubRegionSnapshot instance passed and the Cache
   * MBean. Checks in the set of existingRegionMbeans before initializing Region Mbeans if there are
   * not initialized yet.
   * 
   * @param cache Cache MBean instance
   * @param regionSnapshot RegionSubRegionSnapshot instance
   * @param regionsInfo Map of regions information that gets populated recursively
   * @param existingRegionMbeans Map of ObjectNames of existing region MBeans
   * @throws AdminException if unable to initialize region MBean
   * @throws OperationsException if fails to retrieve the Region MBean attribute info
   * @throws MBeanException if fails to retrieve the Region MBean attribute info
   * @throws ReflectionException if fails to retrieve the Region MBean attribute info
   */
@SuppressWarnings("rawtypes")
private void collectAllRegionsDetails(SystemMemberCacheJmxImpl cache, RegionSubRegionSnapshot regionSnapshot, Map<String, Map<String, ?>> regionsInfo, Map<String, ObjectName> existingRegionMbeans) throws AdminException, OperationsException, MBeanException, ReflectionException {
    String fullPath = regionSnapshot.getFullPath();
    if (!fullPath.equals(PLACE_HOLDER_ROOT_REGION)) {
        fullPath = fullPath.substring(PLACE_HOLDER_ROOT_REGION.length() - 1);
        String name = regionSnapshot.getName();
        Integer entryCount = Integer.valueOf(regionSnapshot.getEntryCount());
        Map<String, Object> details = new TreeMap<String, Object>();
        details.put(REGION_NAME, name);
        details.put(REGION_PATH, fullPath);
        details.put(REGION_ENTRYCOUNT, entryCount);
        ObjectName regionObjectName = existingRegionMbeans.get(fullPath);
        if (regionObjectName == null) {
            // initialize if has not yet been
            regionObjectName = cache.manageRegion(fullPath);
        }
        Object attribute = getAttribute(regionObjectName, "scope", NOT_AVAILABLE);
        attribute = attribute != null ? attribute.toString() : attribute;
        details.put(REGION_SCOPE, attribute);
        attribute = getAttribute(regionObjectName, "dataPolicy", NOT_AVAILABLE);
        attribute = attribute != null ? attribute.toString() : attribute;
        details.put(REGION_DATAPOLICY, attribute);
        SubscriptionAttributes interestPolicyAttr = (SubscriptionAttributes) getAttribute(regionObjectName, "subscriptionAttributes", null);
        String interestPolicyStr = NOT_AVAILABLE;
        if (interestPolicyAttr != null) {
            InterestPolicy interestPolicy = interestPolicyAttr.getInterestPolicy();
            if (interestPolicy != null) {
                interestPolicyStr = interestPolicy.toString();
            }
        }
        details.put(REGION_INTERESTPOLICY, interestPolicyStr);
        attribute = getAttribute(regionObjectName, "diskWriteAttributes", NOT_AVAILABLE);
        attribute = attribute != null ? attribute.toString() : attribute;
        details.put(REGION_DISKATTRS, attribute);
        regionsInfo.put(fullPath, details);
    }
    Set subRegionSnapshots = regionSnapshot.getSubRegionSnapshots();
    for (Iterator iterator = subRegionSnapshots.iterator(); iterator.hasNext(); ) {
        RegionSubRegionSnapshot subRegion = (RegionSubRegionSnapshot) iterator.next();
        collectAllRegionsDetails(cache, subRegion, regionsInfo, existingRegionMbeans);
    }
}
Also used : InterestPolicy(org.apache.geode.cache.InterestPolicy) SubscriptionAttributes(org.apache.geode.cache.SubscriptionAttributes)

Example 2 with InterestPolicy

use of org.apache.geode.cache.InterestPolicy in project geode by apache.

the class CacheXmlGenerator method generate.

/**
   * Generates XML for <code>SubscriptionAttributes</code>
   */
private void generate(SubscriptionAttributes attrs) throws SAXException {
    if (attrs == null) {
        return;
    }
    String interestString = null;
    InterestPolicy ip = attrs.getInterestPolicy();
    AttributesImpl atts = new AttributesImpl();
    if (ip.isAll()) {
        interestString = ALL;
    } else if (ip.isCacheContent()) {
        interestString = CACHE_CONTENT;
    } else {
        throw new InternalGemFireException(LocalizedStrings.CacheXmlGenerator_UNKNOWN_INTERESTPOLICY_0.toLocalizedString(ip));
    }
    atts.addAttribute("", "", INTEREST_POLICY, "", interestString);
    handler.startElement("", SUBSCRIPTION_ATTRIBUTES, SUBSCRIPTION_ATTRIBUTES, atts);
    handler.endElement("", SUBSCRIPTION_ATTRIBUTES, SUBSCRIPTION_ATTRIBUTES);
}
Also used : DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) InternalGemFireException(org.apache.geode.InternalGemFireException) InterestPolicy(org.apache.geode.cache.InterestPolicy)

Aggregations

InterestPolicy (org.apache.geode.cache.InterestPolicy)2 InternalGemFireException (org.apache.geode.InternalGemFireException)1 SubscriptionAttributes (org.apache.geode.cache.SubscriptionAttributes)1 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)1 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1