Skip to content

Commit 98db4b9

Browse files
author
arnett, stu
committed
v2.1.0
1 parent ab4e2cd commit 98db4b9

File tree

13 files changed

+200
-68
lines changed

13 files changed

+200
-68
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Library: slf4j-api
2+
Copyright 2004-2013 QOS.ch
3+
License: MIT
4+
Full License Text:
5+
-----------------------------------------------------------------------------------------------------------------------
6+
7+
Copyright (c) 2004-2013 QOS.ch
8+
All rights reserved.
9+
10+
Permission is hereby granted, free of charge, to any person obtaining
11+
a copy of this software and associated documentation files (the
12+
"Software"), to deal in the Software without restriction, including
13+
without limitation the rights to use, copy, modify, merge, publish,
14+
distribute, sublicense, and/or sell copies of the Software, and to
15+
permit persons to whom the Software is furnished to do so, subject to
16+
the following conditions:
17+
18+
The above copyright notice and this permission notice shall be
19+
included in all copies or substantial portions of the Software.
20+
21+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Library: slf4j-log4j12
2+
Copyright 2004-2013 QOS.ch
3+
License: MIT
4+
Full License Text:
5+
-----------------------------------------------------------------------------------------------------------------------
6+
7+
Copyright (c) 2004-2013 QOS.ch
8+
All rights reserved.
9+
10+
Permission is hereby granted, free of charge, to any person obtaining
11+
a copy of this software and associated documentation files (the
12+
"Software"), to deal in the Software without restriction, including
13+
without limitation the rights to use, copy, modify, merge, publish,
14+
distribute, sublicense, and/or sell copies of the Software, and to
15+
permit persons to whom the Software is furnished to do so, subject to
16+
the following conditions:
17+
18+
The above copyright notice and this permission notice shall be
19+
included in all copies or substantial portions of the Software.
20+
21+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, EMC Corporation.
2+
* Copyright (c) 2015-2016, EMC Corporation.
33
* Redistribution and use in source and binary forms, with or without modification,
44
* are permitted provided that the following conditions are met:
55
*
@@ -29,7 +29,7 @@ description = 'Smart REST Client - JAX-RS (Jersey) REST client that provides cli
2929
ext.githubProjectName = 'smart-client-java'
3030

3131
buildscript {
32-
ext.commonBuildVersion = '1.3.3'
32+
ext.commonBuildVersion = '1.5'
3333
ext.commonBuildDir = "https://raw.githubusercontent.com/emcvipr/ecs-common-build/v$commonBuildVersion"
3434
apply from: "$commonBuildDir/ecs-publish.buildscript.gradle", to: buildscript
3535
}
@@ -40,6 +40,8 @@ dependencies {
4040
compile 'com.sun.jersey:jersey-client:1.19',
4141
'com.sun.jersey.contribs:jersey-apache-client4:1.19',
4242
'org.apache.httpcomponents:httpclient:4.2.6',
43+
'org.slf4j:slf4j-api:1.7.5'
44+
runtime 'org.slf4j:slf4j-log4j12:1.7.5'
45+
testCompile 'junit:junit:4.12',
4346
'log4j:log4j:1.2.17'
44-
testCompile 'junit:junit:4.12'
4547
}

src/main/java/com/emc/rest/smart/Host.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, EMC Corporation.
2+
* Copyright (c) 2015-2016, EMC Corporation.
33
* Redistribution and use in source and binary forms, with or without modification,
44
* are permitted provided that the following conditions are met:
55
*
@@ -26,11 +26,11 @@
2626
*/
2727
package com.emc.rest.smart;
2828

29-
import org.apache.log4j.LogMF;
30-
import org.apache.log4j.Logger;
31-
3229
import java.util.Date;
3330

