Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public Connection(String nid, int bufferSize) {
}

@Override
public void connect(SocketAddress endpoint) throws IOException {
super.connect(endpoint);
public void connect(SocketAddress endpoint, int timeout) throws IOException {
super.connect(endpoint, timeout);
is = new BufferedInputStream(getInputStream());
os = new BufferedOutputStream(getOutputStream());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public synchronized Connection getConnection(String nodeId) throws Exception {
GenericObjectPool<Connection> pool = poolMap.get(nodeId);
if (pool == null) {
PoolableObjectFactory<Connection> factory =
new SocketPoolFactory(nodeId, bufferSize);
new SocketPoolFactory(nodeId, bufferSize, timeout);
pool = new GenericObjectPool<Connection>(factory);
pool.setMaxActive(maxActive);
pool.setMaxIdle(maxIdle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@
public class SocketPoolFactory implements PoolableObjectFactory<Connection> {
private String nodeId;
private int bufferSize;
private int timeout = 1000;

public SocketPoolFactory(String nid, int bufferSize) {
this.nodeId = nid;
this.bufferSize = bufferSize;
}

public SocketPoolFactory(String nid, int bufferSize, int timeout) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks breaking compatibility. Could you

  1. give default value
  2. Or replace this change with adding new constructor SocketPoolFactory(String nid, int bufferSize, int timeout)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks,
I had updated.
and please also help to review another pull request
#5

this.nodeId = nid;
this.bufferSize = bufferSize;
this.timeout = timeout;
}

public Connection makeObject() throws IOException {
Connection con = new Connection(nodeId, bufferSize);
String[] host = nodeId.split("_");
con.connect(new InetSocketAddress(host[0], Integer.valueOf(host[1])));
con.connect(new InetSocketAddress(host[0], Integer.valueOf(host[1])), timeout);
return con;
}

Expand Down