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 | |
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')
39 files changed, 1638 insertions, 768 deletions
diff --git a/java/src/Glacier2/Application.java b/java/src/Glacier2/Application.java index 804f9445aa5..2195eeb83c7 100644 --- a/java/src/Glacier2/Application.java +++ b/java/src/Glacier2/Application.java @@ -318,13 +318,25 @@ public abstract class Application extends Ice.Application private boolean _done = false; } + private class ConnectionCallbackI implements Ice.ConnectionCallback + { + public void heartbeat(Ice.Connection con) + { + + } + + public void closed(Ice.Connection con) + { + sessionDestroyed(); + } + } + protected int doMain(Ice.StringSeqHolder argHolder, Ice.InitializationData initData) { // // Set the default properties for all Glacier2 applications. // - initData.properties.setProperty("Ice.ACM.Client", "0"); initData.properties.setProperty("Ice.RetryIntervals", "-1"); boolean restart; @@ -398,11 +410,31 @@ public abstract class Application extends Ice.Application if(_createdSession) { - long timeout = _router.getSessionTimeout(); - if(timeout > 0) + int acmTimeout = 0; + try + { + acmTimeout = _router.getACMTimeout(); + } + catch(Ice.OperationNotExistException ex) + { + } + if(acmTimeout > 0) { - ping = new SessionPingThread(_router, (timeout * 1000) / 2); - ping.start(); + Ice.Connection connection = _router.ice_getCachedConnection(); + assert(connection != null); + connection.setACM(new Ice.IntOptional(acmTimeout), + null, + new Ice.Optional<Ice.ACMHeartbeat>(Ice.ACMHeartbeat.HeartbeatAlways)); + connection.setCallback(new ConnectionCallbackI()); + } + else + { + long timeout = _router.getSessionTimeout(); + if(timeout > 0) + { + ping = new SessionPingThread(_router, (timeout * 1000) / 2); + ping.start(); + } } _category = _router.getCategoryForClient(); status.value = runWithSession(argHolder.value); diff --git a/java/src/Glacier2/SessionFactoryHelper.java b/java/src/Glacier2/SessionFactoryHelper.java index 79733a82139..120b55a59bf 100644 --- a/java/src/Glacier2/SessionFactoryHelper.java +++ b/java/src/Glacier2/SessionFactoryHelper.java @@ -89,7 +89,6 @@ public class SessionFactoryHelper // // Set default properties; // - _initData.properties.setProperty("Ice.ACM.Client", "0"); _initData.properties.setProperty("Ice.RetryIntervals", "-1"); } diff --git a/java/src/Glacier2/SessionHelper.java b/java/src/Glacier2/SessionHelper.java index e089119cc29..2afe4493e4a 100644 --- a/java/src/Glacier2/SessionHelper.java +++ b/java/src/Glacier2/SessionHelper.java @@ -90,6 +90,26 @@ public class SessionHelper private boolean _done = false; } + private class ConnectionCallbackI implements Ice.ConnectionCallback + { + public ConnectionCallbackI(SessionHelper sessionHelper) + { + _sessionHelper = sessionHelper; + } + + public void heartbeat(Ice.Connection con) + { + + } + + public void closed(Ice.Connection con) + { + _sessionHelper.destroy(); + } + + private final SessionHelper _sessionHelper; + } + /** * Creates a Glacier2 session. * @@ -318,9 +338,17 @@ public class SessionHelper private void connected(RouterPrx router, SessionPrx session) { - Ice.Connection conn = router.ice_getCachedConnection(); - long timeout = router.getSessionTimeout(); String category = router.getCategoryForClient(); + long sessionTimeout = router.getSessionTimeout(); + int acmTimeout = 0; + try + { + acmTimeout = router.getACMTimeout(); + } + catch(Ice.OperationNotExistException ex) + { + } + Ice.Connection conn = router.ice_getCachedConnection(); synchronized(this) { @@ -354,9 +382,18 @@ public class SessionHelper _connected = true; assert _refreshThread == null; - if(timeout > 0) + if(acmTimeout > 0) + { + Ice.Connection connection = _router.ice_getCachedConnection(); + assert(connection != null); + connection.setACM(new Ice.IntOptional(acmTimeout), + null, + new Ice.Optional<Ice.ACMHeartbeat>(Ice.ACMHeartbeat.HeartbeatAlways)); + connection.setCallback(new ConnectionCallbackI(this)); + } + else if(sessionTimeout > 0) { - _refreshThread = new SessionRefreshThread(_router, (timeout * 1000)/2); + _refreshThread = new SessionRefreshThread(_router, (sessionTimeout * 1000)/2); _refreshThread.start(); } diff --git a/java/src/Ice/AsyncResult.java b/java/src/Ice/AsyncResult.java index ff78c968eca..029e191336f 100644 --- a/java/src/Ice/AsyncResult.java +++ b/java/src/Ice/AsyncResult.java @@ -243,7 +243,7 @@ public class AsyncResult } } - public final void __exceptionAsync(final LocalException ex) + public final void __invokeExceptionAsync(final LocalException ex) { // // This is called when it's not safe to call the exception callback synchronously @@ -257,7 +257,7 @@ public class AsyncResult public void run() { - __exception(ex); + __invokeException(ex); } }); } @@ -267,7 +267,7 @@ public class AsyncResult } } - public final void __exception(LocalException ex) + public final void __invokeException(LocalException ex) { synchronized(_monitor) { @@ -276,47 +276,11 @@ public class AsyncResult _exception = ex; _monitor.notifyAll(); } - - if(_callback != null) - { - if(_instance.useApplicationClassLoader()) - { - Thread.currentThread().setContextClassLoader(_callback.getClass().getClassLoader()); - } - - try - { - _callback.__completed(this); - } - catch(RuntimeException exc) - { - __warning(exc); - } - catch(AssertionError exc) - { - __error(exc); - } - catch(OutOfMemoryError exc) - { - __error(exc); - } - finally - { - if(_instance.useApplicationClassLoader()) - { - Thread.currentThread().setContextClassLoader(null); - } - } - } - - if(_observer != null) - { - _observer.detach(); - _observer = null; - } + + __invokeCompleted(); } - protected final void __sentInternal() + protected final void __invokeSentInternal() { // // Note: no need to change the _state here, specializations are responsible for @@ -383,7 +347,7 @@ public class AsyncResult return _observer; } - public final void __sentAsync() + public final void __invokeSentAsync() { // // This is called when it's not safe to call the sent callback synchronously @@ -397,7 +361,7 @@ public class AsyncResult public void run() { - __sentInternal(); + __invokeSentInternal(); } }); } @@ -452,7 +416,7 @@ public class AsyncResult } } - protected final void __response() + protected final void __invokeCompleted() { // // Note: no need to change the _state here, specializations are responsible for @@ -498,6 +462,31 @@ public class AsyncResult } } + protected void + __runTimerTask() + { + IceInternal.RequestHandler handler; + synchronized(_monitor) + { + handler = _timeoutRequestHandler; + _timeoutRequestHandler = null; + } + + if(handler != null) + { + final IceInternal.RequestHandler h = handler; + _instance.clientThreadPool().execute( + new IceInternal.DispatchWorkItem(_instance) + { + public void + run() + { + h.asyncRequestTimedOut((IceInternal.OutgoingAsyncMessageCallback)AsyncResult.this); + } + }); + } + } + protected final void __warning(RuntimeException ex) { if(_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) @@ -521,6 +510,8 @@ public class AsyncResult protected IceInternal.BasicStream _is; protected IceInternal.BasicStream _os; + protected IceInternal.RequestHandler _timeoutRequestHandler; + protected static final byte OK = 0x1; protected static final byte Done = 0x2; protected static final byte Sent = 0x4; diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index 7785c2d2226..c001462c960 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -105,9 +105,9 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne return; } - if(_acmTimeout > 0) + if(_acmLastActivity > 0) { - _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000; + _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); } setState(StateActive); @@ -274,26 +274,66 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } synchronized public void - monitor(long now) + monitor(long now, IceInternal.ACMConfig acm) { if(_state != StateActive) { return; } - // - // Active connection management for idle connections. - // - if(_acmTimeout <= 0 || - !_requests.isEmpty() || !_asyncRequests.isEmpty() || _dispatchCount > 0 || - _readStream.size() > IceInternal.Protocol.headerSize || !_writeStream.isEmpty() || !_batchStream.isEmpty()) + if(_readStream.size() > IceInternal.Protocol.headerSize || !_writeStream.isEmpty()) { + // + // If writing or reading, nothing to do, the connection + // timeout will kick-in if writes or reads don't progress. + // This check is necessary because the actitivy timer is + // only set when a message is fully read/written. + // return; } - if(now >= _acmAbsoluteTimeoutMillis) + // + // We send a heartbeat if there was no activity in the last + // (timeout / 4) period. Sending a heartbeat sooner than + // really needed is safer to ensure that the receiver will + // receive in time the heartbeat. Sending the heartbeat if + // there was no activity in the last (timeout / 2) period + // isn't enough since monitor() is called only every (timeout + // / 2) period. + // + // Note that this doesn't imply that we are sending 4 + // heartbeats per timeout period because the monitor() method + // is sill only called every (timeout / 2) period. + // + + if(acm.heartbeat == ACMHeartbeat.HeartbeatAlways || + (acm.heartbeat != ACMHeartbeat.HeartbeatOff && now >= (_acmLastActivity + acm.timeout / 4))) { - setState(StateClosing, new ConnectionTimeoutException()); + if(acm.heartbeat != ACMHeartbeat.HeartbeatOnInvocation || _dispatchCount > 0) + { + heartbeat(); + } + } + + if(acm.close != ACMClose.CloseOff && now >= (_acmLastActivity + acm.timeout)) + { + if(acm.close == ACMClose.CloseOnIdleForceful || + (acm.close != ACMClose.CloseOnIdle && (!_requests.isEmpty() || !_asyncRequests.isEmpty()))) + { + // + // Close the connection if we didn't receive a heartbeat in + // the last period. + // + setState(StateClosed, new ConnectionTimeoutException()); + } + else if(acm.close != ACMClose.CloseOnInvocation && + _dispatchCount == 0 && _batchStream.isEmpty() && _requests.isEmpty() && _asyncRequests.isEmpty()) + { + // + // The connection is idle, close it. + // + setState(StateClosing, new ConnectionTimeoutException()); + } } } @@ -701,11 +741,11 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne new IceInternal.ConnectionBatchOutgoingAsync(this, _communicator, _instance, __flushBatchRequests_name, cb); try { - result.__send(); + result.__invoke(); } catch(LocalException __ex) { - result.__exceptionAsync(__ex); + result.__invokeExceptionAsync(__ex); } return result; } @@ -738,7 +778,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne if(_batchRequestNum == 0) { - out.sent(false); + out.sent(); return true; } @@ -799,7 +839,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne if(_batchRequestNum == 0) { int status = IceInternal.AsyncStatus.Sent; - if(outAsync.__sent(this)) + if(outAsync.__sent()) { status |= IceInternal.AsyncStatus.InvokeSentCallback; } @@ -841,6 +881,142 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne return status; } + synchronized public void + setCallback(ConnectionCallback callback) + { + if(_state > StateClosing) + { + return; + } + _callback = callback; + } + + synchronized public void + setACM(Ice.IntOptional timeout, Ice.Optional<ACMClose> close, Ice.Optional<ACMHeartbeat> heartbeat) + { + if(_monitor != null) + { + if(_state == StateActive) + { + _monitor.remove(this); + } + _monitor = _monitor.acm(timeout, close, heartbeat); + if(_state == StateActive) + { + _monitor.add(this); + } + + if(_monitor.getACM().timeout <= 0) + { + _acmLastActivity = -1; // Disable the recording of last activity. + } + else if(_state == StateActive && _acmLastActivity == -1) + { + _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + } + } + } + + synchronized public Ice.ACM + getACM() + { + return _monitor != null ? _monitor.getACM() : new ACM(0, ACMClose.CloseOff, ACMHeartbeat.HeartbeatOff); + } + + synchronized public void + requestTimedOut(IceInternal.OutgoingMessageCallback out) + { + java.util.Iterator<OutgoingMessage> it = _sendStreams.iterator(); + while(it.hasNext()) + { + OutgoingMessage o = it.next(); + if(o.out == out) + { + if(o.requestId > 0) + { + _requests.remove(o.requestId); + } + + // + // If the request is being sent, don't remove it from the send streams, + // it will be removed once the sending is finished. + // + if(o == _sendStreams.getFirst()) + { + o.timedOut(); + } + else + { + it.remove(); + } + o.finished(new InvocationTimeoutException()); + return; // We're done. + } + } + + if(out instanceof IceInternal.Outgoing) + { + IceInternal.Outgoing o = (IceInternal.Outgoing)out; + java.util.Iterator<IceInternal.Outgoing> it2 = _requests.values().iterator(); + while(it2.hasNext()) + { + if(it2.next() == o) + { + o.finished(new InvocationTimeoutException(), true); + it2.remove(); + return; // We're done. + } + } + } + } + + synchronized public void + asyncRequestTimedOut(IceInternal.OutgoingAsyncMessageCallback outAsync) + { + java.util.Iterator<OutgoingMessage> it = _sendStreams.iterator(); + while(it.hasNext()) + { + OutgoingMessage o = it.next(); + if(o.outAsync == outAsync) + { + if(o.requestId > 0) + { + _asyncRequests.remove(o.requestId); + } + + // + // If the request is being sent, don't remove it from the send streams, + // it will be removed once the sending is finished. + // + if(o == _sendStreams.getFirst()) + { + o.timedOut(); + } + else + { + it.remove(); + } + o.finished(new InvocationTimeoutException()); + return; // We're done. + } + } + + if(outAsync instanceof IceInternal.OutgoingAsync) + { + IceInternal.OutgoingAsync o = (IceInternal.OutgoingAsync)outAsync; + java.util.Iterator<IceInternal.OutgoingAsync> it2 = _asyncRequests.values().iterator(); + while(it2.hasNext()) + { + if(it2.next() == o) + { + o.__finished(new InvocationTimeoutException(), true); + it2.remove(); + return; // We're done. + } + } + } + } + synchronized public void sendResponse(IceInternal.BasicStream os, byte compressFlag) { @@ -852,7 +1028,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { if(_state == StateFinished) { - _reaper.add(this, _observer); + reap(); } notifyAll(); } @@ -886,7 +1062,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { if(_state == StateFinished) { - _reaper.add(this, _observer); + reap(); } notifyAll(); } @@ -1119,8 +1295,15 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // We start out in holding state. // setState(StateHolding); - startCB = _startCallback; - _startCallback = null; + if(_startCallback != null) + { + startCB = _startCallback; + _startCallback = null; + if(startCB != null) + { + ++_dispatchCount; + } + } } else { @@ -1138,15 +1321,10 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne if((current.operation & IceInternal.SocketOperation.Write) != 0) { sentCBs = sendNextMessage(); - } - - // - // We increment the dispatch count to prevent the - // communicator destruction during the callback. - // - if(sentCBs != null || info != null && info.outAsync != null) - { - ++_dispatchCount; + if(sentCBs != null) + { + ++_dispatchCount; + } } } } @@ -1186,17 +1364,16 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne return; } - if(_acmTimeout > 0) + if(_acmLastActivity > 0) { - _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000; + _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); } - current.ioCompleted(); } if(_dispatcher != null) { - if(info != null) + if(info != null && info.heartbeatCallback == null) // No need for the stream if heartbeat callback { // // Create a new stream for the dispatch instead of using the thread @@ -1239,6 +1416,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne protected void dispatch(StartCallback startCB, java.util.List<OutgoingMessage> sentCBs, MessageInfo info) { + int count = 0; + // // Notify the factory that the connection establishment and // validation has completed. @@ -1246,6 +1425,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne if(startCB != null) { startCB.connectionStartCompleted(this); + ++count; } // @@ -1255,8 +1435,9 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { for(OutgoingMessage msg : sentCBs) { - msg.outAsync.__sent(); + msg.outAsync.__invokeSent(); } + ++count; } if(info != null) @@ -1268,6 +1449,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne if(info.outAsync != null) { info.outAsync.__finished(info.stream); + ++count; } if(info.invokeNum > 0) @@ -1279,17 +1461,36 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // invokeAll(info.stream, info.invokeNum, info.requestId, info.compress, info.servantManager, info.adapter); + + // + // Don't increase count, the dispatch count is + // decreased when the incoming reply is sent. + // + } + + if(info.heartbeatCallback != null) + { + try + { + info.heartbeatCallback.heartbeat(this); + } + catch(Exception ex) + { + _logger.error("connection callback exception:\n" + ex + '\n' + _desc); + } + ++count; } } // // Decrease dispatch count. // - if(sentCBs != null || info != null && info.outAsync != null) + if(count > 0) { synchronized(this) { - if(--_dispatchCount == 0) + _dispatchCount -= count; + if(_dispatchCount == 0) { // // Only initiate shutdown if not already done. It @@ -1311,7 +1512,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } else if(_state == StateFinished) { - _reaper.add(this, _observer); + reap(); } notifyAll(); } @@ -1328,7 +1529,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // finish() with the dispatcher if one is set, or we promote another IO // thread first before calling finish(). // - if(_startCallback == null && _sendStreams.isEmpty() && _asyncRequests.isEmpty()) + if(_startCallback == null && _sendStreams.isEmpty() && _asyncRequests.isEmpty() && _callback == null) { finish(); return; @@ -1428,6 +1629,19 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } _asyncRequests.clear(); + if(_callback != null) + { + try + { + _callback.closed(this); + } + catch(Exception ex) + { + _logger.error("connection callback exception:\n" + ex + '\n' + _desc); + } + _callback = null; + } + // // This must be done last as this will cause waitUntilFinished() to return (and communicator // objects such as the timer might be destroyed too). @@ -1437,7 +1651,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne setState(StateFinished); if(_dispatchCount == 0) { - _reaper.add(this, _observer); + reap(); } } } @@ -1530,20 +1744,20 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { if(_state == StateFinished) { - _reaper.add(this, _observer); + reap(); } notifyAll(); } } } - public ConnectionI(Communicator communicator, IceInternal.Instance instance, IceInternal.ConnectionReaper reaper, + public ConnectionI(Communicator communicator, IceInternal.Instance instance, IceInternal.ACMMonitor monitor, IceInternal.Transceiver transceiver, IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapter adapter) { _communicator = communicator; _instance = instance; - _reaper = reaper; + _monitor = monitor; _transceiver = transceiver; _desc = transceiver.toString(); _type = transceiver.type(); @@ -1562,7 +1776,14 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne _warn = initData.properties.getPropertyAsInt("Ice.Warn.Connections") > 0; _warnUdp = instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0; _cacheBuffers = instance.cacheMessageBuffers(); - _acmAbsoluteTimeoutMillis = 0; + if(_monitor != null && _monitor.getACM().timeout > 0) + { + _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + } + else + { + _acmLastActivity = -1; + } _nextRequestId = 1; _batchAutoFlush = initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0 ? true : false; _batchStream = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding, @@ -1601,22 +1822,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne try { - if(_endpoint.datagram()) - { - _acmTimeout = 0; - } - else - { - if(_adapter != null) - { - _acmTimeout = ((ObjectAdapterI)_adapter).getACM(); - } - else - { - _acmTimeout = _instance.clientACM(); - } - } - if(_adapter != null) { _threadPool = ((ObjectAdapterI)_adapter).getThreadPool(); @@ -1841,15 +2046,19 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // monitor, but only if we were registered before, i.e., if our // old state was StateActive. // - if(_acmTimeout > 0) + if(_monitor != null) { if(state == StateActive) { - _instance.connectionMonitor().add(this); + _monitor.add(this); + if(_acmLastActivity > 0) + { + _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); + } } else if(_state == StateActive) { - _instance.connectionMonitor().remove(this); + _monitor.remove(this); } } @@ -1949,6 +2158,35 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } + private void + heartbeat() + { + assert(_state == StateActive); + + if(!_endpoint.datagram()) + { + IceInternal.BasicStream os = new IceInternal.BasicStream(_instance, + IceInternal.Protocol.currentProtocolEncoding); + os.writeBlob(IceInternal.Protocol.magic); + IceInternal.Protocol.currentProtocol.__write(os); + IceInternal.Protocol.currentProtocolEncoding.__write(os); + os.writeByte(IceInternal.Protocol.validateConnectionMsg); + os.writeByte((byte)0); + os.writeInt(IceInternal.Protocol.headerSize); // Message size. + + try + { + OutgoingMessage message = new OutgoingMessage(os, false, false); + sendMessage(message); + } + catch(Ice.LocalException ex) + { + setState(StateClosed, ex); + assert(_exception != null); + } + } + } + private boolean initialize(int operation) { @@ -2085,7 +2323,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // OutgoingMessage message = _sendStreams.getFirst(); _writeStream.swap(message.stream); - if(message.sent(this, true)) + if(message.sent()) { callbacks.add(message); } @@ -2217,13 +2455,14 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne observerFinishWrite(message.stream.pos()); } int status = IceInternal.AsyncStatus.Sent; - if(message.sent(this, false)) + if(message.sent()) { status |= IceInternal.AsyncStatus.InvokeSentCallback; } - if(_acmTimeout > 0) + + if(_acmLastActivity > 0) { - _acmAbsoluteTimeoutMillis = IceInternal.Time.currentMonotonicTimeMillis() + _acmTimeout * 1000; + _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); } return status; } @@ -2307,6 +2546,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne IceInternal.ServantManager servantManager; ObjectAdapter adapter; IceInternal.OutgoingAsync outAsync; + ConnectionCallback heartbeatCallback; } private MessageInfo @@ -2432,9 +2672,9 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne else { info.outAsync = _asyncRequests.remove(info.requestId); - if(info.outAsync == null) + if(info.outAsync != null) { - throw new UnknownRequestIdException(); + ++_dispatchCount; } } notifyAll(); // Notify threads blocked in close(false) @@ -2444,17 +2684,18 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne case IceInternal.Protocol.validateConnectionMsg: { IceInternal.TraceUtil.traceRecv(info.stream, _logger, _traceLevels); - if(_warn) + if(_callback != null) { - _logger.warning("ignoring unexpected validate connection message:\n" + _desc); + info.heartbeatCallback = _callback; + ++_dispatchCount; } break; } default: { - IceInternal.TraceUtil.trace("received unknown message\n(invalid, closing connection)", - info.stream, _logger, _traceLevels); + IceInternal.TraceUtil.trace("received unknown message\n(invalid, closing connection)", info.stream, + _logger, _traceLevels); throw new UnknownMessageException(); } } @@ -2737,6 +2978,19 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } + private void + reap() + { + if(_monitor != null) + { + _monitor.reap(this); + } + if(_observer != null) + { + _observer.detach(); + } + } + public IceInternal.Outgoing getOutgoing(IceInternal.RequestHandler handler, String operation, OperationMode mode, java.util.Map<String, String> context, InvocationObserver observer) @@ -2818,6 +3072,14 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne this.isSent = false; } + public void + timedOut() + { + assert((out != null || outAsync != null) && !isSent); + out = null; + outAsync = null; + } + public void adopt() { @@ -2832,18 +3094,18 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } public boolean - sent(ConnectionI connection, boolean notify) + sent() { isSent = true; // The message is sent. if(out != null) { - out.sent(notify); // true = notify the waiting thread that the request was sent. + out.sent(); return false; } else if(outAsync != null) { - return outAsync.__sent(connection); + return outAsync.__sent(); } else { @@ -2876,7 +3138,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne private Communicator _communicator; private final IceInternal.Instance _instance; - private final IceInternal.ConnectionReaper _reaper; + private IceInternal.ACMMonitor _monitor; private final IceInternal.Transceiver _transceiver; private String _desc; private final String _type; @@ -2902,8 +3164,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne private final boolean _warn; private final boolean _warnUdp; - private final long _acmTimeout; - private long _acmAbsoluteTimeoutMillis; + + private long _acmLastActivity; private final int _compressionLevel; @@ -2952,6 +3214,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne private Ice.ConnectionInfo _info; + private ConnectionCallback _callback; + private static Ice.Instrumentation.ConnectionState connectionStateMap[] = { Ice.Instrumentation.ConnectionState.ConnectionStateValidating, // StateNotInitialized Ice.Instrumentation.ConnectionState.ConnectionStateValidating, // StateNotValidated diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index d216c3a7979..e661c886007 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -826,21 +826,12 @@ public final class ObjectAdapterI implements ObjectAdapter return _servantManager; } - public int + public IceInternal.ACMConfig getACM() { - // Not check for deactivation here! - + // No check for deactivation here! assert(_instance != null); // Must not be called after destroy(). - - if(_hasAcmTimeout) - { - return _acmTimeout; - } - else - { - return _instance.serverACM(); - } + return _acm; } // @@ -855,8 +846,6 @@ public final class ObjectAdapterI implements ObjectAdapter _instance = instance; _communicator = communicator; _objectAdapterFactory = objectAdapterFactory; - _hasAcmTimeout = false; - _acmTimeout = 0; _servantManager = new IceInternal.ServantManager(instance, name); _activateOneOffDone = false; _name = name; @@ -873,6 +862,7 @@ public final class ObjectAdapterI implements ObjectAdapter _id = ""; _replicaGroupId = ""; _reference = _instance.referenceFactory().create("dummy -t", ""); + _acm = _instance.serverACM(); return; } @@ -933,6 +923,8 @@ public final class ObjectAdapterI implements ObjectAdapter throw ex; } + _acm = new IceInternal.ACMConfig(properties, communicator.getLogger(), _name + ".ACM", instance.serverACM()); + try { int threadPoolSize = properties.getPropertyAsInt(_name + ".ThreadPool.Size"); @@ -946,13 +938,6 @@ public final class ObjectAdapterI implements ObjectAdapter _threadPool = new IceInternal.ThreadPool(_instance, _name + ".ThreadPool", 0); } - _hasAcmTimeout = properties.getProperty(_name + ".ACM").length() > 0; - if(_hasAcmTimeout) - { - _acmTimeout = properties.getPropertyAsInt(_name + ".ACM"); - _instance.connectionMonitor().checkIntervalForACM(_acmTimeout); - } - if(router == null) { router = RouterPrxHelper.uncheckedCast(_instance.proxyFactory().propertyToProxy(name + ".Router")); @@ -1499,6 +1484,9 @@ public final class ObjectAdapterI implements ObjectAdapter static private String[] _suffixes = { "ACM", + "ACM.Timeout", + "ACM.Heartbeat", + "ACM.Close", "AdapterId", "Endpoints", "Locator", @@ -1523,7 +1511,9 @@ public final class ObjectAdapterI implements ObjectAdapter "Router.Locator.PreferSecure", "Router.Locator.CollocationOptimized", "Router.Locator.LocatorCacheTimeout", + "Router.Locator.InvocationTimeout", "Router.LocatorCacheTimeout", + "Router.InvocationTimeout", "ProxyOptions", "ThreadPool.Size", "ThreadPool.SizeMax", @@ -1578,8 +1568,7 @@ public final class ObjectAdapterI implements ObjectAdapter private Communicator _communicator; private IceInternal.ObjectAdapterFactory _objectAdapterFactory; private IceInternal.ThreadPool _threadPool; - private boolean _hasAcmTimeout; - private int _acmTimeout; + private IceInternal.ACMConfig _acm; private IceInternal.ServantManager _servantManager; private boolean _activateOneOffDone; final private String _name; diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java index 53031953f41..74735d75265 100644 --- a/java/src/Ice/ObjectPrx.java +++ b/java/src/Ice/ObjectPrx.java @@ -870,6 +870,13 @@ public interface ObjectPrx int ice_getLocatorCacheTimeout(); /** + * Returns the invocation timeout of this proxy. + * + * @return The invocation timeout value (in seconds). + **/ + int ice_getInvocationTimeout(); + + /** * Returns the connection id of this proxy. * * @return The connection id. @@ -887,6 +894,14 @@ public interface ObjectPrx ObjectPrx ice_locatorCacheTimeout(int newTimeout); /** + * Creates a new proxy that is identical to this proxy, except for the invocation timeout. + * + * @param newTimeout The new invocation timeout (in seconds). + * + **/ + ObjectPrx ice_invocationTimeout(int newTimeout); + + /** * Returns whether this proxy caches connections. * * @return <code>true</code> if this proxy caches connections; <code>false</code>, otherwise. diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index b12b0d5dfbd..8bf9d9ec26d 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -297,11 +297,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable IceInternal.BasicStream __os = __result.__startWriteParams(Ice.FormatType.DefaultFormat); __os.writeString(__id); __result.__endWriteParams(); - __result.__send(true); + __result.__invoke(true); } catch(LocalException __ex) { - __result.__exceptionAsync(__ex); + __result.__invokeExceptionAsync(__ex); } return __result; } @@ -573,11 +573,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable { __result.__prepare(__ice_ping_name, OperationMode.Nonmutating, __context, __explicitCtx); __result.__writeEmptyParams(); - __result.__send(true); + __result.__invoke(true); } catch(LocalException __ex) { - __result.__exceptionAsync(__ex); + __result.__invokeExceptionAsync(__ex); } return __result; } @@ -841,11 +841,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable { __result.__prepare(__ice_ids_name, OperationMode.Nonmutating, __context, __explicitCtx); __result.__writeEmptyParams(); - __result.__send(true); + __result.__invoke(true); } catch(LocalException __ex) { - __result.__exceptionAsync(__ex); + __result.__invokeExceptionAsync(__ex); } return __result; } @@ -1134,11 +1134,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable { __result.__prepare(__ice_id_name, OperationMode.Nonmutating, __context, __explicitCtx); __result.__writeEmptyParams(); - __result.__send(true); + __result.__invoke(true); } catch(LocalException __ex) { - __result.__exceptionAsync(__ex); + __result.__invokeExceptionAsync(__ex); } return __result; } @@ -1545,11 +1545,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable { __result.__prepare(operation, mode, __context, __explicitCtx); __result.__writeParamEncaps(inParams); - __result.__send(true); + __result.__invoke(true); } catch(LocalException __ex) { - __result.__exceptionAsync(__ex); + __result.__invokeExceptionAsync(__ex); } return __result; } @@ -1832,6 +1832,17 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } /** + * Returns the invocation timeout of this proxy. + * + * @return The invocation timeout value (in seconds). + **/ + public final int + ice_getInvocationTimeout() + { + return _reference.getInvocationTimeout(); + } + + /** * Returns the connection id of this proxy. * * @return The connection id. @@ -1864,6 +1875,24 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } /** + * Creates a new proxy that is identical to this proxy, except for the invocation timeout. + * + * @param newTimeout The new invocation timeout (in seconds). + **/ + public final ObjectPrx + ice_invocationTimeout(int newTimeout) + { + if(newTimeout == _reference.getInvocationTimeout()) + { + return this; + } + else + { + return newInstance(_reference.changeInvocationTimeout(newTimeout)); + } + } + + /** * Returns whether this proxy caches connections. * * @return <code>true</code> if this proxy caches connections; <code>false</code>, otherwise. @@ -2498,11 +2527,11 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable new IceInternal.ProxyBatchOutgoingAsync(this, __ice_flushBatchRequests_name, __cb); try { - __result.__send(); + __result.__invoke(); } catch(LocalException __ex) { - __result.__exceptionAsync(__ex); + __result.__invokeExceptionAsync(__ex); } return __result; } diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index 208b193b1a2..911b05a388d 100644 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -1268,8 +1268,7 @@ public class Coordinator login(final SessionKeeper sessionKeeper, final SessionKeeper.ConnectionInfo info, final JDialog parent, - final Cursor oldCursor, - Ice.LongHolder keepAlivePeriodHolder) + final Cursor oldCursor) { // @@ -1709,14 +1708,14 @@ public class Coordinator return _session; } - synchronized public void setKeepAlivePeriod(long keepAlivePeriod) + synchronized public void setSessionTimeout(long sessionTimeout) { - _keepAlivePeriod = keepAlivePeriod; + _sessionTimeout = sessionTimeout; } - synchronized public long getKeepAlivePeriod() + synchronized public void setACMTimeout(int acmTimeout) { - return _keepAlivePeriod; + _acmTimeout = acmTimeout; } synchronized public void loginSuccess() @@ -1731,7 +1730,7 @@ public class Coordinator _newApplicationWithDefaultTemplates.setEnabled(true); _acquireExclusiveWriteAccess.setEnabled(true); _mainPane.setSelectedComponent(_liveDeploymentPane); - _sessionKeeper.loginSuccess(parent, oldCursor, _keepAlivePeriod, _session, info); + _sessionKeeper.loginSuccess(parent, oldCursor, _sessionTimeout, _acmTimeout, _session, info); } synchronized public void loginFailed() @@ -1753,7 +1752,8 @@ public class Coordinator } private AdminSessionPrx _session; - private long _keepAlivePeriod; + private long _sessionTimeout = 0; + private int _acmTimeout = 0; private boolean _failed = false; } @@ -1859,7 +1859,14 @@ public class Coordinator } } cb.setSession(AdminSessionPrxHelper.uncheckedCast(s)); - cb.setKeepAlivePeriod(router.getSessionTimeout() * 1000 / 2); + cb.setSessionTimeout(router.getSessionTimeout()); + try + { + cb.setACMTimeout(router.getACMTimeout()); + } + catch(Ice.OperationNotExistException ex) + { + } SwingUtilities.invokeLater(new Runnable() { public void run() @@ -2113,7 +2120,14 @@ public class Coordinator info.getPassword() != null ? new String(info.getPassword()) : "")); assert cb.getSession() != null; } - cb.setKeepAlivePeriod(cb.getRegistry().getSessionTimeout() * 1000 / 2); + cb.setSessionTimeout(cb.getRegistry().getSessionTimeout()); + try + { + cb.setACMTimeout(cb.getRegistry().getACMTimeout()); + } + catch(Ice.OperationNotExistException ex) + { + } } catch(final IceGrid.PermissionDeniedException e) { @@ -2191,7 +2205,7 @@ public class Coordinator } } } - }while(cb.getSession() == null); + } while(cb.getSession() == null); SwingUtilities.invokeLater(new Runnable() { @@ -2206,20 +2220,19 @@ public class Coordinator } } - void destroySession(AdminSessionPrx session) + void destroySession(AdminSessionPrx session, boolean routed) { _liveDeploymentRoot.closeAllShowLogDialogs(); - Ice.RouterPrx router = _communicator.getDefaultRouter(); - try { - if(router == null) + if(!routed) { session.destroy(); } else { + Ice.RouterPrx router = _communicator.getDefaultRouter(); Glacier2.RouterPrx gr = Glacier2.RouterPrxHelper.uncheckedCast(router); Glacier2.Callback_Router_destroySession cb = new Glacier2.Callback_Router_destroySession() @@ -2242,7 +2255,6 @@ public class Coordinator } catch(Ice.LocalException e) { - // Ignored } } @@ -2519,11 +2531,6 @@ public class Coordinator properties.setProperty("Ice.Override.ConnectTimeout", "5000"); // - // For Glacier - // - properties.setProperty("Ice.ACM.Client", "0"); - - // // Disable retries // properties.setProperty("Ice.RetryIntervals", "-1"); @@ -3360,8 +3367,7 @@ public class Coordinator } catch(Ice.LocalException e) { - System.err.println("_communicator.destroy() raised " - + e.toString()); + System.err.println("_communicator.destroy() raised " + e.toString()); e.printStackTrace(); } _communicator = null; diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java index 6690f4240d1..7fc3072e147 100644 --- a/java/src/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/SessionKeeper.java @@ -87,11 +87,11 @@ public class SessionKeeper // private class Session { - Session(AdminSessionPrx session, long keepAliveperiod, boolean routed, final Component parent) + Session(AdminSessionPrx session, long sessionTimeout, int acmTimeout, boolean routed, final Component parent) throws java.lang.Throwable { _session = session; - + _routed = routed; try { _admin = _session.getAdmin(); @@ -222,13 +222,53 @@ public class SessionKeeper throw e; } - _thread = new Pinger(_session, keepAliveperiod); - _thread.setDaemon(true); - _thread.start(); + if(acmTimeout > 0) + { + _session.ice_getConnection().setACM( + new Ice.IntOptional(acmTimeout), + null, + new Ice.Optional<Ice.ACMHeartbeat>(Ice.ACMHeartbeat.HeartbeatAlways)); + + _session.ice_getConnection().setCallback( + new Ice.ConnectionCallback() + { + public void + heartbeat(Ice.Connection con) + { + } + + public void + closed(Ice.Connection con) + { + try + { + con.getInfo(); // This throws when the connection is closed. + assert(false); + } + catch(final Ice.LocalException ex) + { + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + sessionLost("Failed to contact the IceGrid registry: " + ex.toString()); + } + }); + } + } + }); + } + else + { + _thread = new Pinger(_session, sessionTimeout * 1000 / 2); + _thread.setDaemon(true); + _thread.start(); + } try { - registerObservers(routed); + registerObservers(); } catch(final Ice.LocalException e) { @@ -366,22 +406,24 @@ public class SessionKeeper _adapter.destroy(); _adapter = null; } + + _session.ice_getConnection().setCallback(null); if(destroySession) { - _coordinator.destroySession(_session); + _coordinator.destroySession(_session, _routed); } _coordinator.setConnected(false); } - private void registerObservers(final boolean routed) throws java.lang.Throwable + private void registerObservers() throws java.lang.Throwable { // // Create the object adapter for the observers // String category; - if(!routed) + if(!_routed) { category = "observer"; @@ -454,7 +496,7 @@ public class SessionKeeper try { - if(routed) + if(_routed) { _session.setObservers(registryObserver, nodeObserver, @@ -494,6 +536,7 @@ public class SessionKeeper } private final AdminSessionPrx _session; + private final boolean _routed; private Pinger _thread; @@ -4661,9 +4704,7 @@ public class SessionKeeper Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dispose(); - Ice.LongHolder keepAlivePeriodHolder = new Ice.LongHolder(); - _coordinator.login(SessionKeeper.this, info,parent, oldCursor, - keepAlivePeriodHolder); + _coordinator.login(SessionKeeper.this, info,parent, oldCursor); } } }; @@ -4726,8 +4767,7 @@ public class SessionKeeper { Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - Ice.LongHolder keepAlivePeriodHolder = new Ice.LongHolder(); - _coordinator.login(SessionKeeper.this, info, parent, oldCursor, keepAlivePeriodHolder); + _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } } @@ -4799,9 +4839,7 @@ public class SessionKeeper Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dispose(); - Ice.LongHolder keepAlivePeriodHolder = new Ice.LongHolder(); - _coordinator.login(SessionKeeper.this, info, parent, oldCursor, - keepAlivePeriodHolder); + _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } }; @@ -4859,15 +4897,14 @@ public class SessionKeeper { Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - Ice.LongHolder keepAlivePeriodHolder = new Ice.LongHolder(); - _coordinator.login(SessionKeeper.this, info, parent, oldCursor, keepAlivePeriodHolder); + _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } } } - public void loginSuccess(final JDialog parent, final Cursor oldCursor, final long keepAliveperiod, - final AdminSessionPrx session, final ConnectionInfo info) + public void loginSuccess(final JDialog parent, final Cursor oldCursor, final long sessionTimeout, + final int acmTimeout, final AdminSessionPrx session, final ConnectionInfo info) { assert session != null; try @@ -4906,7 +4943,7 @@ public class SessionKeeper { try { - setSession(new Session(session, keepAliveperiod, !info.getDirect(), parent)); + setSession(new Session(session, sessionTimeout, acmTimeout, !info.getDirect(), parent)); } catch(java.lang.Throwable e) { @@ -5090,9 +5127,7 @@ public class SessionKeeper Cursor oldCursor = parent.getCursor(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dispose(); - Ice.LongHolder keepAlivePeriodHolder = new Ice.LongHolder(); - _coordinator.login(SessionKeeper.this, info, parent, - oldCursor, keepAlivePeriodHolder); + _coordinator.login(SessionKeeper.this, info, parent, oldCursor); } } }); @@ -5221,8 +5256,6 @@ public class SessionKeeper private CertificateManagerDialog _certificateManagerDialog; private static AuthDialog _authDialog; - private ConnectionInfo _connectionInfo; - private final Coordinator _coordinator; private Preferences _loginPrefs; diff --git a/java/src/IceInternal/ACMConfig.java b/java/src/IceInternal/ACMConfig.java new file mode 100644 index 00000000000..466e6728b9b --- /dev/null +++ b/java/src/IceInternal/ACMConfig.java @@ -0,0 +1,81 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +public final class ACMConfig implements java.lang.Cloneable +{ + ACMConfig(boolean server) + { + timeout = 60 * 1000; + heartbeat = Ice.ACMHeartbeat.HeartbeatOnInvocation; + close = server ? Ice.ACMClose.CloseOnInvocation : Ice.ACMClose.CloseOnInvocationAndIdle; + } + + public ACMConfig(Ice.Properties p, Ice.Logger l, String prefix, ACMConfig dflt) + { + assert(prefix != null); + + String timeoutProperty; + if((prefix.equals("Ice.ACM.Client") || prefix.equals("Ice.ACM.Server")) && + p.getProperty(prefix + ".Timeout").isEmpty()) + { + timeoutProperty = prefix; // Deprecated property. + } + else + { + timeoutProperty = prefix + ".Timeout"; + }; + + timeout = p.getPropertyAsIntWithDefault(timeoutProperty, dflt.timeout / 1000) * 1000; // To milliseconds + + int hb = p.getPropertyAsIntWithDefault(prefix + ".Heartbeat", dflt.heartbeat.ordinal()); + Ice.ACMHeartbeat[] heartbeatValues = Ice.ACMHeartbeat.values(); + if(hb >= 0 && hb < heartbeatValues.length) + { + heartbeat = heartbeatValues[hb]; + } + else + { + l.warning("invalid value for property `" + prefix + ".Heartbeat" + "', default value will be used instead"); + heartbeat = dflt.heartbeat; + } + + Ice.ACMClose[] closeValues = Ice.ACMClose.values(); + int cl = p.getPropertyAsIntWithDefault(prefix + ".Close", dflt.close.ordinal()); + if(cl >= 0 && cl < closeValues.length) + { + close = closeValues[cl]; + } + else + { + l.warning("invalid value for property `" + prefix + ".Close" + "', default value will be used instead"); + close = dflt.close; + } + } + + public java.lang.Object + clone() + { + java.lang.Object o = null; + try + { + o = super.clone(); + } + catch(CloneNotSupportedException ex) + { + assert false; // impossible + } + return o; + } + + public int timeout; + public Ice.ACMHeartbeat heartbeat; + public Ice.ACMClose close; +}; diff --git a/java/src/IceInternal/ACMMonitor.java b/java/src/IceInternal/ACMMonitor.java new file mode 100644 index 00000000000..24701416fe6 --- /dev/null +++ b/java/src/IceInternal/ACMMonitor.java @@ -0,0 +1,20 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +public interface ACMMonitor extends TimerTask +{ + void add(Ice.ConnectionI con); + void remove(Ice.ConnectionI con); + void reap(Ice.ConnectionI con); + + ACMMonitor acm(Ice.IntOptional timeout, Ice.Optional<Ice.ACMClose> close, Ice.Optional<Ice.ACMHeartbeat> heartbeat); + Ice.ACM getACM(); +}; 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 diff --git a/java/src/IceInternal/BatchOutgoingAsync.java b/java/src/IceInternal/BatchOutgoingAsync.java index 5ba04e7a547..cfec8416234 100644 --- a/java/src/IceInternal/BatchOutgoingAsync.java +++ b/java/src/IceInternal/BatchOutgoingAsync.java @@ -9,14 +9,21 @@ package IceInternal; -public class BatchOutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessageCallback +public class BatchOutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessageCallback, TimerTask { public BatchOutgoingAsync(Ice.Communicator communicator, Instance instance, String operation, CallbackBase callback) { super(communicator, instance, operation, callback); } - public boolean __sent(Ice.ConnectionI connection) + public int + __send(Ice.ConnectionI connection, boolean compress, boolean response) + { + return connection.flushAsyncBatchRequests(this); + } + + public boolean + __sent() { synchronized(_monitor) { @@ -27,17 +34,24 @@ public class BatchOutgoingAsync extends Ice.AsyncResult implements OutgoingAsync _remoteObserver.detach(); _remoteObserver = null; } + if(_timeoutRequestHandler != null) + { + _instance.timer().cancel(this); + _timeoutRequestHandler = null; + } _monitor.notifyAll(); return true; } } - public void __sent() + public void + __invokeSent() { - __sentInternal(); + __invokeSentInternal(); } - public void __finished(Ice.LocalException exc, boolean sent) + public void + __finished(Ice.LocalException exc, boolean sent) { if(_remoteObserver != null) { @@ -45,6 +59,18 @@ public class BatchOutgoingAsync extends Ice.AsyncResult implements OutgoingAsync _remoteObserver.detach(); _remoteObserver = null; } - __exception(exc); + if(_timeoutRequestHandler != null) + { + _instance.timer().cancel(this); + _timeoutRequestHandler = null; + } + __invokeException(exc); } + + public void + runTimerTask() + { + __runTimerTask(); + } + } diff --git a/java/src/IceInternal/CommunicatorBatchOutgoingAsync.java b/java/src/IceInternal/CommunicatorBatchOutgoingAsync.java index 98955bf4d5e..ea0a8d26177 100644 --- a/java/src/IceInternal/CommunicatorBatchOutgoingAsync.java +++ b/java/src/IceInternal/CommunicatorBatchOutgoingAsync.java @@ -48,7 +48,7 @@ public class CommunicatorBatchOutgoingAsync extends Ice.AsyncResult } public boolean - __sent(Ice.ConnectionI con) + __sent() { if(_remoteObserver != null) { @@ -130,11 +130,11 @@ public class CommunicatorBatchOutgoingAsync extends Ice.AsyncResult // if(!_sentSynchronously || !userThread) { - __sentAsync(); + __invokeSentAsync(); } else { - __sentInternal(); + __invokeSentInternal(); } } diff --git a/java/src/IceInternal/ConnectRequestHandler.java b/java/src/IceInternal/ConnectRequestHandler.java index 34d485d93f0..0cfe4e61aac 100644 --- a/java/src/IceInternal/ConnectRequestHandler.java +++ b/java/src/IceInternal/ConnectRequestHandler.java @@ -22,18 +22,18 @@ public class ConnectRequestHandler this.os.swap(os); } - Request(OutgoingAsync out) + Request(OutgoingMessageCallback out) { this.out = out; } - Request(BatchOutgoingAsync out) + Request(OutgoingAsyncMessageCallback out) { - this.batchOut = out; + this.outAsync = out; } - OutgoingAsync out = null; - BatchOutgoingAsync batchOut = null; + OutgoingMessageCallback out = null; + OutgoingAsyncMessageCallback outAsync = null; BasicStream os = null; } @@ -134,22 +134,23 @@ public class ConnectRequestHandler _connection.abortBatchRequest(); } - public Ice.ConnectionI - sendRequest(Outgoing out) + public boolean + sendRequest(OutgoingMessageCallback out) throws LocalExceptionWrapper { - if(!getConnection(true).sendRequest(out, _compress, _response) || _response) - { - return _connection; // The request has been sent or we're expecting a response. - } - else + synchronized(this) { - return null; // The request hasn't been sent yet. + if(!initialized()) + { + _requests.add(new Request(out)); + return false; // Not sent + } } + return out.send(_connection, _compress, _response) && !_response; // Finished if sent and no response. } public int - sendAsyncRequest(OutgoingAsync out) + sendAsyncRequest(OutgoingAsyncMessageCallback out) throws LocalExceptionWrapper { synchronized(this) @@ -160,29 +161,57 @@ public class ConnectRequestHandler return AsyncStatus.Queued; } } - return _connection.sendAsyncRequest(out, _compress, _response); + return out.__send(_connection, _compress, _response); } - public boolean - flushBatchRequests(BatchOutgoing out) + public void + requestTimedOut(OutgoingMessageCallback out) { - return getConnection(true).flushBatchRequests(out); + synchronized(this) + { + if(!initialized()) + { + java.util.Iterator<Request> it = _requests.iterator(); + while(it.hasNext()) + { + Request request = it.next(); + if(request.out == out) + { + out.finished(new Ice.InvocationTimeoutException(), false); + it.remove(); + return; + } + } + assert(false); // The request has to be queued if it timed out and we're not initialized yet. + } + } + _connection.requestTimedOut(out); } - public int - flushAsyncBatchRequests(BatchOutgoingAsync out) + public void + asyncRequestTimedOut(OutgoingAsyncMessageCallback outAsync) { synchronized(this) { if(!initialized()) { - _requests.add(new Request(out)); - return AsyncStatus.Queued; + java.util.Iterator<Request> it = _requests.iterator(); + while(it.hasNext()) + { + Request request = it.next(); + if(request.outAsync == outAsync) + { + outAsync.__finished(new Ice.InvocationTimeoutException(), false); + it.remove(); + return; + } + } + assert(false); // The request has to be queued if it timed out and we're not initialized yet. } } - return _connection.flushAsyncBatchRequests(out); + _connection.asyncRequestTimedOut(outAsync); } - + public Outgoing getOutgoing(String operation, Ice.OperationMode mode, java.util.Map<String, String> context, InvocationObserver observer) @@ -412,18 +441,14 @@ public class ConnectRequestHandler Request request = p.next(); if(request.out != null) { - if((_connection.sendAsyncRequest(request.out, _compress, _response) & - AsyncStatus.InvokeSentCallback) > 0) - { - sentCallbacks.add(request.out); - } + request.out.send(_connection, _compress, _response); } - else if(request.batchOut != null) + else if(request.outAsync != null) { - if((_connection.flushAsyncBatchRequests(request.batchOut) & + if((request.outAsync.__send(_connection, _compress, _response) & AsyncStatus.InvokeSentCallback) > 0) { - sentCallbacks.add(request.batchOut); + sentCallbacks.add(request.outAsync); } } else @@ -488,7 +513,7 @@ public class ConnectRequestHandler { for(OutgoingAsyncMessageCallback callback : sentCallbacks) { - callback.__sent(); + callback.__invokeSent(); } }; }); @@ -528,12 +553,12 @@ public class ConnectRequestHandler for(Request request : _requests) { if(request.out != null) - { - request.out.__finished(ex, false); + { + request.out.finished(ex, false); } - else if(request.batchOut != null) + else if(request.outAsync != null) { - request.batchOut.__finished(ex, false); + request.outAsync.__finished(ex, false); } } _requests.clear(); @@ -545,12 +570,26 @@ public class ConnectRequestHandler for(Request request : _requests) { if(request.out != null) - { - request.out.__finished(ex); + { + if(request.out instanceof Outgoing) + { + ((Outgoing)request.out).finished(ex); + } + else + { + request.out.finished(ex.get(), false); + } } - else if(request.batchOut != null) + else if(request.outAsync != null) { - request.batchOut.__finished(ex.get(), false); + if(request.outAsync instanceof OutgoingAsync) + { + ((OutgoingAsync)request.outAsync).__finished(ex); + } + else + { + request.outAsync.__finished(ex.get(), false); + } } } _requests.clear(); diff --git a/java/src/IceInternal/ConnectionACMMonitor.java b/java/src/IceInternal/ConnectionACMMonitor.java new file mode 100644 index 00000000000..b8a8021c980 --- /dev/null +++ b/java/src/IceInternal/ConnectionACMMonitor.java @@ -0,0 +1,110 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +class ConnectionACMMonitor implements ACMMonitor +{ + ConnectionACMMonitor(FactoryACMMonitor parent, Timer timer, ACMConfig config) + { + _parent = parent; + _timer = timer; + _config = config; + } + + protected synchronized void + finalize() + throws Throwable + { + try + { + IceUtilInternal.Assert.FinalizerAssert(_connection == null); + } + catch(java.lang.Exception ex) + { + } + finally + { + super.finalize(); + } + } + + public synchronized void + add(Ice.ConnectionI connection) + { + assert(_connection == null); + _connection = connection; + if(_config.timeout > 0) + { + _timer.scheduleRepeated(this, _config.timeout / 2); + } + } + + public synchronized void + remove(Ice.ConnectionI connection) + { + assert(_connection == connection); + _connection = null; + if(_config.timeout > 0) + { + _timer.cancel(this); + } + } + + public void + reap(Ice.ConnectionI connection) + { + _parent.reap(connection); + } + + public ACMMonitor + acm(Ice.IntOptional timeout, Ice.Optional<Ice.ACMClose> close, Ice.Optional<Ice.ACMHeartbeat> heartbeat) + { + return _parent.acm(timeout, close, heartbeat); + } + + public Ice.ACM + getACM() + { + Ice.ACM acm = new Ice.ACM(); + acm.timeout = _config.timeout / 1000; + acm.close = _config.close; + acm.heartbeat = _config.heartbeat; + return acm; + } + + public void + runTimerTask() + { + Ice.ConnectionI connection; + synchronized(this) + { + if(_connection == null) + { + return; + } + connection = _connection; + } + + try + { + connection.monitor(Time.currentMonotonicTimeMillis(), _config); + } + catch(Exception ex) + { + _parent.handleException(ex); + } + } + + final private FactoryACMMonitor _parent; + final private Timer _timer; + final private ACMConfig _config; + + private Ice.ConnectionI _connection; +}; diff --git a/java/src/IceInternal/ConnectionBatchOutgoingAsync.java b/java/src/IceInternal/ConnectionBatchOutgoingAsync.java index dadea467fb3..47870ff2494 100644 --- a/java/src/IceInternal/ConnectionBatchOutgoingAsync.java +++ b/java/src/IceInternal/ConnectionBatchOutgoingAsync.java @@ -18,7 +18,7 @@ public class ConnectionBatchOutgoingAsync extends BatchOutgoingAsync _connection = con; } - public void __send() + public void __invoke() { int status = _connection.flushAsyncBatchRequests(this); if((status & AsyncStatus.Sent) > 0) @@ -26,7 +26,7 @@ public class ConnectionBatchOutgoingAsync extends BatchOutgoingAsync _sentSynchronously = true; if((status & AsyncStatus.InvokeSentCallback) > 0) { - __sent(); + __invokeSent(); } } } diff --git a/java/src/IceInternal/ConnectionMonitor.java b/java/src/IceInternal/ConnectionMonitor.java deleted file mode 100644 index 7941d3cb700..00000000000 --- a/java/src/IceInternal/ConnectionMonitor.java +++ /dev/null @@ -1,160 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package IceInternal; - -public final class ConnectionMonitor implements IceInternal.TimerTask -{ - // - // Renamed from destroy to _destroy to avoid a deprecation warning caused - // by the destroy method inherited from Thread. - // - synchronized public void - destroy() - { - assert(_instance != null); - _instance = null; - _connections = null; - } - - public void - checkIntervalForACM(int acmTimeout) - { - if(acmTimeout <= 0) - { - return; - } - - // - // If Ice.MonitorConnections isn't set (_interval == 0), the given ACM is used - // to determine the check interval: 1/10 of the ACM timeout with a minmal value - // of 5 seconds and a maximum value of 5 minutes. - // - // Note: if Ice.MonitorConnections is set, the timer is schedulded only if ACM - // is configured for the communicator or some object adapters. - // - int interval; - if(_interval == 0) - { - interval = java.lang.Math.min(300, java.lang.Math.max(5, (int)acmTimeout / 10)); - } - else if(_scheduledInterval == _interval) - { - return; // Nothing to do, the timer is already scheduled. - } - else - { - interval = _interval; - } - - // - // If no timer is scheduled yet or if the given ACM requires a smaller interval, - // we re-schedule the timer. - // - synchronized(this) - { - if(_scheduledInterval == 0 || _scheduledInterval > interval) - { - _scheduledInterval = interval; - _instance.timer().cancel(this); - _instance.timer().scheduleRepeated(this, interval * 1000); - } - } - } - - public synchronized void - add(Ice.ConnectionI connection) - { - assert(_instance != null); - _connections.add(connection); - } - - public synchronized void - remove(Ice.ConnectionI connection) - { - assert(_instance != null); - _connections.remove(connection); - } - - // - // Only for use by Instance. - // - ConnectionMonitor(Instance instance, int interval) - { - _instance = instance; - _interval = interval; - _scheduledInterval = 0; - } - - protected synchronized void - finalize() - throws Throwable - { - try - { - IceUtilInternal.Assert.FinalizerAssert(_instance == null); - IceUtilInternal.Assert.FinalizerAssert(_connections == null); - } - catch(java.lang.Exception ex) - { - } - finally - { - super.finalize(); - } - } - - public void - runTimerTask() - { - java.util.Set<Ice.ConnectionI> connections = new java.util.HashSet<Ice.ConnectionI>(); - - synchronized(this) - { - if(_instance == null) - { - return; - } - - connections.clear(); - connections.addAll(_connections); - } - - // - // Monitor connections outside the thread synchronization, - // so that connections can be added or removed during - // monitoring. - // - long now = IceInternal.Time.currentMonotonicTimeMillis(); - for(Ice.ConnectionI conn : connections) - { - try - { - conn.monitor(now); - } - catch(java.lang.Exception ex) - { - synchronized(this) - { - if(_instance == null) - { - return; - } - String s = "exception in connection monitor:\n" + Ex.toString(ex); - _instance.initializationData().logger.error(s); - } - } - } - } - - private Instance _instance; - private final int _interval; - private int _scheduledInterval; - private java.util.Set<Ice.ConnectionI> _connections = new java.util.HashSet<Ice.ConnectionI>(); -} diff --git a/java/src/IceInternal/ConnectionReaper.java b/java/src/IceInternal/ConnectionReaper.java deleted file mode 100644 index 54cac2d2b01..00000000000 --- a/java/src/IceInternal/ConnectionReaper.java +++ /dev/null @@ -1,37 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package IceInternal; - -public class ConnectionReaper -{ - synchronized public void - add(Ice.ConnectionI connection, Ice.Instrumentation.Observer observer) - { - _connections.add(connection); - if(observer != null) - { - observer.detach(); - } - } - - synchronized public java.util.List<Ice.ConnectionI> - swapConnections() - { - if(_connections.isEmpty()) - { - return null; - } - java.util.List<Ice.ConnectionI> connections = _connections; - _connections = new java.util.ArrayList<Ice.ConnectionI>(); - return connections; - } - - private java.util.List<Ice.ConnectionI> _connections = new java.util.ArrayList<Ice.ConnectionI>(); -}; diff --git a/java/src/IceInternal/ConnectionRequestHandler.java b/java/src/IceInternal/ConnectionRequestHandler.java index 79f7ab45440..07a8d9c43e0 100644 --- a/java/src/IceInternal/ConnectionRequestHandler.java +++ b/java/src/IceInternal/ConnectionRequestHandler.java @@ -32,37 +32,30 @@ public class ConnectionRequestHandler implements RequestHandler _connection.abortBatchRequest(); } - public Ice.ConnectionI - sendRequest(Outgoing out) + public boolean + sendRequest(OutgoingMessageCallback out) throws LocalExceptionWrapper { - if(!_connection.sendRequest(out, _compress, _response) || _response) - { - return _connection; // The request has been sent or we're expecting a response. - } - else - { - return null; // The request has been sent. - } + return out.send(_connection, _compress, _response) && !_response; // Finished if sent and no response } public int - sendAsyncRequest(OutgoingAsync out) + sendAsyncRequest(OutgoingAsyncMessageCallback out) throws LocalExceptionWrapper { - return _connection.sendAsyncRequest(out, _compress, _response); + return out.__send(_connection, _compress, _response); } - public boolean - flushBatchRequests(BatchOutgoing out) + public void + requestTimedOut(OutgoingMessageCallback out) { - return _connection.flushBatchRequests(out); + _connection.requestTimedOut(out); } - public int - flushAsyncBatchRequests(BatchOutgoingAsync out) + public void + asyncRequestTimedOut(OutgoingAsyncMessageCallback outAsync) { - return _connection.flushAsyncBatchRequests(out); + _connection.asyncRequestTimedOut(outAsync); } public Outgoing diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java index effc72f51f7..c1c233c71f0 100644 --- a/java/src/IceInternal/DefaultsAndOverrides.java +++ b/java/src/IceInternal/DefaultsAndOverrides.java @@ -113,6 +113,7 @@ public final class DefaultsAndOverrides } defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); + defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0; @@ -130,6 +131,7 @@ public final class DefaultsAndOverrides final public boolean defaultCollocationOptimization; final public Ice.EndpointSelectionType defaultEndpointSelection; final public int defaultLocatorCacheTimeout; + final public int defaultInvocationTimeout; final public boolean defaultPreferSecure; final public Ice.EncodingVersion defaultEncoding; final public Ice.FormatType defaultFormat; diff --git a/java/src/IceInternal/FactoryACMMonitor.java b/java/src/IceInternal/FactoryACMMonitor.java new file mode 100644 index 00000000000..a1071e8a4b6 --- /dev/null +++ b/java/src/IceInternal/FactoryACMMonitor.java @@ -0,0 +1,216 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package IceInternal; + +class FactoryACMMonitor implements ACMMonitor +{ + class Change + { + Change(Ice.ConnectionI connection, boolean remove) + { + this.connection = connection; + this.remove = remove; + } + + final Ice.ConnectionI connection; + final boolean remove; + }; + + FactoryACMMonitor(Instance instance, ACMConfig config) + { + _instance = instance; + _config = config; + } + + protected synchronized void + finalize() + throws Throwable + { + try + { + IceUtilInternal.Assert.FinalizerAssert(_instance == null); + IceUtilInternal.Assert.FinalizerAssert(_connections.isEmpty()); + IceUtilInternal.Assert.FinalizerAssert(_changes.isEmpty()); + IceUtilInternal.Assert.FinalizerAssert(_reapedConnections.isEmpty()); + } + catch(java.lang.Exception ex) + { + } + finally + { + super.finalize(); + } + } + + synchronized void + destroy() + { + if(_instance == null) + { + return; + } + _instance = null; + _connections.clear(); + _changes.clear(); + } + + public void + add(Ice.ConnectionI connection) + { + if(_config.timeout == 0) + { + return; + } + + synchronized(this) + { + if(_connections.isEmpty()) + { + _connections.add(connection); + _instance.timer().scheduleRepeated(this, _config.timeout / 2); + } + else + { + _changes.add(new Change(connection, false)); + } + } + } + + public void + remove(Ice.ConnectionI connection) + { + if(_config.timeout == 0) + { + return; + } + + synchronized(this) + { + assert(_instance != null); + _changes.add(new Change(connection, true)); + } + } + + public synchronized void + reap(Ice.ConnectionI connection) + { + _reapedConnections.add(connection); + } + + public synchronized ACMMonitor + acm(Ice.IntOptional timeout, Ice.Optional<Ice.ACMClose> close, Ice.Optional<Ice.ACMHeartbeat> heartbeat) + { + assert(_instance != null); + + ACMConfig config = (ACMConfig)_config.clone(); + if(timeout != null && timeout.isSet()) + { + config.timeout = timeout.get() * 1000; // To milliseconds + } + if(close != null && close.isSet()) + { + config.close = close.get(); + } + if(heartbeat != null && heartbeat.isSet()) + { + config.heartbeat = heartbeat.get(); + } + return new ConnectionACMMonitor(this, _instance.timer(), config); + } + + public Ice.ACM + getACM() + { + Ice.ACM acm = new Ice.ACM(); + acm.timeout = _config.timeout / 1000; + acm.close = _config.close; + acm.heartbeat = _config.heartbeat; + return acm; + } + + synchronized java.util.List<Ice.ConnectionI> + swapReapedConnections() + { + if(_reapedConnections.isEmpty()) + { + return null; + } + java.util.List<Ice.ConnectionI> connections = _reapedConnections; + _reapedConnections = new java.util.ArrayList<Ice.ConnectionI>(); + return connections; + } + + public void + runTimerTask() + { + synchronized(this) + { + if(_instance == null) + { + return; + } + + for(Change change : _changes) + { + if(change.remove) + { + _connections.remove(change.connection); + } + else + { + _connections.add(change.connection); + } + } + _changes.clear(); + + if(_connections.isEmpty()) + { + _instance.timer().cancel(this); + return; + } + } + + + // + // Monitor connections outside the thread synchronization, so + // that connections can be added or removed during monitoring. + // + long now = Time.currentMonotonicTimeMillis(); + for(Ice.ConnectionI connection : _connections) + { + try + { + connection.monitor(now, _config); + } + catch(Exception ex) + { + handleException(ex); + } + } + } + + synchronized void + handleException(Exception ex) + { + if(_instance == null) + { + return; + } + _instance.initializationData().logger.error("exception in connection monitor:\n" + ex); + } + + private Instance _instance; + final private ACMConfig _config; + + private java.util.Set<Ice.ConnectionI> _connections = new java.util.HashSet<Ice.ConnectionI>(); + private java.util.List<Change> _changes = new java.util.ArrayList<Change>(); + private java.util.List<Ice.ConnectionI> _reapedConnections = new java.util.ArrayList<Ice.ConnectionI>(); +}; + diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java index ff3f7e65839..1616b29c4d7 100644 --- a/java/src/IceInternal/FixedReference.java +++ b/java/src/IceInternal/FixedReference.java @@ -21,7 +21,7 @@ public class FixedReference extends Reference Ice.EncodingVersion encoding, Ice.ConnectionI connection) { - super(instance, communicator, identity, facet, mode, secure, Ice.Util.Protocol_1_0, encoding, null); + super(instance, communicator, identity, facet, mode, secure, Ice.Util.Protocol_1_0, encoding, -1, null); _fixedConnection = connection; } diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java index 476b71cdc7d..54a9076fde7 100644 --- a/java/src/IceInternal/IncomingConnectionFactory.java +++ b/java/src/IceInternal/IncomingConnectionFactory.java @@ -120,14 +120,22 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice synchronized(this) { - // Ensure all the connections are finished and reapable at this point. - java.util.List<Ice.ConnectionI> cons = _reaper.swapConnections(); - assert((cons == null ? 0 : cons.size()) == _connections.size()); - if(cons != null) + if(_transceiver != null) { - cons.clear(); + assert(_connections.size() <= 1); // The connection isn't monitored or reaped. + } + else + { + // Ensure all the connections are finished and reapable at this point. + java.util.List<Ice.ConnectionI> cons = _monitor.swapReapedConnections(); + assert((cons == null ? 0 : cons.size()) == _connections.size()); + if(cons != null) + { + cons.clear(); + } } _connections.clear(); + _monitor.destroy(); } } @@ -196,7 +204,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // // Reap closed connections. // - java.util.List<Ice.ConnectionI> cons = _reaper.swapConnections(); + java.util.List<Ice.ConnectionI> cons = _monitor.swapReapedConnections(); if(cons != null) { for(Ice.ConnectionI c : cons) @@ -246,7 +254,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice try { - connection = new Ice.ConnectionI(_adapter.getCommunicator(), _instance, _reaper, transceiver, null, + connection = new Ice.ConnectionI(_adapter.getCommunicator(), _instance, _monitor, transceiver, null, _endpoint, _adapter); } catch(Ice.LocalException ex) @@ -343,6 +351,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice _adapter = adapter; _warn = _instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Connections") > 0 ? true : false; _state = StateHolding; + _monitor = new FactoryACMMonitor(instance, ((Ice.ObjectAdapterI)adapter).getACM()); DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); if(defaultsAndOverrides.overrideTimeout) @@ -365,7 +374,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice { _endpoint = h.value; Ice.ConnectionI connection = - new Ice.ConnectionI(_adapter.getCommunicator(), _instance, _reaper, _transceiver, null, _endpoint, + new Ice.ConnectionI(_adapter.getCommunicator(), _instance, null, _transceiver, null, _endpoint, _adapter); connection.start(null); _connections.add(connection); @@ -410,6 +419,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice } _state = StateFinished; + _monitor.destroy(); _connections.clear(); if(ex instanceof Ice.LocalException) @@ -549,7 +559,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice } private final Instance _instance; - private final ConnectionReaper _reaper = new ConnectionReaper(); + private final FactoryACMMonitor _monitor; private Acceptor _acceptor; private Transceiver _transceiver; diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index 2a3ef6024b2..be091ba60e7 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -121,18 +121,6 @@ public final class Instance return _outgoingConnectionFactory; } - public synchronized ConnectionMonitor - connectionMonitor() - { - if(_state == StateDestroyed) - { - throw new Ice.CommunicatorDestroyedException(); - } - - assert(_connectionMonitor != null); - return _connectionMonitor; - } - public synchronized ObjectFactoryManager servantFactoryManager() { @@ -278,14 +266,14 @@ public final class Instance return _cacheMessageBuffers; } - public int + public ACMConfig clientACM() { // No mutex lock, immutable. return _clientACM; } - public int + public ACMConfig serverACM() { // No mutex lock, immutable. @@ -718,6 +706,18 @@ public final class Instance _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties); + _clientACM = new ACMConfig(_initData.properties, + _initData.logger, + "Ice.ACM.Client", + new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM", + new ACMConfig(false))); + + _serverACM = new ACMConfig(_initData.properties, + _initData.logger, + "Ice.ACM.Server", + new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM", + new ACMConfig(true))); + { final int defaultMessageSizeMax = 1024; int num = _initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax); @@ -737,12 +737,6 @@ public final class Instance _cacheMessageBuffers = _initData.properties.getPropertyAsIntWithDefault("Ice.CacheMessageBuffers", 2); - // - // Client ACM enabled by default. Server ACM disabled by default. - // - _clientACM = _initData.properties.getPropertyAsIntWithDefault("Ice.ACM.Client", 60); - _serverACM = _initData.properties.getPropertyAsInt("Ice.ACM.Server"); - _implicitContext = Ice.ImplicitContextI.create(_initData.properties.getProperty("Ice.ImplicitContext")); _routerManager = new RouterManager(); @@ -856,7 +850,6 @@ public final class Instance IceUtilInternal.Assert.FinalizerAssert(_referenceFactory == null); IceUtilInternal.Assert.FinalizerAssert(_proxyFactory == null); IceUtilInternal.Assert.FinalizerAssert(_outgoingConnectionFactory == null); - IceUtilInternal.Assert.FinalizerAssert(_connectionMonitor == null); IceUtilInternal.Assert.FinalizerAssert(_servantFactoryManager == null); IceUtilInternal.Assert.FinalizerAssert(_objectAdapterFactory == null); IceUtilInternal.Assert.FinalizerAssert(_clientThreadPool == null); @@ -945,16 +938,6 @@ public final class Instance } // - // Create the connection monitor and ensure the interval for - // monitoring connections is appropriate for client & server - // ACM. - // - int interval = _initData.properties.getPropertyAsInt("Ice.MonitorConnections"); - _connectionMonitor = new ConnectionMonitor(this, interval); - _connectionMonitor.checkIntervalForACM(_clientACM); - _connectionMonitor.checkIntervalForACM(_serverACM); - - // // Server thread pool initialization is lazy in serverThreadPool(). // @@ -1040,12 +1023,6 @@ public final class Instance _outgoingConnectionFactory = null; _retryQueue = null; - if(_connectionMonitor != null) - { - _connectionMonitor.destroy(); - _connectionMonitor = null; - } - if(_serverThreadPool != null) { _serverThreadPool.destroy(); @@ -1241,8 +1218,8 @@ public final class Instance private final DefaultsAndOverrides _defaultsAndOverrides; // Immutable, not reset by destroy(). private final int _messageSizeMax; // Immutable, not reset by destroy(). private final int _cacheMessageBuffers; // Immutable, not reset by destroy(). - private final int _clientACM; // Immutable, not reset by destroy(). - private final int _serverACM; // Immutable, not reset by destroy(). + private final ACMConfig _clientACM; // Immutable, not reset by destroy(). + private final ACMConfig _serverACM; // Immutable, not reset by destroy(). private final Ice.ImplicitContextI _implicitContext; private final Ice.Instrumentation.CommunicatorObserver _observer; private RouterManager _routerManager; @@ -1250,7 +1227,6 @@ public final class Instance private ReferenceFactory _referenceFactory; private ProxyFactory _proxyFactory; private OutgoingConnectionFactory _outgoingConnectionFactory; - private ConnectionMonitor _connectionMonitor; private ObjectFactoryManager _servantFactoryManager; private ObjectAdapterFactory _objectAdapterFactory; private int _protocolSupport; diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index e64c20ae54c..c00a99a2b2b 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -20,6 +20,8 @@ public final class Outgoing implements OutgoingMessageCallback throws LocalExceptionWrapper { _state = StateUnsent; + _exceptionWrapper = false; + _exceptionWrapperRetry = false; _sent = false; _handler = handler; _observer = observer; @@ -41,6 +43,8 @@ public final class Outgoing implements OutgoingMessageCallback { _state = StateUnsent; _exception = null; + _exceptionWrapper = false; + _exceptionWrapperRetry = false; _sent = false; _handler = handler; _observer = observer; @@ -70,77 +74,48 @@ public final class Outgoing implements OutgoingMessageCallback switch(_handler.getReference().getMode()) { + case Reference.ModeOneway: + case Reference.ModeDatagram: case Reference.ModeTwoway: { _state = StateInProgress; - Ice.ConnectionI connection = _handler.sendRequest(this); - assert(connection != null); + if(_handler.sendRequest(this)) // Request sent and no response expected, we're done. + { + return true; + } boolean timedOut = false; - synchronized(this) { - - // - // If the request is being sent in the background we first wait for the - // sent notification. - // - while(_state != StateFailed && !_sent) - { - try - { - wait(); - } - catch(java.lang.InterruptedException ex) - { - } - } - // - // Wait until the request has completed, or until the request - // times out. + // If the handler says it's not finished, we wait until we're done. // - int timeout = connection.timeout(); - while(_state == StateInProgress && !timedOut) + + int invocationTimeout = _handler.getReference().getInvocationTimeout(); + if(invocationTimeout > 0) { - try + long now = Time.currentMonotonicTimeMillis(); + long deadline = now + invocationTimeout; + while((_state == StateInProgress || !_sent) && _state != StateFailed && !timedOut) { - if(timeout >= 0) + try { - wait(timeout); - - if(_state == StateInProgress) - { - timedOut = true; - } + wait(deadline - now); } - else + catch(InterruptedException ex) { - wait(); } - } - catch(InterruptedException ex) - { + if((_state == StateInProgress || !_sent) && _state != StateFailed) + { + now = Time.currentMonotonicTimeMillis(); + timedOut = now >= deadline; + } } } - } - - if(timedOut) - { - // - // Must be called outside the synchronization of - // this object - // - connection.exception(new Ice.TimeoutException()); - - // - // We must wait until the exception set above has - // propagated to this Outgoing object. - // - synchronized(this) + else { - while(_state == StateInProgress) + while((_state == StateInProgress || !_sent) && _state != StateFailed) { try { @@ -153,9 +128,19 @@ public final class Outgoing implements OutgoingMessageCallback } } + if(timedOut) + { + _handler.requestTimedOut(this); + assert(_exception != null); + } + if(_exception != null) { _exception.fillInStackTrace(); + if(_exceptionWrapper) + { + throw new LocalExceptionWrapper(_exception, _exceptionWrapperRetry); + } // // A CloseConnectionException indicates graceful @@ -186,48 +171,8 @@ public final class Outgoing implements OutgoingMessageCallback throw new LocalExceptionWrapper(_exception, false); } - if(_state == StateUserException) - { - return false; - } - else - { - assert(_state == StateOK); - return true; - } - - } - - case Reference.ModeOneway: - case Reference.ModeDatagram: - { - _state = StateInProgress; - if(_handler.sendRequest(this) != null) - { - // - // If the handler returns the connection, we must wait for the sent callback. - // - synchronized(this) - { - while(_state != StateFailed && !_sent) - { - try - { - wait(); - } - catch(java.lang.InterruptedException ex) - { - } - } - - if(_exception != null) - { - assert(!_sent); - throw _exception; - } - } - } - return true; + assert(_state != StateInProgress); + return _state == StateOK; } case Reference.ModeBatchOneway: @@ -268,31 +213,27 @@ public final class Outgoing implements OutgoingMessageCallback throw ex; } - public void - sent(boolean async) + public boolean + send(Ice.ConnectionI connection, boolean compress, boolean response) + throws LocalExceptionWrapper + { + return connection.sendRequest(this, compress, response); + } + + synchronized public void + sent() { - if(async) + if(_handler.getReference().getMode() != Reference.ModeTwoway) { - synchronized(this) + if(_remoteObserver != null) { - _sent = true; - notify(); + _remoteObserver.detach(); + _remoteObserver = null; } + _state = StateOK; } - else - { - // - // No synchronization is necessary if called from sendRequest() because the connection - // send mutex is locked and no other threads can call on Outgoing until it's released. - // - _sent = true; - } - - if(_remoteObserver != null && _handler.getReference().getMode() != Reference.ModeTwoway) - { - _remoteObserver.detach(); - _remoteObserver = null; - } + _sent = true; + notify(); } public synchronized void @@ -459,6 +400,24 @@ public final class Outgoing implements OutgoingMessageCallback notify(); } + public synchronized void + finished(LocalExceptionWrapper ex) + { + if(_remoteObserver != null) + { + _remoteObserver.failed(ex.get().ice_name()); + _remoteObserver.detach(); + _remoteObserver = null; + } + + _state = StateFailed; + _exceptionWrapper = true; + _exceptionWrapperRetry = ex.retry(); + _exception = ex.get(); + _sent = false; + notify(); + } + public BasicStream os() { @@ -639,7 +598,9 @@ public final class Outgoing implements OutgoingMessageCallback private boolean _sent; private Ice.LocalException _exception; - + private boolean _exceptionWrapper; + private boolean _exceptionWrapperRetry; + private static final int StateUnsent = 0; private static final int StateInProgress = 1; private static final int StateOK = 2; diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index fe275569f3d..699477d4607 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -9,7 +9,7 @@ package IceInternal; -public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessageCallback +public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessageCallback, TimerTask { public OutgoingAsync(Ice.ObjectPrx prx, String operation, CallbackBase cb) { @@ -93,57 +93,57 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } } - @Override - public Ice.ObjectPrx getProxy() + @Override public Ice.ObjectPrx + getProxy() { return _proxy; } - public boolean __sent(final Ice.ConnectionI connection) + public int + __send(Ice.ConnectionI connection, boolean compress, boolean response) + throws LocalExceptionWrapper + { + return connection.sendAsyncRequest(this, compress, response); + } + + public boolean + __sent() { synchronized(_monitor) { boolean alreadySent = (_state & Sent) != 0; _state |= Sent; + + assert((_state & Done) == 0); - if((_state & Done) == 0) + if(!_proxy.ice_isTwoway()) { - if(!_proxy.ice_isTwoway()) + if(_remoteObserver != null) { - if(_remoteObserver != null) - { - _remoteObserver.detach(); - _remoteObserver = null; - } - _state |= Done | OK; - _os.resize(0, false); // Clear buffer now, instead of waiting for AsyncResult deallocation + _remoteObserver.detach(); + _remoteObserver = null; } - else if(connection.timeout() > 0) + if(_timeoutRequestHandler != null) { - assert(_timerTaskConnection == null && _timerTask == null); - _timerTaskConnection = connection; - _timerTask = new TimerTask() - { - public void - runTimerTask() - { - __runTimerTask(); - } - }; - _instance.timer().schedule(_timerTask, connection.timeout()); + _instance.timer().cancel(this); + _timeoutRequestHandler = null; } + _state |= Done | OK; + _os.resize(0, false); // Clear buffer now, instead of waiting for AsyncResult deallocation } _monitor.notifyAll(); return !alreadySent; // Don't call the sent call is already sent. } } - public void __sent() + public void + __invokeSent() { - __sentInternal(); + __invokeSentInternal(); } - public void __finished(Ice.LocalException exc, boolean sent) + public void + __finished(Ice.LocalException exc, boolean sent) { synchronized(_monitor) { @@ -154,11 +154,10 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa _remoteObserver.detach(); _remoteObserver = null; } - if(_timerTaskConnection != null) + if(_timeoutRequestHandler != null) { - _instance.timer().cancel(_timerTask); - _timerTaskConnection = null; - _timerTask = null; + _instance.timer().cancel(this); + _timeoutRequestHandler = null; } } @@ -176,16 +175,17 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } else { - __send(false); + __invoke(false); } } catch(Ice.LocalException ex) { - __exception(ex); + __invokeException(ex); } } - public final void __finished(LocalExceptionWrapper exc) + public final void + __finished(LocalExceptionWrapper exc) { // // NOTE: at this point, synchronization isn't needed, no other threads should be @@ -199,7 +199,9 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa _remoteObserver.detach(); _remoteObserver = null; } - + + assert(_timeoutRequestHandler == null); + try { int interval = handleException(exc); // This will throw if the invocation can't be retried. @@ -209,16 +211,17 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } else { - __send(false); + __invoke(false); } } catch(Ice.LocalException ex) { - __exception(ex); + __invokeException(ex); } } - public final void __finished(BasicStream is) + public final void + __finished(BasicStream is) { assert(_proxy.ice_isTwoway()); // Can only be called for twoways. @@ -235,11 +238,10 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa _remoteObserver = null; } - if(_timerTaskConnection != null) + if(_timeoutRequestHandler != null) { - _instance.timer().cancel(_timerTask); - _timerTaskConnection = null; - _timerTask = null; + _instance.timer().cancel(this); + _timeoutRequestHandler = null; } if(_is == null) // _is can already be initialized if the invocation is retried @@ -386,10 +388,11 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } assert(replyStatus == ReplyStatus.replyOK || replyStatus == ReplyStatus.replyUserException); - __response(); + __invokeCompleted(); } - public final boolean __send(boolean synchronous) + public final boolean + __invoke(boolean synchronous) { while(true) { @@ -397,7 +400,8 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa try { _delegate = _proxy.__getDelegate(true); - int status = _delegate.__getRequestHandler().sendAsyncRequest(this); + RequestHandler handler = _delegate.__getRequestHandler(); + int status = handler.sendAsyncRequest(this); if((status & AsyncStatus.Sent) > 0) { if(synchronous) @@ -405,14 +409,30 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa _sentSynchronously = true; if((status & AsyncStatus.InvokeSentCallback) > 0) { - __sent(); // Call from the user thread. + __invokeSent(); // Call from the user thread. } } else { if((status & AsyncStatus.InvokeSentCallback) > 0) { - __sentAsync(); // Call from a client thread pool thread. + __invokeSentAsync(); // Call from a client thread pool thread. + } + } + } + + if(_proxy.ice_isTwoway() || (status & AsyncStatus.Sent) == 0) + { + synchronized(_monitor) + { + if((_state & Done) == 0) + { + int invocationTimeout = handler.getReference().getInvocationTimeout(); + if(invocationTimeout > 0) + { + _instance.timer().schedule(this, invocationTimeout); + _timeoutRequestHandler = handler; + } } } } @@ -468,7 +488,14 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa } } - private int handleException(Ice.LocalException exc, boolean sent) + public void + runTimerTask() + { + __runTimerTask(); + } + + private int + handleException(Ice.LocalException exc, boolean sent) { Ice.IntHolder interval = new Ice.IntHolder(0); try @@ -515,7 +542,8 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa return interval.value; } - private int handleException(LocalExceptionWrapper ex) + private int + handleException(LocalExceptionWrapper ex) { Ice.IntHolder interval = new Ice.IntHolder(0); if(_mode == Ice.OperationMode.Nonmutating || _mode == Ice.OperationMode.Idempotent) @@ -529,27 +557,8 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa return interval.value; } - private final void __runTimerTask() - { - Ice.ConnectionI connection; - synchronized(_monitor) - { - connection = _timerTaskConnection; - _timerTaskConnection = null; - _timerTask = null; - } - - if(connection != null) - { - connection.exception(new Ice.TimeoutException()); - } - } - protected Ice.ObjectPrxHelperBase _proxy; - private Ice.ConnectionI _timerTaskConnection; - private TimerTask _timerTask; - private Ice._ObjectDel _delegate; private Ice.EncodingVersion _encoding; private int _cnt; diff --git a/java/src/IceInternal/OutgoingAsyncMessageCallback.java b/java/src/IceInternal/OutgoingAsyncMessageCallback.java index 5719005d399..bd710644a9e 100644 --- a/java/src/IceInternal/OutgoingAsyncMessageCallback.java +++ b/java/src/IceInternal/OutgoingAsyncMessageCallback.java @@ -16,18 +16,24 @@ package IceInternal; public interface OutgoingAsyncMessageCallback { // + // Called by the request handler to send the request over the connection. + // + int __send(Ice.ConnectionI conection, boolean compress, boolean response) + throws LocalExceptionWrapper; + + // // Called by the connection when the message is confirmed sent. The connection is locked // when this is called so this method can call the sent callback. Instead, this method // returns true if there's a sent callback and false otherwise. If true is returned, the - // connection will call the __sent() method bellow (which in turn should call the sent - // callback). + // connection will call the __invokeSent() method bellow (which in turn should call the + // sent callback). // - public abstract boolean __sent(Ice.ConnectionI connection); + public abstract boolean __sent(); // // Called by the connection to call the user sent callback. // - public abstract void __sent(); + public abstract void __invokeSent(); // // Called by the connection when the request failed. The boolean indicates whether or diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java index 94dd331a3f9..f4822753730 100644 --- a/java/src/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/IceInternal/OutgoingConnectionFactory.java @@ -125,7 +125,7 @@ public final class OutgoingConnectionFactory synchronized(this) { // Ensure all the connections are finished and reapable at this point. - java.util.List<Ice.ConnectionI> cons = _reaper.swapConnections(); + java.util.List<Ice.ConnectionI> cons = _monitor.swapReapedConnections(); if(cons != null) { int size = 0; @@ -142,6 +142,7 @@ public final class OutgoingConnectionFactory assert(_connections.isEmpty()); assert(_connectionsByEndpoint.isEmpty()); } + _monitor.destroy(); } } @@ -449,6 +450,7 @@ public final class OutgoingConnectionFactory { _communicator = communicator; _instance = instance; + _monitor = new FactoryACMMonitor(instance, instance.clientACM()); _destroyed = false; } @@ -617,7 +619,7 @@ public final class OutgoingConnectionFactory // // Reap closed connections // - java.util.List<Ice.ConnectionI> cons = _reaper.swapConnections(); + java.util.List<Ice.ConnectionI> cons = _monitor.swapReapedConnections(); if(cons != null) { for(Ice.ConnectionI c : cons) @@ -716,7 +718,7 @@ public final class OutgoingConnectionFactory throw new Ice.CommunicatorDestroyedException(); } - connection = new Ice.ConnectionI(_communicator, _instance, _reaper, transceiver, ci.connector, + connection = new Ice.ConnectionI(_communicator, _instance, _monitor, transceiver, ci.connector, ci.endpoint.compress(false), null); } catch(Ice.LocalException ex) @@ -1247,7 +1249,7 @@ public final class OutgoingConnectionFactory private Ice.Communicator _communicator; private final Instance _instance; - private final ConnectionReaper _reaper = new ConnectionReaper(); + private final FactoryACMMonitor _monitor; private boolean _destroyed; private MultiHashMap<Connector, Ice.ConnectionI> _connections = new MultiHashMap<Connector, Ice.ConnectionI>(); diff --git a/java/src/IceInternal/OutgoingMessageCallback.java b/java/src/IceInternal/OutgoingMessageCallback.java index 4bf4722396c..af53575d3a9 100644 --- a/java/src/IceInternal/OutgoingMessageCallback.java +++ b/java/src/IceInternal/OutgoingMessageCallback.java @@ -11,6 +11,9 @@ package IceInternal; public interface OutgoingMessageCallback { - void sent(boolean notify); + boolean send(Ice.ConnectionI conection, boolean compress, boolean response) + throws LocalExceptionWrapper; + + void sent(); void finished(Ice.LocalException ex, boolean sent); } diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index 5e48464bced..abce6b0b625 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -6,9 +6,7 @@ // ICE_LICENSE file included in this distribution. // // ********************************************************************** - -///* jshint -W044*/ -// Generated by makeprops.py from file ../config/PropertyNames.xml, Mon Apr 28 19:03:05 2014 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Mon May 12 17:32:39 2014 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -18,8 +16,23 @@ public final class PropertyNames { public static final Property IceProps[] = { + new Property("Ice\\.ACM\\.Client", true, null), + new Property("Ice\\.ACM\\.Server", true, null), + new Property("Ice\\.ACM\\.Timeout", false, null), + new Property("Ice\\.ACM\\.Heartbeat", false, null), + new Property("Ice\\.ACM\\.Close", false, null), + new Property("Ice\\.ACM", false, null), + new Property("Ice\\.ACM\\.Client\\.Timeout", false, null), + new Property("Ice\\.ACM\\.Client\\.Heartbeat", false, null), + new Property("Ice\\.ACM\\.Client\\.Close", false, null), new Property("Ice\\.ACM\\.Client", false, null), + new Property("Ice\\.ACM\\.Server\\.Timeout", false, null), + new Property("Ice\\.ACM\\.Server\\.Heartbeat", false, null), + new Property("Ice\\.ACM\\.Server\\.Close", false, null), new Property("Ice\\.ACM\\.Server", false, null), + new Property("Ice\\.Admin\\.ACM\\.Timeout", false, null), + new Property("Ice\\.Admin\\.ACM\\.Heartbeat", false, null), + new Property("Ice\\.Admin\\.ACM\\.Close", false, null), new Property("Ice\\.Admin\\.ACM", false, null), new Property("Ice\\.Admin\\.AdapterId", false, null), new Property("Ice\\.Admin\\.Endpoints", false, null), @@ -27,6 +40,7 @@ public final class PropertyNames new Property("Ice\\.Admin\\.Locator\\.ConnectionCached", false, null), new Property("Ice\\.Admin\\.Locator\\.PreferSecure", false, null), new Property("Ice\\.Admin\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("Ice\\.Admin\\.Locator\\.InvocationTimeout", false, null), new Property("Ice\\.Admin\\.Locator\\.Locator", false, null), new Property("Ice\\.Admin\\.Locator\\.Router", false, null), new Property("Ice\\.Admin\\.Locator\\.CollocationOptimized", false, null), @@ -38,6 +52,7 @@ public final class PropertyNames new Property("Ice\\.Admin\\.Router\\.ConnectionCached", false, null), new Property("Ice\\.Admin\\.Router\\.PreferSecure", false, null), new Property("Ice\\.Admin\\.Router\\.LocatorCacheTimeout", false, null), + new Property("Ice\\.Admin\\.Router\\.InvocationTimeout", false, null), new Property("Ice\\.Admin\\.Router\\.Locator", false, null), new Property("Ice\\.Admin\\.Router\\.Router", false, null), new Property("Ice\\.Admin\\.Router\\.CollocationOptimized", false, null), @@ -70,12 +85,14 @@ public final class PropertyNames new Property("Ice\\.Default\\.Locator\\.ConnectionCached", false, null), new Property("Ice\\.Default\\.Locator\\.PreferSecure", false, null), new Property("Ice\\.Default\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("Ice\\.Default\\.Locator\\.InvocationTimeout", false, null), new Property("Ice\\.Default\\.Locator\\.Locator", false, null), new Property("Ice\\.Default\\.Locator\\.Router", false, null), new Property("Ice\\.Default\\.Locator\\.CollocationOptimized", false, null), new Property("Ice\\.Default\\.Locator\\.Context\\.[^\\s]+", false, null), new Property("Ice\\.Default\\.Locator", false, null), new Property("Ice\\.Default\\.LocatorCacheTimeout", false, null), + new Property("Ice\\.Default\\.InvocationTimeout", false, null), new Property("Ice\\.Default\\.Package", false, null), new Property("Ice\\.Default\\.PreferSecure", false, null), new Property("Ice\\.Default\\.Protocol", false, null), @@ -83,6 +100,7 @@ public final class PropertyNames new Property("Ice\\.Default\\.Router\\.ConnectionCached", false, null), new Property("Ice\\.Default\\.Router\\.PreferSecure", false, null), new Property("Ice\\.Default\\.Router\\.LocatorCacheTimeout", false, null), + new Property("Ice\\.Default\\.Router\\.InvocationTimeout", false, null), new Property("Ice\\.Default\\.Router\\.Locator", false, null), new Property("Ice\\.Default\\.Router\\.Router", false, null), new Property("Ice\\.Default\\.Router\\.CollocationOptimized", false, null), @@ -176,6 +194,9 @@ public final class PropertyNames public static final Property IceDiscoveryProps[] = { + new Property("IceDiscovery\\.Multicast\\.ACM\\.Timeout", false, null), + new Property("IceDiscovery\\.Multicast\\.ACM\\.Heartbeat", false, null), + new Property("IceDiscovery\\.Multicast\\.ACM\\.Close", false, null), new Property("IceDiscovery\\.Multicast\\.ACM", false, null), new Property("IceDiscovery\\.Multicast\\.AdapterId", false, null), new Property("IceDiscovery\\.Multicast\\.Endpoints", false, null), @@ -183,6 +204,7 @@ public final class PropertyNames new Property("IceDiscovery\\.Multicast\\.Locator\\.ConnectionCached", false, null), new Property("IceDiscovery\\.Multicast\\.Locator\\.PreferSecure", false, null), new Property("IceDiscovery\\.Multicast\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceDiscovery\\.Multicast\\.Locator\\.InvocationTimeout", false, null), new Property("IceDiscovery\\.Multicast\\.Locator\\.Locator", false, null), new Property("IceDiscovery\\.Multicast\\.Locator\\.Router", false, null), new Property("IceDiscovery\\.Multicast\\.Locator\\.CollocationOptimized", false, null), @@ -194,6 +216,7 @@ public final class PropertyNames new Property("IceDiscovery\\.Multicast\\.Router\\.ConnectionCached", false, null), new Property("IceDiscovery\\.Multicast\\.Router\\.PreferSecure", false, null), new Property("IceDiscovery\\.Multicast\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceDiscovery\\.Multicast\\.Router\\.InvocationTimeout", false, null), new Property("IceDiscovery\\.Multicast\\.Router\\.Locator", false, null), new Property("IceDiscovery\\.Multicast\\.Router\\.Router", false, null), new Property("IceDiscovery\\.Multicast\\.Router\\.CollocationOptimized", false, null), @@ -207,6 +230,9 @@ public final class PropertyNames new Property("IceDiscovery\\.Multicast\\.ThreadPool\\.Serialize", false, null), new Property("IceDiscovery\\.Multicast\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("IceDiscovery\\.Multicast\\.ThreadPool\\.ThreadPriority", false, null), + new Property("IceDiscovery\\.Reply\\.ACM\\.Timeout", false, null), + new Property("IceDiscovery\\.Reply\\.ACM\\.Heartbeat", false, null), + new Property("IceDiscovery\\.Reply\\.ACM\\.Close", false, null), new Property("IceDiscovery\\.Reply\\.ACM", false, null), new Property("IceDiscovery\\.Reply\\.AdapterId", false, null), new Property("IceDiscovery\\.Reply\\.Endpoints", false, null), @@ -214,6 +240,7 @@ public final class PropertyNames new Property("IceDiscovery\\.Reply\\.Locator\\.ConnectionCached", false, null), new Property("IceDiscovery\\.Reply\\.Locator\\.PreferSecure", false, null), new Property("IceDiscovery\\.Reply\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceDiscovery\\.Reply\\.Locator\\.InvocationTimeout", false, null), new Property("IceDiscovery\\.Reply\\.Locator\\.Locator", false, null), new Property("IceDiscovery\\.Reply\\.Locator\\.Router", false, null), new Property("IceDiscovery\\.Reply\\.Locator\\.CollocationOptimized", false, null), @@ -225,6 +252,7 @@ public final class PropertyNames new Property("IceDiscovery\\.Reply\\.Router\\.ConnectionCached", false, null), new Property("IceDiscovery\\.Reply\\.Router\\.PreferSecure", false, null), new Property("IceDiscovery\\.Reply\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceDiscovery\\.Reply\\.Router\\.InvocationTimeout", false, null), new Property("IceDiscovery\\.Reply\\.Router\\.Locator", false, null), new Property("IceDiscovery\\.Reply\\.Router\\.Router", false, null), new Property("IceDiscovery\\.Reply\\.Router\\.CollocationOptimized", false, null), @@ -238,6 +266,9 @@ public final class PropertyNames new Property("IceDiscovery\\.Reply\\.ThreadPool\\.Serialize", false, null), new Property("IceDiscovery\\.Reply\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("IceDiscovery\\.Reply\\.ThreadPool\\.ThreadPriority", false, null), + new Property("IceDiscovery\\.Locator\\.ACM\\.Timeout", false, null), + new Property("IceDiscovery\\.Locator\\.ACM\\.Heartbeat", false, null), + new Property("IceDiscovery\\.Locator\\.ACM\\.Close", false, null), new Property("IceDiscovery\\.Locator\\.ACM", false, null), new Property("IceDiscovery\\.Locator\\.AdapterId", false, null), new Property("IceDiscovery\\.Locator\\.Endpoints", false, null), @@ -245,6 +276,7 @@ public final class PropertyNames new Property("IceDiscovery\\.Locator\\.Locator\\.ConnectionCached", false, null), new Property("IceDiscovery\\.Locator\\.Locator\\.PreferSecure", false, null), new Property("IceDiscovery\\.Locator\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceDiscovery\\.Locator\\.Locator\\.InvocationTimeout", false, null), new Property("IceDiscovery\\.Locator\\.Locator\\.Locator", false, null), new Property("IceDiscovery\\.Locator\\.Locator\\.Router", false, null), new Property("IceDiscovery\\.Locator\\.Locator\\.CollocationOptimized", false, null), @@ -256,6 +288,7 @@ public final class PropertyNames new Property("IceDiscovery\\.Locator\\.Router\\.ConnectionCached", false, null), new Property("IceDiscovery\\.Locator\\.Router\\.PreferSecure", false, null), new Property("IceDiscovery\\.Locator\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceDiscovery\\.Locator\\.Router\\.InvocationTimeout", false, null), new Property("IceDiscovery\\.Locator\\.Router\\.Locator", false, null), new Property("IceDiscovery\\.Locator\\.Router\\.Router", false, null), new Property("IceDiscovery\\.Locator\\.Router\\.CollocationOptimized", false, null), @@ -287,6 +320,9 @@ public final class PropertyNames new Property("IceBox\\.LoadOrder", false, null), new Property("IceBox\\.PrintServicesReady", false, null), new Property("IceBox\\.Service\\.[^\\s]+", false, null), + new Property("IceBox\\.ServiceManager\\.ACM\\.Timeout", false, null), + new Property("IceBox\\.ServiceManager\\.ACM\\.Heartbeat", false, null), + new Property("IceBox\\.ServiceManager\\.ACM\\.Close", false, null), new Property("IceBox\\.ServiceManager\\.ACM", false, null), new Property("IceBox\\.ServiceManager\\.AdapterId", false, null), new Property("IceBox\\.ServiceManager\\.Endpoints", false, null), @@ -294,6 +330,7 @@ public final class PropertyNames new Property("IceBox\\.ServiceManager\\.Locator\\.ConnectionCached", false, null), new Property("IceBox\\.ServiceManager\\.Locator\\.PreferSecure", false, null), new Property("IceBox\\.ServiceManager\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceBox\\.ServiceManager\\.Locator\\.InvocationTimeout", false, null), new Property("IceBox\\.ServiceManager\\.Locator\\.Locator", false, null), new Property("IceBox\\.ServiceManager\\.Locator\\.Router", false, null), new Property("IceBox\\.ServiceManager\\.Locator\\.CollocationOptimized", false, null), @@ -305,6 +342,7 @@ public final class PropertyNames new Property("IceBox\\.ServiceManager\\.Router\\.ConnectionCached", false, null), new Property("IceBox\\.ServiceManager\\.Router\\.PreferSecure", false, null), new Property("IceBox\\.ServiceManager\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceBox\\.ServiceManager\\.Router\\.InvocationTimeout", false, null), new Property("IceBox\\.ServiceManager\\.Router\\.Locator", false, null), new Property("IceBox\\.ServiceManager\\.Router\\.Router", false, null), new Property("IceBox\\.ServiceManager\\.Router\\.CollocationOptimized", false, null), @@ -329,6 +367,7 @@ public final class PropertyNames new Property("IceBoxAdmin\\.ServiceManager\\.Proxy\\.ConnectionCached", false, null), new Property("IceBoxAdmin\\.ServiceManager\\.Proxy\\.PreferSecure", false, null), new Property("IceBoxAdmin\\.ServiceManager\\.Proxy\\.LocatorCacheTimeout", false, null), + new Property("IceBoxAdmin\\.ServiceManager\\.Proxy\\.InvocationTimeout", false, null), new Property("IceBoxAdmin\\.ServiceManager\\.Proxy\\.Locator", false, null), new Property("IceBoxAdmin\\.ServiceManager\\.Proxy\\.Router", false, null), new Property("IceBoxAdmin\\.ServiceManager\\.Proxy\\.CollocationOptimized", false, null), @@ -351,6 +390,9 @@ public final class PropertyNames public static final Property IceGridProps[] = { + new Property("IceGrid\\.AdminRouter\\.ACM\\.Timeout", false, null), + new Property("IceGrid\\.AdminRouter\\.ACM\\.Heartbeat", false, null), + new Property("IceGrid\\.AdminRouter\\.ACM\\.Close", false, null), new Property("IceGrid\\.AdminRouter\\.ACM", false, null), new Property("IceGrid\\.AdminRouter\\.AdapterId", false, null), new Property("IceGrid\\.AdminRouter\\.Endpoints", false, null), @@ -358,6 +400,7 @@ public final class PropertyNames new Property("IceGrid\\.AdminRouter\\.Locator\\.ConnectionCached", false, null), new Property("IceGrid\\.AdminRouter\\.Locator\\.PreferSecure", false, null), new Property("IceGrid\\.AdminRouter\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.AdminRouter\\.Locator\\.InvocationTimeout", false, null), new Property("IceGrid\\.AdminRouter\\.Locator\\.Locator", false, null), new Property("IceGrid\\.AdminRouter\\.Locator\\.Router", false, null), new Property("IceGrid\\.AdminRouter\\.Locator\\.CollocationOptimized", false, null), @@ -369,6 +412,7 @@ public final class PropertyNames new Property("IceGrid\\.AdminRouter\\.Router\\.ConnectionCached", false, null), new Property("IceGrid\\.AdminRouter\\.Router\\.PreferSecure", false, null), new Property("IceGrid\\.AdminRouter\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.AdminRouter\\.Router\\.InvocationTimeout", false, null), new Property("IceGrid\\.AdminRouter\\.Router\\.Locator", false, null), new Property("IceGrid\\.AdminRouter\\.Router\\.Router", false, null), new Property("IceGrid\\.AdminRouter\\.Router\\.CollocationOptimized", false, null), @@ -383,6 +427,9 @@ public final class PropertyNames new Property("IceGrid\\.AdminRouter\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("IceGrid\\.AdminRouter\\.ThreadPool\\.ThreadPriority", false, null), new Property("IceGrid\\.InstanceName", false, null), + new Property("IceGrid\\.Node\\.ACM\\.Timeout", false, null), + new Property("IceGrid\\.Node\\.ACM\\.Heartbeat", false, null), + new Property("IceGrid\\.Node\\.ACM\\.Close", false, null), new Property("IceGrid\\.Node\\.ACM", false, null), new Property("IceGrid\\.Node\\.AdapterId", false, null), new Property("IceGrid\\.Node\\.Endpoints", false, null), @@ -390,6 +437,7 @@ public final class PropertyNames new Property("IceGrid\\.Node\\.Locator\\.ConnectionCached", false, null), new Property("IceGrid\\.Node\\.Locator\\.PreferSecure", false, null), new Property("IceGrid\\.Node\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Node\\.Locator\\.InvocationTimeout", false, null), new Property("IceGrid\\.Node\\.Locator\\.Locator", false, null), new Property("IceGrid\\.Node\\.Locator\\.Router", false, null), new Property("IceGrid\\.Node\\.Locator\\.CollocationOptimized", false, null), @@ -401,6 +449,7 @@ public final class PropertyNames new Property("IceGrid\\.Node\\.Router\\.ConnectionCached", false, null), new Property("IceGrid\\.Node\\.Router\\.PreferSecure", false, null), new Property("IceGrid\\.Node\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Node\\.Router\\.InvocationTimeout", false, null), new Property("IceGrid\\.Node\\.Router\\.Locator", false, null), new Property("IceGrid\\.Node\\.Router\\.Router", false, null), new Property("IceGrid\\.Node\\.Router\\.CollocationOptimized", false, null), @@ -435,6 +484,7 @@ public final class PropertyNames new Property("IceGrid\\.Node\\.UserAccountMapper\\.ConnectionCached", false, null), new Property("IceGrid\\.Node\\.UserAccountMapper\\.PreferSecure", false, null), new Property("IceGrid\\.Node\\.UserAccountMapper\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Node\\.UserAccountMapper\\.InvocationTimeout", false, null), new Property("IceGrid\\.Node\\.UserAccountMapper\\.Locator", false, null), new Property("IceGrid\\.Node\\.UserAccountMapper\\.Router", false, null), new Property("IceGrid\\.Node\\.UserAccountMapper\\.CollocationOptimized", false, null), @@ -446,12 +496,16 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.Locator", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.Router", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.CollocationOptimized", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier\\.Context\\.[^\\s]+", false, null), new Property("IceGrid\\.Registry\\.AdminPermissionsVerifier", false, null), new Property("IceGrid\\.Registry\\.AdminSessionFilters", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ACM\\.Timeout", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ACM\\.Heartbeat", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ACM\\.Close", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.ACM", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Endpoints", false, null), @@ -459,6 +513,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator\\.Locator", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator\\.Router", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Locator\\.CollocationOptimized", false, null), @@ -470,6 +525,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router\\.Locator", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router\\.Router", false, null), new Property("IceGrid\\.Registry\\.AdminSessionManager\\.Router\\.CollocationOptimized", false, null), @@ -487,11 +543,15 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.Locator", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.Router", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.CollocationOptimized", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier\\.Context\\.[^\\s]+", false, null), new Property("IceGrid\\.Registry\\.AdminSSLPermissionsVerifier", false, null), + new Property("IceGrid\\.Registry\\.Client\\.ACM\\.Timeout", false, null), + new Property("IceGrid\\.Registry\\.Client\\.ACM\\.Heartbeat", false, null), + new Property("IceGrid\\.Registry\\.Client\\.ACM\\.Close", false, null), new Property("IceGrid\\.Registry\\.Client\\.ACM", false, null), new Property("IceGrid\\.Registry\\.Client\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Client\\.Endpoints", false, null), @@ -499,6 +559,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Client\\.Locator\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.Client\\.Locator\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.Client\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.Client\\.Locator\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.Client\\.Locator\\.Locator", false, null), new Property("IceGrid\\.Registry\\.Client\\.Locator\\.Router", false, null), new Property("IceGrid\\.Registry\\.Client\\.Locator\\.CollocationOptimized", false, null), @@ -510,6 +571,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Client\\.Router\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.Client\\.Router\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.Client\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.Client\\.Router\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.Client\\.Router\\.Locator", false, null), new Property("IceGrid\\.Registry\\.Client\\.Router\\.Router", false, null), new Property("IceGrid\\.Registry\\.Client\\.Router\\.CollocationOptimized", false, null), @@ -527,6 +589,9 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Data", false, null), new Property("IceGrid\\.Registry\\.DefaultTemplates", false, null), new Property("IceGrid\\.Registry\\.DynamicRegistration", false, null), + new Property("IceGrid\\.Registry\\.Internal\\.ACM\\.Timeout", false, null), + new Property("IceGrid\\.Registry\\.Internal\\.ACM\\.Heartbeat", false, null), + new Property("IceGrid\\.Registry\\.Internal\\.ACM\\.Close", false, null), new Property("IceGrid\\.Registry\\.Internal\\.ACM", false, null), new Property("IceGrid\\.Registry\\.Internal\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Endpoints", false, null), @@ -534,6 +599,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Internal\\.Locator\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Locator\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.Internal\\.Locator\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Locator\\.Locator", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Locator\\.Router", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Locator\\.CollocationOptimized", false, null), @@ -545,6 +611,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Internal\\.Router\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Router\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.Internal\\.Router\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Router\\.Locator", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Router\\.Router", false, null), new Property("IceGrid\\.Registry\\.Internal\\.Router\\.CollocationOptimized", false, null), @@ -563,6 +630,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.Locator", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.Router", false, null), new Property("IceGrid\\.Registry\\.PermissionsVerifier\\.CollocationOptimized", false, null), @@ -572,6 +640,9 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.ReplicaSessionTimeout", false, null), new Property("IceGrid\\.Registry\\.RequireNodeCertCN", false, null), new Property("IceGrid\\.Registry\\.RequireReplicaCertCN", false, null), + new Property("IceGrid\\.Registry\\.Server\\.ACM\\.Timeout", false, null), + new Property("IceGrid\\.Registry\\.Server\\.ACM\\.Heartbeat", false, null), + new Property("IceGrid\\.Registry\\.Server\\.ACM\\.Close", false, null), new Property("IceGrid\\.Registry\\.Server\\.ACM", false, null), new Property("IceGrid\\.Registry\\.Server\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.Server\\.Endpoints", false, null), @@ -579,6 +650,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Server\\.Locator\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.Server\\.Locator\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.Server\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.Server\\.Locator\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.Server\\.Locator\\.Locator", false, null), new Property("IceGrid\\.Registry\\.Server\\.Locator\\.Router", false, null), new Property("IceGrid\\.Registry\\.Server\\.Locator\\.CollocationOptimized", false, null), @@ -590,6 +662,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Server\\.Router\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.Server\\.Router\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.Server\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.Server\\.Router\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.Server\\.Router\\.Locator", false, null), new Property("IceGrid\\.Registry\\.Server\\.Router\\.Router", false, null), new Property("IceGrid\\.Registry\\.Server\\.Router\\.CollocationOptimized", false, null), @@ -604,6 +677,9 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.Server\\.ThreadPool\\.ThreadIdleTime", false, null), new Property("IceGrid\\.Registry\\.Server\\.ThreadPool\\.ThreadPriority", false, null), new Property("IceGrid\\.Registry\\.SessionFilters", false, null), + new Property("IceGrid\\.Registry\\.SessionManager\\.ACM\\.Timeout", false, null), + new Property("IceGrid\\.Registry\\.SessionManager\\.ACM\\.Heartbeat", false, null), + new Property("IceGrid\\.Registry\\.SessionManager\\.ACM\\.Close", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.ACM", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.AdapterId", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Endpoints", false, null), @@ -611,6 +687,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.SessionManager\\.Locator\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Locator\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.SessionManager\\.Locator\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Locator\\.Locator", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Locator\\.Router", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Locator\\.CollocationOptimized", false, null), @@ -622,6 +699,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.SessionManager\\.Router\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Router\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.SessionManager\\.Router\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Router\\.Locator", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Router\\.Router", false, null), new Property("IceGrid\\.Registry\\.SessionManager\\.Router\\.CollocationOptimized", false, null), @@ -640,6 +718,7 @@ public final class PropertyNames new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.ConnectionCached", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.PreferSecure", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.LocatorCacheTimeout", false, null), + new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.InvocationTimeout", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.Locator", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.Router", false, null), new Property("IceGrid\\.Registry\\.SSLPermissionsVerifier\\.CollocationOptimized", false, null), @@ -670,6 +749,9 @@ public final class PropertyNames public static final Property IcePatch2Props[] = { + new Property("IcePatch2\\.ACM\\.Timeout", false, null), + new Property("IcePatch2\\.ACM\\.Heartbeat", false, null), + new Property("IcePatch2\\.ACM\\.Close", false, null), new Property("IcePatch2\\.ACM", false, null), new Property("IcePatch2\\.AdapterId", false, null), new Property("IcePatch2\\.Endpoints", false, null), @@ -677,6 +759,7 @@ public final class PropertyNames new Property("IcePatch2\\.Locator\\.ConnectionCached", false, null), new Property("IcePatch2\\.Locator\\.PreferSecure", false, null), new Property("IcePatch2\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("IcePatch2\\.Locator\\.InvocationTimeout", false, null), new Property("IcePatch2\\.Locator\\.Locator", false, null), new Property("IcePatch2\\.Locator\\.Router", false, null), new Property("IcePatch2\\.Locator\\.CollocationOptimized", false, null), @@ -688,6 +771,7 @@ public final class PropertyNames new Property("IcePatch2\\.Router\\.ConnectionCached", false, null), new Property("IcePatch2\\.Router\\.PreferSecure", false, null), new Property("IcePatch2\\.Router\\.LocatorCacheTimeout", false, null), + new Property("IcePatch2\\.Router\\.InvocationTimeout", false, null), new Property("IcePatch2\\.Router\\.Locator", false, null), new Property("IcePatch2\\.Router\\.Router", false, null), new Property("IcePatch2\\.Router\\.CollocationOptimized", false, null), @@ -769,6 +853,9 @@ public final class PropertyNames { new Property("Glacier2\\.AddSSLContext", true, null), new Property("Glacier2\\.AddConnectionContext", false, null), + new Property("Glacier2\\.Client\\.ACM\\.Timeout", false, null), + new Property("Glacier2\\.Client\\.ACM\\.Heartbeat", false, null), + new Property("Glacier2\\.Client\\.ACM\\.Close", false, null), new Property("Glacier2\\.Client\\.ACM", false, null), new Property("Glacier2\\.Client\\.AdapterId", false, null), new Property("Glacier2\\.Client\\.Endpoints", false, null), @@ -776,6 +863,7 @@ public final class PropertyNames new Property("Glacier2\\.Client\\.Locator\\.ConnectionCached", false, null), new Property("Glacier2\\.Client\\.Locator\\.PreferSecure", false, null), new Property("Glacier2\\.Client\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.Client\\.Locator\\.InvocationTimeout", false, null), new Property("Glacier2\\.Client\\.Locator\\.Locator", false, null), new Property("Glacier2\\.Client\\.Locator\\.Router", false, null), new Property("Glacier2\\.Client\\.Locator\\.CollocationOptimized", false, null), @@ -787,6 +875,7 @@ public final class PropertyNames new Property("Glacier2\\.Client\\.Router\\.ConnectionCached", false, null), new Property("Glacier2\\.Client\\.Router\\.PreferSecure", false, null), new Property("Glacier2\\.Client\\.Router\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.Client\\.Router\\.InvocationTimeout", false, null), new Property("Glacier2\\.Client\\.Router\\.Locator", false, null), new Property("Glacier2\\.Client\\.Router\\.Router", false, null), new Property("Glacier2\\.Client\\.Router\\.CollocationOptimized", false, null), @@ -820,6 +909,7 @@ public final class PropertyNames new Property("Glacier2\\.PermissionsVerifier\\.ConnectionCached", false, null), new Property("Glacier2\\.PermissionsVerifier\\.PreferSecure", false, null), new Property("Glacier2\\.PermissionsVerifier\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.PermissionsVerifier\\.InvocationTimeout", false, null), new Property("Glacier2\\.PermissionsVerifier\\.Locator", false, null), new Property("Glacier2\\.PermissionsVerifier\\.Router", false, null), new Property("Glacier2\\.PermissionsVerifier\\.CollocationOptimized", false, null), @@ -830,12 +920,16 @@ public final class PropertyNames new Property("Glacier2\\.SSLPermissionsVerifier\\.ConnectionCached", false, null), new Property("Glacier2\\.SSLPermissionsVerifier\\.PreferSecure", false, null), new Property("Glacier2\\.SSLPermissionsVerifier\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.SSLPermissionsVerifier\\.InvocationTimeout", false, null), new Property("Glacier2\\.SSLPermissionsVerifier\\.Locator", false, null), new Property("Glacier2\\.SSLPermissionsVerifier\\.Router", false, null), new Property("Glacier2\\.SSLPermissionsVerifier\\.CollocationOptimized", false, null), new Property("Glacier2\\.SSLPermissionsVerifier\\.Context\\.[^\\s]+", false, null), new Property("Glacier2\\.SSLPermissionsVerifier", false, null), new Property("Glacier2\\.RoutingTable\\.MaxSize", false, null), + new Property("Glacier2\\.Server\\.ACM\\.Timeout", false, null), + new Property("Glacier2\\.Server\\.ACM\\.Heartbeat", false, null), + new Property("Glacier2\\.Server\\.ACM\\.Close", false, null), new Property("Glacier2\\.Server\\.ACM", false, null), new Property("Glacier2\\.Server\\.AdapterId", false, null), new Property("Glacier2\\.Server\\.Endpoints", false, null), @@ -843,6 +937,7 @@ public final class PropertyNames new Property("Glacier2\\.Server\\.Locator\\.ConnectionCached", false, null), new Property("Glacier2\\.Server\\.Locator\\.PreferSecure", false, null), new Property("Glacier2\\.Server\\.Locator\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.Server\\.Locator\\.InvocationTimeout", false, null), new Property("Glacier2\\.Server\\.Locator\\.Locator", false, null), new Property("Glacier2\\.Server\\.Locator\\.Router", false, null), new Property("Glacier2\\.Server\\.Locator\\.CollocationOptimized", false, null), @@ -854,6 +949,7 @@ public final class PropertyNames new Property("Glacier2\\.Server\\.Router\\.ConnectionCached", false, null), new Property("Glacier2\\.Server\\.Router\\.PreferSecure", false, null), new Property("Glacier2\\.Server\\.Router\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.Server\\.Router\\.InvocationTimeout", false, null), new Property("Glacier2\\.Server\\.Router\\.Locator", false, null), new Property("Glacier2\\.Server\\.Router\\.Router", false, null), new Property("Glacier2\\.Server\\.Router\\.CollocationOptimized", false, null), @@ -877,6 +973,7 @@ public final class PropertyNames new Property("Glacier2\\.SessionManager\\.ConnectionCached", false, null), new Property("Glacier2\\.SessionManager\\.PreferSecure", false, null), new Property("Glacier2\\.SessionManager\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.SessionManager\\.InvocationTimeout", false, null), new Property("Glacier2\\.SessionManager\\.Locator", false, null), new Property("Glacier2\\.SessionManager\\.Router", false, null), new Property("Glacier2\\.SessionManager\\.CollocationOptimized", false, null), @@ -886,6 +983,7 @@ public final class PropertyNames new Property("Glacier2\\.SSLSessionManager\\.ConnectionCached", false, null), new Property("Glacier2\\.SSLSessionManager\\.PreferSecure", false, null), new Property("Glacier2\\.SSLSessionManager\\.LocatorCacheTimeout", false, null), + new Property("Glacier2\\.SSLSessionManager\\.InvocationTimeout", false, null), new Property("Glacier2\\.SSLSessionManager\\.Locator", false, null), new Property("Glacier2\\.SSLSessionManager\\.Router", false, null), new Property("Glacier2\\.SSLSessionManager\\.CollocationOptimized", false, null), diff --git a/java/src/IceInternal/ProxyBatchOutgoingAsync.java b/java/src/IceInternal/ProxyBatchOutgoingAsync.java index f6a6c676a9f..8bea231573d 100644 --- a/java/src/IceInternal/ProxyBatchOutgoingAsync.java +++ b/java/src/IceInternal/ProxyBatchOutgoingAsync.java @@ -19,7 +19,7 @@ public class ProxyBatchOutgoingAsync extends BatchOutgoingAsync _observer = ObserverHelper.get(prx, operation); } - public void __send() + public void __invoke() { Protocol.checkSupportedProtocol(_proxy.__reference().getProtocol()); @@ -32,13 +32,37 @@ public class ProxyBatchOutgoingAsync extends BatchOutgoingAsync try { delegate = _proxy.__getDelegate(false); - int status = delegate.__getRequestHandler().flushAsyncBatchRequests(this); + RequestHandler handler = delegate.__getRequestHandler(); + int status; + try + { + status = handler.sendAsyncRequest(this); + } + catch(IceInternal.LocalExceptionWrapper ex) + { + throw ex.get(); + } if((status & AsyncStatus.Sent) > 0) { _sentSynchronously = true; if((status & AsyncStatus.InvokeSentCallback) > 0) { - __sent(); + __invokeSent(); + } + } + else + { + synchronized(_monitor) + { + if((_state & Done) == 0) + { + int invocationTimeout = handler.getReference().getInvocationTimeout(); + if(invocationTimeout > 0) + { + _instance.timer().schedule(this, invocationTimeout); + _timeoutRequestHandler = handler; + } + } } } } diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java index 8575d33e558..c3fba4c0a88 100644 --- a/java/src/IceInternal/ProxyFactory.java +++ b/java/src/IceInternal/ProxyFactory.java @@ -203,6 +203,14 @@ public final class ProxyFactory throw ex; } + // + // Don't retry invocation timeouts. + // + if(ex instanceof Ice.InvocationTimeoutException) + { + throw ex; + } + ++cnt; assert(cnt > 0); diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java index b9ba4a7b5d7..1fed84467d0 100644 --- a/java/src/IceInternal/Reference.java +++ b/java/src/IceInternal/Reference.java @@ -72,6 +72,12 @@ public abstract class Reference implements Cloneable return _context; } + public int + getInvocationTimeout() + { + return _invocationTimeout; + } + public final Ice.Communicator getCommunicator() { @@ -161,6 +167,18 @@ public abstract class Reference implements Cloneable return r; } + public final Reference + changeInvocationTimeout(int newTimeout) + { + if(newTimeout == _invocationTimeout) + { + return this; + } + Reference r = _instance.referenceFactory().copy(this); + r._invocationTimeout = newTimeout; + return r; + } + public Reference changeEncoding(Ice.EncodingVersion newEncoding) { @@ -220,6 +238,7 @@ public abstract class Reference implements Cloneable } h = IceInternal.HashUtil.hashAdd(h, _protocol); h = IceInternal.HashUtil.hashAdd(h, _encoding); + h = IceInternal.HashUtil.hashAdd(h, _invocationTimeout); _hashValue = h; _hashInitialized = true; @@ -447,6 +466,11 @@ public abstract class Reference implements Cloneable return false; } + if(_invocationTimeout != r._invocationTimeout) + { + return false; + } + return true; } @@ -480,6 +504,7 @@ public abstract class Reference implements Cloneable private String _facet; private Ice.ProtocolVersion _protocol; private Ice.EncodingVersion _encoding; + private int _invocationTimeout; protected boolean _overrideCompress; protected boolean _compress; // Only used if _overrideCompress == true @@ -492,6 +517,7 @@ public abstract class Reference implements Cloneable boolean secure, Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, + int invocationTimeout, java.util.Map<String, String> context) { // @@ -510,6 +536,7 @@ public abstract class Reference implements Cloneable _facet = facet; _protocol = protocol; _encoding = encoding; + _invocationTimeout = invocationTimeout; _hashInitialized = false; _overrideCompress = false; _compress = false; diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index 4c15505c11d..b5e7aca509e 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -671,8 +671,8 @@ public final class ReferenceFactory "EndpointSelection", "ConnectionCached", "PreferSecure", - "EncodingVersion", "LocatorCacheTimeout", + "InvocationTimeout", "Locator", "Router", "CollocationOptimized", @@ -759,6 +759,7 @@ public final class ReferenceFactory boolean preferSecure = defaultsAndOverrides.defaultPreferSecure; Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection; int locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; + int invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout; java.util.Map<String, String> context = null; // @@ -839,6 +840,9 @@ public final class ReferenceFactory property = propertyPrefix + ".LocatorCacheTimeout"; locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); + property = propertyPrefix + ".InvocationTimeout"; + invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); + property = propertyPrefix + ".Context."; java.util.Map<String, String> contexts = properties.getPropertiesForPrefix(property); if(!contexts.isEmpty()) @@ -871,6 +875,7 @@ public final class ReferenceFactory preferSecure, endpointSelection, locatorCacheTimeout, + invocationTimeout, context); } diff --git a/java/src/IceInternal/RequestHandler.java b/java/src/IceInternal/RequestHandler.java index baad0a45e91..070ff48106a 100644 --- a/java/src/IceInternal/RequestHandler.java +++ b/java/src/IceInternal/RequestHandler.java @@ -18,14 +18,14 @@ public interface RequestHandler void finishBatchRequest(BasicStream out); void abortBatchRequest(); - Ice.ConnectionI sendRequest(Outgoing out) + boolean sendRequest(OutgoingMessageCallback out) throws LocalExceptionWrapper; - int sendAsyncRequest(OutgoingAsync out) + int sendAsyncRequest(OutgoingAsyncMessageCallback out) throws LocalExceptionWrapper; - boolean flushBatchRequests(BatchOutgoing out); - int flushAsyncBatchRequests(BatchOutgoingAsync out); + void requestTimedOut(OutgoingMessageCallback out); + void asyncRequestTimedOut(OutgoingAsyncMessageCallback outAsync); Reference getReference(); diff --git a/java/src/IceInternal/RetryTask.java b/java/src/IceInternal/RetryTask.java index fb75a5468f0..e1c44452448 100644 --- a/java/src/IceInternal/RetryTask.java +++ b/java/src/IceInternal/RetryTask.java @@ -24,11 +24,11 @@ class RetryTask implements TimerTask { try { - _outAsync.__send(false); + _outAsync.__invoke(false); } catch(Ice.LocalException ex) { - _outAsync.__exceptionAsync(ex); + _outAsync.__invokeExceptionAsync(ex); } } } @@ -36,7 +36,7 @@ class RetryTask implements TimerTask public void destroy() { - _outAsync.__exceptionAsync(new Ice.CommunicatorDestroyedException()); + _outAsync.__invokeExceptionAsync(new Ice.CommunicatorDestroyedException()); } private final RetryQueue _queue; diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java index 694975959c5..563cbb90297 100644 --- a/java/src/IceInternal/RoutableReference.java +++ b/java/src/IceInternal/RoutableReference.java @@ -351,9 +351,16 @@ public class RoutableReference extends Reference properties.put(prefix + ".EndpointSelection", _endpointSelection == Ice.EndpointSelectionType.Random ? "Random" : "Ordered"); - StringBuffer s = new StringBuffer(); - s.append(_locatorCacheTimeout); - properties.put(prefix + ".LocatorCacheTimeout", s.toString()); + { + StringBuffer s = new StringBuffer(); + s.append(getInvocationTimeout()); + properties.put(prefix + ".InvocationTimeout", s.toString()); + } + { + StringBuffer s = new StringBuffer(); + s.append(_locatorCacheTimeout); + properties.put(prefix + ".LocatorCacheTimeout", s.toString()); + } if(_routerInfo != null) { @@ -656,9 +663,10 @@ public class RoutableReference extends Reference boolean prefereSecure, Ice.EndpointSelectionType endpointSelection, int locatorCacheTimeout, + int invocationTimeout, java.util.Map<String, String> context) { - super(instance, communicator, identity, facet, mode, secure, protocol, encoding, context); + super(instance, communicator, identity, facet, mode, secure, protocol, encoding, invocationTimeout, context); _endpoints = endpoints; _adapterId = adapterId; _locatorInfo = locatorInfo; |