Skip to content

Commit

Permalink
[AS7-3623] implementation of the mod_cluster 1.1 Writer, added missin…
Browse files Browse the repository at this point in the history
…g 'balancer' in XSD, pretty prenting in Reader, TODO: tests
  • Loading branch information
rhusar committed Feb 7, 2012
1 parent 4fafc8b commit c7a46cd
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 95 deletions.
35 changes: 18 additions & 17 deletions build/src/main/resources/docs/schema/jboss-as-mod-cluster_1_1.xsd
Expand Up @@ -37,27 +37,27 @@
<xs:element name="advertise" type="advertiseType" minOccurs="0" maxOccurs="1"/>
<xs:element name="proxies" type="proxiesType" minOccurs="0" maxOccurs="1"/>
<xs:element name="contexts" type="contextsType" minOccurs="0" maxOccurs="1"/>

<!-- Simple load-provider or a dynamic one -->
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="simple-load-provider" type="simple-load-providerType"/>
<xs:element name="dynamic-load-provider" type="dynamic-load-providerType"/>
</xs:choice>

<!-- SSL configuration -->
<xs:element name="ssl" type="sslType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="sticky-sessionType" abstract="true">
<xs:attribute name="enable" type="xs:boolean" use="optional" default="true"/>
<xs:attribute name="force" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="remove" type="xs:boolean" use="optional" default="false"/>
</xs:complexType>

<!-- Example:
<advertise enable="true" socket-binding"modcluster" security-key="secureKey"/>
-->
-->
<xs:complexType name="advertiseType" abstract="true">
<xs:attribute name="enable" type="xs:boolean" use="optional" default="true"/>
<!-- Get the actual advertiseGroupAddress / advertisePort from advertiseSocket -->
Expand All @@ -70,29 +70,29 @@
-->
<xs:complexType name="proxiesType" abstract="true">
<xs:attribute name="url" type="xs:string" use="optional"/>
<xs:attribute name="node-timeout" type="xs:int" use="optional" default="-1">
<xs:attribute name="outbound-socket-bindings" type="xs:list" use="optional">
<xs:annotation>
<xs:documentation>Timeout (in seconds) for proxy connections to a node. That is the time mod_cluster will wait for the back-end response before returning error.</xs:documentation>
<xs:documentation>outbound-socket-binding groups for proxies.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ping" type="xs:int" use="optional" default="10">
<xs:attribute name="load-balancing-group" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Time (in seconds) in which to wait for a pong answer to a ping.</xs:documentation>
<xs:documentation>If specified, load will be balanced among jvmRoutes withing the same load balancing group. A loadBalancingGroup is conceptually equivalent to a mod_jk domain directive.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="socket-timeout" type="xs:int" use="optional" default="20">
<xs:attribute name="ping" type="xs:int" use="optional" default="10">
<xs:annotation>
<xs:documentation>Number of seconds to wait for a response from an httpd proxy to MCMP commands before timing out, and flagging the proxy as in error.</xs:documentation>
<xs:documentation>Time (in seconds) in which to wait for a pong answer to a ping.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="outbound-socket-bindings" type="xs:list" use="optional">
<xs:attribute name="node-timeout" type="xs:int" use="optional" default="-1">
<xs:annotation>
<xs:documentation>outbound-socket-binding groups for proxies</xs:documentation>
<xs:documentation>Timeout (in seconds) for proxy connections to a node. That is the time mod_cluster will wait for the back-end response before returning error.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="load-balancing-group" type="xs:string" use="optional">
<xs:attribute name="socket-timeout" type="xs:int" use="optional" default="20">
<xs:annotation>
<xs:documentation>If specified, load will be balanced among jvmRoutes withing the same load balancing group. A loadBalancingGroup is conceptually equivalent to a mod_jk domain directive.</xs:documentation>
<xs:documentation>Number of seconds to wait for a response from an httpd proxy to MCMP commands before timing out, and flagging the proxy as in error.</xs:documentation>
</xs:annotation>
</xs:attribute>

Expand Down Expand Up @@ -127,6 +127,7 @@
<xs:documentation>Time to live (in seconds) for idle connections above smax.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="balancer" type="xs:string" use="optional"/>
</xs:complexType>

<!-- Example:
Expand Down Expand Up @@ -229,8 +230,8 @@
</xs:restriction>
</xs:simpleType>

