You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/08/28 12:56:50 UTC

[1/5] incubator-brooklyn git commit: Adding timestamp to the template options' name

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 9aee1f34e -> 6212d198a


Adding timestamp to the template options' name

- timeStamp replaces the previously used randId. 
- timeStamp uses the standard unix timestamp represented
  as a 8-char hex string.
- It represents the moment in time when the name is constructed. 
- It gives the possibility to search easily for instances, security
  groups, keypairs, etc based on timestamp without complicated
  enumeration

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

Branch: refs/heads/master
Commit: cdcce8c6cb738eeae24dbb89b8f911e192cdb3e8
Parents: b4547d9
Author: Yavor Yanchev <ya...@yanchev.com>
Authored: Wed Aug 26 18:29:35 2015 +0300
Committer: Yavor Yanchev <ya...@yanchev.com>
Committed: Wed Aug 26 18:29:35 2015 +0300

----------------------------------------------------------------------
 .../location/cloud/names/BasicCloudMachineNamer.java  | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cdcce8c6/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java b/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
index 4777ad4..d6445c9 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
@@ -41,9 +41,15 @@ public class BasicCloudMachineNamer extends AbstractCloudMachineNamer {
         StringShortener shortener = Strings.shortener().separator("-");
         shortener.append("system", "brooklyn");
         
-        // randId often not necessary, as an 8-char hex identifier is added later (in jclouds? can we override?)
-        // however it can be useful to have this early in the string, to prevent collisions in places where it is abbreviated 
-        shortener.append("randId", Identifiers.makeRandomId(4));
+        /* timeStamp replaces the previously used randId. 
+         * 
+         * timeStamp uses the standard unix timestamp represented as a 8-char hex string.
+         * 
+         * It represents the moment in time when the name is constructed. 
+         * It gives the possibility to search easily for instances, security groups, keypairs, etc
+         * based on timestamp without complicated enumeration        
+         */ 
+        shortener.append("timeStamp", Long.toString(System.currentTimeMillis() / 1000L, 16));
         
         String user = System.getProperty("user.name");
         if (!"brooklyn".equals(user))
@@ -79,7 +85,7 @@ public class BasicCloudMachineNamer extends AbstractCloudMachineNamer {
                 .canTruncate("user", 4)
                 .canRemove("entity")
                 .canTruncate("context", 4)
-                .canTruncate("randId", 2)
+                .canTruncate("timeStamp", 8)
                 .canRemove("user")
                 .canTruncate("appId", 2)
                 .canRemove("appId");


[2/5] incubator-brooklyn git commit: Username can be omitted if it is longer than the rules defined in BasicCloudMachineNamer()

Posted by al...@apache.org.
Username can be omitted if it is longer than the rules defined in
  BasicCloudMachineNamer()

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

Branch: refs/heads/master
Commit: ed18f7c76adebf43dd98f08ba52febd46ff8940d
Parents: cdcce8c
Author: Yavor Yanchev <ya...@yanchev.com>
Authored: Wed Aug 26 19:19:05 2015 +0300
Committer: Yavor Yanchev <ya...@yanchev.com>
Committed: Thu Aug 27 15:49:00 2015 +0300

----------------------------------------------------------------------
 .../location/jclouds/JcloudsMachineNamerTest.java      | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ed18f7c7/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsMachineNamerTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsMachineNamerTest.java b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsMachineNamerTest.java
index 515f10d..8c796fa 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsMachineNamerTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsMachineNamerTest.java
@@ -42,10 +42,15 @@ public class JcloudsMachineNamerTest {
         // br-<code>-<user>-myco-1234
         Assert.assertTrue(result.length() <= 24-4-1, "result: "+result);
         
-        String user = Strings.maxlen(System.getProperty("user.name"), 2).toLowerCase();
-        // (length 2 will happen if user is brooklyn, to avoid brooklyn-brooklyn at start!)
-        Assert.assertTrue(result.indexOf(user) >= 0);
+        String user = System.getProperty("user.name");
+        String userExt = Strings.maxlen(user, 2).toLowerCase();
+        
+        // Username can be omitted if it is longer than the rules defined in BasicCloudMachineNamer()
+        if (user.length() <= 4) { 
+            // (length 2 will happen if user is brooklyn, to avoid brooklyn-brooklyn at start!)
+            Assert.assertTrue(result.indexOf(userExt) >= 0);
+        }
         Assert.assertTrue(result.indexOf("-myc") >= 0);
     }
     
-}
+}
\ No newline at end of file


[4/5] incubator-brooklyn git commit: Adjusting the test to take into account the new length

Posted by al...@apache.org.
Adjusting the test to take into account the new length

Name max length is set to 9, because the constructed name will look
  like "br-ntsb50"
  br - 2 chars
  dash (-) - 1 char
  timeStamp - 6 chars

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

