diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-05-23 11:59:44 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-05-23 11:59:44 +0200 |
commit | d81701ca8182942b7936f9fd84a019b695e9c890 (patch) | |
tree | dc036c9d701fbbe1afad67782bd78572c0f61974 /java/src/IceInternal/BatchOutgoing.java | |
parent | Fixed bug ICE-5543: stringToIdentity bug with escaped escapes (diff) | |
download | ice-d81701ca8182942b7936f9fd84a019b695e9c890.tar.bz2 ice-d81701ca8182942b7936f9fd84a019b695e9c890.tar.xz ice-d81701ca8182942b7936f9fd84a019b695e9c890.zip |
Added support for invocation timeouts and ACM heartbeats
Diffstat (limited to 'java/src/IceInternal/BatchOutgoing.java')
-rw-r--r-- | java/src/IceInternal/BatchOutgoing.java | 92 |
1 files changed, 70 insertions, 22 deletions
diff --git a/java/src/IceInternal/BatchOutgoing.java b/java/src/IceInternal/BatchOutgoing.java index 2bbfe3a5ca9..65795d25c92 100644 --- a/java/src/IceInternal/BatchOutgoing.java +++ b/java/src/IceInternal/BatchOutgoing.java @@ -38,50 +38,98 @@ public final class BatchOutgoing implements OutgoingMessageCallback { assert(_handler != null || _connection != null); - if(_handler != null && !_handler.flushBatchRequests(this) || - _connection != null && !_connection.flushBatchRequests(this)) + int timeout; + if(_connection != null) { - synchronized(this) + if(_connection.flushBatchRequests(this)) { - while(_exception == null && !_sent) + return; + } + timeout = -1; + } + else + { + try + { + if(_handler.sendRequest(this)) + { + return; + } + } + catch(IceInternal.LocalExceptionWrapper ex) + { + throw ex.get(); + } + timeout = _handler.getReference().getInvocationTimeout(); + } + + boolean timedOut = false; + synchronized(this) + { + if(timeout > 0) + { + long now = Time.currentMonotonicTimeMillis(); + long deadline = now + timeout; + while(_exception == null && !_sent && !timedOut) { try { - wait(); + wait(deadline - now); + if(_exception == null && !_sent) + { + now = Time.currentMonotonicTimeMillis(); + timedOut = now >= deadline; + } } - catch(java.lang.InterruptedException ex) + catch(InterruptedException ex) { } } - - if(_exception != null) + } + else + { + while(_exception == null && !_sent) { - throw _exception; + try + { + wait(); + } + catch(InterruptedException ex) + { + } } } } - } - - public void - sent(boolean async) - { - if(async) + + if(timedOut) { - synchronized(this) - { - _sent = true; - notify(); - } + _handler.requestTimedOut(this); + assert(_exception != null); } - else + + if(_exception != null) { - _sent = true; + _exception.fillInStackTrace(); + throw _exception; } + } + + public boolean + send(Ice.ConnectionI connection, boolean compress, boolean response) + { + return connection.flushBatchRequests(this); + } + + synchronized public void + sent() + { if(_remoteObserver != null) { _remoteObserver.detach(); _remoteObserver = null; } + _sent = true; + notify(); } public synchronized void |