geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r594117 [1/2] - in /geronimo/server/trunk: assemblies/geronimo-jetty6-javaee5/src/main/assembly/ assemblies/geronimo-jetty6-javaee5/src/main/resources/cluster-repository/ assemblies/geronimo-jetty6-javaee5/src/main/resources/master-reposito...
Date Mon, 12 Nov 2007 13:35:51 GMT
Author: gdamour
Date: Mon Nov 12 05:35:48 2007
New Revision: 594117

URL: http://svn.apache.org/viewvc?rev=594117&view=rev
Log:
Add support for:
* static configuration of cluster members: this is the purpose of the
o.a.g.c.config package. BasicClusterInfo is used to statically configure
a cluster. At this stage, only the name of the cluster can be defined. 
BasicNodeInfo is used to statically configure a cluster member. This 
configuration encompasses the name of a member along with the necessary
JMX connection info, abstracted by ExtendedJMXConnectorInfo, in order
to connect to it.
* clustered deployments of configuration: this is the purpose of the
o.a.g.c.deployment package. MasterConfigurationStore abstracts a clustered
repository: when a configuration is installed to it, it cascades to the
cluster members, statically configured, the installation of this 
configuration. Also, it automcallically creates "master" configurations,
which are able to remote start or stop the configurations cascaded to
cluster members..
* clustered start/stop of configuration: also in o.a.g.c.deployment. 
ClusterConfigurationController is a GBean, which knows how to remote
start or stop a given configuration on a given cluster member.

Following this commit, two new repositories will be listed for the 
geronimo-jetty6-jee5 assembly: master-repository and cluster-repository.
master-repository is a repository where the "master" configurations will
be maintained along with a carbon-copy of the associated "raw" configurations.
cluster-repository is a repository, which is a target of the 
MastConfigurationStore.

This fixes GERONIMO-3597 - Distribution and start/stop of clustered deployments

Added:
    geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/cluster-repository/
    geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/cluster-repository/EMPTY
    geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/master-repository/
    geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/master-repository/EMPTY
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicClusterInfo.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicExtendedJMXConnectorInfo.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicNodeInfo.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ClusterInfo.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ExtendedJMXConnectorInfo.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/NodeInfo.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationController.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStore.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClient.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilder.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationController.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStore.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStoreClient.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/DirectoryPackager.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStore.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ZipDirectoryPackager.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationControllerTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClientTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilderTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStoreTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/ZipDirectoryPackagerTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/resources/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/resources/folderToZip/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/resources/folderToZip/folder1/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/resources/folderToZip/folder1/file1
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/resources/folderToZip/folder1/file2
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/resources/folderToZip/folder2/
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/resources/folderToZip/folder2/file1
Modified:
    geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/assembly/bin.xml
    geronimo/server/trunk/plugins/clustering/clustering/pom.xml
    geronimo/server/trunk/plugins/clustering/clustering/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/pom.xml

Modified: geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/assembly/bin.xml?rev=594117&r1=594116&r2=594117&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/assembly/bin.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/assembly/bin.xml Mon Nov 12 05:35:48 2007
@@ -156,6 +156,22 @@
         </fileSet>
         
         <fileSet>
+            <directory>src/main/resources/cluster-repository</directory>
+            <outputDirectory>cluster-repository</outputDirectory>
+            <includes>
+                <include>*</include>
+            </includes>
+        </fileSet>
+
+        <fileSet>
+            <directory>src/main/resources/master-repository</directory>
+            <outputDirectory>master-repository</outputDirectory>
+            <includes>
+                <include>*</include>
+            </includes>
+        </fileSet>
+
+        <fileSet>
             <directory>target/classes</directory>
             <outputDirectory>/</outputDirectory>
             <includes>

Added: geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/cluster-repository/EMPTY
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/cluster-repository/EMPTY?rev=594117&view=auto
==============================================================================
    (empty)

Added: geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/master-repository/EMPTY
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/src/main/resources/master-repository/EMPTY?rev=594117&view=auto
==============================================================================
    (empty)

