geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r835995 - in /geronimo/server/branches/2.1/plugins: clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/ tomcat/geronimo-tomcat6-clustering-b...
Date Fri, 13 Nov 2009 21:23:14 GMT
Author: kevan
Date: Fri Nov 13 21:23:09 2009
New Revision: 835995

URL: http://svn.apache.org/viewvc?rev=835995&view=rev
Log:
GERONIMO-4900 Apply patch from Ashish Jain. Fix farmed deployment of configurations with JNDI
resource references. Thanks Ashish! 

Added:
    geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
  (with props)
    geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
  (with props)
Modified:
    geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
    geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java
    geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java

Added: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java?rev=835995&view=auto
==============================================================================
--- geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
(added)
+++ geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
Fri Nov 13 21:23:09 2009
@@ -0,0 +1,51 @@
+/*
+ * 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.farm.deployment;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class BasicConfigurationNameBuilder implements ConfigurationNameBuilder {
+    private static final String ARTIFACT_SUFFIX = "_G_MASTER";
+
+    public Artifact buildMasterConfigurationName(Artifact configId) {
+        return newArtifact(configId, configId.getArtifactId() + ARTIFACT_SUFFIX);
+    }
+
+    public Artifact buildSlaveConfigurationName(Artifact configId) {
+        if (!isMasterConfigurationName(configId)) {
+            throw new IllegalArgumentException("[" + configId + "] is not a master configuration
name");
+        }
+        String artifactId = configId.getArtifactId();
+        return newArtifact(configId, artifactId.substring(0, artifactId.length() - ARTIFACT_SUFFIX.length()));
+    }
+    
+    public boolean isMasterConfigurationName(Artifact configId) {
+        return configId.getArtifactId().endsWith(ARTIFACT_SUFFIX);
+    }
+    
+    protected Artifact newArtifact(Artifact configId, String artifactId) {
+        return new Artifact(configId.getGroupId(), artifactId, configId.getVersion(), configId.getType());
+    }
+    
+}

Propchange: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/BasicConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java?rev=835995&view=auto
==============================================================================
--- geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
(added)
+++ geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
Fri Nov 13 21:23:09 2009
@@ -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.farm.deployment;
+
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ConfigurationNameBuilder {
+    Artifact buildMasterConfigurationName(Artifact configId);
+
+    Artifact buildSlaveConfigurationName(Artifact configId);
+
+    boolean isMasterConfigurationName(Artifact configId);
+}

Propchange: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/ConfigurationNameBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java?rev=835995&r1=835994&r2=835995&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
(original)
+++ geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/main/java/org/apache/geronimo/farm/deployment/MasterConfigurationStore.java
Fri Nov 13 21:23:09 2009
@@ -38,6 +38,7 @@
 import org.apache.geronimo.gbean.GBeanData;
 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.ConfigurationAlreadyExistsException;
 import org.apache.geronimo.kernel.config.ConfigurationData;
@@ -50,12 +51,14 @@
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.WritableListableRepository;
 import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
+import org.apache.geronimo.gbean.GBeanInfo;
 
 /**
  *
  * @version $Rev:$ $Date:$
  */
