[teiid-commits] teiid SVN: r1725 - trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Sat Jan 9 07:54:58 EST 2010
Author: shawkins
Date: 2010-01-09 07:54:57 -0500 (Sat, 09 Jan 2010)
New Revision: 1725
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
Log:
TEIID-916 re-updating client timeouts to values that are safer under load
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-08 20:39:31 UTC (rev 1724)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2010-01-09 12:54:57 UTC (rev 1725)
@@ -297,7 +297,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) {
@@ -310,26 +310,28 @@
* 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();
+ synchronized (SocketServerInstanceImpl.this) {
+ while (!isDone()) {
+ if (timeoutMillis <= 0) {
+ throw new TimeoutException();
+ }
+ long start = System.currentTimeMillis();
+ try {
+ receivedMessage(socketChannel.read());
+ } catch (SocketTimeoutException e) {
+ } catch (IOException e) {
+ exceptionOccurred(e);
+ } catch (ClassNotFoundException e) {
+ exceptionOccurred(e);
+ }
+ if (!isDone()) {
+ timeoutMillis -= (System.currentTimeMillis() - start);
+ }
}
- long start = System.currentTimeMillis();
- try {
- receivedMessage(socketChannel.read());
- } catch (SocketTimeoutException e) {
- } catch (IOException e) {
- exceptionOccurred(e);
- } catch (ClassNotFoundException e) {
- exceptionOccurred(e);
- }
- if (!isDone()) {
- timeoutMillis -= (System.currentTimeMillis() - start);
- }
}
return super.get(timeout, unit);
}
More information about the teiid-commits
mailing list