brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [2/9] incubator-brooklyn git commit: Fixes mongodb authentication for sharded deployment with webapp
Date Wed, 16 Sep 2015 10:52:14 GMT
Fixes mongodb authentication for sharded deployment with webapp


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/aed8448b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/aed8448b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/aed8448b

Branch: refs/heads/master
Commit: aed8448b415a0828d01ea7be6930e5c88a1aeea6
Parents: 1d0e254
Author: Martin Harris <github@nakomis.com>
Authored: Mon Sep 14 16:32:00 2015 +0100
Committer: Martin Harris <github@nakomis.com>
Committed: Mon Sep 14 16:36:22 2015 +0100

----------------------------------------------------------------------
 .../hello-world-sql/src/main/webapp/mongo.jsp   | 15 +++++++--
 parent/pom.xml                                  |  2 +-
 .../nosql/mongodb/AbstractMongoDBSshDriver.java | 12 +++----
 .../nosql/mongodb/MongoDBClientSupport.java     | 19 ++++++-----
 .../nosql/mongodb/MongoDBReplicaSetImpl.java    | 15 +++++++--
 .../entity/nosql/mongodb/ReplicaSetConfig.java  |  4 +++
 .../MongoDBConfigServerClusterImpl.java         |  7 +++--
 .../sharding/MongoDBShardClusterImpl.java       | 33 +++++++++++---------
 .../sharding/MongoDBShardedDeploymentImpl.java  |  3 +-
 .../entity/nosql/mongodb/MongoDBTestHelper.java |  2 +-
 .../resources/mongo-sharded-authentication.yaml | 26 +++++++++++++--
 .../src/test/resources/mongo-sharded.yaml       | 11 ++-----
 12 files changed, 101 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/examples/webapps/hello-world-sql/src/main/webapp/mongo.jsp
----------------------------------------------------------------------
diff --git a/examples/webapps/hello-world-sql/src/main/webapp/mongo.jsp b/examples/webapps/hello-world-sql/src/main/webapp/mongo.jsp
index 7e110cc..bad529f 100644
--- a/examples/webapps/hello-world-sql/src/main/webapp/mongo.jsp
+++ b/examples/webapps/hello-world-sql/src/main/webapp/mongo.jsp
@@ -55,13 +55,24 @@ if (port==null) {
 
 <%
 /* begin database-enabled block */ }
-MongoCredential credential = MongoCredential.createMongoCRCredential(username, authenticationDatabase,
password.toCharArray());
+boolean authenticationEnabled = password != null && password.length() > 0;
+
 ServerAddress address = new ServerAddress("localhost", new Integer(port));
+
 MongoClientOptions connectionOptions = MongoClientOptions.builder()
     .autoConnectRetry(true)
     .socketKeepAlive(true)
     .build();
-MongoClient client = new MongoClient(address, Arrays.asList(credential),connectionOptions);
+
+MongoClient client;
+
+if (authenticationEnabled) {
+    MongoCredential credential = MongoCredential.createMongoCRCredential(username, authenticationDatabase,
password.toCharArray());
+    client = new MongoClient(address, Arrays.asList(credential),connectionOptions);
+} else {
+    client = new MongoClient(address, connectionOptions);
+}
+
 DB database = client.getDB("visitors");
 DBCollection messages =  database.getCollection("messages");
 int i=0;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 246f64c..ad4ebb1 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -107,7 +107,7 @@
         <jsonPath.version>2.0.0</jsonPath.version>
         <commons-compress.version>1.4</commons-compress.version>
         <qpid.version>0.20</qpid.version>
-        <mongodb.version>2.11.4</mongodb.version>
+        <mongodb.version>3.0.3</mongodb.version>
         <riak.version>1.4.0</riak.version>
         <maven-war-plugin.version>2.4</maven-war-plugin.version>
         <validation-api.version>1.0.0.GA</validation-api.version>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/AbstractMongoDBSshDriver.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/AbstractMongoDBSshDriver.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/AbstractMongoDBSshDriver.java
index 9fe949d..277fafd 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/AbstractMongoDBSshDriver.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/AbstractMongoDBSshDriver.java
@@ -27,8 +27,8 @@ import org.apache.brooklyn.api.location.OsDetails;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessSshDriver;
 import org.apache.brooklyn.entity.software.base.lifecycle.ScriptHelper;