<!-- Example:
<simple-load-provider load="1"/>
<!-- Example:
<simple-load-provider load="1"/>
-->
<xs:complexType name="simple-load-providerType">
<xs:attribute name="factor" type="xs:int" use="optional" default="1" />
Expand Down
Expand Up @@ -34,29 +34,15 @@
import static org.jboss.as.modcluster.CommonAttributes.ADVERTISE_SOCKET;
import static org.jboss.as.modcluster.CommonAttributes.AUTO_ENABLE_CONTEXTS;
import static org.jboss.as.modcluster.CommonAttributes.BALANCER;
import static org.jboss.as.modcluster.CommonAttributes.CAPACITY;
import static org.jboss.as.modcluster.CommonAttributes.CA_CERTIFICATE_FILE;
import static org.jboss.as.modcluster.CommonAttributes.CA_REVOCATION_URL;
import static org.jboss.as.modcluster.CommonAttributes.CERTIFICATE_KEY_FILE;
import static org.jboss.as.modcluster.CommonAttributes.CIPHER_SUITE;
import static org.jboss.as.modcluster.CommonAttributes.CLASS;
import static org.jboss.as.modcluster.CommonAttributes.CUSTOM_LOAD_METRIC;
import static org.jboss.as.modcluster.CommonAttributes.DECAY;
import static org.jboss.as.modcluster.CommonAttributes.DOMAIN;
import static org.jboss.as.modcluster.CommonAttributes.DYNAMIC_LOAD_PROVIDER;
import static org.jboss.as.modcluster.CommonAttributes.EXCLUDED_CONTEXTS;
import static org.jboss.as.modcluster.CommonAttributes.FACTOR;
import static org.jboss.as.modcluster.CommonAttributes.FLUSH_PACKETS;
import static org.jboss.as.modcluster.CommonAttributes.FLUSH_WAIT;
import static org.jboss.as.modcluster.CommonAttributes.HISTORY;
import static org.jboss.as.modcluster.CommonAttributes.KEY_ALIAS;
import static org.jboss.as.modcluster.CommonAttributes.LOAD_METRIC;
import static org.jboss.as.modcluster.CommonAttributes.MAX_ATTEMPTS;
import static org.jboss.as.modcluster.CommonAttributes.MOD_CLUSTER_CONFIG;
import static org.jboss.as.modcluster.CommonAttributes.NODE_TIMEOUT;
import static org.jboss.as.modcluster.CommonAttributes.PASSWORD;
import static org.jboss.as.modcluster.CommonAttributes.PING;
import static org.jboss.as.modcluster.CommonAttributes.PROTOCOL;
import static org.jboss.as.modcluster.CommonAttributes.PROXY_LIST;
import static org.jboss.as.modcluster.CommonAttributes.PROXY_URL;
import static org.jboss.as.modcluster.CommonAttributes.SIMPLE_LOAD_PROVIDER;
Expand All @@ -68,28 +54,23 @@
import static org.jboss.as.modcluster.CommonAttributes.STICKY_SESSION_REMOVE;
import static org.jboss.as.modcluster.CommonAttributes.STOP_CONTEXT_TIMEOUT;
import static org.jboss.as.modcluster.CommonAttributes.TTL;
import static org.jboss.as.modcluster.CommonAttributes.TYPE;
import static org.jboss.as.modcluster.CommonAttributes.URL;
import static org.jboss.as.modcluster.CommonAttributes.WEIGHT;
import static org.jboss.as.modcluster.CommonAttributes.WORKER_TIMEOUT;

import java.util.Collections;
import java.util.List;

import javax.xml.stream.XMLStreamException;

import org.jboss.as.controller.parsing.ParseUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.staxmapper.XMLElementReader;
import org.jboss.staxmapper.XMLExtendedStreamReader;

/**
*
* @author Radoslav Husar
* @since AS 7.1.0.Final
*/
public class ModClusterSubsystemXMLReader_1_1 extends ModClusterSubsystemXMLReader_1_0 implements XMLElementReader<List<ModelNode>> {
public class ModClusterSubsystemXMLReader_1_1 extends ModClusterSubsystemXMLReader_1_0
implements XMLElementReader<List<ModelNode>> {

/**
* {@inheritDoc}
Expand Down Expand Up @@ -146,7 +127,7 @@ public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) th
}

// TODO Remove only for debug
System.out.println(config.toJSONString(false));
// System.out.println(config.toJSONString(false));
}
}

Expand Down Expand Up @@ -274,32 +255,4 @@ static void parseContexts(XMLExtendedStreamReader reader, ModelNode conf) throws
}
ParseUtils.requireNoContent(reader);
}

//// TODO >>>>
static ModelNode parseModClusterConfig(XMLExtendedStreamReader reader) throws XMLStreamException {
final ModelNode config = new ModelNode();
// Parse the attributes.
parsePropConf(reader, config);
// Parse the elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case SIMPLE_LOAD_PROVIDER:
final ModelNode load = parseSimpleLoadProvider(reader);
config.get(SIMPLE_LOAD_PROVIDER).set(load);
break;
case DYNAMIC_LOAD_PROVIDER:
final ModelNode dynload = parseDynamicLoadProvider(reader);
config.get(DYNAMIC_LOAD_PROVIDER).set(dynload);
break;
case SSL:
final ModelNode ssl = parseSSL(reader);
config.get(SSL).set(ssl);
break;
default:
throw unexpectedElement(reader);
}
}
return config;
}
}

0 comments on commit c7a46cd

Please sign in to comment.