Author: shawkins
Date: 2010-01-05 14:55:45 -0500 (Tue, 05 Jan 2010)
New Revision: 1710
Removed:
trunk/client/src/main/java/com/metamatrix/dqp/internal/
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectChannel.java
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
trunk/client/src/main/resources/teiid-client-settings.properties
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
Log:
TEIID-916 updating client timeouts to values that are safer under load
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectChannel.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectChannel.java 2010-01-05
18:46:34 UTC (rev 1709)
+++
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/ObjectChannel.java 2010-01-05
19:55:45 UTC (rev 1710)
@@ -28,7 +28,10 @@
public interface ObjectChannel {
- Object read() throws IOException, ClassNotFoundException;
+ /**
+ * Callers must obtain a lock prior to calling read
+ */
+ Object read(int timeout) throws IOException, ClassNotFoundException;
SocketAddress getRemoteAddress();
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2010-01-05
18:46:34 UTC (rev 1709)
+++
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/OioOjbectChannelFactory.java 2010-01-05
19:55:45 UTC (rev 1710)
@@ -58,7 +58,6 @@
private final Socket socket;
private ObjectOutputStream outputStream;
private ObjectInputStream inputStream;
- private Object readLock = new Object();
private OioObjectChannel(Socket socket) throws IOException {
log.fine("creating new OioObjectChannel"); //$NON-NLS-1$
@@ -117,17 +116,16 @@
//## JDBC4.0-begin ##
@Override
//## JDBC4.0-end ##
- public Object read() throws IOException, ClassNotFoundException {
+ public Object read(int timeout) throws IOException, ClassNotFoundException {
log.finer("reading message from socket"); //$NON-NLS-1$
- synchronized (readLock) {
- try {
- return inputStream.readObject();
- } catch (SocketTimeoutException e) {
- throw e;
- } catch (IOException e) {
- close();
- throw e;
- }
+ socket.setSoTimeout(timeout);
+ try {
+ return inputStream.readObject();
+ } catch (SocketTimeoutException e) {
+ throw e;
+ } catch (IOException e) {
+ close();
+ throw e;
}
}
@@ -154,7 +152,7 @@
private int receiveBufferSize = 0;
private int sendBufferSize = 0;
private boolean conserveBandwidth;
- private int soTimeout = 3000;
+ private int soTimeout = 30000;
private volatile SSLSocketFactory sslSocketFactory;
public OioOjbectChannelFactory(Properties props) {
@@ -187,7 +185,7 @@
socket.setSendBufferSize(sendBufferSize);
}
socket.setTcpNoDelay(!conserveBandwidth); // enable Nagle's algorithm to
conserve bandwidth
- socket.connect(address);
+ socket.connect(address, soTimeout);
socket.setSoTimeout(soTimeout);
return new OioObjectChannel(socket);
}
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
===================================================================
---
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-01-05
18:46:34 UTC (rev 1709)
+++
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-01-05
19:55:45 UTC (rev 1710)
@@ -95,7 +95,7 @@
InetSocketAddress address = new InetSocketAddress(hostInfo.getInetAddress(),
hostInfo.getPortNumber());
this.socketChannel = channelFactory.createObjectChannel(address, ssl);
try {
- doHandshake();
+ doHandshake(channelFactory.getSoTimeout());
} catch (CommunicationException e) {
this.socketChannel.close();
throw e;
@@ -123,10 +123,10 @@
return ApplicationInfo.getInstance().getMajorReleaseNumber();
}
- private void doHandshake() throws IOException, CommunicationException {
+ private void doHandshake(int timeout) throws IOException, CommunicationException {
final Handshake handshake;
try {
- Object obj = this.socketChannel.read();
+ Object obj = this.socketChannel.read(timeout);
if (!(obj instanceof Handshake)) {
throw new
CommunicationException(CommPlatformPlugin.Util.getString("SocketServerInstanceImpl.handshake_error"));
//$NON-NLS-1$
@@ -288,7 +288,7 @@
}
@Override
- public synchronized Object get() throws InterruptedException, ExecutionException {
+ public Object get() throws InterruptedException, ExecutionException {
try {
return this.get(SocketServerConnectionFactory.getInstance().getSynchronousTtl(),
TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
@@ -301,25 +301,26 @@
* the actual reads.
*/
@Override
- public synchronized Object get(long timeout, TimeUnit unit)
+ public Object get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException,
TimeoutException {
int timeoutMillis = (int)Math.min(unit.toMillis(timeout), Integer.MAX_VALUE);
- while (!isDone()) {
- if (timeoutMillis <= 0) {
- throw new TimeoutException();
- }
- long start = System.currentTimeMillis();
- try {
- receivedMessage(socketChannel.read());
- } catch (IOException e) {
- if (e instanceof SocketTimeoutException) {
+ synchronized (SocketServerInstanceImpl.this) {
+ while (!isDone()) {
+ if (timeoutMillis <= 0) {
+ throw new TimeoutException();
+ }
+ long start = System.currentTimeMillis();
+ try {
+ receivedMessage(socketChannel.read(timeoutMillis));
timeoutMillis -= (System.currentTimeMillis() - start);
- continue;
+ } catch (SocketTimeoutException e) {
+ throw new TimeoutException();
+ } catch (IOException e) {
+ exceptionOccurred(e);
+ } catch (ClassNotFoundException e) {
+ exceptionOccurred(e);
}
- exceptionOccurred(e);
- } catch (ClassNotFoundException e) {
- exceptionOccurred(e);
}
}
return super.get(timeout, unit);
Modified: trunk/client/src/main/resources/teiid-client-settings.properties
===================================================================
--- trunk/client/src/main/resources/teiid-client-settings.properties 2010-01-05 18:46:34
UTC (rev 1709)
+++ trunk/client/src/main/resources/teiid-client-settings.properties 2010-01-05 19:55:45
UTC (rev 1710)
@@ -71,10 +71,8 @@
# A timeout during the initialization, handshake, or
# a server ping will be treated as an error.
#
-# Setting this value too low may cause read errors.
-#
-org.teiid.sockets.soTimeout=3000
+org.teiid.sockets.soTimeout=30000
#
# The max number of cached server instances
@@ -100,7 +98,7 @@
# synchronous calls.
#
-org.teiid.sockets.synchronousttl=120000
+org.teiid.sockets.synchronousttl=240000
#
# Set the socket receive buffer size (in bytes)
Modified:
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java
===================================================================
---
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-01-05
18:46:34 UTC (rev 1709)
+++
trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerInstanceImpl.java 2010-01-05
19:55:45 UTC (rev 1710)
@@ -80,7 +80,7 @@
//## JDBC4.0-begin ##
@Override
//## JDBC4.0-end ##
- public Object read() throws IOException,
+ public Object read(int timeout) throws IOException,
ClassNotFoundException {
Object msg = readMsgs.get(readCount++);
if (msg instanceof IOException) {
Modified: trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-01-05
18:46:34 UTC (rev 1709)
+++ trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-01-05
19:55:45 UTC (rev 1710)
@@ -86,7 +86,7 @@
}
@Override
- public Object read() throws IOException,
+ public Object read(int timeout) throws IOException,
ClassNotFoundException {
throw new UnsupportedOperationException();
}