Search in sources :

Example 1 with ServerLoadProbe

use of org.apache.geode.cache.server.ServerLoadProbe in project geode by apache.

the class CacheXmlGenerator method generate.

/**
   * Generates XML for the given cache server
   *
   * @since GemFire 4.0
   */
private void generate(CacheServer bridge) throws SAXException {
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_4_0) < 0) {
        return;
    }
    AttributesImpl atts = new AttributesImpl();
    try {
        if (generateDefaults() || bridge.getPort() != CacheServer.DEFAULT_PORT)
            atts.addAttribute("", "", PORT, "", String.valueOf(bridge.getPort()));
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_4_1) < 0) {
            return;
        }
        if (generateDefaults() || bridge.getMaximumTimeBetweenPings() != CacheServer.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS)
            atts.addAttribute("", "", MAXIMUM_TIME_BETWEEN_PINGS, "", String.valueOf(bridge.getMaximumTimeBetweenPings()));
        if (generateDefaults() || bridge.getNotifyBySubscription() != CacheServer.DEFAULT_NOTIFY_BY_SUBSCRIPTION)
            atts.addAttribute("", "", NOTIFY_BY_SUBSCRIPTION, "", String.valueOf(bridge.getNotifyBySubscription()));
        if (generateDefaults() || bridge.getSocketBufferSize() != CacheServer.DEFAULT_SOCKET_BUFFER_SIZE)
            atts.addAttribute("", "", SOCKET_BUFFER_SIZE, "", String.valueOf(bridge.getSocketBufferSize()));
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_0) < 0) {
            return;
        }
        if (generateDefaults() || bridge.getMaxConnections() != CacheServer.DEFAULT_MAX_CONNECTIONS)
            atts.addAttribute("", "", MAX_CONNECTIONS, "", String.valueOf(bridge.getMaxConnections()));
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_1) < 0) {
            return;
        }
        if (generateDefaults() || bridge.getMaxThreads() != CacheServer.DEFAULT_MAX_THREADS)
            atts.addAttribute("", "", MAX_THREADS, "", String.valueOf(bridge.getMaxThreads()));
        if (generateDefaults() || bridge.getMaximumMessageCount() != CacheServer.DEFAULT_MAXIMUM_MESSAGE_COUNT)
            atts.addAttribute("", "", MAXIMUM_MESSAGE_COUNT, "", String.valueOf(bridge.getMaximumMessageCount()));
        if (generateDefaults() || bridge.getMessageTimeToLive() != CacheServer.DEFAULT_MESSAGE_TIME_TO_LIVE) {
            atts.addAttribute("", "", MESSAGE_TIME_TO_LIVE, "", String.valueOf(bridge.getMessageTimeToLive()));
        }
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) < 0) {
            return;
        }
        if (bridge.getBindAddress() != null) {
            if (generateDefaults() || !CacheServer.DEFAULT_BIND_ADDRESS.equals(bridge.getBindAddress()))
                atts.addAttribute("", "", BIND_ADDRESS, "", bridge.getBindAddress());
        }
        if (bridge.getHostnameForClients() != null && !bridge.getHostnameForClients().equals("")) {
            atts.addAttribute("", "", HOSTNAME_FOR_CLIENTS, "", bridge.getHostnameForClients());
        }
        if (generateDefaults() || bridge.getLoadPollInterval() != CacheServer.DEFAULT_LOAD_POLL_INTERVAL)
            atts.addAttribute("", "", LOAD_POLL_INTERVAL, "", String.valueOf(bridge.getLoadPollInterval()));
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_8_0) < 0) {
            return;
        }
        if (generateDefaults() || bridge.getTcpNoDelay() != CacheServer.DEFAULT_TCP_NO_DELAY) {
            atts.addAttribute("", "", TCP_NO_DELAY, "", "" + bridge.getTcpNoDelay());
        }
    } finally {
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
            handler.startElement("", CACHE_SERVER, CACHE_SERVER, atts);
        } else {
            handler.startElement("", BRIDGE_SERVER, BRIDGE_SERVER, atts);
        }
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
            String[] groups = bridge.getGroups();
            if (groups.length > 0) {
                for (int i = 0; i < groups.length; i++) {
                    String group = groups[i];
                    handler.startElement("", GROUP, GROUP, EMPTY);
                    handler.characters(group.toCharArray(), 0, group.length());
                    handler.endElement("", GROUP, GROUP);
                }
            }
            if (!bridge.getClientSubscriptionConfig().getEvictionPolicy().equals("none")) {
                generateClientHaQueue(bridge);
            }
            ServerLoadProbe probe = bridge.getLoadProbe();
            if (generateDefaults() || !probe.equals(CacheServer.DEFAULT_LOAD_PROBE)) {
                generate(LOAD_PROBE, probe);
            }
        }
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
            handler.endElement("", "", CACHE_SERVER);
        } else {
            handler.endElement("", "", BRIDGE_SERVER);
        }
    }
}
Also used : DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) ServerLoadProbe(org.apache.geode.cache.server.ServerLoadProbe)

