use of org.apache.geode.cache.Declarable 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);
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endLoadProbe.
/**
* When a <code>load-probe</code> element is encountered, create a new probe for the current
* <code>CacheServer</code>.
*
* @since GemFire 5.7
*/
private void endLoadProbe() {
Declarable d = createDeclarable();
if (!(d instanceof ServerLoadProbe)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "BridgeLoadProbe" }));
}
stack.push(d);
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endDeclarable.
/**
* When we have finished a <code>declarable</code>, instantiate an instance of the
* {@link Declarable}and push it on the stack.
*/
private void endDeclarable() {
Declarable d = createDeclarable();
stack.push(d);
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endPartitionResolver.
/**
* When a <code>partition-resolver</code> element is finished, the {@link Parameter}s and class
* names are popped off the stack. The <code>PartitionResolver</code> is instantiated and
* initialized with the parameters, if appropriate.
*/
private void endPartitionResolver() {
Declarable d = createDeclarable();
if (!(d instanceof PartitionResolver)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "PartitionResolver" }));
}
PartitionAttributesImpl pai = peekPartitionAttributesImpl(PARTITION_ATTRIBUTES);
pai.setPartitionResolver((PartitionResolver) d);
}
use of org.apache.geode.cache.Declarable in project geode by apache.
the class CacheXmlParser method endPartitionListener.
/**
* When a <code>partition-listener</code> element is finished, the {@link Parameter}s and class
* names are popped off the stack. The <code>PartitionListener</code> is instantiated and
* initialized with the parameters, if appropriate.
*/
private void endPartitionListener() {
Declarable d = createDeclarable();
if (!(d instanceof PartitionListener)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "PartitionListener" }));
}
PartitionAttributesImpl pai = peekPartitionAttributesImpl(PARTITION_ATTRIBUTES);
pai.addPartitionListener((PartitionListener) d);
}
Aggregations