From f3668453f08d1289f2b360537c0e88a2661f3a9c Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Wed, 12 Mar 2014 09:03:58 +0100 Subject: [PATCH] Fix compile issues in mysql-ha plugin --- plugins/database/mysql-ha/pom.xml | 4 ++-- .../com/cloud/utils/db/StaticStrategy.java | 21 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/database/mysql-ha/pom.xml b/plugins/database/mysql-ha/pom.xml index 5ce6d6f52b1..d5eb3971804 100644 --- a/plugins/database/mysql-ha/pom.xml +++ b/plugins/database/mysql-ha/pom.xml @@ -15,8 +15,8 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT - ../pom.xml + 4.3.0 + ../../pom.xml diff --git a/plugins/database/mysql-ha/src/com/cloud/utils/db/StaticStrategy.java b/plugins/database/mysql-ha/src/com/cloud/utils/db/StaticStrategy.java index 29e96dfc18e..5426c5ffdf4 100644 --- a/plugins/database/mysql-ha/src/com/cloud/utils/db/StaticStrategy.java +++ b/plugins/database/mysql-ha/src/com/cloud/utils/db/StaticStrategy.java @@ -34,14 +34,17 @@ public class StaticStrategy implements BalanceStrategy { public StaticStrategy() { } + @Override public void destroy() { // we don't have anything to clean up } + @Override public void init(Connection conn, Properties props) throws SQLException { // we don't have anything to initialize } + @Override public ConnectionImpl pickConnection(LoadBalancingConnectionProxy proxy, List configuredHosts, Map liveConnections, long[] responseTimes, int numRetries) throws SQLException { @@ -51,13 +54,13 @@ public class StaticStrategy implements BalanceStrategy { List whiteList = new ArrayList(numHosts); whiteList.addAll(configuredHosts); - + Map blackList = proxy.getGlobalBlacklist(); whiteList.removeAll(blackList.keySet()); - - Map whiteListMap = this.getArrayIndexMap(whiteList); - + + Map whiteListMap = getArrayIndexMap(whiteList); + for (int attempts = 0; attempts < numRetries;) { if(whiteList.size() == 0){ @@ -81,7 +84,7 @@ public class StaticStrategy implements BalanceStrategy { // exclude this host from being picked again if (whiteListIndex != null) { whiteList.remove(whiteListIndex.intValue()); - whiteListMap = this.getArrayIndexMap(whiteList); + whiteListMap = getArrayIndexMap(whiteList); } proxy.addToGlobalBlacklist( hostPortSpec ); @@ -98,7 +101,7 @@ public class StaticStrategy implements BalanceStrategy { blackList = proxy.getGlobalBlacklist(); whiteList.removeAll(blackList.keySet()); - whiteListMap = this.getArrayIndexMap(whiteList); + whiteListMap = getArrayIndexMap(whiteList); } continue; @@ -107,7 +110,7 @@ public class StaticStrategy implements BalanceStrategy { throw sqlEx; } } - + return conn; } @@ -117,14 +120,14 @@ public class StaticStrategy implements BalanceStrategy { return null; // we won't get here, compiler can't tell } - + private Map getArrayIndexMap(List l) { Map m = new HashMap(l.size()); for (int i = 0; i < l.size(); i++) { m.put(l.get(i), Integer.valueOf(i)); } return m; - + } } \ No newline at end of file