geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r609453 - in /geronimo/server/trunk/plugins/clustering/geronimo-clustering/src: main/java/org/apache/geronimo/clustering/deployment/ test/java/org/apache/geronimo/clustering/deployment/
Date Sun, 06 Jan 2008 22:39:25 GMT
Author: gdamour
Date: Sun Jan  6 14:39:21 2008
New Revision: 609453

URL: http://svn.apache.org/viewvc?rev=609453&view=rev
Log:
Change naming conventions of artifacts when deploying to the master
configuration store:
* the actual deployment now is cascaded to the cluster repository with
an artifact, whose Artifact is suffixed by _G_SLAVE; and
* the master configuration, i.e. the configuration defining the GBeans
controlling the remoate slave configuration, has the same name than the one
specified in the plan.

Added:
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicSlaveConfigurationNameBuilder.java
      - copied, changed from r609028, 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/SlaveConfigurationNameBuilder.java
      - copied, changed from r609028, geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java
Removed:
    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/MasterConfigurationNameBuilder.java
Modified:
    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/MasterConfigurationStore.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

Modified: 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=609453&r1=609452&r2=609453&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClient.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicClusterConfigurationStoreClient.java
Sun Jan  6 14:39:21 2008
@@ -41,7 +41,6 @@
 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;
 
 /**

Copied: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicSlaveConfigurationNameBuilder.java
(from r609028, 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/BasicSlaveConfigurationNameBuilder.java?p2=geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicSlaveConfigurationNameBuilder.java&p1=geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilder.java&r1=609028&r2=609453&rev=609453&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilder.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/BasicSlaveConfigurationNameBuilder.java
Sun Jan  6 14:39:21 2008
@@ -25,29 +25,17 @@
  *
  * @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 class BasicSlaveConfigurationNameBuilder implements SlaveConfigurationNameBuilder
{
+    private static final String ARTIFACT_SUFFIX = "_G_SLAVE";
 
     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.getArtifactId() + ARTIFACT_SUFFIX,
             configId.getVersion(),
             configId.getType());
     }
     
-    public boolean isMasterConfigurationName(Artifact configId) {
+    public boolean isSlaveConfigurationName(Artifact configId) {
         return configId.getArtifactId().endsWith(ARTIFACT_SUFFIX);
     }
     

Modified: 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=609453&r1=609452&r2=609453&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStore.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStore.java
Sun Jan  6 14:39:21 2008
@@ -63,7 +63,7 @@
     private final ClusterInfo clusterInfo;
     private final AbstractName clusterInfoName;
     private final ClusterConfigurationStoreClient storeDelegate;
-    private final MasterConfigurationNameBuilder builder;
+    private final SlaveConfigurationNameBuilder slaveConfigNameBuilder;
     
     public MasterConfigurationStore(Kernel kernel,
             String objectName,
@@ -89,20 +89,21 @@
         this.clusterInfo = clusterInfo;
         this.storeDelegate = storeDelegate;
 
-        builder = newMasterConfigurationBuilder();
+        slaveConfigNameBuilder = newSlaveConfigurationNameBuilder();
         clusterInfoName = kernel.getAbstractNameFor(clusterInfo);
         delegate = newConfigurationStore(kernel, objectName, abstractName, repository);
     }
 
     public boolean containsConfiguration(Artifact configId) {
-        if (!builder.isMasterConfigurationName(configId)) {
+        if (slaveConfigNameBuilder.isSlaveConfigurationName(configId)) {
             return false;
         }
         return delegate.containsConfiguration(configId);
     }
 
     public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException
{
-        return delegate.createNewConfigurationDir(configId);
+        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(configId);
+        return delegate.createNewConfigurationDir(slaveConfigId);
     }
 
     public void exportConfiguration(Artifact configId, OutputStream output) throws IOException,
NoSuchConfigException {
@@ -119,11 +120,17 @@
     }
 
     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);
 
-        installRawConfiguration(configurationData);
+        environment.setConfigId(actualConfigId);
 
-        installMasterConfiguration(configurationData);
+        installMasterConfiguration(configurationData, slaveConfigId);
     }
 
     public boolean isInPlaceConfiguration(Artifact configId) throws NoSuchConfigException,
IOException {
@@ -136,11 +143,11 @@
         
         List<ConfigurationInfo> filteredConfigurationInfos = new ArrayList<ConfigurationInfo>();
         for (ConfigurationInfo configurationInfo : configurationInfos) {
-            if (builder.isMasterConfigurationName(configurationInfo.getConfigID())) {
+            if (!slaveConfigNameBuilder.isSlaveConfigurationName(configurationInfo.getConfigID()))
{
                 filteredConfigurationInfos.add(configurationInfo);
             }
         }
-        
+
         return filteredConfigurationInfos;
     }
 
@@ -159,7 +166,7 @@
     public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
         ensureArtifactForMasterConfiguration(configId);
         
-        Artifact slaveConfigId = builder.buildSlaveConfigurationName(configId);
+        Artifact slaveConfigId = slaveConfigNameBuilder.buildSlaveConfigurationName(configId);
         storeDelegate.uninstall(clusterInfo, slaveConfigId);
 
         try {
@@ -171,7 +178,7 @@
     }
 
     protected void ensureArtifactForMasterConfiguration(Artifact configId) throws NoSuchConfigException
{
-        if (!builder.isMasterConfigurationName(configId)) {
+        if (slaveConfigNameBuilder.isSlaveConfigurationName(configId)) {
             throw new NoSuchConfigException(configId);
         }
     }
@@ -183,19 +190,19 @@
         return new RepositoryConfigurationStore(kernel, objectName, abstractName, repository);
     }
 
-    protected MasterConfigurationNameBuilder newMasterConfigurationBuilder() {
-        return new BasicMasterConfigurationNameBuilder();
+    protected SlaveConfigurationNameBuilder newSlaveConfigurationNameBuilder() {
+        return new BasicSlaveConfigurationNameBuilder();
     }
 
-    protected void installMasterConfiguration(ConfigurationData configurationData)
+    protected void installMasterConfiguration(ConfigurationData configurationData, Artifact
slaveConfigId)
             throws IOException, InvalidConfigException {
-        ConfigurationData masterConfigurationData = buildMasterConfigurationData(configurationData);
+        ConfigurationData masterConfigurationData = buildMasterConfigurationData(configurationData,
slaveConfigId);
         try {
             delegate.install(masterConfigurationData);
         } catch (Exception e) {
-            storeDelegate.uninstall(clusterInfo, configurationData.getId());
+            storeDelegate.uninstall(clusterInfo, slaveConfigId);
             try {
-                delegate.uninstall(configurationData.getId());
+                delegate.uninstall(slaveConfigId);
             } catch (NoSuchConfigException nestedE) {
             }
             if (e instanceof IOException) {
@@ -207,7 +214,7 @@
         }
     }
 
-    protected void installRawConfiguration(ConfigurationData configurationData)
+    protected void installSlaveConfiguration(ConfigurationData configurationData)
             throws IOException, InvalidConfigException {
         try {
             delegate.install(configurationData);
@@ -222,12 +229,13 @@
         }
     }
 
-    protected ConfigurationData buildMasterConfigurationData(ConfigurationData configurationData)
{
+    protected ConfigurationData buildMasterConfigurationData(ConfigurationData configurationData,
+        Artifact slaveConfigId) {
         Environment environment = buildEnvironment(configurationData);
 
         Artifact configId = environment.getConfigId();
         
-        List<GBeanData> gbeans = buildControllerGBeans(configId, configurationData);
+        List<GBeanData> gbeans = buildControllerGBeans(configId, slaveConfigId);
         
         File configurationDir = delegate.createNewConfigurationDir(configId);
         
@@ -243,27 +251,24 @@
 
     protected Environment buildEnvironment(ConfigurationData configurationData) {
         Environment environment = new Environment(defaultEnvironment);
-        Artifact configId = builder.buildMasterConfigurationName(configurationData.getId());
-        environment.setConfigId(configId);
+        environment.setConfigId(configurationData.getId());
         return environment;
     }
 
-    protected List<GBeanData> buildControllerGBeans(Artifact configId, ConfigurationData
configurationData) {
+    protected List<GBeanData> buildControllerGBeans(Artifact configId, Artifact slaveConfigId)
{
         List<GBeanData> gbeans = new ArrayList<GBeanData>();
         for (NodeInfo nodeInfo : clusterInfo.getNodeInfos()) {
-            GBeanData gbean = buildControllerGBean(configId, configurationData, nodeInfo);
+            GBeanData gbean = buildControllerGBean(configId, nodeInfo, slaveConfigId);
             gbeans.add(gbean);
         }
         return gbeans;
     }
 
-    protected GBeanData buildControllerGBean(Artifact configId,
-            ConfigurationData configurationData,
-            NodeInfo nodeInfo) {
-        AbstractName controllerName = buildControllerName(configId, configurationData, nodeInfo);
+    protected GBeanData buildControllerGBean(Artifact configId, NodeInfo nodeInfo, Artifact
slaveConfigId) {
+        AbstractName controllerName = buildControllerName(configId, nodeInfo);
         
         GBeanData gbean = new GBeanData(controllerName, BasicClusterConfigurationController.GBEAN_INFO);
-        gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT, configurationData.getId());
+        gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT, slaveConfigId);
         gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START,
             Boolean.TRUE);
         gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_NODE_NAME, nodeInfo.getName());
@@ -273,7 +278,6 @@
     }
 
     protected AbstractName buildControllerName(Artifact configId,
-            ConfigurationData configurationData, 
             NodeInfo nodeInfo) {
         return new AbstractName(configId, Collections.singletonMap("nodeName", nodeInfo.getName()));
     }

Copied: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/SlaveConfigurationNameBuilder.java
(from r609028, 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/SlaveConfigurationNameBuilder.java?p2=geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/SlaveConfigurationNameBuilder.java&p1=geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java&r1=609028&r2=609453&rev=609453&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/MasterConfigurationNameBuilder.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/deployment/SlaveConfigurationNameBuilder.java
Sun Jan  6 14:39:21 2008
@@ -25,10 +25,8 @@
  *
  * @version $Rev:$ $Date:$
  */
