This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 727
idle connection reaper #149
Merged
kramer
merged 4 commits into
searchbox-io:master
from
matthewbogner:idle-connection-reaping
Sep 30, 2014
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
jest-common/src/main/java/io/searchbox/client/config/idle/IdleConnectionReaper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.searchbox.client.config.idle; | ||
|
||
import com.google.common.util.concurrent.AbstractScheduledService; | ||
import io.searchbox.client.config.ClientConfig; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Used to reap idle connections from the connection manager. | ||
*/ | ||
public class IdleConnectionReaper extends AbstractScheduledService { | ||
|
||
final static Logger logger = LoggerFactory.getLogger(IdleConnectionReaper.class); | ||
|
||
private final ReapableConnectionManager reapableConnectionManager; | ||
private final ClientConfig clientConfig; | ||
|
||
public IdleConnectionReaper(ClientConfig clientConfig, ReapableConnectionManager reapableConnectionManager) { | ||
this.reapableConnectionManager = reapableConnectionManager; | ||
this.clientConfig = clientConfig; | ||
} | ||
|
||
@Override | ||
protected void runOneIteration() throws Exception { | ||
logger.info("closing idle connections..."); | ||
reapableConnectionManager.closeIdleConnections(clientConfig.getMaxConnectionIdleTime(), | ||
clientConfig.getMaxConnectionIdleTimeDurationTimeUnit()); | ||
} | ||
|
||
@Override | ||
protected Scheduler scheduler() { | ||
return Scheduler.newFixedDelaySchedule(0l, | ||
clientConfig.getMaxConnectionIdleTime(), | ||
clientConfig.getMaxConnectionIdleTimeDurationTimeUnit()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
jest-common/src/main/java/io/searchbox/client/config/idle/ReapableConnectionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.searchbox.client.config.idle; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public interface ReapableConnectionManager { | ||
void closeIdleConnections(long idleTimeout, TimeUnit unit); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
jest-droid/src/main/java/com/searchly/jestdroid/DroidReapableConnectionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.searchly.jestdroid; | ||
|
||
import ch.boye.httpclientandroidlib.impl.conn.PoolingClientConnectionManager; | ||
import io.searchbox.client.config.idle.ReapableConnectionManager; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class DroidReapableConnectionManager implements ReapableConnectionManager { | ||
|
||
private final PoolingClientConnectionManager connectionManager; | ||
|
||
public DroidReapableConnectionManager(PoolingClientConnectionManager connectionManager) { | ||
this.connectionManager = connectionManager; | ||
} | ||
|
||
@Override | ||
public void closeIdleConnections(long idleTimeout, TimeUnit unit) { | ||
connectionManager.closeIdleConnections(idleTimeout, unit); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+301 KB
jest/lib/bin/lib/x86_64-MacOSX-gpp/jni/libbarchart-udt-core-2.3.0-SNAPSHOT.jnilib
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
jest/src/main/java/io/searchbox/client/config/idle/HttpReapableConnectionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.searchbox.client.config.idle; | ||
|
||
import org.apache.http.conn.HttpClientConnectionManager; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class HttpReapableConnectionManager implements ReapableConnectionManager { | ||
private final HttpClientConnectionManager connectionManager; | ||
|
||
public HttpReapableConnectionManager(HttpClientConnectionManager connectionManager) { | ||
this.connectionManager = connectionManager; | ||
} | ||
|
||
@Override | ||
public void closeIdleConnections(long idleTimeout, TimeUnit unit) { | ||
connectionManager.closeIdleConnections(idleTimeout, unit); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will probably get too chatty for regular usage, won't it? I suggest changing the level to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed (was following lead of NodeChecker).