Modified: geronimo/server/trunk/plugins/clustering/clustering/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/clustering/pom.xml?rev=594117&r1=594116&r2=594117&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/clustering/pom.xml (original)
+++ geronimo/server/trunk/plugins/clustering/clustering/pom.xml Mon Nov 12 05:35:48 2007
@@ -56,6 +56,18 @@
             <artifactId>geronimo-clustering</artifactId>
             <version>${version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-deploy-config</artifactId>
+            <version>${version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-deploy-jsr88</artifactId>
+            <version>${version}</version>
+        </dependency>
     </dependencies>
 
     <build>
@@ -75,8 +87,12 @@
                                 <gbean name="Node">
                                     <attribute name="nodeName">#{clusterNodeName}</attribute>
                                 </gbean>
+                                <gbean name="ClusterInfo">
+                                    <attribute name="name">#{clusterName}</attribute>
+                                </gbean>
                             </config-xml-content>
                             <config-substitution key="clusterNodeName">NODE</config-substitution>
+                            <config-substitution key="clusterName">CLUSTER_NAME</config-substitution>
                         </plugin-artifact>
                     </instance>
                 </configuration>

Modified: geronimo/server/trunk/plugins/clustering/clustering/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/clustering/src/main/plan/plan.xml?rev=594117&r1=594116&r2=594117&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/clustering/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/clustering/clustering/src/main/plan/plan.xml Mon Nov 12 05:35:48 2007
@@ -27,4 +27,78 @@
         </reference>
     </gbean>
 
+    <gbean name="MasterRepository" class="org.apache.geronimo.system.repository.Maven2Repository">
+        <attribute name="root">master-repository/</attribute>
+        <reference name="ServerInfo">
+            <name>ServerInfo</name>
+        </reference>
+    </gbean>
+
+    <gbean name="MasterConfigurationStore" class="org.apache.geronimo.clustering.deployment.MasterConfigurationStore">
+        <xml-attribute name="defaultEnvironment">
+            <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
+                <dependencies>
+                    <dependency>
+                        <groupId>${pom.groupId}</groupId>
+                        <artifactId>clustering</artifactId>
+                        <type>car</type>
+                    </dependency>
+                </dependencies>
+            </environment>
+        </xml-attribute>
+        <reference name="Repository">
+            <name>MasterRepository</name>
+        </reference>
+        <reference name="ClusterInfo">
+            <name>ClusterInfo</name>
+        </reference>
+        <reference name="ClusterConfigurationStoreClient">
+            <name>ClusterConfigurationStoreClient</name>
+        </reference>
+    </gbean>
+
+    <gbean name="ClusterConfigurationStoreClient" class="org.apache.geronimo.clustering.deployment.BasicClusterConfigurationStoreClient">
+        <attribute name="clusterConfigurationStoreNameQuery">?name=ClusterConfigurationStore</attribute>
+    </gbean>
+
+    <gbean name="ClusterRepository" class="org.apache.geronimo.system.repository.Maven2Repository">
+        <attribute name="root">cluster-repository/</attribute>
+        <reference name="ServerInfo">
+            <name>ServerInfo</name>
+        </reference>
+    </gbean>
+
+    <gbean name="ClusterStore" class="org.apache.geronimo.system.configuration.RepositoryConfigurationStore">
+        <reference name="Repository">
+            <name>ClusterRepository</name>
+        </reference>
+    </gbean>
+
+    <gbean name="ClusterConfigurationStore" class="org.apache.geronimo.clustering.deployment.BasicClusterConfigurationStore">
+        <reference name="ConfigurationStore">
+            <name>ClusterStore</name>
+        </reference>
+    </gbean>
+
+    <!-- Static Cluster Configuration -->
+    <gbean name="ClusterInfo" class="org.apache.geronimo.clustering.config.BasicClusterInfo">
+        <attribute name="name">${PlanClusterName}</attribute>
+        <reference name="NodeInfos"></reference>
+    </gbean>
+
+    <gbean name="NodeInfo" class="org.apache.geronimo.clustering.config.BasicNodeInfo">
+          <attribute name="name">NodeName</attribute>
+          <xml-attribute name="extendedJMXConnectorInfo">
+              <ns:javabean xmlns:ns="http://geronimo.apache.org/xml/ns/deployment/javabean-1.0" class="org.apache.geronimo.clustering.config.BasicExtendedJMXConnectorInfo">
+                  <ns:property name="username">system</ns:property>
+                  <ns:property name="password">manager</ns:property>
+                  <ns:property name="protocol">rmi</ns:property>
+                  <ns:property name="host">localhost</ns:property>
+                  <ns:property name="port">1099</ns:property>
+                  <ns:property name="urlPath">JMXConnector</ns:property>
+                  <ns:property name="local">true</ns:property>
+              </ns:javabean>
+          </xml-attribute>
+      </gbean>
+
 </module>

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/pom.xml?rev=594117&r1=594116&r2=594117&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/pom.xml (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/pom.xml Mon Nov 12 05:35:48 2007
@@ -35,7 +35,7 @@
     <dependencies>
         <dependency>
             <groupId>${pom.groupId}</groupId>
-            <artifactId>geronimo-system</artifactId>
+            <artifactId>geronimo-deploy-jsr88</artifactId>
             <version>${version}</version>
         </dependency>
 

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicClusterInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicClusterInfo.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicClusterInfo.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicClusterInfo.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.config;
+
+import java.util.Collection;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicClusterInfo implements ClusterInfo {
+    private final String name;
+    private final Collection<NodeInfo> nodes;
+
+    public BasicClusterInfo(String name, Collection<NodeInfo> nodes) {
+        if (null == name) {
+            throw new IllegalArgumentException("name is required");
+        } else if (null == nodes) {
+            throw new IllegalArgumentException("nodes is required");
+        }
+        this.name = name;
+        this.nodes = nodes;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Collection<NodeInfo> getNodeInfos() {
+        return nodes;
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static final String GBEAN_J2EE_TYPE = "ClusterInfo";
+    public static final String GBEAN_ATTR_CLUSTER_NAME = "name";
+    public static final String GBEAN_REF_NODE_INFOS = "NodeInfos";
+    
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(BasicClusterInfo.class, GBEAN_J2EE_TYPE);
+        builder.addAttribute(GBEAN_ATTR_CLUSTER_NAME, String.class, true);
+        builder.addReference(GBEAN_REF_NODE_INFOS, NodeInfo.class, "NodeInfo");
+        builder.addInterface(ClusterInfo.class);
+        builder.setConstructor(new String[]{GBEAN_ATTR_CLUSTER_NAME, GBEAN_REF_NODE_INFOS});
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+    
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicExtendedJMXConnectorInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicExtendedJMXConnectorInfo.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicExtendedJMXConnectorInfo.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicExtendedJMXConnectorInfo.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.config;
+
+import java.io.Serializable;
+import java.net.InetSocketAddress;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicExtendedJMXConnectorInfo implements ExtendedJMXConnectorInfo, Serializable {
+    private String username;
+    private String password;
+    private String protocol;
+    private String host;
+    private int port = -1;
+    private String urlPath;
+    private boolean local;
+    
+    public String getHost() {
+        return host;
+    }
+
+    public InetSocketAddress getListenAddress() {
+        return new InetSocketAddress(host, port);
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public String getProtocol() {
+        return protocol;
+    }
+
+    public String getUrlPath() {
+        return urlPath;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public void setProtocol(String protocol) {
+        this.protocol = protocol;
+    }
+
+    public void setUrlPath(String urlPath) {
+        this.urlPath = urlPath;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public boolean isLocal() {
+        return local;
+    }
+
+    public void setLocal(boolean local) {
+        this.local = local;
+    }
+
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicNodeInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicNodeInfo.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicNodeInfo.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/BasicNodeInfo.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.config;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.system.jmx.KernelDelegate;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicNodeInfo implements NodeInfo {
+    private final String name;
+    private final ExtendedJMXConnectorInfo connectorInfo;
+    private final Kernel kernel;
+
+    public BasicNodeInfo(Kernel kernel, String name, ExtendedJMXConnectorInfo connectorInfo) {
+        if (null == kernel) {
+            throw new IllegalArgumentException("kernel is required");
+        } else if (null == name) {
+            throw new IllegalArgumentException("name is required");
+        } else if (null == connectorInfo) {
+            throw new IllegalArgumentException("connectorInfo is required");
+        }
+        this.kernel = kernel;
+        this.name = name;
+        this.connectorInfo = connectorInfo;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public ExtendedJMXConnectorInfo getConnectorInfo() {
+        return connectorInfo;
+    }
+
+    public Kernel newKernel() throws IOException {
+        if (connectorInfo.isLocal()) {
+            return kernel;
+        }
+        
+        String url = "service:jmx:rmi://" + connectorInfo.getHost() + "/jndi/"
+                        + connectorInfo.getProtocol() + "://" + connectorInfo.getHost() + ":"
+                        + connectorInfo.getPort() + "/" + connectorInfo.getUrlPath();
+
+        Map environment = new HashMap();
+        environment.put("jmx.remote.credentials",
+            new String[] {connectorInfo.getUsername(), connectorInfo.getPassword()});
+
+        return newKernel(url, environment);
+    }
+
+    protected Kernel newKernel(String url, Map environment) throws IOException {
+        JMXConnector jmxConnector = JMXConnectorFactory.connect(new JMXServiceURL(url), environment);
+        MBeanServerConnection mbServerConnection = jmxConnector.getMBeanServerConnection();
+        return new KernelDelegate(mbServerConnection);
+    }
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static final String GBEAN_J2EE_TYPE = "NodeInfo";
+    public static final String GBEAN_ATTR_KERNEL = "kernel";
+    public static final String GBEAN_ATTR_NODE_NAME = "name";
+    public static final String GBEAN_ATTR_EXT_JMX_CONN_INFO = "extendedJMXConnectorInfo";
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(BasicNodeInfo.class, GBEAN_J2EE_TYPE);
+
+        builder.addAttribute(GBEAN_ATTR_KERNEL, Kernel.class, false);
+        builder.addAttribute(GBEAN_ATTR_NODE_NAME, String.class, true);
+        builder.addAttribute(GBEAN_ATTR_EXT_JMX_CONN_INFO, ExtendedJMXConnectorInfo.class, true);
+        
+        builder.addInterface(NodeInfo.class);
+        
+        builder.setConstructor(new String[]{GBEAN_ATTR_KERNEL,
+            GBEAN_ATTR_NODE_NAME,
+            GBEAN_ATTR_EXT_JMX_CONN_INFO});
+
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ClusterInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ClusterInfo.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ClusterInfo.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ClusterInfo.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.config;
+
+import java.util.Collection;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface ClusterInfo {
+    String getName();
+
+    Collection<NodeInfo> getNodeInfos();
+}
\ No newline at end of file

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ExtendedJMXConnectorInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ExtendedJMXConnectorInfo.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ExtendedJMXConnectorInfo.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/ExtendedJMXConnectorInfo.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.config;
+
+import java.io.Serializable;
+
+import org.apache.geronimo.jmxremoting.JMXConnectorInfo;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface ExtendedJMXConnectorInfo extends JMXConnectorInfo, Serializable {
+    String getUsername();
+    
+    void setUsername(String username);
+    
+    String getPassword();
+    
+    void setPassword(String password);
+    
+    boolean isLocal();
+
+    void setLocal(boolean local);
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/NodeInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/NodeInfo.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/NodeInfo.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/config/NodeInfo.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.config;
+
+import java.io.IOException;
+
+import org.apache.geronimo.kernel.Kernel;
+
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface NodeInfo {
+    String getName();
+
+    ExtendedJMXConnectorInfo getConnectorInfo();
+    
+    Kernel newKernel() throws IOException;
+}
\ No newline at end of file

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationController.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationController.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationController.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationController.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.clustering.config.ClusterInfo;
+import org.apache.geronimo.clustering.config.NodeInfo;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicClusterConfigurationController implements GBeanLifecycle, ClusterConfigurationController {
+    private static final Log log = LogFactory.getLog(BasicClusterConfigurationController.class);
+    
+    private final ClusterInfo clusterInfo;
+    private final String nodeName;
+    private final Artifact artifact;
+    private boolean startConfigurationUponStart;
+    private boolean ignoreStartConfigurationFailureUponStart;
+
+    public BasicClusterConfigurationController(ClusterInfo clusterInfo,
+            String nodeName,
+            Artifact artifact,
+            boolean startConfigurationUponStart,
+            boolean ignoreStartConfigurationFailureUponStart) {
+        if (null == clusterInfo) {
+            throw new IllegalArgumentException("clusterInfo is required");
+        } else if (null == nodeName) {
+            throw new IllegalArgumentException("nodeName is required");
+        } else if (null == artifact) {
+            throw new IllegalArgumentException("artifact is required");
+        }
+        this.clusterInfo = clusterInfo;
+        this.nodeName = nodeName;
+        this.artifact = artifact;
+        this.startConfigurationUponStart = startConfigurationUponStart;
+        this.ignoreStartConfigurationFailureUponStart = ignoreStartConfigurationFailureUponStart;
+    }
+
+    public void doStart() throws Exception {
+        if (startConfigurationUponStart) {
+            try {
+                startConfiguration();
+            } catch (Exception e) {
+                if (ignoreStartConfigurationFailureUponStart) {
+                    log.info("Exception while starting configuration [" + artifact + "] on [" + nodeName
+                        + "]. Ignoring.", e);
+                } else {
+                    log.error("Exception while starting configuration [" + artifact + "] on [" + nodeName + "].", e);
+                    throw e;
+                }
+            }
+        }
+    }
+    
+    public void doFail() {
+        try {
+            stopConfiguration();
+        } catch (Exception e) {
+            log.error("Exception while stopping configuration [" + artifact + "] on [" + nodeName + "].", e);
+        }
+    }
+
+    public void doStop() throws Exception {
+        try {
+            stopConfiguration();
+        } catch (Exception e) {
+            log.error("Exception while stopping configuration [" + artifact + "] on [" + nodeName + "].", e);
+            throw e;
+        }
+    }
+
+    public void startConfiguration() throws Exception {
+        for (NodeInfo nodeInfo : clusterInfo.getNodeInfos()) {
+            if (!nodeInfo.getName().equals(nodeName)) {
+                continue;
+            }
+            
+            Kernel kernel = nodeInfo.newKernel();
+            
+            ConfigurationManager configurationManager = newConfigurationManager(kernel);
+            if (!configurationManager.isLoaded(artifact)) {
+                configurationManager.loadConfiguration(artifact);
+            }
+            configurationManager.startConfiguration(artifact);
+        }
+    }
+
+    public void stopConfiguration() throws Exception {
+        for (NodeInfo nodeInfo : clusterInfo.getNodeInfos()) {
+            if (!nodeInfo.getName().equals(nodeName)) {
+                continue;
+            }
+            
+            Kernel kernel = nodeInfo.newKernel();
+            
+            ConfigurationManager configurationManager = newConfigurationManager(kernel);
+            configurationManager.stopConfiguration(artifact);
+        }
+    }
+    
+    protected ConfigurationManager newConfigurationManager(Kernel kernel) {
+        return ConfigurationUtil.getConfigurationManager(kernel);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static final String GBEAN_J2EE_TYPE = "ClusterConfigurationController";
+    public static final String GBEAN_ATTR_NODE_NAME = "nodeName";
+    public static final String GBEAN_ATTR_ARTIFACT = "artifact";
+    public static final String GBEAN_ATTR_START_CONF_UPON_START= "startConfigurationUponStart";
+    public static final String GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START= "ignoreStartConfigurationFailureUponStart";
+    public static final String GBEAN_REF_CLUSTER_INFO = "ClusterInfo";
+    
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(BasicClusterConfigurationController.class, GBEAN_J2EE_TYPE);
+        
+        builder.addAttribute(GBEAN_ATTR_NODE_NAME, String.class, true);
+        builder.addAttribute(GBEAN_ATTR_ARTIFACT, Artifact.class, true);
+        builder.addAttribute(GBEAN_ATTR_START_CONF_UPON_START, boolean.class, true);
+        builder.addAttribute(GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START, boolean.class, true);
+
+        builder.addReference(GBEAN_REF_CLUSTER_INFO, ClusterInfo.class);
+        
+        builder.addInterface(ClusterConfigurationController.class);
+
+        builder.setConstructor(new String[] {GBEAN_REF_CLUSTER_INFO,
+            GBEAN_ATTR_NODE_NAME,
+            GBEAN_ATTR_ARTIFACT,
+            GBEAN_ATTR_START_CONF_UPON_START,
+            GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START});
+
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+    
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+    
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStore.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStore.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStore.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.IOUtil;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicClusterConfigurationStore implements ClusterConfigurationStore {
+    private final ConfigurationStore actualConfigurationStore;
+    
+    public BasicClusterConfigurationStore(ConfigurationStore actualConfigurationStore) {
+        if (null == actualConfigurationStore) {
+            throw new IllegalArgumentException("actualConfigurationStore is required");
+        }
+        this.actualConfigurationStore = actualConfigurationStore;
+    }
+
+    public void install(ConfigurationData configurationData, File packedConfigurationDir)
+            throws IOException, InvalidConfigException {
+        try {
+            File configurationDir = actualConfigurationStore.createNewConfigurationDir(configurationData.getId());
+
+            DirectoryPackager directoryPackager = newDirectoryPackager();
+            directoryPackager.unpack(configurationDir, packedConfigurationDir);
+            configurationData.setConfigurationDir(configurationDir);
+            
+            actualConfigurationStore.install(configurationData);
+        } finally {
+            deleteDir(packedConfigurationDir);
+        }
+    }
+
+    public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
+        actualConfigurationStore.uninstall(configId);
+    }
+
+    protected void deleteDir(File packedConfigurationDir) {
+        IOUtil.recursiveDelete(packedConfigurationDir);
+    }
+
+    protected DirectoryPackager newDirectoryPackager() {
+        return new ZipDirectoryPackager();
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static final String GBEAN_J2EE_TYPE = "ClusterConfigurationStore";
+    public static final String GBEAN_REF_CONF_STORE = "ConfigurationStore";
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(BasicClusterConfigurationStore.class, GBEAN_J2EE_TYPE);
+        
+        builder.addReference(GBEAN_REF_CONF_STORE, ConfigurationStore.class, "ConfigurationStore");
+        
+        builder.addInterface(ClusterConfigurationStore.class);
+        
+        builder.setConstructor(new String[]{GBEAN_REF_CONF_STORE});
+        
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClient.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClient.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClient.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClient.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,236 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.clustering.config.ClusterInfo;
+import org.apache.geronimo.clustering.config.ExtendedJMXConnectorInfo;
+import org.apache.geronimo.clustering.config.NodeInfo;
+import org.apache.geronimo.deployment.plugin.remote.FileUploadClient;
+import org.apache.geronimo.deployment.plugin.remote.FileUploadProgress;
+import org.apache.geronimo.deployment.plugin.remote.FileUploadServletClient;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicClusterConfigurationStoreClient implements ClusterConfigurationStoreClient {
+    private static final Log log = LogFactory.getLog(BasicClusterConfigurationStoreClient.class);
+
+    private static final String[] METHOD_SIGNATURE_INSTALL =
+        new String[] {ConfigurationData.class.getName(), File.class.getName()};
+    private static final String[] METHOD_SIGNATURE_UNINSTALL = new String[] {Artifact.class.getName()};
+
+    private final AbstractNameQuery clusterConfigurationStoreNameQuery;
+    private final DirectoryPackager packager;
+    private final FileUploadClient fileUploadClient;
+
+    public BasicClusterConfigurationStoreClient(AbstractNameQuery clusterConfigurationStoreNameQuery) {
+        if (null == clusterConfigurationStoreNameQuery) {
+            throw new IllegalArgumentException("clusterConfigurationStoreNameQuery is required");
+        }
+        this.clusterConfigurationStoreNameQuery = clusterConfigurationStoreNameQuery;
+        
+        packager = newDirectoryPackager();
+        fileUploadClient = newFileUploadClient();
+    }
+
+    public void install(ClusterInfo clusterInfo, ConfigurationData configurationData)
+            throws IOException, InvalidConfigException {
+        Collection<NodeInfo> nodeInfos = clusterInfo.getNodeInfos();
+
+        Collection<NodeInfo> installedToNodeInfos = new ArrayList<NodeInfo>();
+        for (NodeInfo nodeInfo : nodeInfos) {
+            try {
+                install(nodeInfo, configurationData);
+                installedToNodeInfos.add(nodeInfo);
+            } catch (Exception e) {
+                uninstall(clusterInfo, configurationData.getId(), installedToNodeInfos);
+                if (e instanceof IOException) {
+                    throw (IOException) e;
+                } else if (e instanceof InvalidConfigException) {
+                    throw (InvalidConfigException) e;
+                }
+                throw (IOException) new IOException("See nested").initCause(e);
+            }
+        }
+    }
+
+    public void uninstall(ClusterInfo clusterInfo, Artifact configId) {
+        uninstall(clusterInfo, configId, clusterInfo.getNodeInfos());
+    }
+
+    protected void uninstall(ClusterInfo clusterInfo, Artifact configId, Collection<NodeInfo> installedToNodeInfos) {
+        for (NodeInfo nodeInfo : installedToNodeInfos) {
+            try {
+                uninstall(nodeInfo, configId);
+            } catch (Exception e) {
+                log.info("Ignoring error while uninstalling [" + configId + "]from [" + nodeInfo + "]", e);
+            }
+        }
+    }
+    
+    protected void install(NodeInfo nodeInfo, ConfigurationData configurationData) throws IOException {
+        Kernel kernel = nodeInfo.newKernel();
+
+        AbstractName clusterConfigurationStoreName = searchClusterConfigurationStore(kernel);
+
+        File configurationDataFile = uploadConfiguration(kernel, nodeInfo, configurationData);
+
+        boolean inVMCall = nodeInfo.getConnectorInfo().isLocal();
+        File oldConfigurationDir = null;
+        if (inVMCall) {
+            oldConfigurationDir = configurationData.getConfigurationDir();
+        }
+        Object[] params = new Object[] {configurationData, configurationDataFile};
+        try {
+            kernel.invoke(clusterConfigurationStoreName, "install", params, METHOD_SIGNATURE_INSTALL);
+        } catch (Exception e) {
+            throw (IOException) new IOException("See nested").initCause(e);
+        } finally {
+            if (inVMCall) {
+                configurationData.setConfigurationDir(oldConfigurationDir);
+            }
+        }
+    }
+
+    protected void uninstall(NodeInfo nodeInfo, Artifact configId) throws IOException {
+        Kernel kernel = nodeInfo.newKernel();
+        
+        AbstractName clusterConfigurationStoreName = searchClusterConfigurationStore(kernel);
+        
+        Object[] params = new Object[] {configId};
+        try {
+            kernel.invoke(clusterConfigurationStoreName, "uninstall", params, METHOD_SIGNATURE_UNINSTALL);
+        } catch (Exception e) {
+            throw (IOException) new IOException("See nested").initCause(e);
+        }
+    }
+    
+    protected File uploadConfiguration(Kernel kernel, NodeInfo nodeInfo, ConfigurationData configurationData) throws IOException {
+        File packedConfigurationDir = packager.pack(configurationData.getConfigurationDir());
+
+        if (nodeInfo.getConnectorInfo().isLocal()) {
+            return packedConfigurationDir;
+        }
+        
+        URL remoteDeployUploadURL = fileUploadClient.getRemoteDeployUploadURL(kernel);
+
+        ConfigurationUploadProgress configurationUploadProgress = new ConfigurationUploadProgress(configurationData);
+        File[] configurationDataFiles = new File[] {packedConfigurationDir};
+        ExtendedJMXConnectorInfo connectorInfo = nodeInfo.getConnectorInfo();
+        fileUploadClient.uploadFilesToServer(remoteDeployUploadURL, 
+            connectorInfo.getUsername(),
+            connectorInfo.getPassword(),
+            configurationDataFiles,
+            configurationUploadProgress);
+
+        if (configurationUploadProgress.failure) {
+            if (null != configurationUploadProgress.exception) {
+                throw (IOException) new IOException("See nested").initCause(configurationUploadProgress.exception);
+            }
+            throw new IOException(configurationUploadProgress.failureMessage);
+        }
+        
+        return configurationDataFiles[0];
+    }
+
+    protected DirectoryPackager newDirectoryPackager() {
+        return new ZipDirectoryPackager();
+    }
+
+    protected FileUploadClient newFileUploadClient() {
+        return new FileUploadServletClient();
+    }
+
+    protected AbstractName searchClusterConfigurationStore(Kernel kernel) throws IOException {
+        Set<AbstractName> clusterConfigurationStoreNames = kernel.listGBeans(clusterConfigurationStoreNameQuery);
+        if (1 != clusterConfigurationStoreNames.size()) {
+            throw new IOException("Cannot locate remote store. Found [" + clusterConfigurationStoreNames + "]");
+        }
+        return clusterConfigurationStoreNames.iterator().next();
+    }
+
+    protected class ConfigurationUploadProgress implements FileUploadProgress {
+        private final ConfigurationData configurationData;
+        private boolean failure;
+        private Exception exception;
+        private String failureMessage;
+
+        public ConfigurationUploadProgress(ConfigurationData configurationData) {
+            this.configurationData = configurationData;
+        }
+
+        public void fail(String message) {
+            failure = true;
+            failureMessage = "Upload of configuration [" + configurationData.getId() + "] - [" + message + "]";
+            log.error("Upload of configuration [" + configurationData.getId() + "] - [" + message + "]");
+        }
+
+        public void fail(Exception exception) {
+            failure = true;
+            this.exception = exception;
+            log.error("Upload of configuration [" + configurationData.getId() + "]", exception);
+        }
+
+        public void updateStatus(String message) {
+            log.info("Upload of configuration [" + configurationData.getId() + "] - [" + message + "]");
+        }
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static final String GBEAN_J2EE_TYPE = "ClusterConfigurationStoreClient";
+    public static final String GBEAN_ATTR_CLUSTER_CONF_STORE_NAME_QUERY = "clusterConfigurationStoreNameQuery";
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(BasicClusterConfigurationStoreClient.class, GBEAN_J2EE_TYPE);
+        
+        builder.addAttribute(GBEAN_ATTR_CLUSTER_CONF_STORE_NAME_QUERY, AbstractNameQuery.class, true);
+        
+        builder.addInterface(ClusterConfigurationStoreClient.class);
+
+        builder.setConstructor(new String[]{GBEAN_ATTR_CLUSTER_CONF_STORE_NAME_QUERY});
+
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+    
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilder.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilder.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilder.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicMasterConfigurationNameBuilder implements MasterConfigurationNameBuilder {
+    private static final String ARTIFACT_SUFFIX = "_G_MASTER";
+
+    public Artifact buildMasterConfigurationName(Artifact configId) {
+        return new Artifact(configId.getGroupId(),
+              configId.getArtifactId() + ARTIFACT_SUFFIX,
+              configId.getVersion(),
+              configId.getType());
+    }
+
+    public Artifact buildSlaveConfigurationName(Artifact configId) {
+        if (!isMasterConfigurationName(configId)) {
+            throw new IllegalArgumentException("[" + configId + "] is not a master configuration name.");
+        }
+        
+        String artifactId = configId.getArtifactId();
+        return new Artifact(configId.getGroupId(),
+            artifactId.substring(0, artifactId.length() - ARTIFACT_SUFFIX.length()),
+            configId.getVersion(),
+            configId.getType());
+    }
+    
+    public boolean isMasterConfigurationName(Artifact configId) {
+        return configId.getArtifactId().endsWith(ARTIFACT_SUFFIX);
+    }
+    
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationController.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationController.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationController.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationController.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+/**
+*
+* @version $Rev:$ $Date:$
+*/
+public interface ClusterConfigurationController {
+    void startConfiguration() throws Exception;
+
+    void stopConfiguration() throws Exception;
+}
\ No newline at end of file

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStore.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStore.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStore.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface ClusterConfigurationStore {
+    void install(ConfigurationData configurationData, File packedConfigurationDir) throws IOException, InvalidConfigException;
+    
+    void uninstall(Artifact configId) throws NoSuchConfigException, IOException;
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStoreClient.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStoreClient.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStoreClient.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ClusterConfigurationStoreClient.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import java.io.IOException;
+
+import org.apache.geronimo.clustering.config.ClusterInfo;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface ClusterConfigurationStoreClient {
+    void install(ClusterInfo clusterInfo, ConfigurationData configurationData) throws IOException, InvalidConfigException;
+
+    void uninstall(ClusterInfo clusterInfo, Artifact configId);
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/DirectoryPackager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/DirectoryPackager.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/DirectoryPackager.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/DirectoryPackager.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface DirectoryPackager {
+    File pack(File configurationDir) throws IOException;
+
+    File unpack(File packedConfigurationDir) throws IOException;
+
+    void unpack(File targetDir, File packedConfigurationDir) throws IOException;
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface MasterConfigurationNameBuilder {
+    Artifact buildMasterConfigurationName(Artifact configId);
+
+    Artifact buildSlaveConfigurationName(Artifact configId);
+
+    boolean isMasterConfigurationName(Artifact configId);
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStore.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStore.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStore.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,316 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.clustering.config.ClusterInfo;
+import org.apache.geronimo.clustering.config.NodeInfo;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.WritableListableRepository;
+import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class MasterConfigurationStore implements ConfigurationStore {
+    private static final Log log = LogFactory.getLog(MasterConfigurationStore.class);
+    
+    private final ConfigurationStore delegate;
+    private final Environment defaultEnvironment;
+    private final ClusterInfo clusterInfo;
+    private final AbstractName clusterInfoName;
+    private final ClusterConfigurationStoreClient storeDelegate;
+    private final MasterConfigurationNameBuilder builder;
+    
+    public MasterConfigurationStore(Kernel kernel,
+            String objectName,
+            WritableListableRepository repository,
+            Environment defaultEnvironment,
+            ClusterInfo clusterInfo,
+            ClusterConfigurationStoreClient storeDelegate) {
+        if (null == kernel) {
+            throw new IllegalArgumentException("kernel is required");
+        } else if (null == objectName) {
+            throw new IllegalArgumentException("objectName is required");
+        } else if (null == repository) {
+            throw new IllegalArgumentException("repository is required");
+        } else if (null == defaultEnvironment) {
+            throw new IllegalArgumentException("defaultEnvironment is required");
+        } else if (null == clusterInfo) {
+            throw new IllegalArgumentException("clusterInfo is required");
+        } else if (null == storeDelegate) {
+            throw new IllegalArgumentException("storeDelegate is required");
+        }
+        this.defaultEnvironment = defaultEnvironment;
+        this.clusterInfo = clusterInfo;
+        this.storeDelegate = storeDelegate;
+
+        builder = newMasterConfigurationBuilder();
+        clusterInfoName = kernel.getAbstractNameFor(clusterInfo);
+        delegate = newConfigurationStore(kernel, objectName, repository);
+    }
+
+    public boolean containsConfiguration(Artifact configId) {
+        if (!builder.isMasterConfigurationName(configId)) {
+            return false;
+        }
+        return delegate.containsConfiguration(configId);
+    }
+
+    public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
+        return delegate.createNewConfigurationDir(configId);
+    }
+
+    public void exportConfiguration(Artifact configId, OutputStream output) throws IOException, NoSuchConfigException {
+        ensureArtifactForMasterConfiguration(configId);
+        delegate.exportConfiguration(configId, output);
+    }
+
+    public AbstractName getAbstractName() {
+        return delegate.getAbstractName();
+    }
+
+    public String getObjectName() {
+        return delegate.getObjectName();
+    }
+
+    public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException {
+        storeDelegate.install(clusterInfo, configurationData);
+
+        installRawConfiguration(configurationData);
+
+        installMasterConfiguration(configurationData);
+    }
+
+    public boolean isInPlaceConfiguration(Artifact configId) throws NoSuchConfigException, IOException {
+        ensureArtifactForMasterConfiguration(configId);
+        return false;
+    }
+
+    public List<ConfigurationInfo> listConfigurations() {
+        List<ConfigurationInfo> configurationInfos = delegate.listConfigurations();
+        
+        List<ConfigurationInfo> filteredConfigurationInfos = new ArrayList<ConfigurationInfo>();
+        for (ConfigurationInfo configurationInfo : configurationInfos) {
+            if (builder.isMasterConfigurationName(configurationInfo.getConfigID())) {
+                filteredConfigurationInfos.add(configurationInfo);
+            }
+        }
+        
+        return filteredConfigurationInfos;
+    }
+
+    public ConfigurationData loadConfiguration(Artifact configId)
+            throws NoSuchConfigException, IOException, InvalidConfigException {
+        ensureArtifactForMasterConfiguration(configId);
+        return delegate.loadConfiguration(configId);
+    }
+
+    public Set<URL> resolve(Artifact configId, String moduleName, String path)
+            throws NoSuchConfigException, MalformedURLException {
+        ensureArtifactForMasterConfiguration(configId);
+        return delegate.resolve(configId, moduleName, path);
+    }
+
+    public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
+        ensureArtifactForMasterConfiguration(configId);
+        
+        Artifact slaveConfigId = builder.buildSlaveConfigurationName(configId);
+        storeDelegate.uninstall(clusterInfo, slaveConfigId);
+
+        try {
+            delegate.uninstall(slaveConfigId);
+        } catch (Exception e) {
+            log.warn("Exception when uninstalling [" + slaveConfigId + "]", e);
+        }
+        delegate.uninstall(configId);
+    }
+
+    protected void ensureArtifactForMasterConfiguration(Artifact configId) throws NoSuchConfigException {
+        if (!builder.isMasterConfigurationName(configId)) {
+            throw new NoSuchConfigException(configId);
+        }
+    }
+
+    protected ConfigurationStore newConfigurationStore(Kernel kernel,
+        String objectName,
+        WritableListableRepository repository) {
+        return new RepositoryConfigurationStore(kernel, objectName, repository);
+    }
+
+    protected MasterConfigurationNameBuilder newMasterConfigurationBuilder() {
+        return new BasicMasterConfigurationNameBuilder();
+    }
+
+    protected void installMasterConfiguration(ConfigurationData configurationData)
+            throws IOException, InvalidConfigException {
+        ConfigurationData masterConfigurationData = buildMasterConfigurationData(configurationData);
+        try {
+            delegate.install(masterConfigurationData);
+        } catch (Exception e) {
+            storeDelegate.uninstall(clusterInfo, configurationData.getId());
+            try {
+                delegate.uninstall(configurationData.getId());
+            } catch (NoSuchConfigException nestedE) {
+            }
+            if (e instanceof IOException) {
+                throw (IOException) e;
+            } else if (e instanceof InvalidConfigException) {
+                throw (InvalidConfigException) e;
+            }
+            throw (IOException) new IOException("See nested").initCause(e);
+        }
+    }
+
+    protected void installRawConfiguration(ConfigurationData configurationData)
+            throws IOException, InvalidConfigException {
+        try {
+            delegate.install(configurationData);
+        } catch (Exception e) {
+            storeDelegate.uninstall(clusterInfo, configurationData.getId());
+            if (e instanceof IOException) {
+                throw (IOException) e;
+            } else if (e instanceof InvalidConfigException) {
+                throw (InvalidConfigException) e;
+            }
+            throw (IOException) new IOException("See nested").initCause(e);
+        }
+    }
+
+    protected ConfigurationData buildMasterConfigurationData(ConfigurationData configurationData) {
+        Environment environment = buildEnvironment(configurationData);
+
+        Artifact configId = environment.getConfigId();
+        
+        List<GBeanData> gbeans = buildControllerGBeans(configId, configurationData);
+        
+        File configurationDir = delegate.createNewConfigurationDir(configId);
+        
+        return new ConfigurationData(ConfigurationModuleType.CAR,
+            new LinkedHashSet(),
+            gbeans,
+            Collections.EMPTY_MAP,
+            environment,
+            configurationDir,
+            null,
+            configurationData.getNaming()); 
+    }
+
+    protected Environment buildEnvironment(ConfigurationData configurationData) {
+        Environment environment = new Environment(defaultEnvironment);
+        Artifact configId = builder.buildMasterConfigurationName(configurationData.getId());
+        environment.setConfigId(configId);
+        return environment;
+    }
+
+    protected List<GBeanData> buildControllerGBeans(Artifact configId, ConfigurationData configurationData) {
+        List<GBeanData> gbeans = new ArrayList<GBeanData>();
+        for (NodeInfo nodeInfo : clusterInfo.getNodeInfos()) {
+            GBeanData gbean = buildControllerGBean(configId, configurationData, nodeInfo);
+            gbeans.add(gbean);
+        }
+        return gbeans;
+    }
+
+    protected GBeanData buildControllerGBean(Artifact configId,
+            ConfigurationData configurationData,
+            NodeInfo nodeInfo) {
+        AbstractName controllerName = buildControllerName(configId, configurationData, nodeInfo);
+        
+        GBeanData gbean = new GBeanData(controllerName, BasicClusterConfigurationController.GBEAN_INFO);
+        gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT, configurationData.getId());
+        gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START,
+            Boolean.TRUE);
+        gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_NODE_NAME, nodeInfo.getName());
+        gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_START_CONF_UPON_START, Boolean.TRUE);
+        gbean.setReferencePattern(BasicClusterConfigurationController.GBEAN_REF_CLUSTER_INFO, clusterInfoName);
+        return gbean;
+    }
+
+    protected AbstractName buildControllerName(Artifact configId,
+            ConfigurationData configurationData, 
+            NodeInfo nodeInfo) {
+        return new AbstractName(configId, Collections.singletonMap("nodeName", nodeInfo.getName()));
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    public static final String GBEAN_J2EE_TYPE = "ConfigurationStore";
+    public static final String GBEAN_ATTR_KERNEL = "kernel";
+    public static final String GBEAN_ATTR_OBJECT_NAME = "objectName";
+    public static final String GBEAN_ATTR_DEFAULT_ENV = "defaultEnvironment";
+    public static final String GBEAN_REF_REPOSITORY = "Repository";
+    public static final String GBEAN_REF_CLUSTER_INFO = "ClusterInfo";
+    public static final String GBEAN_REF_CLUSTER_CONF_STORE_CLIENT = "ClusterConfigurationStoreClient";
+
+    static {
+        GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(MasterConfigurationStore.class, GBEAN_J2EE_TYPE);
+        
+        builder.addAttribute(GBEAN_ATTR_KERNEL, Kernel.class, false);
+        builder.addAttribute(GBEAN_ATTR_OBJECT_NAME, String.class, false);
+        builder.addAttribute(GBEAN_ATTR_DEFAULT_ENV, Environment.class, true, true);
+        
+        builder.addReference(GBEAN_REF_REPOSITORY, WritableListableRepository.class, "Repository");
+        builder.addReference(GBEAN_REF_CLUSTER_INFO, ClusterInfo.class);
+        builder.addReference(GBEAN_REF_CLUSTER_CONF_STORE_CLIENT, ClusterConfigurationStoreClient.class);
+        
+        builder.addInterface(ConfigurationStore.class);
+        
+        builder.setConstructor(new String[]{GBEAN_ATTR_KERNEL,
+            GBEAN_ATTR_OBJECT_NAME,
+            GBEAN_REF_REPOSITORY,
+            GBEAN_ATTR_DEFAULT_ENV,
+            GBEAN_REF_CLUSTER_INFO,
+            GBEAN_REF_CLUSTER_CONF_STORE_CLIENT});
+        
+        GBEAN_INFO = builder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ZipDirectoryPackager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ZipDirectoryPackager.java?rev=594117&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ZipDirectoryPackager.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/ZipDirectoryPackager.java Mon Nov 12 05:35:48 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.deployment;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class ZipDirectoryPackager implements DirectoryPackager {
+
+    public File pack(File configurationDir) throws IOException {
+        File zippedDir = File.createTempFile(configurationDir.getName(), ".zip");
+
+        OutputStream out = new FileOutputStream(zippedDir);
+        out = new BufferedOutputStream(out);
+        ZipOutputStream zos = new ZipOutputStream(out);
+        zip(zos, configurationDir, configurationDir);
+        zos.close();
+
+        return zippedDir;
+    }
+
+    public File unpack(File packedConfigurationDir) throws IOException {
+        String tmpDirAsString = System.getProperty("java.io.tmpdir");
+        File targetDir = new File(new File(tmpDirAsString), packedConfigurationDir.getName() + "_unpack");
+        unpack(targetDir, packedConfigurationDir);
+        return targetDir;
+    }
+    
+    public void unpack(File targetDir, File packedConfigurationDir) throws IOException {
+        ZipFile zipFile = new ZipFile(packedConfigurationDir);
+        Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
+        while (zipEntries.hasMoreElements()) {
+            ZipEntry zipEntry = zipEntries.nextElement();
+            File targetFile = new File(targetDir, zipEntry.getName());
+
+            if (zipEntry.isDirectory()) {
+                targetFile.mkdirs();
+            } else {
+                targetFile.getParentFile().mkdirs();
+                targetFile.createNewFile();
+                OutputStream out = new FileOutputStream(targetFile);
+                out = new BufferedOutputStream(out);
+                InputStream in = zipFile.getInputStream(zipEntry);
+
+                byte[] buffer = new byte[1024];
+                int read;
+                while (-1 != (read = in.read(buffer))) {
+                    out.write(buffer, 0, read);
+                }
+                
+                in.close();
+                out.close();
+            }
+        }
+    }
+    
+    protected void zip(ZipOutputStream zos, File configurationDir, File nestedFile) throws IOException {
+        if (nestedFile.isDirectory()) {
+            File[] nestedFiles = nestedFile.listFiles();
+            for (int i = 0; i < nestedFiles.length; i++) {
+                zip(zos, configurationDir, nestedFiles[i]);
+            }
+        } else {
+            String nestedFilePath = nestedFile.getAbsolutePath();
+            String zipEntryName = nestedFilePath.substring(configurationDir.getAbsolutePath().length() + 1, nestedFilePath.length());
+            ZipEntry zipEntry = new ZipEntry(zipEntryName);
+            zos.putNextEntry(zipEntry);
+            
+            InputStream in = new FileInputStream(nestedFile);
+            in = new BufferedInputStream(in);
+            
+            byte[] buffer = new byte[1024];
+            int read;
+            while (-1 != (read = in.read(buffer))) {
+                zos.write(buffer, 0, read);
+            }
+
+            in.close();
+            zos.closeEntry();
+        }
+    }
+
+}



Mime
View raw message