-public interface MasterConfigurationNameBuilder {
-    Artifact buildMasterConfigurationName(Artifact configId);
-
+public interface SlaveConfigurationNameBuilder {
     Artifact buildSlaveConfigurationName(Artifact configId);
 
-    boolean isMasterConfigurationName(Artifact configId);
+    boolean isSlaveConfigurationName(Artifact configId);
 }

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilderTest.java?rev=609453&r1=609452&r2=609453&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilderTest.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/BasicMasterConfigurationNameBuilderTest.java
Sun Jan  6 14:39:21 2008
@@ -29,37 +29,27 @@
  */
 public class BasicMasterConfigurationNameBuilderTest extends TestCase {
 
-    private BasicMasterConfigurationNameBuilder builder;
+    private BasicSlaveConfigurationNameBuilder builder;
 
     @Override
     protected void setUp() throws Exception {
-        builder = new BasicMasterConfigurationNameBuilder();
+        builder = new BasicSlaveConfigurationNameBuilder();
     }
     
-    public void testIsMasterConfigurationName() throws Exception {
+    public void testIsSlaveConfigurationName() throws Exception {
         Artifact artifact = new Artifact("groupId", "artifactId", "2.0", "car");
-        assertFalse(builder.isMasterConfigurationName(artifact));
-        Artifact masterConfiguration = builder.buildMasterConfigurationName(artifact);
-        assertTrue(builder.isMasterConfigurationName(masterConfiguration));
+        assertFalse(builder.isSlaveConfigurationName(artifact));
+        Artifact masterConfiguration = builder.buildSlaveConfigurationName(artifact);
+        assertTrue(builder.isSlaveConfigurationName(masterConfiguration));
     }
     
-    public void testBuildMasterConfigurationName() throws Exception {
+    public void testBuildSlaveConfigurationName() throws Exception {
         Artifact artifact = new Artifact("groupId", "artifactId", "2.0", "car");
-        Artifact masterConfiguration = builder.buildMasterConfigurationName(artifact);
+        Artifact masterConfiguration = builder.buildSlaveConfigurationName(artifact);
         assertEquals(artifact.getGroupId(), masterConfiguration.getGroupId());
-        assertEquals(artifact.getArtifactId() + "_G_MASTER", masterConfiguration.getArtifactId());
+        assertEquals(artifact.getArtifactId() + "_G_SLAVE", masterConfiguration.getArtifactId());
         assertEquals(artifact.getVersion(), masterConfiguration.getVersion());
         assertEquals(artifact.getType(), masterConfiguration.getType());
-    }
-    
-    public void testBuildSlaveConfigurationName() throws Exception {
-        Artifact artifact = new Artifact("groupId", "artifactId", "2.0", "car");
-        Artifact masterConfiguration = builder.buildMasterConfigurationName(artifact);
-        Artifact actualArtifact = builder.buildSlaveConfigurationName(masterConfiguration);
-        assertEquals(artifact.getGroupId(), actualArtifact.getGroupId());
-        assertEquals(artifact.getArtifactId(), actualArtifact.getArtifactId());
-        assertEquals(artifact.getVersion(), actualArtifact.getVersion());
-        assertEquals(artifact.getType(), actualArtifact.getType());
     }
     
 }

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStoreTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStoreTest.java?rev=609453&r1=609452&r2=609453&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStoreTest.java
(original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/test/java/org/apache/geronimo/clustering/deployment/MasterConfigurationStoreTest.java
Sun Jan  6 14:39:21 2008
@@ -62,7 +62,7 @@
     private ClusterConfigurationStoreClient storeClient;
     private AbstractName clusterInfoName;
     private ConfigurationStore delegate;
-    private MasterConfigurationNameBuilder nameBuilder;
+    private SlaveConfigurationNameBuilder nameBuilder;
     private Artifact configId;
 
     @Override
@@ -77,7 +77,7 @@
         modify().returnValue(clusterInfoName);
         
         delegate = (ConfigurationStore) mock(ConfigurationStore.class);
-        nameBuilder = (MasterConfigurationNameBuilder) mock(MasterConfigurationNameBuilder.class);
+        nameBuilder = (SlaveConfigurationNameBuilder) mock(SlaveConfigurationNameBuilder.class);
     }
 
     private MasterConfigurationStore newMasterConfigurationStore() {
@@ -96,15 +96,15 @@
                 return delegate;
             }
             @Override
-            protected MasterConfigurationNameBuilder newMasterConfigurationBuilder() {
+            protected SlaveConfigurationNameBuilder newSlaveConfigurationNameBuilder() {
                 return nameBuilder;
             }
         };
     }
     
     public void testContainsConfigurationOK() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(false);
 
         delegate.containsConfiguration(configId);
         modify().returnValue(true);
@@ -116,8 +116,8 @@
     }
     
     public void testContainsConfigurationFailsWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(true);
 
         startVerification();
         
@@ -126,7 +126,11 @@
     }
 
     public void testDelegateCreateNewConfigurationDir() throws Exception {
-        delegate.createNewConfigurationDir(configId);
+        Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
+        nameBuilder.buildSlaveConfigurationName(configId);
+        modify().returnValue(slaveId);
+        
+        delegate.createNewConfigurationDir(slaveId);
         File expectedFile = new File("confDir");
         modify().returnValue(expectedFile);
         
@@ -137,8 +141,8 @@
     }
     
     public void testExportFailsWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(true);
 
         startVerification();
         
