brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [2/5] git commit: misc chef mysql stuff
Date Mon, 09 Jun 2014 02:05:18 GMT
misc chef mysql stuff


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

Branch: refs/heads/master
Commit: c5c90b6eb9bf40d0e7ebe48fbd21508b5df44dba
Parents: a7f956d
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri May 30 00:03:44 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Mon Jun 2 23:20:50 2014 +0100

----------------------------------------------------------------------
 .../SameServerDriverLifecycleEffectorTasks.java |  2 ++
 .../brooklyn/entity/basic/SameServerEntity.java |  7 ++--
 .../java/brooklyn/entity/chef/ChefConfigs.java  |  6 +++-
 .../mysql/ChefSoloDriverToyMySqlEntity.java     |  2 +-
 .../chef/mysql/DynamicToyMySqlEntityChef.java   |  3 +-
 .../chef/mysql/TypedToyMySqlEntityChef.java     | 37 ++++++++++++++++++++
 .../mysql/DynamicToyMySqlEntityBuilder.java     |  2 +-
 .../main/java/brooklyn/util/git/GithubUrls.java | 24 +++++++++++++
 8 files changed, 76 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/software/base/src/main/java/brooklyn/entity/basic/SameServerDriverLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SameServerDriverLifecycleEffectorTasks.java
