You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by as...@apache.org on 2011/04/18 21:41:30 UTC
svn commit: r1094708 - in /incubator/whirr/trunk: ./ core/
core/src/main/java/org/apache/whirr/
core/src/main/java/org/apache/whirr/service/ core/src/main/resources/
core/src/test/java/org/apache/whirr/
Author: asavu
Date: Mon Apr 18 19:41:30 2011
New Revision: 1094708
URL: http://svn.apache.org/viewvc?rev=1094708&view=rev
Log:
WHIRR-279. Create ClusterSpec aware BlobStoreContext factory class (asavu)
Added:
incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java
Modified:
incubator/whirr/trunk/CHANGES.txt
incubator/whirr/trunk/core/pom.xml
incubator/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
incubator/whirr/trunk/core/src/main/resources/whirr-default.properties
incubator/whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java
incubator/whirr/trunk/pom.xml
Modified: incubator/whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/CHANGES.txt?rev=1094708&r1=1094707&r2=1094708&view=diff
==============================================================================
--- incubator/whirr/trunk/CHANGES.txt (original)
+++ incubator/whirr/trunk/CHANGES.txt Mon Apr 18 19:41:30 2011
@@ -37,6 +37,8 @@ Trunk (unreleased changes)
WHIRR-283. Whirr in 5 minutes. (tomwhite)
+ WHIRR-279. Create ClusterSpec aware BlobStoreContext factory class (asavu)
+
BUG FIXES
WHIRR-253. ZooKeeper service should only authorize ingress to ZooKeeper
Modified: incubator/whirr/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/pom.xml?rev=1094708&r1=1094707&r2=1094708&view=diff
==============================================================================
--- incubator/whirr/trunk/core/pom.xml (original)
+++ incubator/whirr/trunk/core/pom.xml Mon Apr 18 19:41:30 2011
@@ -62,6 +62,10 @@
<artifactId>cloudservers-uk</artifactId>
</dependency>
<dependency>
+ <groupId>org.jclouds</groupId>
+ <artifactId>jclouds-allblobstore</artifactId>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
Modified: incubator/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java?rev=1094708&r1=1094707&r2=1094708&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java (original)
+++ incubator/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java Mon Apr 18 19:41:30 2011
@@ -25,6 +25,7 @@ import static org.apache.whirr.util.KeyP
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
@@ -70,9 +71,19 @@ public class ClusterSpec {
}
public enum Property {
+ CLUSTER_NAME(String.class, false, "The name of the cluster " +
+ "to operate on. E.g. hadoopcluster."),
+
SERVICE_NAME(String.class, false, "(optional) The name of the " +
"service to use. E.g. hadoop."),
+ LOGIN_USER(String.class, false, "Override the default login user "+
+ "used to bootstrap whirr. E.g. ubuntu or myuser:mypass."),
+
+ CLUSTER_USER(String.class, false, "The name of the user that Whirr " +
+ "will create on all the cluster instances. You have to use " +
+ "this user to login to nodes."),
+
INSTANCE_TEMPLATES(String.class, false, "The number of instances " +
"to launch for each set of roles. E.g. 1 hadoop-namenode+" +
"hadoop-jobtracker, 10 hadoop-datanode+hadoop-tasktracker"),
@@ -99,15 +110,19 @@ public class ClusterSpec {
CREDENTIAL(String.class, false, "The cloud credential."),
IDENTITY(String.class, false, "The cloud identity."),
-
- CLUSTER_NAME(String.class, false, "The name of the cluster " +
- "to operate on. E.g. hadoopcluster."),
-
+
PUBLIC_KEY_FILE(String.class, false, "The filename of the public " +
"key used to connect to instances."),
PRIVATE_KEY_FILE(String.class, false, "The filename of the " +
"private RSA key used to connect to instances."),
+
+ BLOBSTORE_PROVIDER(String.class, false, "The blob store provider. " +
+ "E.g. aws-s3, cloudfiles-us, cloudfiles-uk"),
+
+ BLOBSTORE_IDENTITY(String.class, false, "The blob store identity"),
+
+ BLOBSTORE_CREDENTIAL(String.class, false, "The blob store credential"),
IMAGE_ID(String.class, false, "The ID of the image to use for " +
"instances. If not specified then a vanilla Linux image is " +
@@ -122,21 +137,14 @@ public class ClusterSpec {
LOCATION_ID(String.class, false, "The location to launch " +
"instances in. If not specified then an arbitrary location " +
"will be chosen."),
-
- CLIENT_CIDRS(String.class, true, "A comma-separated list of CIDR" +
+
+ CLIENT_CIDRS(String.class, true, "A comma-separated list of CIDR" +
" blocks. E.g. 208.128.0.0/11,108.128.0.0/11"),
VERSION(String.class, false, ""),
RUN_URL_BASE(String.class, false, "The base URL for forming run " +
- "urls from. Change this to host your own set of launch scripts."),
-
- LOGIN_USER(String.class, false, "Override the default login user "+
- "used to bootstrap whirr. E.g. ubuntu or myuser:mypass."),
-
- CLUSTER_USER(String.class, false, "The name of the user that Whirr " +
- "will create on all the cluster instances. You have to use " +
- "this user to login to nodes.");
+ "urls from. Change this to host your own set of launch scripts.");
private Class<?> type;
private boolean multipleArguments;
@@ -223,6 +231,10 @@ public class ClusterSpec {
private String identity;
private String credential;
+ private String blobStoreProvider;
+ private String blobStoreIdentity;
+ private String blobStoreCredential;
+
private String privateKey;
private File privateKeyFile;
private String publicKey;
@@ -272,6 +284,10 @@ public class ClusterSpec {
setIdentity(getString(Property.IDENTITY));
setCredential(getString(Property.CREDENTIAL));
+ setBlobStoreProvider(getString(Property.BLOBSTORE_PROVIDER));
+ setBlobStoreIdentity(getString(Property.BLOBSTORE_IDENTITY));
+ setBlobStoreCredential(getString(Property.BLOBSTORE_CREDENTIAL));
+
checkAndSetKeyPair();
setImageId(getString(Property.IMAGE_ID));
@@ -382,6 +398,46 @@ public class ClusterSpec {
return clusterName;
}
+ public String getBlobStoreProvider() {
+ if (blobStoreProvider == null) {
+ return getDefaultBlobStoreForComputeProvider();
+ }
+ return blobStoreProvider;
+ }
+
+ /**
+ * Probably jclouds should provide a similar mechanism
+ */
+ private String getDefaultBlobStoreForComputeProvider() {
+ Map<String, String> mappings = Maps.newHashMap();
+
+ mappings.put("ec2","aws-s3");
+ mappings.put("aws-ec2", "aws-s3");
+
+ mappings.put("cloudservers", "cloudfiles-us");
+ mappings.put("cloudservers-us", "cloudfiles-us");
+ mappings.put("cloudservers-uk", "cloudfiles-uk");
+
+ if (!mappings.containsKey(provider)) {
+ return null;
+ }
+ return mappings.get(provider);
+ }
+
+ public String getBlobStoreIdentity() {
+ if (blobStoreIdentity == null) {
+ return identity;
+ }
+ return blobStoreIdentity;
+ }
+
+ public String getBlobStoreCredential() {
+ if (blobStoreCredential == null) {
+ return credential;
+ }
+ return blobStoreCredential;
+ }
+
public String getServiceName() {
return serviceName;
}
@@ -454,6 +510,18 @@ public class ClusterSpec {
this.credential = credential;
}
+ public void setBlobStoreProvider(String provider) {
+ blobStoreProvider = provider;
+ }
+
+ public void setBlobStoreIdentity(String identity) {
+ blobStoreIdentity = identity;
+ }
+
+ public void setBlobStoreCredential(String credential) {
+ blobStoreCredential = credential;
+ }
+
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
@@ -596,6 +664,9 @@ public class ClusterSpec {
&& Objects.equal(provider, that.provider)
&& Objects.equal(identity, that.identity)
&& Objects.equal(credential, that.credential)
+ && Objects.equal(blobStoreProvider, that.blobStoreProvider)
+ && Objects.equal(blobStoreIdentity, that.blobStoreIdentity)
+ && Objects.equal(blobStoreCredential, that.blobStoreCredential)
&& Objects.equal(clusterName, that.clusterName)
&& Objects.equal(serviceName, that.serviceName)
&& Objects.equal(clusterUser, that.clusterUser)
@@ -613,9 +684,9 @@ public class ClusterSpec {
public int hashCode() {
return Objects.hashCode(instanceTemplates, maxStartupRetries, provider,
- identity, credential, clusterName, serviceName, clusterUser, loginUser,
- publicKey, privateKey, imageId, hardwareId, locationId, clientCidrs,
- version, runUrlBase);
+ identity, credential, blobStoreProvider, blobStoreIdentity, blobStoreCredential,
+ clusterName, serviceName, clusterUser, loginUser, publicKey, privateKey, imageId,
+ hardwareId, locationId, clientCidrs, version, runUrlBase);
}
public String toString() {
@@ -625,6 +696,9 @@ public class ClusterSpec {
.add("provider", provider)
.add("identity", identity)
.add("credential", credential)
+ .add("blobStoreProvider", blobStoreProvider)
+ .add("blobStoreCredential", blobStoreCredential)
+ .add("blobStoreIdentity", blobStoreIdentity)
.add("clusterName", clusterName)
.add("serviceName", serviceName)
.add("clusterUser", clusterUser)
Added: incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java?rev=1094708&view=auto
==============================================================================
--- incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java (added)
+++ incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/BlobStoreContextBuilder.java Mon Apr 18 19:41:30 2011
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.service;
+
+import org.apache.whirr.ClusterSpec;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.BlobStoreContextFactory;
+
+public class BlobStoreContextBuilder {
+
+ public static BlobStoreContext build(final ClusterSpec spec) {
+ return build(new BlobStoreContextFactory(), spec);
+ }
+
+ public static BlobStoreContext build(final BlobStoreContextFactory factory,
+ final ClusterSpec spec) {
+ return factory.createContext(spec.getBlobStoreProvider(),
+ spec.getBlobStoreIdentity(), spec.getBlobStoreCredential());
+ }
+
+}
Modified: incubator/whirr/trunk/core/src/main/resources/whirr-default.properties
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/main/resources/whirr-default.properties?rev=1094708&r1=1094707&r2=1094708&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/main/resources/whirr-default.properties (original)
+++ incubator/whirr/trunk/core/src/main/resources/whirr-default.properties Mon Apr 18 19:41:30 2011
@@ -20,3 +20,4 @@ whirr.version=${version}
whirr.max-startup-retries=1
whirr.cluster-user=${sys:user.name}
+
Modified: incubator/whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java?rev=1094708&r1=1094707&r2=1094708&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java (original)
+++ incubator/whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java Mon Apr 18 19:41:30 2011
@@ -292,4 +292,23 @@ public class ClusterSpecTest {
assertThat(spec.getClusterUser(), is(System.getProperty("user.name")));
}
+ @Test
+ public void testDefaultBlobStoreforComputeProvider() throws Exception {
+ for(String pair : new String[]{
+ "ec2:aws-s3",
+ "aws-ec2:aws-s3",
+ "cloudservers:cloudfiles-us",
+ "cloudservers-us:cloudfiles-us",
+ "cloudservers-uk:cloudfiles-uk"
+ }) {
+ String[] parts = pair.split(":");
+
+ Configuration config = new PropertiesConfiguration();
+ config.addProperty("whirr.provider", parts[0]);
+
+ ClusterSpec spec = ClusterSpec.withTemporaryKeys(config);
+ assertThat(spec.getBlobStoreProvider(), is(parts[1]));
+ }
+ }
+
}
Modified: incubator/whirr/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/pom.xml?rev=1094708&r1=1094707&r2=1094708&view=diff
==============================================================================
--- incubator/whirr/trunk/pom.xml (original)
+++ incubator/whirr/trunk/pom.xml Mon Apr 18 19:41:30 2011
@@ -96,6 +96,12 @@
<artifactId>cloudservers-uk</artifactId>
<version>${jclouds.version}</version>
</dependency>
+ <!-- All cloud blob store providers are supported by default -->
+ <dependency>
+ <groupId>org.jclouds</groupId>
+ <artifactId>jclouds-allblobstore</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
<!-- End supported cloud providers. -->
<dependency>
<groupId>junit</groupId>