@@ -153,8 +157,8 @@
     public void testDelegateExport() throws Exception {
         OutputStream out = new ByteArrayOutputStream();
         
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(false);
         
         delegate.exportConfiguration(configId, out);
         
@@ -186,8 +190,8 @@
     }
     
     public void testIsInPlaceConfigurationWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(true);
 
         startVerification();
         
@@ -200,8 +204,8 @@
     }
 
     public void testIsInPlaceConfigurationReturnsFalse() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(false);
         
         startVerification();
         
@@ -222,12 +226,12 @@
         delegate.listConfigurations();
         modify().returnValue(configurationInfos);
         
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(true);
-        
-        nameBuilder.isMasterConfigurationName(configId2);
+        nameBuilder.isSlaveConfigurationName(configId);
         modify().returnValue(false);
         
+        nameBuilder.isSlaveConfigurationName(configId2);
+        modify().returnValue(true);
+        
         startVerification();
         
         MasterConfigurationStore store = newMasterConfigurationStore();
@@ -237,8 +241,8 @@
     }
 
     public void testLoadConfigurationWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(true);
 
         startVerification();
         
@@ -251,8 +255,8 @@
     }
 
     public void testDelegateLoadConfiguration() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(false);
         
         delegate.loadConfiguration(configId);
         
