Author: tomwhite
Date: Tue Oct 26 16:39:35 2010
New Revision: 1027637
URL: http://svn.apache.org/viewvc?rev=1027637&view=rev
Log:
WHIRR-114. Support + character in version number.
Modified:
incubator/whirr/trunk/CHANGES.txt
incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterSpec.java
incubator/whirr/trunk/core/src/main/resources/whirr-default.properties
incubator/whirr/trunk/core/src/test/java/org/apache/whirr/service/ClusterSpecTest.java
Modified: incubator/whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/CHANGES.txt?rev=1027637&r1=1027636&r2=1027637&view=diff
==============================================================================
--- incubator/whirr/trunk/CHANGES.txt (original)
+++ incubator/whirr/trunk/CHANGES.txt Tue Oct 26 16:39:35 2010
@@ -52,6 +52,8 @@ Trunk (unreleased changes)
WHIRR-113. Hadoop cluster instances should all start in the same location.
(tomwhite)
+ WHIRR-114. Support + character in version number. (tomwhite)
+
Release 0.1.0 - 2010-09-02
INCOMPATIBLE CHANGES
Modified: incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterSpec.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterSpec.java?rev=1027637&r1=1027636&r2=1027637&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterSpec.java (original)
+++ incubator/whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterSpec.java Tue
Oct 26 16:39:35 2010
@@ -30,6 +30,8 @@ import com.google.common.collect.Sets;
import java.io.File;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.util.List;
import java.util.Set;
@@ -58,6 +60,7 @@ public class ClusterSpec {
HARDWARE_ID(String.class, false),
LOCATION_ID(String.class, false),
CLIENT_CIDRS(String.class, true),
+ VERSION(String.class, false),
RUN_URL_BASE(String.class, false);
private Class<?> type;
@@ -154,6 +157,7 @@ public class ClusterSpec {
private String hardwareId;
private String locationId;
private List<String> clientCidrs;
+ private String version;
private String runUrlBase;
private Configuration config;
@@ -196,7 +200,17 @@ public class ClusterSpec {
setHardwareId(config.getString(Property.HARDWARE_ID.getConfigName()));
setLocationId(config.getString(Property.LOCATION_ID.getConfigName()));
setClientCidrs(c.getList(Property.CLIENT_CIDRS.getConfigName()));
- setRunUrlBase(c.getString(Property.RUN_URL_BASE.getConfigName()));
+ setVersion(c.getString(Property.VERSION.getConfigName()));
+ String runUrlBase = c.getString(Property.RUN_URL_BASE.getConfigName());
+ if (runUrlBase == null) {
+ try {
+ runUrlBase = String.format("http://whirr.s3.amazonaws.com/%s/",
+ URLEncoder.encode(getVersion(), "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ throw new ConfigurationException(e);
+ }
+ }
+ setRunUrlBase(runUrlBase);
this.config = c;
}
@@ -264,7 +278,9 @@ public class ClusterSpec {
public List<String> getClientCidrs() {
return clientCidrs;
}
-
+ public String getVersion() {
+ return version;
+ }
public String getRunUrlBase() {
return runUrlBase;
}
@@ -354,6 +370,10 @@ public class ClusterSpec {
public void setClientCidrs(List<String> clientCidrs) {
this.clientCidrs = clientCidrs;
}
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
public void setRunUrlBase(String runUrlBase) {
this.runUrlBase = runUrlBase;
@@ -378,6 +398,7 @@ public class ClusterSpec {
&& Objects.equal(hardwareId, that.hardwareId)
&& Objects.equal(locationId, that.locationId)
&& Objects.equal(clientCidrs, that.clientCidrs)
+ && Objects.equal(version, that.version)
&& Objects.equal(runUrlBase, that.runUrlBase)
;
}
@@ -387,7 +408,7 @@ public class ClusterSpec {
public int hashCode() {
return Objects.hashCode(instanceTemplates, serviceName,
provider, identity, credential, clusterName, publicKey,
- privateKey, imageId, hardwareId, locationId, clientCidrs,
+ privateKey, imageId, hardwareId, locationId, clientCidrs, version,
runUrlBase);
}
@@ -405,6 +426,7 @@ public class ClusterSpec {
.add("instanceSizeId", hardwareId)
.add("locationId", locationId)
.add("clientCidrs", clientCidrs)
+ .add("version", version)
.add("runUrlBase", runUrlBase)
.toString();
}
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=1027637&r1=1027636&r2=1027637&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/main/resources/whirr-default.properties (original)
+++ incubator/whirr/trunk/core/src/main/resources/whirr-default.properties Tue Oct 26 16:39:35
2010
@@ -12,4 +12,4 @@
whirr.private-key-file=${sys:user.home}/.ssh/id_rsa
whirr.public-key-file=${sys:user.home}/.ssh/id_rsa.pub
-whirr.run-url-base=http://whirr.s3.amazonaws.com/${version}/
\ No newline at end of file
+whirr.version=${version}
Modified: incubator/whirr/trunk/core/src/test/java/org/apache/whirr/service/ClusterSpecTest.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/core/src/test/java/org/apache/whirr/service/ClusterSpecTest.java?rev=1027637&r1=1027636&r2=1027637&view=diff
==============================================================================
--- incubator/whirr/trunk/core/src/test/java/org/apache/whirr/service/ClusterSpecTest.java
(original)
+++ incubator/whirr/trunk/core/src/test/java/org/apache/whirr/service/ClusterSpecTest.java
Tue Oct 26 16:39:35 2010
@@ -18,6 +18,7 @@
package org.apache.whirr.service;
+import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
@@ -41,8 +42,16 @@ public class ClusterSpecTest {
conf.setProperty(ClusterSpec.Property.RUN_URL_BASE.getConfigName(),
"http://example.org");
ClusterSpec spec = new ClusterSpec(conf);
- assertThat(spec.getRunUrlBase(),
- startsWith("http://example.org"));
+ assertThat(spec.getRunUrlBase(), is("http://example.org"));
}
+ @Test
+ public void testVersionInRunUrlbaseIsUrlEncoded()
+ throws ConfigurationException {
+ Configuration conf = new PropertiesConfiguration();
+ conf.setProperty(ClusterSpec.Property.VERSION.getConfigName(), "0.1.0+1");
+ ClusterSpec spec = new ClusterSpec(conf);
+ assertThat(spec.getRunUrlBase(),
+ is("http://whirr.s3.amazonaws.com/0.1.0%2B1/"));
+ }
}
|