b/software/base/src/main/java/brooklyn/entity/basic/SameServerDriverLifecycleEffectorTasks.java
index 791fa62..956584b 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SameServerDriverLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SameServerDriverLifecycleEffectorTasks.java
@@ -60,6 +60,7 @@ public class SameServerDriverLifecycleEffectorTasks extends MachineLifecycleEffe
         return ports;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     protected Map<String, Object> obtainProvisioningFlags(MachineProvisioningLocation<?>
location) {
         Map<String, Object> result = super.obtainProvisioningFlags(location);
@@ -78,6 +79,7 @@ public class SameServerDriverLifecycleEffectorTasks extends MachineLifecycleEffe
     }
 
     /** @return provisioning flags for the given entity */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
     protected Map<String,Object> obtainProvisioningFlags(Entity entity, MachineProvisioningLocation
location) {
         Map<String,Object> result = Maps.newLinkedHashMap();
         result.putAll(Maps.newLinkedHashMap(location.getProvisioningFlags(ImmutableList.of(entity.getEntityType().getName()))));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/software/base/src/main/java/brooklyn/entity/basic/SameServerEntity.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SameServerEntity.java b/software/base/src/main/java/brooklyn/entity/basic/SameServerEntity.java
index 95efe99..7d25b0f 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SameServerEntity.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SameServerEntity.java
@@ -2,19 +2,18 @@ package brooklyn.entity.basic;
 
 import java.util.Map;
 
-import com.google.common.reflect.TypeToken;
-
 import brooklyn.config.ConfigKey;
 import brooklyn.entity.Entity;
 import brooklyn.entity.proxying.ImplementedBy;
 import brooklyn.entity.trait.Startable;
 import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.BasicAttributeSensor;
-import brooklyn.event.basic.BasicConfigKey;
 import brooklyn.location.MachineProvisioningLocation;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.flags.SetFromFlag;
 
+import com.google.common.reflect.TypeToken;
+
 /**
  * An entity that, on start({@link MachineProvisioningLocation}), will obtain a machine
  * and pass that to each of its children by calling their {@link Startable#start(java.util.Collection)}
@@ -25,6 +24,7 @@ import brooklyn.util.flags.SetFromFlag;
  * @author aled
  */
 @ImplementedBy(SameServerEntityImpl.class)
+@SuppressWarnings("serial")
 public interface SameServerEntity extends Entity, Startable {
 
     @SetFromFlag("provisioningProperties")
@@ -35,6 +35,7 @@ public interface SameServerEntity extends Entity, Startable {
     
     AttributeSensor<Lifecycle> SERVICE_STATE = Attributes.SERVICE_STATE;
 
+    @SuppressWarnings("rawtypes")
     AttributeSensor<MachineProvisioningLocation> PROVISIONING_LOCATION = new BasicAttributeSensor<MachineProvisioningLocation>(
             MachineProvisioningLocation.class, "softwareservice.provisioningLocation", "Location
used to provision a machine where this is running");
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/software/base/src/main/java/brooklyn/entity/chef/ChefConfigs.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/chef/ChefConfigs.java b/software/base/src/main/java/brooklyn/entity/chef/ChefConfigs.java
index 0afa375..6494b69 100644
--- a/software/base/src/main/java/brooklyn/entity/chef/ChefConfigs.java
+++ b/software/base/src/main/java/brooklyn/entity/chef/ChefConfigs.java
@@ -8,6 +8,7 @@ import brooklyn.entity.basic.EntityInternal;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.event.basic.MapConfigKey.MapModifications;
 import brooklyn.event.basic.SetConfigKey.SetModifications;
+import brooklyn.util.git.GithubUrls;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Preconditions;
@@ -38,7 +39,10 @@ public class ChefConfigs {
     }
 
     public static String getGithubOpscodeRepo(String cookbookName) {
-        return "https://github.com/opscode-cookbooks/"+cookbookName+"/archive/master.tar.gz";
+        return getGithubOpscodeRepo(cookbookName, "master");
+    }
+    public static String getGithubOpscodeRepo(String cookbookName, String tag) {
+        return GithubUrls.tgz("opscode-cookbooks", cookbookName, tag);
     }
     
     public static void addToCookbooksFromGithub(EntitySpec<?> entity, String cookbookName,
String cookbookUrl) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
b/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
index 4b47852..eabf687 100644
--- a/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
+++ b/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
@@ -14,7 +14,7 @@ import brooklyn.management.TaskFactory;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.time.Duration;
 
-@Deprecated /** @deprecated since 0.7.0 use MySqlEntityChef */
+@Deprecated /** @deprecated since 0.7.0 use see examples {Dynamic,Typed}ToyMySqlEntityChef
*/
 public class ChefSoloDriverToyMySqlEntity extends SoftwareProcessImpl implements ChefConfig
{
 
     public static final String PID_FILE = "/var/run/mysqld/mysqld.pid";

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
b/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
index 0288e86..7b196fd 100644
--- a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
+++ b/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
@@ -20,7 +20,8 @@ public class DynamicToyMySqlEntityChef implements ChefConfig {
         
         ChefConfigs.addToLaunchRunList(spec, "mysql::server");
         spec.configure(PID_FILE, "/var/run/mysqld/mysql*.pid");
-        spec.configure(SERVICE_NAME, "mysql");
+        // it's sometimes mysql, sometimes mysqld, depending ubuntu/centos:
+//        spec.configure(SERVICE_NAME, "mysql");
         
         // chef mysql fails on first run but works on second if switching between server
and solo modes
         spec.configure(ChefConfig.CHEF_RUN_CONVERGE_TWICE, true);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
b/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
new file mode 100644
index 0000000..95f2ee1
--- /dev/null
+++ b/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
@@ -0,0 +1,37 @@
+package brooklyn.entity.chef.mysql;
+
+import brooklyn.entity.chef.ChefConfig;
+import brooklyn.entity.chef.ChefEntityImpl;
+import brooklyn.util.git.GithubUrls;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/** Illustrates how to define an entity using Java as a Java class, extending ChefEntityImpl
*/
+public class TypedToyMySqlEntityChef extends ChefEntityImpl {
+
+    @Override
+    public void init() {
+        super.init();
+
+        String password = "p4ssw0rd";
+        
+        setConfig(CHEF_COOKBOOK_PRIMARY_NAME, "mysql");
+        setConfig(CHEF_COOKBOOK_URLS, ImmutableMap.of(
+            "mysql", GithubUrls.tgz("opscode-cookbooks", "mysql", "v4.0.12"),
+            "openssl", GithubUrls.tgz("opscode-cookbooks", "openssl", "v1.1.0"),
+            "mysql", GithubUrls.tgz("opscode-cookbooks", "build-essential", "v1.4.4")));
+        
+        setConfig(CHEF_LAUNCH_RUN_LIST, ImmutableSet.of("mysql::server"));
+        setConfig(CHEF_LAUNCH_ATTRIBUTES, ImmutableMap.<String,Object>of(
+            "mysql", ImmutableMap.of(
+                "server_root_password", password,
+                "server_repl_password", password,
+                "server_debian_password", password)));
+        
+        setConfig(ChefConfig.PID_FILE, "/var/run/mysqld/mysqld.pid");
+        
+        setConfig(CHEF_MODE, ChefModes.SOLO);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/software/base/src/test/java/brooklyn/entity/software/mysql/DynamicToyMySqlEntityBuilder.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/software/mysql/DynamicToyMySqlEntityBuilder.java
b/software/base/src/test/java/brooklyn/entity/software/mysql/DynamicToyMySqlEntityBuilder.java
index 4da521c..2dfb87e 100644
--- a/software/base/src/test/java/brooklyn/entity/software/mysql/DynamicToyMySqlEntityBuilder.java
+++ b/software/base/src/test/java/brooklyn/entity/software/mysql/DynamicToyMySqlEntityBuilder.java
@@ -156,7 +156,7 @@ public class DynamicToyMySqlEntityBuilder {
     }
 
     private static boolean isLinux(Supplier<MachineLocation> machineS) {
-        return machineS.get().getOsDetails().isLinux();
+        return machineS.get().getMachineDetails().getOsDetails().isLinux();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c5c90b6e/utils/common/src/main/java/brooklyn/util/git/GithubUrls.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/util/git/GithubUrls.java b/utils/common/src/main/java/brooklyn/util/git/GithubUrls.java
new file mode 100644
index 0000000..ef3a2c3
--- /dev/null
+++ b/utils/common/src/main/java/brooklyn/util/git/GithubUrls.java
@@ -0,0 +1,24 @@
+package brooklyn.util.git;
+
+import brooklyn.util.net.Urls;
+
+public class GithubUrls {
+
+    public static String BASE_URL = "https://github.com/";
+    
+    /** returns URL for the root of the given repo */
+    public static String root(String owner, String repo) {
+        return Urls.mergePaths(BASE_URL, owner, repo);
+    }
+    
+    /** returns URL for downloading a .tar.gz version of a tag of a repository */
+    public static String tgz(String owner, String repo, String tag) {
+        return Urls.mergePaths(root(owner, repo), "archive", tag+".tar.gz");
+    }
+
+    /** returns URL for downloading a .zip version of a tag of a repository */
+    public static String zip(String owner, String repo, String tag) {
+        return Urls.mergePaths(root(owner, repo), "archive", tag+".zip");
+    }
+
+}


Mime
View raw message