brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [06/10] incubator-brooklyn git commit: MySqlCluster - address PR comments
Date Fri, 07 Aug 2015 17:53:39 GMT
MySqlCluster - address PR comments

Also remove public static final modifiers in interface.


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

Branch: refs/heads/master
Commit: f8cb40cea7bdec7ea8fea4af61decddf853d7bea
Parents: 937bc2e
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Wed Aug 5 15:03:59 2015 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Wed Aug 5 15:30:51 2015 +0300

----------------------------------------------------------------------
 .../entity/database/mysql/MySqlCluster.java     |  3 +-
 .../entity/database/mysql/MySqlClusterImpl.java | 13 ++++-----
 .../entity/database/mysql/MySqlNode.java        | 29 ++++++++++----------
 3 files changed, 22 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f8cb40ce/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlCluster.java
----------------------------------------------------------------------
diff --git a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlCluster.java
b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlCluster.java
index 322ada9..54e7869 100644
--- a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlCluster.java
+++ b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlCluster.java
@@ -20,9 +20,10 @@ package brooklyn.entity.database.mysql;
 
 import java.util.Collection;
 
+import org.apache.brooklyn.catalog.Catalog;
+
 import com.google.common.reflect.TypeToken;
 
-import brooklyn.catalog.Catalog;
 import brooklyn.config.ConfigKey;
 import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.database.DatastoreMixins.HasDatastoreUrl;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f8cb40ce/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlClusterImpl.java
----------------------------------------------------------------------
diff --git a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlClusterImpl.java
b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlClusterImpl.java
index 190a0d7..dfa9fe0 100644
--- a/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlClusterImpl.java
+++ b/software/database/src/main/java/brooklyn/entity/database/mysql/MySqlClusterImpl.java
@@ -221,7 +221,7 @@ public class MySqlClusterImpl extends DynamicClusterImpl implements MySqlCluster
         if (!IS_MASTER.apply(node)) {
             ServiceNotUpLogic.updateNotUpIndicator((EntityLocal)node, MySqlSlave.SLAVE_HEALTHY,
"Replication not started");
 
-            FunctionFeed.builder()
+            addFeed(FunctionFeed.builder()
                 .entity((EntityLocal)node)
                 .period(Duration.FIVE_SECONDS)
                 .poll(FunctionPollConfig.forSensor(MySqlSlave.SLAVE_HEALTHY)
@@ -230,7 +230,7 @@ public class MySqlClusterImpl extends DynamicClusterImpl implements MySqlCluster
                         .onSuccess(new SlaveStateParser(node))
                         .setOnFailure(false)
                         .description("Polls SHOW SLAVE STATUS"))
-                .build();
+                .build());
 
             node.addEnricher(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS)
                     .from(MySqlSlave.SLAVE_HEALTHY)
@@ -240,7 +240,7 @@ public class MySqlClusterImpl extends DynamicClusterImpl implements MySqlCluster
         return node;
     }
 
