diff --git a/build.gradle b/build.gradle index f269b24..b9b2c96 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ description = 'Smart REST Client - JAX-RS (Jersey) REST client that provides cli ext.githubProjectName = 'smart-client-java' buildscript { - ext.commonBuildVersion = '1.5' + ext.commonBuildVersion = '1.6' ext.commonBuildDir = "https://raw.githubusercontent.com/emcvipr/ecs-common-build/v$commonBuildVersion" apply from: "$commonBuildDir/ecs-publish.buildscript.gradle", to: buildscript } @@ -37,8 +37,8 @@ buildscript { apply from: "$commonBuildDir/ecs-publish.gradle" dependencies { - compile 'com.sun.jersey:jersey-client:1.19', - 'com.sun.jersey.contribs:jersey-apache-client4:1.19', + compile 'com.sun.jersey:jersey-client:1.19.3', + 'com.sun.jersey.contribs:jersey-apache-client4:1.19.3', 'org.apache.httpcomponents:httpclient:4.2.6', 'org.slf4j:slf4j-api:1.7.5' runtime 'org.slf4j:slf4j-log4j12:1.7.5' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c97a8bd..d3b8398 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 77bcfb0..025c765 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Feb 10 16:00:30 CST 2015 +#Thu Mar 02 11:15:41 CST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..27309d9 100755 --- a/gradlew +++ b/gradlew @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..832fdb6 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,7 +46,7 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args diff --git a/src/main/java/com/emc/rest/smart/Host.java b/src/main/java/com/emc/rest/smart/Host.java index 2b1fc14..4314929 100644 --- a/src/main/java/com/emc/rest/smart/Host.java +++ b/src/main/java/com/emc/rest/smart/Host.java @@ -26,11 +26,11 @@ */ package com.emc.rest.smart; -import java.util.Date; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Date; + /** * Some basic statements about response index calculation: *

@@ -105,7 +105,9 @@ public boolean isHealthy() { if (!healthy) return false; else if (consecutiveErrors == 0) return true; else { - long coolDownExp = consecutiveErrors > MAX_COOL_DOWN_EXP ? MAX_COOL_DOWN_EXP : consecutiveErrors - 1; + // errorWaitTime * 2 ^ (min(errors-1, 4)) + // i.e. back-off is doubled for each consecutive error up to 4 + long coolDownExp = Math.min(consecutiveErrors - 1, MAX_COOL_DOWN_EXP); long msSinceLastUse = System.currentTimeMillis() - lastConnectionTime; long errorCoolDown = (long) Math.pow(2, coolDownExp) * errorWaitTime; return msSinceLastUse > errorCoolDown; diff --git a/src/main/java/com/emc/rest/smart/SmartClientFactory.java b/src/main/java/com/emc/rest/smart/SmartClientFactory.java index 6709fe9..2f5efac 100644 --- a/src/main/java/com/emc/rest/smart/SmartClientFactory.java +++ b/src/main/java/com/emc/rest/smart/SmartClientFactory.java @@ -138,9 +138,9 @@ static ApacheHttpClient4Handler createApacheClientHandler(SmartConfig smartConfi // set up multi-threaded connection pool org.apache.http.impl.conn.PoolingClientConnectionManager connectionManager = new org.apache.http.impl.conn.PoolingClientConnectionManager(); - // 200 maximum active connections (should be more than enough for any JVM instance) - connectionManager.setDefaultMaxPerRoute(200); - connectionManager.setMaxTotal(200); + // 999 maximum active connections (max allowed) + connectionManager.setDefaultMaxPerRoute(999); + connectionManager.setMaxTotal(999); clientConfig.getProperties().put(ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER, connectionManager); // set proxy config diff --git a/src/test/java/com/emc/rest/smart/HostTest.java b/src/test/java/com/emc/rest/smart/HostTest.java index fc30426..151469e 100644 --- a/src/test/java/com/emc/rest/smart/HostTest.java +++ b/src/test/java/com/emc/rest/smart/HostTest.java @@ -71,7 +71,7 @@ public void testHost() throws Exception { Thread.sleep(errorWaitTime - 500); // wait until just before the error is cooled down Assert.assertFalse(host.isHealthy()); // host should still be in cool down period - Thread.sleep(500); // wait until cool down period is over + Thread.sleep(600); // wait until cool down period is over Assert.assertTrue(host.isHealthy()); // test another error @@ -89,7 +89,7 @@ public void testHost() throws Exception { Thread.sleep(2 * errorWaitTime - 500); // wait until just before cool down is over Assert.assertFalse(host.isHealthy()); - Thread.sleep(500); // wait until cool down period is over + Thread.sleep(600); // wait until cool down period is over Assert.assertTrue(host.isHealthy()); // test one more error @@ -107,7 +107,7 @@ public void testHost() throws Exception { Thread.sleep(2 * 2 * errorWaitTime - 500); // wait until just before cool down is over Assert.assertFalse(host.isHealthy()); - Thread.sleep(500); // wait until cool down period is over + Thread.sleep(600); // wait until cool down period is over Assert.assertTrue(host.isHealthy()); // test no more errors diff --git a/src/test/java/com/emc/rest/smart/SmartClientTest.java b/src/test/java/com/emc/rest/smart/SmartClientTest.java index 0afaafc..7306e3a 100644 --- a/src/test/java/com/emc/rest/smart/SmartClientTest.java +++ b/src/test/java/com/emc/rest/smart/SmartClientTest.java @@ -55,7 +55,7 @@ public class SmartClientTest { public static final String PROP_ATMOS_ENDPOINTS = "atmos.endpoints"; public static final String PROP_ATMOS_UID = "atmos.uid"; - public static final String PROP_ATMOS_SECRET = "atmos.secret_key"; + public static final String PROP_ATMOS_SECRET = "atmos.secret"; private static final String HEADER_FORMAT = "EEE, d MMM yyyy HH:mm:ss z"; private static final ThreadLocal headerFormat = new ThreadLocal(); @@ -115,7 +115,7 @@ public void testConnTimeout() throws Exception { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, CONNECTION_TIMEOUT_MILLIS); - SmartConfig smartConfig = new SmartConfig("10.4.4.180"); + SmartConfig smartConfig = new SmartConfig("8.8.4.4:9020"); smartConfig.setProperty(ApacheHttpClient4Config.PROPERTY_HTTP_PARAMS, httpParams); final Client client = SmartClientFactory.createStandardClient(smartConfig); @@ -123,7 +123,7 @@ public void testConnTimeout() throws Exception { Future future = Executors.newSingleThreadExecutor().submit(new Runnable() { @Override public void run() { - client.resource("http://10.4.4.180:9020/?ping").get(String.class); + client.resource("http://8.8.4.4:9020/?ping").get(String.class); Assert.fail("response was not expected; choose an IP that is not in use"); } });