You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2006/04/20 01:55:33 UTC
svn commit: r395444 - in /lucene/hadoop/trunk: CHANGES.txt
src/java/org/apache/hadoop/ipc/RPC.java
Author: cutting
Date: Wed Apr 19 16:55:32 2006
New Revision: 395444
URL: http://svn.apache.org/viewcvs?rev=395444&view=rev
Log:
Fix HADOOP-151. Close a potential socket leak.
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/RPC.java
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/CHANGES.txt?rev=395444&r1=395443&r2=395444&view=diff
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Wed Apr 19 16:55:32 2006
@@ -64,6 +64,11 @@
18. Fix HADOOP-148. Maintain a task failure count for each
tasktracker and display it in the web ui. (omalley via cutting)
+19. Fix HADOOP-151. Close a potential socket leak, where new IPC
+ connection pools were created per configuration instance that RPCs
+ use. Now a global RPC connection pool is used again, as
+ originally intended. (cutting)
+
Release 0.1.1 - 2006-04-08
Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/RPC.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/RPC.java?rev=395444&r1=395443&r2=395444&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/RPC.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/RPC.java Wed Apr 19 16:55:32 2006
@@ -121,25 +121,33 @@
}
- //TODO mb@media-style.com: static client or non-static client?
private static Client CLIENT;
+ private static synchronized Client getClient(Configuration conf) {
+ // Construct & cache client. The configuration is only used for timeout,
+ // and Clients have connection pools. So we can either (a) lose some
+ // connection pooling and leak sockets, or (b) use the same timeout for all
+ // configurations. Since the IPC is usually intended globally, not
+ // per-job, we choose (a).
+ if (CLIENT == null) {
+ CLIENT = new Client(ObjectWritable.class, conf);
+ }
+ return CLIENT;
+ }
+
private static class Invoker implements InvocationHandler {
private InetSocketAddress address;
+ private Client client;
public Invoker(InetSocketAddress address, Configuration conf) {
this.address = address;
- CLIENT = (Client) conf.getObject(Client.class.getName());
- if(CLIENT == null) {
- CLIENT = new Client(ObjectWritable.class, conf);
- conf.setObject(Client.class.getName(), CLIENT);
- }
+ this.client = getClient(conf);
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
ObjectWritable value = (ObjectWritable)
- CLIENT.call(new Invocation(method, args), address);
+ client.call(new Invocation(method, args), address);
return value.get();
}
}
@@ -160,12 +168,7 @@
Invocation[] invocations = new Invocation[params.length];
for (int i = 0; i < params.length; i++)
invocations[i] = new Invocation(method, params[i]);
- CLIENT = (Client) conf.getObject(Client.class.getName());
- if(CLIENT == null) {
- CLIENT = new Client(ObjectWritable.class, conf);
- conf.setObject(Client.class.getName(), CLIENT);
- }
- Writable[] wrappedValues = CLIENT.call(invocations, addrs);
+ Writable[] wrappedValues = getClient(conf).call(invocations, addrs);
if (method.getReturnType() == Void.TYPE) {
return null;