Search in sources :

Example 1 with SizeClassOnceObjectSizer

use of org.apache.geode.internal.size.SizeClassOnceObjectSizer in project geode by apache.

the class CacheXmlGenerator method generate.

private void generate(EvictionAttributes ea) throws SAXException {
    EvictionAction eAction = ea.getAction();
    if (eAction.isNone()) {
        return;
    }
    AttributesImpl atts = new AttributesImpl();
    atts.addAttribute("", "", ACTION, "", eAction.toString());
    handler.startElement("", EVICTION_ATTRIBUTES, EVICTION_ATTRIBUTES, EMPTY);
    if (ea.getAlgorithm() == EvictionAlgorithm.LRU_ENTRY) {
        atts.addAttribute("", "", MAXIMUM, "", String.valueOf(ea.getMaximum()));
        handler.startElement("", LRU_ENTRY_COUNT, LRU_ENTRY_COUNT, atts);
        handler.endElement("", LRU_ENTRY_COUNT, LRU_ENTRY_COUNT);
    } else if (ea.getAlgorithm() == EvictionAlgorithm.LRU_MEMORY) {
        atts.addAttribute("", "", MAXIMUM, "", String.valueOf(ea.getMaximum()));
        handler.startElement("", LRU_MEMORY_SIZE, LRU_MEMORY_SIZE, atts);
        ObjectSizer os = ea.getObjectSizer();
        if (os != null && os != ObjectSizer.DEFAULT) {
            generate((Declarable) os, false);
        }
        handler.endElement("", LRU_MEMORY_SIZE, LRU_MEMORY_SIZE);
    } else if (ea.getAlgorithm() == EvictionAlgorithm.LRU_HEAP) {
        handler.startElement("", LRU_HEAP_PERCENTAGE, LRU_HEAP_PERCENTAGE, atts);
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_6_0) >= 0) {
            ObjectSizer os = ea.getObjectSizer();
            if (!(os instanceof SizeClassOnceObjectSizer)) {
                if (os != null) {
                    generate((Declarable) os, false);
                }
            }
        }
        handler.endElement("", LRU_HEAP_PERCENTAGE, LRU_HEAP_PERCENTAGE);
    } else {
    // all other algos are ignored
    }
    handler.endElement("", EVICTION_ATTRIBUTES, EVICTION_ATTRIBUTES);
}
Also used : EvictionAction(org.apache.geode.cache.EvictionAction) DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) Declarable(org.apache.geode.cache.Declarable) ObjectSizer(org.apache.geode.cache.util.ObjectSizer) SizeClassOnceObjectSizer(org.apache.geode.internal.size.SizeClassOnceObjectSizer) SizeClassOnceObjectSizer(org.apache.geode.internal.size.SizeClassOnceObjectSizer)

Aggregations

Declarable (org.apache.geode.cache.Declarable)1 EvictionAction (org.apache.geode.cache.EvictionAction)1 ObjectSizer (org.apache.geode.cache.util.ObjectSizer)1 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)1 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)1 SizeClassOnceObjectSizer (org.apache.geode.internal.size.SizeClassOnceObjectSizer)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1