-    public class SlaveStateCallable implements Callable<String> {
+    public static class SlaveStateCallable implements Callable<String> {
         private Entity slave;
         public SlaveStateCallable(Entity slave) {
             this.slave = slave;
@@ -257,7 +257,7 @@ public class MySqlClusterImpl extends DynamicClusterImpl implements MySqlCluster
 
     }
 
-    public class SlaveStateParser implements Function<String, Boolean> {
+    public static class SlaveStateParser implements Function<String, Boolean> {
         private Entity slave;
 
         public SlaveStateParser(Entity slave) {
@@ -376,9 +376,6 @@ public class MySqlClusterImpl extends DynamicClusterImpl implements MySqlCluster
                     !Boolean.TRUE.equals(node.getAttribute(NODE_REPLICATION_INITIALIZED)))
{
 
                 // Events executed sequentially so no need to synchronize here.
-                if (Boolean.TRUE.equals(node.getAttribute(NODE_REPLICATION_INITIALIZED)))
{
-                    return;
-                }
                 ((EntityLocal)node).setAttribute(NODE_REPLICATION_INITIALIZED, Boolean.TRUE);
 
                 DynamicTasks.queueIfPossible(TaskBuilder.builder()
@@ -430,7 +427,7 @@ public class MySqlClusterImpl extends DynamicClusterImpl implements MySqlCluster
 
     // Can't call node.executeScript directly, need to change execution context, so use an
effector task
     private static String executeScriptOnNode(MySqlNode node, String commands) {
-        return node.invoke(MySqlNode.EXECUTE_SCRIPT, ImmutableMap.of("commands", commands)).getUnchecked();
+        return node.invoke(MySqlNode.EXECUTE_SCRIPT, ImmutableMap.of(MySqlNode.EXECUTE_SCRIPT_COMMANDS,
commands)).getUnchecked();
     }
 
     private static String validateSqlParam(String config) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f8cb40ce/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 a5c44e0..c136c2c 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
@@ -44,51 +44,52 @@ public interface MySqlNode extends SoftwareProcess, HasShortName, DatastoreCommo
 
     // NOTE MySQL changes the minor version number of their GA release frequently, check
for latest version if install fails
     @SetFromFlag("version")
-    public static final ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION,
"5.6.26");
+    ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION,
"5.6.26");
 
     //http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26-osx10.9-x86_64.tar.gz
     //http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
     @SetFromFlag("downloadUrl")
-    public static final BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new
StringAttributeSensorAndConfigKey(
+    BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new StringAttributeSensorAndConfigKey(
             Attributes.DOWNLOAD_URL, "http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-${version}-${driver.osTag}.tar.gz");
 
     @SetFromFlag("port")
-    public static final PortAttributeSensorAndConfigKey MYSQL_PORT = new PortAttributeSensorAndConfigKey("mysql.port",
"MySQL port", PortRanges.fromString("3306, 13306+"));
+    PortAttributeSensorAndConfigKey MYSQL_PORT = new PortAttributeSensorAndConfigKey("mysql.port",
"MySQL port", PortRanges.fromString("3306, 13306+"));
 
     @SetFromFlag("dataDir")
-    public static final ConfigKey<String> DATA_DIR = ConfigKeys.newStringConfigKey(
+    ConfigKey<String> DATA_DIR = ConfigKeys.newStringConfigKey(
             "mysql.datadir", "Directory for writing data files", null);
 
     @SetFromFlag("serverConf")
-    public static final MapConfigKey<Object> MYSQL_SERVER_CONF = new MapConfigKey<Object>(
+    MapConfigKey<Object> MYSQL_SERVER_CONF = new MapConfigKey<Object>(
             Object.class, "mysql.server.conf", "Configuration options for mysqld");
     
-    public static final ConfigKey<Object> MYSQL_SERVER_CONF_LOWER_CASE_TABLE_NAMES
= MYSQL_SERVER_CONF.subKey("lower_case_table_names", "See MySQL guide. Set 1 to ignore case
in table names (useful for OS portability)");
+    ConfigKey<Object> MYSQL_SERVER_CONF_LOWER_CASE_TABLE_NAMES = MYSQL_SERVER_CONF.subKey("lower_case_table_names",
"See MySQL guide. Set 1 to ignore case in table names (useful for OS portability)");
     
     @SetFromFlag("serverId")
-    public static final ConfigKey<Integer> MYSQL_SERVER_ID = ConfigKeys.newIntegerConfigKey("mysql.server_id",
"Corresponds to server_id option", 0);
+    ConfigKey<Integer> MYSQL_SERVER_ID = ConfigKeys.newIntegerConfigKey("mysql.server_id",
"Corresponds to server_id option", 0);
     
     @SetFromFlag("password")
-    public static final StringAttributeSensorAndConfigKey PASSWORD = new StringAttributeSensorAndConfigKey(
+    StringAttributeSensorAndConfigKey PASSWORD = new StringAttributeSensorAndConfigKey(
             "mysql.password", "Database admin password (or randomly generated if not set)",
null);
 
     @SetFromFlag("socketUid")
-    public static final StringAttributeSensorAndConfigKey SOCKET_UID = new StringAttributeSensorAndConfigKey(
+    StringAttributeSensorAndConfigKey SOCKET_UID = new StringAttributeSensorAndConfigKey(
             "mysql.socketUid", "Socket uid, for use in file /tmp/mysql.sock.<uid>.3306
(or randomly generated if not set)", null);
     
     /** @deprecated since 0.7.0 use DATASTORE_URL */ @Deprecated
-    public static final AttributeSensor<String> MYSQL_URL = DATASTORE_URL;
+    AttributeSensor<String> MYSQL_URL = DATASTORE_URL;
 
     @SetFromFlag("configurationTemplateUrl")
-    static final BasicAttributeSensorAndConfigKey<String> TEMPLATE_CONFIGURATION_URL
= new StringAttributeSensorAndConfigKey(
+    BasicAttributeSensorAndConfigKey<String> TEMPLATE_CONFIGURATION_URL = new StringAttributeSensorAndConfigKey(
             "mysql.template.configuration.url", "Template file (in freemarker format) for
the mysql.conf file",
             "classpath://brooklyn/entity/database/mysql/mysql.conf");
 
-    public static final AttributeSensor<Double> QUERIES_PER_SECOND_FROM_MYSQL = Sensors.newDoubleSensor("mysql.queries.perSec.fromMysql");
+    AttributeSensor<Double> QUERIES_PER_SECOND_FROM_MYSQL = Sensors.newDoubleSensor("mysql.queries.perSec.fromMysql");
 
     MethodEffector<String> EXECUTE_SCRIPT = new MethodEffector<String>(MySqlNode.class,
"executeScript");
-    
+    String EXECUTE_SCRIPT_COMMANDS = "commands";
+
     @Effector(description = "Execute SQL script on the node as the root user")
-    public String executeScript(@EffectorParam(name="commands") String commands);
+    String executeScript(@EffectorParam(name=EXECUTE_SCRIPT_COMMANDS) String commands);
 
 }


Mime
View raw message