brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [04/10] incubator-brooklyn git commit: Improve MySqlNode - executeScript effector, fail on invalid creation script
Date Fri, 07 Aug 2015 17:53:37 GMT
Improve MySqlNode - executeScript effector, fail on invalid creation script

* executeScript must be called as an effector to have the correct execution context when creating
the ssh task in the driver. If called as a method the ssh task is executed against the calling
entity which has the wrong machine.
* Fail on creation script execution error


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

Branch: refs/heads/master
Commit: 0c6248fbae3266f5e4a0636e404ea89cbf05b2bf
Parents: 93993f1
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Wed Jul 29 15:37:50 2015 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Wed Aug 5 15:23:06 2015 +0300

----------------------------------------------------------------------
 .../main/java/brooklyn/entity/database/mysql/MySqlNode.java  | 8 +++++++-
 .../java/brooklyn/entity/database/mysql/MySqlSshDriver.java  | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0c6248fb/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlNode.java
----------------------------------------------------------------------
diff --git a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlNode.java
b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlNode.java
index 0268520..36b4812 100644
--- a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlNode.java
+++ b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlNode.java
@@ -20,8 +20,11 @@ package brooklyn.entity.database.mysql;
 
 import org.apache.brooklyn.catalog.Catalog;
 import brooklyn.config.ConfigKey;
+import brooklyn.entity.annotation.Effector;
+import brooklyn.entity.annotation.EffectorParam;
 import brooklyn.entity.basic.Attributes;
 import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.entity.basic.MethodEffector;
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
 import brooklyn.entity.proxying.ImplementedBy;
@@ -80,6 +83,9 @@ public interface MySqlNode extends SoftwareProcess, HasShortName, DatastoreCommo
 
     public static final AttributeSensor<Double> QUERIES_PER_SECOND_FROM_MYSQL = Sensors.newDoubleSensor("mysql.queries.perSec.fromMysql");
 
-    public String executeScript(String commands);
+    MethodEffector<String> EXECUTE_SCRIPT = new MethodEffector<String>(MySqlNode.class,
"executeScript");
+    
+    @Effector(description = "Execute SQL script on the node as the root user")
+    public String executeScript(@EffectorParam(name="commands") String commands);
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0c6248fb/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlSshDriver.java
----------------------------------------------------------------------
diff --git a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlSshDriver.java
b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlSshDriver.java
index c51c7d7..d4fd396 100644
--- a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlSshDriver.java
+++ b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlSshDriver.java
@@ -173,7 +173,7 @@ public class MySqlSshDriver extends AbstractSoftwareProcessSshDriver implements
             ).summary("setting password"));
 
         if (hasCreationScript)
-            executeScriptFromInstalledFileAsync("creation-script.sql");
+            executeScriptFromInstalledFileAsync("creation-script.sql").asTask().getUnchecked();
 
         // not sure necessary to stop then subsequently launch, but seems safest
         // (if skipping, use a flag in launch to indicate we've just launched it)
@@ -270,6 +270,7 @@ public class MySqlSshDriver extends AbstractSoftwareProcessSshDriver implements
                 SshEffectorTasks.ssh(
                                 "cd "+getRunDir(),
                                 getBaseDir()+"/bin/mysql --defaults-file="+getConfigFile()+"
< "+filenameAlreadyInstalledAtServer)
+                        .requiringExitCodeZero()
                         .summary("executing datastore script "+filenameAlreadyInstalledAtServer));
     }
 


Mime
View raw message