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 <[email protected]>
Authored: Wed Aug 26 18:29:35 2015 +0300
Committer: Yavor Yanchev <[email protected]>
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");

Reply via email to