Repository: incubator-brooklyn Updated Branches: refs/heads/master 68592b4db -> be9396160
Replaced CouchbaseLoadGenerator classes with yaml VanillaSoftwareProcess Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f2d05ff3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f2d05ff3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f2d05ff3 Branch: refs/heads/master Commit: f2d05ff3d48925bffea39ec96d28345f00d3601f Parents: 21a037f Author: Martin Harris <[email protected]> Authored: Thu Jun 19 14:38:10 2014 +0100 Committer: Martin Harris <[email protected]> Committed: Mon Aug 18 14:36:11 2014 +0100 ---------------------------------------------------------------------- .../nosql/couchbase/CouchbaseLoadGenerator.java | 59 --------- .../couchbase/CouchbaseLoadGeneratorDriver.java | 28 ----- .../couchbase/CouchbaseLoadGeneratorImpl.java | 50 -------- .../CouchbaseLoadGeneratorSshDriver.java | 122 ------------------- .../launcher/src/test/resources/couchbase.yaml | 77 +++++++++++- 5 files changed, 75 insertions(+), 261 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2d05ff3/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGenerator.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGenerator.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGenerator.java deleted file mode 100644 index 37130b9..0000000 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGenerator.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 brooklyn.entity.nosql.couchbase; - -import brooklyn.entity.annotation.Effector; -import brooklyn.entity.annotation.EffectorParam; -import brooklyn.entity.basic.MethodEffector; -import brooklyn.entity.basic.SoftwareProcess; -import brooklyn.entity.proxying.ImplementedBy; - -@ImplementedBy(CouchbaseLoadGeneratorImpl.class) -public interface CouchbaseLoadGenerator extends SoftwareProcess { - public static final MethodEffector<Void> PILLOWFIGHT = new MethodEffector<Void>(CouchbaseLoadGenerator.class, "pillowfight"); - - /** - * NOTE: EffectorParam names match the documentation at http://www.couchbase.com/autodocs/couchbase-c-client-2.1.1/cbc.1.html - */ - @Effector(description = "Runs cbc pillowfight") - public void pillowfight( - @EffectorParam(name = "host", defaultValue="127.0.0.1:8091", - description = "list of hosts to connect to") String targetHostnameAndPort, - @EffectorParam(name = "bucket", defaultValue = "default", - description = "bucket to use") String bucket, - @EffectorParam(name = "username", description = "username used for authentication to the cluster") String username, - @EffectorParam(name = "password", description = "password used for authentication to the cluster") String password, - @EffectorParam(name = "iterations", defaultValue = "1000", - description = "number of iterations to run") Integer iterations, - @EffectorParam(name = "num-items", defaultValue = "1000", - description = "number of items to operate on") Integer numItems, - @EffectorParam(name = "key-prefix", description = "prefix for keys") String keyPrefix, - @EffectorParam(name = "num-threads", defaultValue = "1", - description = "number of threads to use") Integer numThreads, - @EffectorParam(name = "num-instances", defaultValue = "1", - description = "number of connection instances to put into the shared connection pool") Integer numInstances, - @EffectorParam(name = "random-seed", defaultValue = "0", description = "random seed") Integer randomSeed, - @EffectorParam(name = "ratio", defaultValue = "33", - description = "Specify SET/GET command ratio (default: 33, i.e. 33% SETs and 67% GETs)") Integer ratio, - @EffectorParam(name = "min-size", defaultValue = "50", - description = "minimum size of payload, i.e. document body") Integer minSize, - @EffectorParam(name = "max-size", defaultValue = "5120", - description = "maximum size of payload, i.e. document body") Integer maxSize - ); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2d05ff3/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorDriver.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorDriver.java deleted file mode 100644 index 62b1249..0000000 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorDriver.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 brooklyn.entity.nosql.couchbase; - -import brooklyn.entity.basic.SoftwareProcessDriver; - -public interface CouchbaseLoadGeneratorDriver extends SoftwareProcessDriver { - - void pillowfight(String targetHostnameAndPort, String bucket, String username, String password, Integer iterations, - Integer numItems, String keyPrefix, Integer numThreads, Integer numInstances, Integer randomSeed, Integer ratio, - Integer minSize, Integer maxSize); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2d05ff3/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorImpl.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorImpl.java deleted file mode 100644 index 8d932df..0000000 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 brooklyn.entity.nosql.couchbase; - -import brooklyn.entity.basic.SoftwareProcessImpl; - -public class CouchbaseLoadGeneratorImpl extends SoftwareProcessImpl implements CouchbaseLoadGenerator { - - @SuppressWarnings("rawtypes") - @Override - public Class getDriverInterface() { - return CouchbaseLoadGeneratorSshDriver.class; - } - - @Override - public CouchbaseLoadGeneratorSshDriver getDriver() { - return (CouchbaseLoadGeneratorSshDriver)super.getDriver(); - } - - @Override - public void pillowfight(String targetHostnameAndPort, String bucket, String username, String password, Integer iterations, - Integer numItems, String keyPrefix, Integer numThreads, Integer numInstances, Integer randomSeed, Integer ratio, - Integer minSize, Integer maxSize) { - getDriver().pillowfight(targetHostnameAndPort, bucket, username, password, - iterations, numItems, keyPrefix, numThreads, numInstances, randomSeed, ratio, minSize, maxSize); - } - - @Override - protected void connectSensors() { - super.connectSensors(); - connectServiceUpIsRunning(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2d05ff3/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorSshDriver.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorSshDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorSshDriver.java deleted file mode 100644 index b47c5d0..0000000 --- a/software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseLoadGeneratorSshDriver.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 brooklyn.entity.nosql.couchbase; - -import java.util.List; - -import brooklyn.entity.basic.AbstractSoftwareProcessSshDriver; -import brooklyn.entity.basic.EntityLocal; -import brooklyn.location.OsDetails; -import brooklyn.location.basic.SshMachineLocation; -import brooklyn.util.ssh.BashCommands; -import brooklyn.util.text.Strings; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -public class CouchbaseLoadGeneratorSshDriver extends AbstractSoftwareProcessSshDriver implements CouchbaseLoadGeneratorDriver { - - public CouchbaseLoadGeneratorSshDriver(EntityLocal entity, SshMachineLocation machine) { - super(entity, machine); - } - - @Override - public void install() { - OsDetails osDetails = getMachine().getMachineDetails().getOsDetails(); - if (osDetails.isLinux()) { - String aptSetup = BashCommands.ifExecutableElse0("apt-get", BashCommands.chainGroup( - BashCommands.sudo("apt-get update"), - BashCommands.sudo("wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1204.list"), - "wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add - " - )); - String yumSetup = BashCommands.ifExecutableElse0("yum", BashCommands.chainGroup( - // TODO: 32bit / 64bit - BashCommands.sudo("yum check-update"), - BashCommands.sudo("wget -O/etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos55-x86_64.repo") - )); - String installPackage = BashCommands.installPackage(ImmutableMap.of( - "apt", "libcouchbase2-libevent libcouchbase-dev libcouchbase2-bin", - "yum", "libcouchbase2-libevent libcouchbase-devel libcouchbase2-bin" - ), null); - List<String> commands = ImmutableList.<String>builder() - .add(BashCommands.INSTALL_WGET) - .add(BashCommands.alternatives(aptSetup, yumSetup)) - .add(installPackage) - .build(); - newScript(INSTALLING) - .body.append(commands).execute(); - } - } - - @Override - public void customize() { - // no-op - } - - @Override - public void launch() { - // no-op, process is only launch when pillowfight is called - } - - @Override - public boolean isRunning() { - return true; - } - - @Override - public void stop() { - // no-op - } - - @Override - public void pillowfight(String targetHostnameAndPort, String bucket, String username, String password, Integer iterations, - Integer numItems, String keyPrefix, Integer numThreads, Integer numInstances, Integer randomSeed, Integer ratio, - Integer minSize, Integer maxSize) { - StringBuilder builder = new StringBuilder(); - builder.append("cbc pillowfight "); - addOptionalStringParam(builder, "h", targetHostnameAndPort); - addOptionalStringParam(builder, "b", bucket); - addOptionalStringParam(builder, "u", username); - addOptionalStringParam(builder, "P", password); - addIntegerParam(builder, "i", iterations); - addIntegerParam(builder, "I", numItems); - addOptionalStringParam(builder, "p", keyPrefix); - addIntegerParam(builder, "t", numThreads); - addIntegerParam(builder, "Q", numInstances); - addIntegerParam(builder, "s", randomSeed); - addIntegerParam(builder, "r", ratio); - addIntegerParam(builder, "m", minSize); - addIntegerParam(builder, "M", maxSize); - newScript("pillow-fight") - .body.append(builder.toString()) - .gatherOutput() - .failOnNonZeroResultCode() - .execute(); - } - - private void addOptionalStringParam(StringBuilder builder, String paramFlag, String value) { - if (!Strings.isEmpty(value)) { - builder.append(String.format("-%s %s ", paramFlag, value)); - } - } - - private void addIntegerParam(StringBuilder builder, String paramFlag, Integer value) { - builder.append(String.format("-%s %d ", paramFlag, value)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2d05ff3/usage/launcher/src/test/resources/couchbase.yaml ---------------------------------------------------------------------- diff --git a/usage/launcher/src/test/resources/couchbase.yaml b/usage/launcher/src/test/resources/couchbase.yaml index 0359bd8..f22d4f5 100644 --- a/usage/launcher/src/test/resources/couchbase.yaml +++ b/usage/launcher/src/test/resources/couchbase.yaml @@ -17,10 +17,83 @@ # under the License. # name: Couchbase + +location: aws-ec2:eu-west-1 + services: - type: brooklyn.entity.nosql.couchbase.CouchbaseCluster adminUsername: Administrator adminPassword: Password initialSize: 3 -- type: brooklyn.entity.nosql.couchbase.CouchbaseLoadGenerator -location: aws-ec2 +- type: brooklyn.entity.basic.VanillaSoftwareProcess + name: CBC Pillowfight + checkRunning.command: "" + stop.command: "" + launch.command: | + sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1204.list + sudo wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add - + sudo apt-get update + sudo apt-get install -y libcouchbase2-libevent libcouchbase-dev libcouchbase2-bin + brooklyn.initializers: + - type: brooklyn.entity.software.ssh.SshCommandEffector + brooklyn.config: + name: cbcPillowFight + description: runs cbc pillowfight + command: > + cbc pillowfight + `if [ -n "$host" ]; then echo -h $host; fi` + `if [ -n "$bucket" ]; then echo -b $bucket; fi` + `if [ -n "$username" ]; then echo -u $username; fi` + `if [ -n "$password" ]; then echo -p $password; fi` + `if [ -n "$iterations" ]; then echo -i $iterations; fi` + `if [ -n "$numItems" ]; then echo -I $numItems; fi` + `if [ -n "$keyPrefix" ]; then echo -p $keyPrefix; fi` + `if [ -n "$numThreads" ]; then echo -t $numThreads; fi` + `if [ -n "$numInstances" ]; then echo -Q $numInstances; fi` + `if [ -n "$randomSeed" ]; then echo -s $randomSeed; fi` + `if [ -n "$minSize" ]; then echo -m $minSize; fi` + `if [ -n "$maxSize" ]; then echo -M $maxSize; fi` + parameters: + host: + description: list of hosts to connect to + defaultValue: 127.0.0.1:8091 + bucket: + description: bucket to use + defaultValue: default + username: + description: username used for authentication to the cluster + password: + description: password used for authentication to the cluster + iterations: + description: number of iterations to run + defaultValue: 1000 + numItems: + description: number of items to operate on + defaultValue: 1000 + keyPrefix: + description: prefix for keys + numThreads: + description: number of threads to use + defaultValue: 1 + numInstances: + description: number of connection instances to put into the shared connection pool + defaultValue: 1 + randomSeed: + description: random seed + defaultValue: 0 + ratio: + description: "specify SET/GET command ratio (default: 33, i.e. 33% SETs and 67% GETs)" + defaultValue: 33 + minSize: + description: minimum size of payload, i.e. document body + defaultValue: 50 + maxSize: + description: maximum size of payload, i.e. document body + defaultValue: 5120 + +# For CentOS, use the following launch command: +# launch.command: | +# sudo wget -O/etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos55-x86_64.repo +# sudo yum check-update +# sudo yum install -y libcouchbase2-libevent libcouchbase-devel libcouchbase2-bin +