+import org.apache.brooklyn.util.core.internal.ssh.SshTool;
 import org.apache.brooklyn.util.time.Duration;
-import org.apache.brooklyn.util.time.Time;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
@@ -61,7 +61,7 @@ public abstract class AbstractMongoDBSshDriver extends AbstractSoftwareProcessSs
         List<String> urls = resolver.getTargets();
         String saveAs = resolver.getFilename();
     
-        List<String> commands = new LinkedList<String>();
+        List<String> commands = new LinkedList<>();
         commands.addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs));
         commands.add(BashCommands.INSTALL_TAR);
         commands.add("tar xzfv " + saveAs);
@@ -75,7 +75,7 @@ public abstract class AbstractMongoDBSshDriver extends AbstractSoftwareProcessSs
     public void customize() {
         Map<?,?> ports = ImmutableMap.of("port", getServerPort());
         Networking.checkPortsValid(ports);
-        List<String> commands = new LinkedList<String>();
+        List<String> commands = new LinkedList<>();
         commands.add(String.format("mkdir -p %s", getDataDirectory()));
 
         if (MongoDBAuthenticationUtils.usesAuthentication(entity)) {
@@ -87,8 +87,8 @@ public abstract class AbstractMongoDBSshDriver extends AbstractSoftwareProcessSs
                 copyResource(keyfileUrl, destinationLocation);
             } else {
                 commands.add(BashCommands.pipeTextToFile(keyfileContents, destinationLocation));
-                commands.add("chmod 600 " + destinationLocation);
             }
+            commands.add("chmod 600 " + destinationLocation);
         }
 
         newScript(CUSTOMIZING)
