diff options
author | Mark Spruiell <mes@zeroc.com> | 2003-05-05 16:08:01 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2003-05-05 16:08:01 +0000 |
commit | c1f3783f2ce63cf62fee134fbba772cca332d954 (patch) | |
tree | b9cc7b1a3efbb1edd8328c6c7000d407c12d0da8 /java/src | |
parent | merge with e3_2003 (diff) | |
download | ice-c1f3783f2ce63cf62fee134fbba772cca332d954.tar.bz2 ice-c1f3783f2ce63cf62fee134fbba772cca332d954.tar.xz ice-c1f3783f2ce63cf62fee134fbba772cca332d954.zip |
merge with e3_2003
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/CommunicatorI.java | 9 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelper.java | 20 | ||||
-rw-r--r-- | java/src/Ice/PluginManagerI.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/Connection.java | 135 | ||||
-rw-r--r-- | java/src/IceInternal/Incoming.java | 14 | ||||
-rw-r--r-- | java/src/IceInternal/Instance.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/TcpTransceiver.java | 6 |
7 files changed, 114 insertions, 78 deletions
diff --git a/java/src/Ice/CommunicatorI.java b/java/src/Ice/CommunicatorI.java index d9b8ee164a9..225ccab5102 100644 --- a/java/src/Ice/CommunicatorI.java +++ b/java/src/Ice/CommunicatorI.java @@ -209,10 +209,11 @@ final class CommunicatorI extends LocalObjectImpl implements Communicator public synchronized void setLogger(Logger logger) { - if(_destroyed) - { - throw new CommunicatorDestroyedException(); - } + // + // No check for destruction. It must be possible to set the + // logger after destruction (needed by logger plugins for + // example to unset the logger). + // _instance.logger(logger); } diff --git a/java/src/Ice/ObjectPrxHelper.java b/java/src/Ice/ObjectPrxHelper.java index 63d3330e1fd..a8fd21d33fa 100644 --- a/java/src/Ice/ObjectPrxHelper.java +++ b/java/src/Ice/ObjectPrxHelper.java @@ -509,8 +509,24 @@ public class ObjectPrxHelper implements ObjectPrx public final void ice_flush() { - _ObjectDel __del = __getDelegate(); - __del.ice_flush(); + // + // Retry is necessary for ice_flush in case the current connection + // is closed. If that's the case we need to get a new connection. + // + int __cnt = 0; + while(true) + { + try + { + _ObjectDel __del = __getDelegate(); + __del.ice_flush(); + return; + } + catch(LocalException __ex) + { + __cnt = __handleException(__ex, __cnt); + } + } } public final boolean diff --git a/java/src/Ice/PluginManagerI.java b/java/src/Ice/PluginManagerI.java index b20b47bc8eb..b6d2823e716 100644 --- a/java/src/Ice/PluginManagerI.java +++ b/java/src/Ice/PluginManagerI.java @@ -60,7 +60,7 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag { if(_communicator != null) { - java.util.Iterator i = _plugins.entrySet().iterator(); + java.util.Iterator i = _plugins.values().iterator(); while(i.hasNext()) { Plugin p = (Plugin)i.next(); @@ -77,7 +77,7 @@ public final class PluginManagerI extends LocalObjectImpl implements PluginManag _communicator = communicator; } - private void + public void loadPlugins(StringSeqHolder cmdArgs) { assert(_communicator != null); diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index bb2f4176add..54be943f87e 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -94,6 +94,7 @@ public final class Connection extends EventHandler if(System.currentTimeMillis() >= absoluteTimeoutMillis) { setState(StateClosed, new Ice.CloseTimeoutException()); + assert(_dispatchCount == 0); // No return here, we must still wait until _transceiver becomes null. } } @@ -136,10 +137,7 @@ public final class Connection extends EventHandler // // Active connection management for idle connections. // - if(_acmTimeout > 0 && - _requests.isEmpty() && _asyncRequests.isEmpty() && - !_batchStreamInUse && _batchStream.isEmpty() && - _dispatchCount == 0) + if(_acmTimeout > 0 && closeOK()) { if(System.currentTimeMillis() >= _acmAbsoluteTimeoutMillis) { @@ -322,15 +320,8 @@ public final class Connection extends EventHandler assert(_proxyCount > 0); --_proxyCount; - // - // We close the connection if - // - no proxy uses this connection anymore; and - // - there are not outstanding asynchronous requests; and - // - this is an outgoing connection only. - // - if(_proxyCount == 0 && _asyncRequests.isEmpty() && _adapter == null) + if(_proxyCount == 0 && _adapter == null && closeOK()) { - assert(_requests.isEmpty()); setState(StateClosing, new Ice.CloseConnectionException()); } } @@ -573,54 +564,57 @@ public final class Connection extends EventHandler } } - if(_batchStream.isEmpty()) - { - return; // Nothing to send. - } - if(_exception != null) { throw _exception; } assert(_state > StateNotValidated && _state < StateClosing); - try + if(!_batchStream.isEmpty()) { - _batchStream.pos(10); - - // - // Fill in the message size. - // - _batchStream.writeInt(_batchStream.size()); - - // - // Fill in the number of requests in the batch. - // - _batchStream.writeInt(_batchRequestNum); - - // - // Send the batch request. - // - TraceUtil.traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels); - _transceiver.write(_batchStream, _endpoint.timeout()); + try + { + _batchStream.pos(10); + + // + // Fill in the message size. + // + _batchStream.writeInt(_batchStream.size()); + + // + // Fill in the number of requests in the batch. + // + _batchStream.writeInt(_batchRequestNum); + + // + // Send the batch request. + // + TraceUtil.traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels); + _transceiver.write(_batchStream, _endpoint.timeout()); + + // + // Reset _batchStream so that new batch messages can be sent. + // + _batchStream.destroy(); + _batchStream = new BasicStream(_instance); + _batchRequestNum = 0; + } + catch(Ice.LocalException ex) + { + setState(StateClosed, ex); + assert(_exception != null); + throw _exception; + } - // - // Reset _batchStream so that new batch messages can be sent. - // - _batchStream.destroy(); - _batchStream = new BasicStream(_instance); - _batchRequestNum = 0; - } - catch(Ice.LocalException ex) - { - setState(StateClosed, ex); - assert(_exception != null); - throw _exception; + if(_acmTimeout > 0) + { + _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000; + } } - if(_acmTimeout > 0) + if(_proxyCount == 0 && _adapter == null && closeOK()) { - _acmAbsoluteTimeoutMillis = System.currentTimeMillis() + _acmTimeout * 1000; + setState(StateClosing, new Ice.CloseConnectionException()); } } @@ -629,16 +623,17 @@ public final class Connection extends EventHandler { try { - if(--_dispatchCount == 0) + if(_state == StateClosed) { - notifyAll(); + assert(_dispatchCount == 0); + return; } - if(_state == StateClosed) + if(--_dispatchCount == 0) { - return; + notifyAll(); } - + // // Fill in the message size. // @@ -673,6 +668,12 @@ public final class Connection extends EventHandler { try { + if(_state == StateClosed) + { + assert(_dispatchCount == 0); + return; + } + if(--_dispatchCount == 0) { notifyAll(); @@ -921,15 +922,8 @@ public final class Connection extends EventHandler throw new Ice.UnknownRequestIdException(); } - // - // We close the connection if - // - no proxy uses this connection anymore; and - // - there are not outstanding asynchronous requests; and - // - this is an outgoing connection only. - // - if(_proxyCount == 0 && _asyncRequests.isEmpty() && _adapter == null) + if(_proxyCount == 0 && _adapter == null && closeOK()) { - assert(_requests.isEmpty()); setState(StateClosing, new Ice.CloseConnectionException()); } } @@ -1272,6 +1266,12 @@ public final class Connection extends EventHandler case StateClosed: { // + // If we do a hard close, all outstanding requests are + // disregarded. + // + _dispatchCount = 0; + + // // If we change from not validated, we can close right // away. Otherwise we first must make sure that we are // registered, then we unregister, and let finished() @@ -1457,6 +1457,17 @@ public final class Connection extends EventHandler } } + private boolean + closeOK() + { + return + _requests.isEmpty() && + _asyncRequests.isEmpty() && + !_batchStreamInUse && + _batchStream.isEmpty() && + _dispatchCount == 0; + } + private Transceiver _transceiver; private final Endpoint _endpoint; diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index c22ffc83606..a3730a0d38f 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -182,7 +182,12 @@ final public class Incoming extends IncomingBase _os.endWriteEncaps(); _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); - _os.writeString(ex.toString()); +// _os.writeString(ex.toString()); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + _os.writeString(sw.toString()); } __finishInvoke(false); @@ -203,7 +208,12 @@ final public class Incoming extends IncomingBase _os.endWriteEncaps(); _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. _os.writeByte((byte)DispatchStatus._DispatchUnknownException); - _os.writeString(ex.toString()); +// _os.writeString(ex.toString()); + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + ex.printStackTrace(pw); + pw.flush(); + _os.writeString(sw.toString()); } __finishInvoke(false); diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index d38e754d020..e6ab5414695 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -351,8 +351,8 @@ public class Instance // // Load plug-ins. // - //pluginManagerImpl = (Ice.PluginManagerI)_pluginManager; - //pluginManagerImpl.loadPlugins(args); + Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager; + pluginManagerImpl.loadPlugins(args); // // Get default router and locator proxies. Don't move this diff --git a/java/src/IceInternal/TcpTransceiver.java b/java/src/IceInternal/TcpTransceiver.java index 7bb684f9e2f..6473f500249 100644 --- a/java/src/IceInternal/TcpTransceiver.java +++ b/java/src/IceInternal/TcpTransceiver.java @@ -66,11 +66,9 @@ final class TcpTransceiver implements Transceiver public void write(BasicStream stream, int timeout) { - // TODO: Timeouts are ignored!! - java.nio.ByteBuffer buf = stream.prepareWrite(); - java.nio.channels.Selector selector = null; // TODO: Very inefficient!! + java.nio.channels.Selector selector = null; try { @@ -166,7 +164,7 @@ final class TcpTransceiver implements Transceiver remaining = buf.remaining(); } - java.nio.channels.Selector selector = null; // TODO: Very inefficient!! + java.nio.channels.Selector selector = null; try { |