Skip to content

Commit 643a6d4

Browse files
author
Xinzhi Zou
committed
Fixes for merging in upstream
1 parent a21ff1f commit 643a6d4

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/main/java/net/spy/memcached/MemcachedClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ <T> T get(InetSocketAddress sa, final String key, final Transcoder<T> tc) {
12651265
<T> GetFuture<T> asyncGet(InetSocketAddress sa, final String key, final Transcoder<T> tc) {
12661266

12671267
final CountDownLatch latch = new CountDownLatch(1);
1268-
final GetFuture<T> rv = new GetFuture<T>(latch, operationTimeout, key);
1268+
final GetFuture<T> rv = new GetFuture<T>(latch, operationTimeout, key, executorService);
12691269
Operation op = opFact.get(key, new GetOperation.Callback() {
12701270
private Future<T> val = null;
12711271

@@ -1964,7 +1964,7 @@ public <T> T getConfig(InetSocketAddress addr, ConfigurationType type, Transcode
19641964
public <T> GetConfigFuture<T> asyncGetConfig(InetSocketAddress addr, final ConfigurationType type, final Transcoder<T> tc) {
19651965

19661966
final CountDownLatch latch = new CountDownLatch(1);
1967-
final GetConfigFuture<T> rv = new GetConfigFuture<T>(latch, operationTimeout, type);
1967+
final GetConfigFuture<T> rv = new GetConfigFuture<T>(latch, operationTimeout, type, executorService);
19681968
Operation op = opFact.getConfig(type, new GetConfigOperation.Callback() {
19691969
private Future<T> val = null;
19701970

@@ -2021,7 +2021,7 @@ private <T> OperationFuture<Boolean> asyncSetConfig(InetSocketAddress addr,
20212021
CachedData co = tc.encode(value);
20222022
final CountDownLatch latch = new CountDownLatch(1);
20232023
final OperationFuture<Boolean> rv =
2024-
new OperationFuture<Boolean>(configurationType.getValue(), latch, operationTimeout);
2024+
new OperationFuture<Boolean>(configurationType.getValue(), latch, operationTimeout, executorService);
20252025
Operation op = opFact.setConfig(configurationType, co.getFlags(), co.getData(),
20262026
new OperationCallback() {
20272027
public void receivedStatus(OperationStatus val) {
@@ -2049,7 +2049,7 @@ public void complete() {
20492049
public OperationFuture<Boolean> deleteConfig(InetSocketAddress addr, ConfigurationType configurationType) {
20502050
final CountDownLatch latch = new CountDownLatch(1);
20512051
final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(configurationType.getValue(),
2052-
latch, operationTimeout);
2052+
latch, operationTimeout, executorService);
20532053
DeleteConfigOperation op = opFact.deleteConfig(configurationType, new OperationCallback() {
20542054
public void receivedStatus(OperationStatus s) {
20552055
rv.set(s.isSuccess(), s);

src/main/java/net/spy/memcached/MemcachedConnection.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,8 @@ private void handleInputQueue() {
761761

762762
Collection<MemcachedNode> nodeList = locator.getAll();
763763
// Now process the queue.
764-
for (MemcachedNode qa : todo) {
765-
if(!nodeList.contains(qa)){
764+
for (MemcachedNode node : todo) {
765+
if(!nodeList.contains(node)){
766766
continue;
767767
}
768768
boolean readyForIO = false;
@@ -864,9 +864,9 @@ boolean belongsToCluster(final MemcachedNode node) {
864864
* @param sk the selector to handle IO against.
865865
*/
866866
private void handleIO(final SelectionKey sk) {
867-
MemcachedNode qa = (MemcachedNode) sk.attachment();
867+
MemcachedNode node = (MemcachedNode) sk.attachment();
868868
Collection<MemcachedNode> nodeList = locator.getAll();
869-
if(!nodeList.contains(qa)){
869+
if(!nodeList.contains(node)){
870870
return;
871871
}
872872

@@ -1327,6 +1327,8 @@ private void attemptReconnects() {
13271327
sa = node.getSocketAddress();
13281328
}
13291329
if (ch.connect(sa)) {
1330+
connected(node);
1331+
addedQueue.offer(node);
13301332
getLogger().info("Immediately reconnected to %s", node);
13311333
assert ch.isConnected();
13321334
} else {

src/main/java/net/spy/memcached/internal/GetConfigFuture.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import java.util.concurrent.CountDownLatch;
1515
import java.util.concurrent.ExecutionException;
16+
import java.util.concurrent.ExecutorService;
1617
import java.util.concurrent.Future;
1718
import java.util.concurrent.TimeUnit;
1819
import java.util.concurrent.TimeoutException;
@@ -32,8 +33,9 @@ public class GetConfigFuture<T> implements Future<T> {
3233

3334
private final OperationFuture<Future<T>> rv;
3435

35-
public GetConfigFuture(CountDownLatch l, long opTimeout, ConfigurationType type) {
36-
this.rv = new OperationFuture<Future<T>>(type.getValue(), l, opTimeout);
36+
public GetConfigFuture(CountDownLatch l, long opTimeout, ConfigurationType type,
37+
ExecutorService service) {
38+
this.rv = new OperationFuture<Future<T>>(type.getValue(), l, opTimeout, service);
3739
}
3840

3941
public boolean cancel(boolean ign) {

0 commit comments

Comments
 (0)