Search in sources :

Example 1 with XmlNode

use of org.jgroups.conf.XmlNode in project JGroups by belaban.

the class RelayConfig method parseBridges.

protected static void parseBridges(SiteConfig site_config, XmlNode root) throws Exception {
    List<XmlNode> children = root.getChildren();
    if (children == null || children.isEmpty())
        return;
    for (XmlNode node : children) {
        String node_name = node.getName();
        match(BRIDGE, node_name);
        Map<String, String> attrs = node.getAttributes();
        if (attrs == null || attrs.isEmpty())
            continue;
        String name = attrs.get("name");
        String config = attrs.get("config");
        BridgeConfig bridge_config = new PropertiesBridgeConfig(name, config);
        site_config.addBridge(bridge_config);
    }
}
Also used : XmlNode(org.jgroups.conf.XmlNode)

Example 2 with XmlNode

use of org.jgroups.conf.XmlNode in project JGroups by belaban.

the class RelayConfig method parse.

public static void parse(XmlNode root, final Map<String, SiteConfig> map) throws Exception {
    match(RELAY_CONFIG, root.getName());
    List<XmlNode> children = root.getChildren();
    if (children == null || children.isEmpty())
        return;
    for (XmlNode node : children) {
        match(SITES, node.getName());
        parseSites(map, node);
    }
}
Also used : XmlNode(org.jgroups.conf.XmlNode)

Example 3 with XmlNode

use of org.jgroups.conf.XmlNode in project JGroups by belaban.

the class ForkConfig method parse.

public static Map<String, List<ProtocolConfiguration>> parse(XmlNode root) throws Exception {
    match(FORK_STACKS, root.getName());
    List<XmlNode> children = root.getChildren();
    if (children == null || children.isEmpty())
        return null;
    Map<String, List<ProtocolConfiguration>> map = new HashMap<>();
    for (XmlNode node : children) {
        match(FORK_STACK, node.getName());
        parseForkStack(map, node);
    }
    return map;
}
Also used : XmlNode(org.jgroups.conf.XmlNode) HashMap(java.util.HashMap) List(java.util.List)

Example 4 with XmlNode

use of org.jgroups.conf.XmlNode in project JGroups by belaban.

the class ForkConfig method parseForkStack.

protected static void parseForkStack(final Map<String, List<ProtocolConfiguration>> map, XmlNode root) throws Exception {
    List<XmlNode> children = root.getChildren();
    if (children == null || children.isEmpty())
        return;
    Map<String, String> attributes = root.getAttributes();
    String fork_stack_id = attributes.get(ID);
    if (map.containsKey(fork_stack_id))
        throw new IllegalStateException("duplicate fork-stack ID: \"" + fork_stack_id + "\"");
    for (XmlNode node : children) {
        List<ProtocolConfiguration> protocols = XmlConfigurator.parseProtocols(node);
        map.put(fork_stack_id, protocols);
    }
}
Also used : ProtocolConfiguration(org.jgroups.conf.ProtocolConfiguration) XmlNode(org.jgroups.conf.XmlNode)

Example 5 with XmlNode

use of org.jgroups.conf.XmlNode in project JGroups by belaban.

the class RelayConfig method parseSites.

protected static void parseSites(final Map<String, SiteConfig> map, XmlNode root) throws Exception {
    List<XmlNode> children = root.getChildren();
    if (children == null || children.isEmpty())
        return;
    for (XmlNode node : children) {
        match(SITE, node.getName());
        Map<String, String> attrs = node.getAttributes();
        if (attrs == null || attrs.isEmpty() || !attrs.containsKey("name"))
            throw new IllegalStateException(String.format("site must have a name (attrs: %s)", attrs));
        String site_name = attrs.get("name");
        if (map.containsKey(site_name))
            throw new Exception("Site \"" + site_name + "\" already defined");
        SiteConfig site_config = new SiteConfig(site_name);
        map.put(site_name, site_config);
        parseBridgesAndForwards(site_config, node);
    }
}
Also used : XmlNode(org.jgroups.conf.XmlNode)

Aggregations

XmlNode (org.jgroups.conf.XmlNode)8 HashMap (java.util.HashMap)1 List (java.util.List)1 ProtocolConfiguration (org.jgroups.conf.ProtocolConfiguration)1