@@ -263,8 +267,8 @@
     }
 
     public void testResolveWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(true);
         
         startVerification();
         
@@ -277,8 +281,8 @@
     }
     
     public void testDelegateResolve() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(false);
         
         delegate.resolve(configId, null, null);
         
@@ -289,8 +293,8 @@
     }
     
     public void testUninstall() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(true);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(false);
         
         nameBuilder.buildSlaveConfigurationName(configId);
         Artifact slaveId = new Artifact("groupId", "slaveId", "2.0", "car");
@@ -308,8 +312,8 @@
     }
     
     public void testUninstallWhenNotMasterConfigId() throws Exception {
-        nameBuilder.isMasterConfigurationName(configId);
-        modify().returnValue(false);
+        nameBuilder.isSlaveConfigurationName(configId);
+        modify().returnValue(true);
         
         startVerification();
         
@@ -331,13 +335,33 @@
             null,
             new Jsr77Naming());
         
-        final Artifact masterId = new Artifact("groupId", "masterId", "2.0", "car");
-        nameBuilder.buildMasterConfigurationName(configId);
-        modify().returnValue(masterId);
+        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() {
+            public void describeWith(ExpressionDescriber arg) throws IOException {
+            }
+
+            public boolean passes(Object arg) {
+                ConfigurationData configurationData = (ConfigurationData) arg;
+                assertSame(slaveId, configurationData.getId());
+                return true;
+            }
+        });
         
         delegate.install(configurationData);
