Search in sources :

Example 11 with Declarable

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);
}
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)

Example 12 with Declarable

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);
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) ServerLoadProbe(org.apache.geode.cache.server.ServerLoadProbe)

Example 13 with Declarable

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);
}
Also used : Declarable(org.apache.geode.cache.Declarable)

Example 14 with Declarable

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);
}
Also used : FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) PartitionResolver(org.apache.geode.cache.PartitionResolver)

Example 15 with Declarable

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);
}
Also used : PartitionListener(org.apache.geode.cache.partition.PartitionListener) FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException)

Aggregations

Declarable (org.apache.geode.cache.Declarable)29 CacheXmlException (org.apache.geode.cache.CacheXmlException)22 Properties (java.util.Properties)5 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)4 ObjectSizer (org.apache.geode.cache.util.ObjectSizer)3 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)3 File (java.io.File)2 IOException (java.io.IOException)2 EmptyStackException (java.util.EmptyStackException)2 InternalGemFireException (org.apache.geode.InternalGemFireException)2 CacheException (org.apache.geode.cache.CacheException)2 CacheWriterException (org.apache.geode.cache.CacheWriterException)2 ExpirationAttributes (org.apache.geode.cache.ExpirationAttributes)2 GatewayException (org.apache.geode.cache.GatewayException)2 RegionExistsException (org.apache.geode.cache.RegionExistsException)2 TimeoutException (org.apache.geode.cache.TimeoutException)2 Function (org.apache.geode.cache.execute.Function)2 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)2 EvictionAttributesImpl (org.apache.geode.internal.cache.EvictionAttributesImpl)2 FixedPartitionAttributesImpl (org.apache.geode.internal.cache.FixedPartitionAttributesImpl)2