-public class MasterConfigurationStore implements ConfigurationStore {
+//@GBean(j2eeType=MasterConfigurationStore.GBEAN_J2EE_TYPE)
+public class MasterConfigurationStore implements ConfigurationStore, GBeanLifecycle  {
     private static final Log log = LogFactory.getLog(MasterConfigurationStore.class);
     
     private final ConfigurationStore delegate;
@@ -63,16 +66,17 @@
     private final ClusterInfo clusterInfo;
     private final AbstractName clusterInfoName;
     private final ClusterConfigurationStoreClient storeDelegate;
-    private final SlaveConfigurationNameBuilder slaveConfigNameBuilder;
+    private final ConfigurationNameBuilder configNameBuilder;
+    public static final GBeanInfo GBEAN_INFO;
+    public static final String GBEAN_J2EE_TYPE = "ConfigurationStore";
+    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";
     
-    public MasterConfigurationStore(Kernel kernel,
-            String objectName,
-            AbstractName abstractName,
-            WritableListableRepository repository,
-            Environment defaultEnvironment,
-            ClusterInfo clusterInfo,
-            ClusterConfigurationStoreClient storeDelegate) {
-        if (null == kernel) {
+    public MasterConfigurationStore(Kernel kernel,String objectName,AbstractName abstractName,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");
@@ -89,21 +93,23 @@
         this.clusterInfo = clusterInfo;
         this.storeDelegate = storeDelegate;
 
-        slaveConfigNameBuilder = newSlaveConfigurationNameBuilder();
+        configNameBuilder = newMasterConfigurationNameBuilder();
         clusterInfoName = kernel.getAbstractNameFor(clusterInfo);
         delegate = newConfigurationStore(kernel, objectName, abstractName, repository);
+
     }
+   
+       
 
     public boolean containsConfiguration(Artifact configId) {
-        if (slaveConfigNameBuilder.isSlaveConfigurationName(configId)) {
+        if (!configNameBuilder.isMasterConfigurationName(configId)) {
             return false;
         }
         return delegate.containsConfiguration(configId);
     }
 
     public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException
{
-        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(configId);
-        return delegate.createNewConfigurationDir(slaveConfigId);
+        return delegate.createNewConfigurationDir(configId);
     }
 
     public void exportConfiguration(Artifact configId, OutputStream output) throws IOException,
NoSuchConfigException {
@@ -120,16 +126,14 @@
     }
 
     public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException
{
-        Environment environment = configurationData.getEnvironment();
-        Artifact actualConfigId = environment.getConfigId();
-        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(actualConfigId);
-        environment.setConfigId(slaveConfigId);
-
         storeDelegate.install(clusterInfo, configurationData);
-        installSlaveConfiguration(configurationData);
 
-        environment.setConfigId(actualConfigId);
+        installSlaveConfiguration(configurationData);
 
+        Environment environment = configurationData.getEnvironment();
+        Artifact slaveConfigId = environment.getConfigId();
+        Artifact masterConfigId = configNameBuilder.buildMasterConfigurationName(slaveConfigId);
+        environment.setConfigId(masterConfigId);
         installMasterConfiguration(configurationData, slaveConfigId);
     }
 
@@ -143,7 +147,7 @@
         
         List<ConfigurationInfo> filteredConfigurationInfos = new ArrayList<ConfigurationInfo>();
         for (ConfigurationInfo configurationInfo : configurationInfos) {
-            if (!slaveConfigNameBuilder.isSlaveConfigurationName(configurationInfo.getConfigID()))
{
+            if (configNameBuilder.isMasterConfigurationName(configurationInfo.getConfigID()))
{
                 filteredConfigurationInfos.add(configurationInfo);
             }
         }
@@ -166,7 +170,7 @@
     public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
         ensureArtifactForMasterConfiguration(configId);
         
-        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(configId);
+        Artifact slaveConfigId = configNameBuilder.buildSlaveConfigurationName(configId);
         storeDelegate.uninstall(clusterInfo, slaveConfigId);
 
         try {
@@ -178,7 +182,7 @@
     }
 
     protected void ensureArtifactForMasterConfiguration(Artifact configId) throws NoSuchConfigException
{
-        if (slaveConfigNameBuilder.isSlaveConfigurationName(configId)) {
+        if (!configNameBuilder.isMasterConfigurationName(configId)) {
             throw new NoSuchConfigException(configId);
         }
     }
@@ -190,8 +194,8 @@
         return new RepositoryConfigurationStore(kernel, objectName, abstractName, repository);
     }
 
-    protected SlaveConfigurationNameBuilder newSlaveConfigurationNameBuilder() {
-        return new BasicSlaveConfigurationNameBuilder();
+    protected ConfigurationNameBuilder newMasterConfigurationNameBuilder() {
+        return new BasicConfigurationNameBuilder();
     }
 
     protected void installMasterConfiguration(ConfigurationData configurationData, Artifact
slaveConfigId)
@@ -263,11 +267,23 @@
         }
         return gbeans;
     }
+    
+    public void doFail() {
+        log.warn("Failed");
+    }
+
+    public void doStart() throws Exception {
+        //log.debug("Started host name '" + host.getName() + "'");
+    }
+
+    public void doStop() throws Exception {
+        //log.debug("Stopped host '" + host.getName() + "'");
+    }
 
     protected GBeanData buildControllerGBean(Artifact configId, NodeInfo nodeInfo, Artifact
slaveConfigId) {
         AbstractName controllerName = buildControllerName(configId, nodeInfo);
         
-        GBeanData gbean = new GBeanData(controllerName, BasicClusterConfigurationController.GBEAN_INFO);
+        GBeanData gbean = new GBeanData(controllerName,BasicClusterConfigurationController.GBEAN_INFO);
         gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT, slaveConfigId);
         gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START,
             Boolean.TRUE);
@@ -281,44 +297,28 @@
             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("abstractName", AbstractName.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);
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(MasterConfigurationStore.class);//,ConfigurationStore.class);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+        infoFactory.addAttribute("objectName", String.class, false);
+        infoFactory.addAttribute("abstractName", AbstractName.class, true);
+        infoFactory.addReference(GBEAN_REF_REPOSITORY, WritableListableRepository.class,
"Repository");
+        infoFactory.addAttribute("defaultEnvironment",Environment.class, false);
+        infoFactory.addReference(GBEAN_REF_CLUSTER_INFO,ClusterInfo.class);
+        infoFactory.addReference(GBEAN_REF_CLUSTER_CONF_STORE_CLIENT, ClusterConfigurationStoreClient.class);
+        infoFactory.setConstructor(new String[] { "kernel","objectName","abstractName",GBEAN_REF_REPOSITORY,"defaultEnvironment",GBEAN_REF_CLUSTER_INFO,GBEAN_REF_CLUSTER_CONF_STORE_CLIENT});
         
-        builder.addInterface(ConfigurationStore.class);
-        
-        builder.setConstructor(new String[]{GBEAN_ATTR_KERNEL,
-            GBEAN_ATTR_OBJECT_NAME,
-                "abstractName",
-            GBEAN_REF_REPOSITORY,
-            GBEAN_ATTR_DEFAULT_ENV,
-            GBEAN_REF_CLUSTER_INFO,
-            GBEAN_REF_CLUSTER_CONF_STORE_CLIENT});
-        
-        GBEAN_INFO = builder.getBeanInfo();
+        GBEAN_INFO = infoFactory.getBeanInfo();
     }
 
     public static GBeanInfo getGBeanInfo() {
         return GBEAN_INFO;
     }
-
+    
+   
 }

Modified: geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java?rev=835995&r1=835994&r2=835995&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java
(original)
+++ geronimo/server/branches/2.1/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/MasterConfigurationStoreTest.java
Fri Nov 13 21:23:09 2009
@@ -62,7 +62,7 @@
     private ClusterConfigurationStoreClient storeClient;
     private AbstractName clusterInfoName;
     private ConfigurationStore delegate;
-    private SlaveConfigurationNameBuilder nameBuilder;
+    private ConfigurationNameBuilder nameBuilder;
     private Artifact configId;
 
     @Override
@@ -77,13 +77,13 @@
         modify().returnValue(clusterInfoName);
         
         delegate = (ConfigurationStore) mock(ConfigurationStore.class);
-        nameBuilder = (SlaveConfigurationNameBuilder) mock(SlaveConfigurationNameBuilder.class);
+        nameBuilder = (ConfigurationNameBuilder) mock(ConfigurationNameBuilder.class);
     }
 
     private MasterConfigurationStore newMasterConfigurationStore() {
         return new MasterConfigurationStore(kernel,
             "objectName",
-                null,
+            null,
             repository,
             new Environment(),
             clusterInfo,
@@ -96,15 +96,15 @@
                 return delegate;
             }
             @Override
-            protected SlaveConfigurationNameBuilder newSlaveConfigurationNameBuilder() {
+            protected ConfigurationNameBuilder newMasterConfigurationNameBuilder() {
                 return nameBuilder;
             }
         };
     }
     
     public void testContainsConfigurationOK() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
 
         delegate.containsConfiguration(configId);
         modify().returnValue(true);
@@ -116,8 +116,8 @@
     }
     
     public void testContainsConfigurationFailsWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -126,11 +126,7 @@
     }
 
     public void testDelegateCreateNewConfigurationDir() throws Exception {
-        Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
-        nameBuilder.buildSlaveConfigurationName(configId);
-        modify().returnValue(slaveId);
-        
-        delegate.createNewConfigurationDir(slaveId);
+        delegate.createNewConfigurationDir(configId);
         File expectedFile = new File("confDir");
         modify().returnValue(expectedFile);
         
@@ -141,8 +137,8 @@
     }
     
     public void testExportFailsWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -157,8 +153,8 @@
     public void testDelegateExport() throws Exception {
         OutputStream out = new ByteArrayOutputStream();
         
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         delegate.exportConfiguration(configId, out);
         
@@ -179,8 +175,8 @@
     }
     
     public void testDelegateGetObjectName() throws Exception {
-        delegate.getObjectName();
         String expectedName = "name";
+        delegate.getObjectName();
         modify().returnValue(expectedName);
         
         startVerification();
@@ -190,8 +186,8 @@
     }
     
     public void testIsInPlaceConfigurationWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -204,8 +200,8 @@
     }
 
     public void testIsInPlaceConfigurationReturnsFalse() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         startVerification();
         
