Skip to content

Commit

Permalink
Merge pull request #3 from EMCECS/release-2.1.1
Browse files Browse the repository at this point in the history
Release 2.1.1
  • Loading branch information
twincitiesguy authored Aug 22, 2017
2 parents d82ec59 + eb4cd8e commit b381697
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 47 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ 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
}

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'
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
52 changes: 26 additions & 26 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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`
Expand Down
8 changes: 4 additions & 4 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/emc/rest/smart/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* <p>
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/emc/rest/smart/SmartClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/emc/rest/smart/HostTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/emc/rest/smart/SmartClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateFormat> headerFormat = new ThreadLocal<DateFormat>();
Expand Down Expand Up @@ -115,15 +115,15 @@ 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);

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");
}
});
Expand Down

0 comments on commit b381697

Please sign in to comment.