Branch: refs/heads/master
Commit: 7923aa7c061c74e3615895314a2cea2ebc911ff3
Parents: dee6481
Author: Yavor Yanchev <ya...@yanchev.com>
Authored: Fri Aug 28 12:07:24 2015 +0300
Committer: Yavor Yanchev <ya...@yanchev.com>
Committed: Fri Aug 28 12:07:24 2015 +0300

----------------------------------------------------------------------
 .../brooklyn/core/location/cloud/CloudMachineNamerTest.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7923aa7c/core/src/test/java/org/apache/brooklyn/core/location/cloud/CloudMachineNamerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/cloud/CloudMachineNamerTest.java b/core/src/test/java/org/apache/brooklyn/core/location/cloud/CloudMachineNamerTest.java
index 4ebaaec..0759114 100644
--- a/core/src/test/java/org/apache/brooklyn/core/location/cloud/CloudMachineNamerTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/location/cloud/CloudMachineNamerTest.java
@@ -113,9 +113,13 @@ public class CloudMachineNamerTest {
         ConfigBag cfg = new ConfigBag()
             .configure(CloudLocationConfig.CALLER_CONTEXT, child);
         BasicCloudMachineNamer namer = new BasicCloudMachineNamer();
-        namer.setDefaultMachineNameMaxLength(10);
+        // name max length is set to 9, because the constructed name will look like "br-ntsb50"
+        // br - 2 chars
+        // dash (-) - 1 char
+        // timeStamp - 6 chars
+        namer.setDefaultMachineNameMaxLength(2 + 1 + 6);
         String result = namer.generateNewMachineUniqueName(cfg);
-        Assert.assertEquals(result.length(), 10);
+        Assert.assertEquals(result.length(), 2 + 1 + 6);
     }
     
     @Test


[5/5] incubator-brooklyn git commit: This closes #868

Posted by al...@apache.org.
This closes #868


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

Branch: refs/heads/master
Commit: 6212d198ae4f4a5cef87858d4d56b741522202cd
Parents: 9aee1f3 7923aa7
Author: Aled Sage <al...@gmail.com>
Authored: Fri Aug 28 11:56:36 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Aug 28 11:56:36 2015 +0100

----------------------------------------------------------------------
 .../location/cloud/names/BasicCloudMachineNamer.java | 15 ++++++++++-----
 .../core/location/cloud/CloudMachineNamerTest.java   |  8 ++++++--
 .../location/jclouds/JcloudsMachineNamerTest.java    | 13 +++++++++----
 3 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[3/5] incubator-brooklyn git commit: - Change the radix to use MAX_RADIX value. - Character.MAX_RADIX value is 36 - Using Character.MAX_RADIX gives a 6-chars long string, instead of the previous 8-chars string when radix is 16

Posted by al...@apache.org.
- Change the radix to use MAX_RADIX value.
- Character.MAX_RADIX value is 36
- Using Character.MAX_RADIX gives a 6-chars long string, instead of
  the previous 8-chars string when radix is 16

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

Branch: refs/heads/master
Commit: dee6481e5e96dcdb0f55b1baee5976a398b4b4c6
Parents: ed18f7c
Author: Yavor Yanchev <ya...@yanchev.com>
Authored: Fri Aug 28 11:10:43 2015 +0300
Committer: Yavor Yanchev <ya...@yanchev.com>
Committed: Fri Aug 28 11:57:38 2015 +0300

----------------------------------------------------------------------
 .../core/location/cloud/names/BasicCloudMachineNamer.java       | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dee6481e/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java b/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
index d6445c9..38ecbe5 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/cloud/names/BasicCloudMachineNamer.java
@@ -22,7 +22,6 @@ import org.apache.brooklyn.api.entity.Application;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
 import org.apache.brooklyn.util.core.config.ConfigBag;
-import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.brooklyn.util.text.StringShortener;
 import org.apache.brooklyn.util.text.Strings;
 
@@ -49,7 +48,7 @@ public class BasicCloudMachineNamer extends AbstractCloudMachineNamer {
          * It gives the possibility to search easily for instances, security groups, keypairs, etc
          * based on timestamp without complicated enumeration        
          */ 
-        shortener.append("timeStamp", Long.toString(System.currentTimeMillis() / 1000L, 16));
+        shortener.append("timeStamp", Long.toString(System.currentTimeMillis() / 1000L, Character.MAX_RADIX));
         
         String user = System.getProperty("user.name");
         if (!"brooklyn".equals(user))
@@ -85,7 +84,7 @@ public class BasicCloudMachineNamer extends AbstractCloudMachineNamer {
                 .canTruncate("user", 4)
                 .canRemove("entity")
                 .canTruncate("context", 4)
-                .canTruncate("timeStamp", 8)
+                .canTruncate("timeStamp", 6)
                 .canRemove("user")
                 .canTruncate("appId", 2)
                 .canRemove("appId");