@@ -226,12 +222,12 @@
         delegate.listConfigurations();
         modify().returnValue(configurationInfos);
         
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
-        
-        nameBuilder.isSlaveConfigurationName(configId2);
+        nameBuilder.isMasterConfigurationName(configId);
         modify().returnValue(true);
         
+        nameBuilder.isMasterConfigurationName(configId2);
+        modify().returnValue(false);
+        
         startVerification();
         
         MasterConfigurationStore store = newMasterConfigurationStore();
@@ -241,8 +237,8 @@
     }
 
     public void testLoadConfigurationWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
 
         startVerification();
         
@@ -255,8 +251,8 @@
     }
 
     public void testDelegateLoadConfiguration() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         delegate.loadConfiguration(configId);
         
@@ -267,8 +263,8 @@
     }
 
     public void testResolveWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
         
         startVerification();
         
@@ -281,8 +277,8 @@
     }
     
     public void testDelegateResolve() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         delegate.resolve(configId, null, null);
         
@@ -293,8 +289,8 @@
     }
     
     public void testUninstall() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(true);
         
         nameBuilder.buildSlaveConfigurationName(configId);
         Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
@@ -312,8 +308,8 @@
     }
     
     public void testUninstallWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isSlaveConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isMasterConfigurationName(configId);