+        modify().args(new AbstractExpression() {
+            public void describeWith(ExpressionDescriber arg) throws IOException {
+            }
+
+            public boolean passes(Object arg) {
+                ConfigurationData configurationData = (ConfigurationData) arg;
+                assertSame(slaveId, configurationData.getId());
+                return true;
+            }
+        });
         
         NodeInfo nodeInfo = (NodeInfo) mock(NodeInfo.class);
         nodeInfo.getName();
@@ -346,7 +370,7 @@
         clusterInfo.getNodeInfos();
         modify().returnValue(Collections.singleton(nodeInfo));
         
-        delegate.createNewConfigurationDir(masterId);
+        delegate.createNewConfigurationDir(configId);
         final File masterDir = new File("masterDir");
         modify().returnValue(masterDir);
         
@@ -357,7 +381,7 @@
 
             public boolean passes(Object arg) {
                 ConfigurationData configurationData = (ConfigurationData) arg;
-                assertSame(masterId, configurationData.getId());
+                assertSame(configId, configurationData.getId());
                 assertSame(masterDir, configurationData.getConfigurationDir());
                 
                 List<GBeanData> gbeans;
@@ -369,7 +393,7 @@
                 assertEquals(1, gbeans.size());
                 GBeanData gbean = gbeans.get(0);
                 assertEquals(BasicClusterConfigurationController.GBEAN_INFO, gbean.getGBeanInfo());
-                assertEquals(configId, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT));
+                assertEquals(slaveId, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT));
                 assertEquals(nodeName, gbean.getAttribute(BasicClusterConfigurationController.GBEAN_ATTR_NODE_NAME));
                 return true;
             }



Mime
View raw message