31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
33+
3434
/**
3535
* Some basic statements about response index calculation:
3636
* <p>
@@ -42,7 +42,8 @@
4242
* </ul>
4343
*/
4444
public class Host implements HostStats {
45-
private static final Logger l4j = Logger.getLogger(Host.class);
45+
46+
private static final Logger log = LoggerFactory.getLogger(Host.class);
4647

4748
public static final int DEFAULT_ERROR_WAIT_MS = 1500;
4849
public static final int LOG_DELAY = 60000; // 1 minute
@@ -79,7 +80,7 @@ public synchronized void connectionClosed() {
7980
if (openConnections < 0) {
8081
long currentTime = System.currentTimeMillis();
8182
if (currentTime - lastLogTime > LOG_DELAY) {
82-
LogMF.warn(l4j, "openConnections for host %s is %d !", this, openConnections);
83+
log.warn("openConnections for host {} is {} !", this.toString(), Integer.toString(openConnections));
8384
lastLogTime = currentTime;
8485
}
8586
}
@@ -89,8 +90,8 @@ public synchronized void callComplete(boolean isError) {
8990
if (isError) {
9091
totalErrors++;
9192
consecutiveErrors++;
92-
LogMF.debug(l4j, "error tallied for {2}; total errors: {0}, consecutive errors: {1}",
93-
totalErrors, consecutiveErrors, name);
93+
log.debug("error tallied for {}; total errors: {}, consecutive errors: {}",
94+
name, totalErrors, consecutiveErrors);
9495
} else {
9596
consecutiveErrors = 0;
9697
}

src/main/java/com/emc/rest/smart/HostListProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface HostListProvider {
4141
/**
4242
* Destroy this provider. Any system resources associated with the provider
4343
* will be cleaned up.
44-
* <p/>
44+
* <p>
4545
* The provider must not be reused after this method is called otherwise
4646
* undefined behavior will occur.
4747
*/

src/main/java/com/emc/rest/smart/HostStats.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@
2929
import java.util.Date;
3030

3131
public interface HostStats {
32-
@SuppressWarnings("unused")
32+
3333
long getTotalConnections();
3434

35-
@SuppressWarnings("unused")
35+
3636
long getTotalErrors();
3737

38-
@SuppressWarnings("unused")
38+
3939
int getOpenConnections();
4040

41-
@SuppressWarnings("unused")
41+
4242
Date getLastConnectionTime();
43+
4344
}

src/main/java/com/emc/rest/smart/PollingDaemon.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, EMC Corporation.
2+
* Copyright (c) 2015-2016, EMC Corporation.
33
* Redistribution and use in source and binary forms, with or without modification,
44
* are permitted provided that the following conditions are met:
55
*
@@ -26,16 +26,16 @@
2626
*/
2727
package com.emc.rest.smart;
2828

29-
import org.apache.log4j.LogMF;
30-
import org.apache.log4j.Logger;
29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
3131

3232
/**
3333
* Polling thread that will terminate automatically when the application exits
3434
*/
3535
public class PollingDaemon extends Thread {
3636
public static final String PROPERTY_KEY = "com.emc.rest.smart.pollingDaemon";
3737

38-
private static final Logger l4j = Logger.getLogger(PollingDaemon.class);
38+
private static final Logger log = LoggerFactory.getLogger(PollingDaemon.class);
3939

4040
private SmartConfig smartConfig;
4141
private boolean running = true;
@@ -49,36 +49,36 @@ public PollingDaemon(SmartConfig smartConfig) {
4949
public void run() {
5050
while (running) {
5151
long start = System.currentTimeMillis();
52-
l4j.debug("polling daemon running");
52+
log.debug("polling daemon running");
5353

5454
LoadBalancer loadBalancer = smartConfig.getLoadBalancer();
5555
HostListProvider hostListProvider = smartConfig.getHostListProvider();
5656

5757
if (!smartConfig.isHostUpdateEnabled()) {
58-
l4j.info("host update is disabled; not updating hosts");
58+
log.info("host update is disabled; not updating hosts");
5959
} else if (hostListProvider == null) {
60-
l4j.info("no host list provider; not updating hosts");
60+
log.info("no host list provider; not updating hosts");
6161
} else {
6262
try {
6363
loadBalancer.updateHosts(hostListProvider.getHostList());
6464
} catch (Throwable t) {
65-
l4j.warn("unable to enumerate servers", t);
65+
log.warn("unable to enumerate servers", t);
6666
}
6767
}
6868

6969
if (!smartConfig.isHealthCheckEnabled()) {
70-
l4j.info("health check is disabled; not checking hosts");
70+
log.info("health check is disabled; not checking hosts");
7171
} else if (hostListProvider == null) {
72-
l4j.info("no host list provider; not checking hosts");
72+
log.info("no host list provider; not checking hosts");
7373
} else {
7474
for (Host host : loadBalancer.getAllHosts()) {
7575
try {
7676
hostListProvider.runHealthCheck(host);
7777
host.setHealthy(true);
78-
LogMF.debug(l4j, "health check successful for {0}; host is marked healthy", host.getName());
78+
log.debug("health check successful for {}; host is marked healthy", host.getName());
7979
} catch (Throwable t) {
8080
host.setHealthy(false);
81-
l4j.warn("health check failed for " + host.getName() + "; host is marked unhealthy", t);
81+
log.warn("health check failed for " + host.getName() + "; host is marked unhealthy", t);
8282
}
8383
}
8484
}
@@ -87,15 +87,14 @@ public void run() {
8787
try {
8888
long sleepTime = smartConfig.getPollInterval() * 1000 - callTime;
8989
if (sleepTime < 0) sleepTime = 0;
90-
LogMF.debug(l4j, "polling daemon finished; will poll again in {0}ms..", sleepTime);
90+
log.debug("polling daemon finished; will poll again in {}ms..", Long.toString(sleepTime));
9191
if (sleepTime > 0) Thread.sleep(sleepTime);
9292
} catch (InterruptedException e) {
93-
l4j.warn("interrupted while sleeping", e);
93+
log.warn("interrupted while sleeping", e);
9494
}
9595
}
9696
}
9797

98-
@SuppressWarnings("unused")
9998
public void terminate() {
10099
running = false;
101100
}

src/main/java/com/emc/rest/smart/SmartClientFactory.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, EMC Corporation.
2+
* Copyright (c) 2015-2016, EMC Corporation.
33
* Redistribution and use in source and binary forms, with or without modification,
44
* are permitted provided that the following conditions are met:
55
*
@@ -26,6 +26,9 @@
2626
*/
2727
package com.emc.rest.smart;
2828

29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
31+
2932
import com.sun.jersey.api.client.Client;
3033
import com.sun.jersey.api.client.ClientHandler;
3134
import com.sun.jersey.api.client.config.ClientConfig;
@@ -36,10 +39,10 @@
3639
import com.sun.jersey.core.impl.provider.entity.ByteArrayProvider;
3740
import com.sun.jersey.core.impl.provider.entity.FileProvider;
3841
import com.sun.jersey.core.impl.provider.entity.InputStreamProvider;
39-
import org.apache.log4j.Logger;
4042

4143
public final class SmartClientFactory {
42-
private static final Logger l4j = Logger.getLogger(SmartClientFactory.class);
44+
45+
private static final Logger log = LoggerFactory.getLogger(SmartClientFactory.class);
4346

4447
public static final String DISABLE_APACHE_RETRY = "com.emc.rest.smart.disableApacheRetry";
4548

@@ -109,24 +112,24 @@ public static Client createStandardClient(SmartConfig smartConfig,
109112
/**
110113
* Destroy this client. Any system resources associated with the client
111114
* will be cleaned up.
112-
* <p/>
115+
* <p>
113116
* This method must be called when there are not responses pending otherwise
114117
* undefined behavior will occur.
115-
* <p/>
118+
* <p>
116119
* The client must not be reused after this method is called otherwise
117120
* undefined behavior will occur.
118121
*/
119122
public static void destroy(Client client) {
120123
PollingDaemon pollingDaemon = (PollingDaemon) client.getProperties().get(PollingDaemon.PROPERTY_KEY);
121124
if (pollingDaemon != null) {
122-
l4j.debug("terminating polling daemon");
125+
log.debug("terminating polling daemon");
123126
pollingDaemon.terminate();
124127
if (pollingDaemon.getSmartConfig().getHostListProvider() != null) {
125-
l4j.debug("destroying host list provider");
128+
log.debug("destroying host list provider");
126129
pollingDaemon.getSmartConfig().getHostListProvider().destroy();
127130
}
128131
}
129-
l4j.debug("destroying Jersey client");
132+
log.debug("destroying Jersey client");
130133
client.destroy();
131134
}
132135

0 commit comments

Comments
 (0)