+        modify().returnValue(false);
         
         startVerification();
         
@@ -326,7 +322,7 @@
     }
     
     public void testInstallOK() throws Exception {
-        ConfigurationData configurationData = new ConfigurationData(ConfigurationModuleType.CAR,
+        final ConfigurationData configurationData = new ConfigurationData(ConfigurationModuleType.CAR,
             new LinkedHashSet(),
             new ArrayList(),
             Collections.EMPTY_MAP,
@@ -335,33 +331,34 @@
             null,
             new Jsr77Naming());
         
-        final Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
-        nameBuilder.buildSlaveConfigurationName(configId);
-        modify().returnValue(slaveId);
-        
-        storeClient.install(clusterInfo, configurationData);
-        modify().args(is.AS_RECORDED, new AbstractExpression() {
+        AbstractExpression assertConfigurationData = new AbstractExpression() {
             public void describeWith(ExpressionDescriber arg) throws IOException {
             }
-
+            
             public boolean passes(Object arg) {
-                ConfigurationData configurationData = (ConfigurationData) arg;
-                assertSame(slaveId, configurationData.getId());
+                assertSame(configurationData, arg);
                 return true;
             }
-        });
+        };
+
+        storeClient.install(clusterInfo, configurationData);
+        modify().args(is.AS_RECORDED, assertConfigurationData);
         
         delegate.install(configurationData);
-        modify().args(new AbstractExpression() {
-            public void describeWith(ExpressionDescriber arg) throws IOException {
-            }
+        modify().args(assertConfigurationData);
+        
+        recordInstallMasterConfiguration();
+        
+        startVerification();
 
-            public boolean passes(Object arg) {
-                ConfigurationData configurationData = (ConfigurationData) arg;
-                assertSame(slaveId, configurationData.getId());
-                return true;
-            }
-        });
+        MasterConfigurationStore store = newMasterConfigurationStore();
+        store.install(configurationData);
+    }
+
+    private void recordInstallMasterConfiguration() throws IOException, InvalidConfigException
{
+        final Artifact masterId = new Artifact("groupId", "masterId", "2.0", "car");
+        nameBuilder.buildMasterConfigurationName(configId);
+        modify().returnValue(masterId);
         
         NodeInfo nodeInfo = (NodeInfo) mock(NodeInfo.class);
         nodeInfo.getName();
@@ -370,7 +367,7 @@
         clusterInfo.getNodeInfos();
         modify().returnValue(Collections.singleton(nodeInfo));
         
-        delegate.createNewConfigurationDir(configId);
+        delegate.createNewConfigurationDir(masterId);
         final File masterDir = new File("masterDir");
         modify().returnValue(masterDir);
         
@@ -381,7 +378,7 @@
 
             public boolean passes(Object arg) {
                 ConfigurationData configurationData = (ConfigurationData) arg;
-                assertSame(configId, configurationData.getId());
+                assertSame(masterId, configurationData.getId());
                 assertSame(masterDir, configurationData.getConfigurationDir());
                 
                 List<GBeanData> gbeans;
@@ -392,17 +389,12 @@
                 }
                 assertEquals(1, gbeans.size());
                 GBeanData gbean = gbeans.get(0);
-                assertEquals(BasicClusterConfigurationController.GBEAN_INFO, gbean.getGBeanInfo());
-                assertEquals(slaveId, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT));
+                assertEquals(BasicClusterConfigurationController.class.getName(), gbean.getGBeanInfo().getClassName());
+                assertEquals(configId, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT));
                 assertEquals(nodeName, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_NODE_NAME));
                 return true;
             }
         });
-        
-        startVerification();
-
-        MasterConfigurationStore store = newMasterConfigurationStore();
-        store.install(configurationData);
     }
     
     private ConfigurationInfo newConfigurationInfo(Artifact configId) {

Modified: geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java?rev=835995&r1=835994&r2=835995&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
(original)
+++ geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
Fri Nov 13 21:23:09 2009
@@ -149,11 +149,10 @@
     }
 
     protected GBeanData extractWebModule(DeploymentContext moduleContext) throws DeploymentException
{
-        AbstractNameQuery webModuleQuery = createTomcatWebAppContextNameQuery(moduleContext);
         Configuration configuration = moduleContext.getConfiguration();
         try {
-            return configuration.findGBeanData(webModuleQuery);
-        } catch (GBeanNotFoundException e) {
+            return configuration.getGBeans().get(moduleContext.getModuleName());
+        } catch (Exception e) {
             throw new DeploymentException("Could not locate web module gbean in web app configuration",
e);
         }
     }



Mime
View raw message