Example 2 with ServerLoadProbe

use of org.apache.geode.cache.server.ServerLoadProbe 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 3 with ServerLoadProbe

use of org.apache.geode.cache.server.ServerLoadProbe in project geode by apache.

the class CacheXmlParser method endCacheServer.

/**
   * set attributes from clientHaQueue when we finish a cache server
   */
private void endCacheServer() {
    List groups = new ArrayList();
    ServerLoadProbe probe = null;
    ClientHaQueueCreation haCreation = null;
    if (stack.peek() instanceof ServerLoadProbe) {
        probe = (ServerLoadProbe) stack.pop();
    }
    if (stack.peek() instanceof ClientHaQueueCreation) {
        haCreation = (ClientHaQueueCreation) stack.pop();
    }
    while (stack.peek() instanceof String) {
        groups.add(stack.pop());
    }
    CacheServer bs = (CacheServer) stack.pop();
    if (groups.size() > 0) {
        Collections.reverse(groups);
        String[] groupArray = new String[groups.size()];
        groups.toArray(groupArray);
        bs.setGroups(groupArray);
    }
    if (probe != null) {
        bs.setLoadProbe(probe);
    }
    if (haCreation != null) {
        ClientSubscriptionConfig csc = bs.getClientSubscriptionConfig();
        String diskStoreName = haCreation.getDiskStoreName();
        if (diskStoreName != null) {
            csc.setDiskStoreName(diskStoreName);
        } else {
            csc.setOverflowDirectory(haCreation.getOverflowDirectory() == null ? ClientSubscriptionConfig.DEFAULT_OVERFLOW_DIRECTORY : haCreation.getOverflowDirectory());
        }
        csc.setCapacity(haCreation.getCapacity());
        csc.setEvictionPolicy(haCreation.getEvictionPolicy());
    }
}
Also used : ArrayList(java.util.ArrayList) ServerLoadProbe(org.apache.geode.cache.server.ServerLoadProbe) ClientSubscriptionConfig(org.apache.geode.cache.server.ClientSubscriptionConfig) CacheServer(org.apache.geode.cache.server.CacheServer) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with ServerLoadProbe

use of org.apache.geode.cache.server.ServerLoadProbe in project geode by apache.

the class CacheServerBridge method fetchLoadProbe.

/** Get the load probe for this cache server **/
public ServerLoadData fetchLoadProbe() {
    ServerLoadProbe probe = cacheServer.getLoadProbe();
    ServerLoad load = probe.getLoad(new ServerMetricsImpl(cacheServer.getMaxConnections()));
    ServerLoadData data = new ServerLoadData(load.getConnectionLoad(), load.getSubscriptionConnectionLoad(), load.getLoadPerConnection(), load.getLoadPerSubscriptionConnection());
    return data;
}
Also used : ServerLoad(org.apache.geode.cache.server.ServerLoad) ServerLoadData(org.apache.geode.management.ServerLoadData) ServerLoadProbe(org.apache.geode.cache.server.ServerLoadProbe) ServerMetricsImpl(org.apache.geode.cache.server.internal.ServerMetricsImpl)

Aggregations

ServerLoadProbe (org.apache.geode.cache.server.ServerLoadProbe)4 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CacheXmlException (org.apache.geode.cache.CacheXmlException)1 Declarable (org.apache.geode.cache.Declarable)1 CacheServer (org.apache.geode.cache.server.CacheServer)1 ClientSubscriptionConfig (org.apache.geode.cache.server.ClientSubscriptionConfig)1 ServerLoad (org.apache.geode.cache.server.ServerLoad)1 ServerMetricsImpl (org.apache.geode.cache.server.internal.ServerMetricsImpl)1 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)1 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)1 ServerLoadData (org.apache.geode.management.ServerLoadData)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1