@@ -192,8 +192,7 @@ public abstract class AbstractMongoDBSshDriver extends AbstractSoftwareProcessSs
 
     protected ImmutableList.Builder<String> getArgsBuilderWithDefaults(AbstractMongoDBServer
server) {
         ImmutableList.Builder<String> builder = getArgsBuilderWithNoAuthentication(server);
-        String keyfileContents = entity.config().get(AbstractMongoDBServer.MONGODB_KEYFILE_CONTENTS);
-        if (keyfileContents != null) {
+        if (MongoDBAuthenticationUtils.usesAuthentication(entity)) {
             builder.add("--keyFile", entity.getAttribute(AbstractMongoDBServer.MONGODB_KEYFILE_DESTINATION));
         }
         return builder;
@@ -216,6 +215,7 @@ public abstract class AbstractMongoDBSshDriver extends AbstractSoftwareProcessSs
         commands.add(String.format("%s/bin/mongod %s > out.log 2> err.log < /dev/null",
getExpandedInstallDir(), args));
 
         newScript(LAUNCHING)
+                .setFlag(SshTool.PROP_CONNECT_TIMEOUT, Duration.TEN_SECONDS.toMilliseconds())
                 .updateTaskAndFailOnNonZeroResultCode()
                 .body.append(commands).execute();
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBClientSupport.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBClientSupport.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBClientSupport.java
index fa2022f..32c128c 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBClientSupport.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBClientSupport.java
@@ -65,7 +65,6 @@ public class MongoDBClientSupport {
 
     // Set client to automatically reconnect to servers.
     private static final MongoClientOptions connectionOptions = MongoClientOptions.builder()
-            .autoConnectRetry(true)
             .socketKeepAlive(true)
             .build();
 
@@ -112,12 +111,18 @@ public class MongoDBClientSupport {
         MongoClient client = client();
         try {
             DB db = client.getDB(database);
-            CommandResult status;
-            try {
-                status = db.command(command);
-            } catch (MongoException e) {
-                LOG.warn("Command " + command + " on " + getServerAddress() + " failed",
e);
-                return Optional.absent();
+            CommandResult status = null;
+            // The mongoDB client can occasionally fail to connect. Try up to 5 times to
run the command
+            for (int i = 0; i < 5; i++) {
+                try {
+                    status = db.command(command);
+                    break;
+                } catch (MongoException e) {
+                    LOG.warn("Command " + command + " on " + getServerAddress() + " failed",
e);
+                    if (i == 4) {
+                        return Optional.absent();
+                    }
+                }
             }
             if (!status.ok()) {
                 LOG.debug("Unexpected result of {} on {}: {}",

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
index a9db033..046c716 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetImpl.java
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import javax.annotation.Nullable;
 
 import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.policy.PolicySpec;
@@ -400,10 +401,18 @@ public class MongoDBReplicaSetImpl extends DynamicClusterImpl implements
MongoDB
             // Ignored
         }
         @Override protected void onEntityAdded(Entity member) {
-            ((MongoDBReplicaSetImpl)entity).serverAdded((MongoDBServer) member);
+            try {
+                ((MongoDBReplicaSetImpl) entity).serverAdded((MongoDBServer) member);
+            } catch (Exception e) {
+                ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator((EntityLocal)member,
"Failed to update replicaset", e);
+            }
         }
         @Override protected void onEntityRemoved(Entity member) {
-            ((MongoDBReplicaSetImpl)entity).serverRemoved((MongoDBServer) member);
+            try {
+                ((MongoDBReplicaSetImpl) entity).serverRemoved((MongoDBServer) member);
+            } catch (Exception e) {
+                ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator((EntityLocal)member,
"Failed to update replicaset", e);
+            }
         }
-    };
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/ReplicaSetConfig.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/ReplicaSetConfig.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/ReplicaSetConfig.java
index 9ea240b..9da870e 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/ReplicaSetConfig.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/ReplicaSetConfig.java
@@ -148,6 +148,10 @@ public class ReplicaSetConfig {
         BasicBSONObject member = new BasicBSONObject();
         member.put("_id", id);
         member.put("host", String.format("%s:%s", hostname, port));
+        if (members.contains(member)) {
+            LOG.warn("Ignoring attempt to add entity to a set of which it is already a member");
+            return this;
+        }
         members.add(member);
         return this;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerClusterImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerClusterImpl.java
index 70fd15e..b5bf2cc 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerClusterImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerClusterImpl.java
@@ -23,11 +23,13 @@ import java.util.Collection;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;
 import org.apache.brooklyn.entity.group.DynamicClusterImpl;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
+import com.google.common.net.HostAndPort;
 
 public class MongoDBConfigServerClusterImpl extends DynamicClusterImpl implements MongoDBConfigServerCluster
{
     
@@ -46,10 +48,11 @@ public class MongoDBConfigServerClusterImpl extends DynamicClusterImpl
implement
         Iterable<String> memberHostNamesAndPorts = Iterables.transform(getMembers(),
new Function<Entity, String>() {
             @Override
             public String apply(Entity entity) {
-                return entity.getAttribute(MongoDBConfigServer.SUBNET_HOSTNAME) + ":" + entity.getAttribute(MongoDBConfigServer.PORT);
+                HostAndPort hostAndPort = BrooklynAccessUtils.getBrooklynAccessibleAddress(entity,
entity.getAttribute(MongoDBConfigServer.PORT));
+                return hostAndPort.getHostText() + ":" + hostAndPort.getPort();
             }
         });
-        setAttribute(MongoDBConfigServerCluster.CONFIG_SERVER_ADDRESSES, ImmutableList.copyOf(memberHostNamesAndPorts));
+        sensors().set(MongoDBConfigServerCluster.CONFIG_SERVER_ADDRESSES, ImmutableList.copyOf(memberHostNamesAndPorts));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardClusterImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardClusterImpl.java
index 31198a8..5f008ea 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardClusterImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardClusterImpl.java
@@ -141,23 +141,28 @@ public class MongoDBShardClusterImpl extends DynamicClusterImpl implements
Mongo
                     } catch (UnknownHostException e) {
                         throw Exceptions.propagate(e);
                     }
-                    
-                    MongoDBServer primary = replicaSet.getAttribute(MongoDBReplicaSet.PRIMARY_ENTITY);
-                    if (primary != null) {
-                        String addr = String.format("%s:%d", primary.getAttribute(MongoDBServer.SUBNET_HOSTNAME),
primary.getAttribute(MongoDBServer.PORT));
-                        String replicaSetURL = ((MongoDBReplicaSet) replicaSet).getName()
+ "/" + addr;
-                        boolean added = client.addShardToRouter(replicaSetURL);
-                        if (added) {
-                            LOG.info("{} added shard {} via {}", new Object[] {MongoDBShardClusterImpl.this,
replicaSetURL, router});
-                            addedMembers.add(replicaSet);
-                            reschedule = false;
+
+                    try {
+                        MongoDBServer primary = replicaSet.getAttribute(MongoDBReplicaSet.PRIMARY_ENTITY);
+                        if (primary != null) {
+                            String addr = String.format("%s:%d", primary.getAttribute(MongoDBServer.SUBNET_HOSTNAME),
primary.getAttribute(MongoDBServer.PORT));
+                            String replicaSetURL = ((MongoDBReplicaSet) replicaSet).getName()
+ "/" + addr;
+                            boolean added = client.addShardToRouter(replicaSetURL);
+                            if (added) {
+                                LOG.info("{} added shard {} via {}", new Object[]{MongoDBShardClusterImpl.this,
replicaSetURL, router});
+                                addedMembers.add(replicaSet);
+                                reschedule = false;
+                            } else {
+                                LOG.debug("Rescheduling addition of shard {} because add
failed via router {}", replicaSetURL, router);
+                                reschedule = true;
+                            }
                         } else {
-                            LOG.debug("Rescheduling addition of shard {} because add failed
via router {}", replicaSetURL, router);
+                            LOG.debug("Rescheduling addition of shard {} because primary
is null", replicaSet);
                             reschedule = true;
                         }
-                    } else {
-                        LOG.debug("Rescheduling addition of shard {} because primary is null",
replicaSet);
-                        reschedule = true;
+                    } catch (Exception e) {
+                        LOG.error("Failed to add shard to router {}:  ", router,  e);
+                        throw Exceptions.propagate(e);
                     }
                 }
                 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentImpl.java
b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentImpl.java
index 0b8a1b6..198e787 100644
--- a/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentImpl.java
+++ b/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentImpl.java
@@ -95,13 +95,14 @@ public class MongoDBShardedDeploymentImpl extends AbstractEntity implements
Mong
             final MongoDBShardCluster shards = getAttribute(SHARD_CLUSTER);
             List<DynamicCluster> clusters = ImmutableList.of(getAttribute(CONFIG_SERVER_CLUSTER),
routers, shards);
             Entities.invokeEffectorList(this, clusters, Startable.START, ImmutableMap.of("locations",
locations))
-                .get();
+                    .get();
 
             if (getConfigRaw(MongoDBShardedDeployment.CO_LOCATED_ROUTER_GROUP, true).isPresent())
{
                 addPolicy(PolicySpec.create(ColocatedRouterTrackingPolicy.class)
                         .displayName("Co-located router tracker")
                         .configure("group", getConfig(MongoDBShardedDeployment.CO_LOCATED_ROUTER_GROUP)));
             }
+
             ServiceNotUpLogic.clearNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL);
             ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
index fb47895..76b2a91 100644
--- a/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
+++ b/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
@@ -115,7 +115,7 @@ public class MongoDBTestHelper {
         try {
             HostAndPort hap = BrooklynAccessUtils.getBrooklynAccessibleAddress(server, server.getAttribute(MongoDBServer.PORT));
             return new MongoClient(hap.getHostText(), hap.getPort());
-        } catch (UnknownHostException e) {
+        } catch (Exception e) {
             // Fail whatever test called this method.
             throw Throwables.propagate(e);
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/usage/launcher/src/test/resources/mongo-sharded-authentication.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/mongo-sharded-authentication.yaml b/usage/launcher/src/test/resources/mongo-sharded-authentication.yaml
index 2d59f1c..9e594db 100644
--- a/usage/launcher/src/test/resources/mongo-sharded-authentication.yaml
+++ b/usage/launcher/src/test/resources/mongo-sharded-authentication.yaml
@@ -1,6 +1,25 @@
+#
+# 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.
+#
+
 name: Sharded MongoDB With Web App
 description: Auto-scaling web app backed by MongoDB
-location: softlayer:ams01
+location: AWS California
 services:
 - type: org.apache.brooklyn.entity.nosql.mongodb.sharding.MongoDBShardedDeployment
   id: mongo
@@ -8,6 +27,7 @@ services:
   brooklyn.config:
     initialShardClusterSize: 5
     shardReplicaSetSize: 3
+    mongodb.router.cluster.initial.size: 0
     coLocatedRouterGroup: $brooklyn:component("webappcluster").attributeWhenReady("controlleddynamicwebappcluster.cluster")
     mongodb.keyfile.url: classpath://mongo.key
     mongodb.root.username: mongouser
@@ -19,7 +39,7 @@ services:
       $brooklyn:entitySpec:
         type: org.apache.brooklyn.entity.nosql.mongodb.sharding.CoLocatedMongoDBRouter
         brooklyn.enrichers:
-          - type: brooklyn.enricher.basic.Propagator
+          - type: org.apache.brooklyn.enricher.stock.Propagator
             brooklyn.config:
               enricher.propagating.sensorMapping:
                 $brooklyn:sensor("org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
"http.port"): $brooklyn:sensor("org.apache.brooklyn.entity.webapp.tomcat.TomcatServer", "http.port")
@@ -42,4 +62,4 @@ services:
                   brooklyn.example.mongodb.password: $brooklyn:component("mongo").attributeWhenReady("mongodb.root.password")
                   brooklyn.example.mongodb.authenticationDatabase: $brooklyn:component("mongo").attributeWhenReady("mongodb.authentication.database")
           - $brooklyn:entitySpec:
-              type: brooklyn.entity.basic.EmptySoftwareProcess
+              type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aed8448b/usage/launcher/src/test/resources/mongo-sharded.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/mongo-sharded.yaml b/usage/launcher/src/test/resources/mongo-sharded.yaml
index 75b5413..d453329 100644
--- a/usage/launcher/src/test/resources/mongo-sharded.yaml
+++ b/usage/launcher/src/test/resources/mongo-sharded.yaml
@@ -18,7 +18,7 @@
 #
 name: Sharded MongoDB With Web App
 description: Auto-scaling web app backed by MongoDB
-location: my-docker-cloud
+location: localhost
 services:
 - type: org.apache.brooklyn.entity.nosql.mongodb.sharding.MongoDBShardedDeployment
   id: mongo
@@ -27,8 +27,6 @@ services:
     initialShardClusterSize: 5
     shardReplicaSetSize: 3
     coLocatedRouterGroup: $brooklyn:component("webappcluster").attributeWhenReady("controlleddynamicwebappcluster.cluster")
-    mongodb.keyfile.url: classpath://mongo.key
-    mongodb.root.user: mongouser
 
 - type: org.apache.brooklyn.entity.webapp.ControlledDynamicWebAppCluster
   id: webappcluster
@@ -40,20 +38,17 @@ services:
           - type: org.apache.brooklyn.enricher.stock.Propagator
             brooklyn.config:
               enricher.propagating.sensorMapping:
-                $brooklyn:sensor("org.apache.brooklyn.entity.webapp.jboss.JBoss7Server",
"http.port"): $brooklyn:sensor("org.apache.brooklyn.entity.webapp.jboss.JBoss7Server", "http.port")

+                $brooklyn:sensor("org.apache.brooklyn.entity.webapp.tomcat.TomcatServer",
"http.port"): $brooklyn:sensor("org.apache.brooklyn.entity.webapp.tomcat.TomcatServer", "http.port")
               enricher.producer: $brooklyn:component("child", "appserver")
         brooklyn.config:
           shardedDeployment: $brooklyn:component("mongo")
           siblingSpecs:
           - $brooklyn:entitySpec:
               id: appserver
-              type: org.apache.brooklyn.entity.webapp.jboss.JBoss7Server
+              type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
               brooklyn.config:
                 war: "classpath://brooklyn-example-hello-world-sql-webapp.war"
                 java.sysprops:
                   brooklyn.example.mongodb.port: $brooklyn:component("parent", "").attributeWhenReady("mongodb.server.port")
-                  brooklyn.example.mongodb.username: $brooklyn:component("parent", "").attributeWhenReady("mongodb.root.username")
-                  brooklyn.example.mongodb.password: $brooklyn:component("parent", "").attributeWhenReady("mongodb.root.password")
-                  brooklyn.example.mongodb.authenticationDatabase: $brooklyn:component("parent",
"").attributeWhenReady("mongodb.root.password")
           - $brooklyn:entitySpec:
               type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess


Mime
View raw message