public void writeException(Ice.LocalException ex) { lock (this) { _writeException = ex; } }
public void initializeException(Ice.LocalException ex) { lock (this) { _initializeException = ex; } }
public int closing(bool initiator, Ice.LocalException ex) { // // Nothing to do. // return(SocketOperation.None); }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { lock (this) { if (_exception != null) { return; // The request has been notified of a failure already. } if (!initialized()) { LinkedListNode <ProxyOutgoingAsyncBase> p = _requests.First; while (p != null) { if (p.Value == outAsync) { _requests.Remove(p); if (outAsync.exception(ex)) { outAsync.invokeExceptionAsync(); } return; } p = p.Next; } Debug.Assert(false); // The request has to be queued if it timed out and we're not initialized yet. } } _connection.asyncRequestCanceled(outAsync, ex); }
public void setException(Ice.LocalException ex) { lock (this) { Debug.Assert(!_initialized && _exception == null); _exception = ex; _proxies.Clear(); _proxy = null; // Break cyclic reference count. // // NOTE: remove the request handler *before* notifying the // requests that the connection failed. It's important to ensure // that future invocations will obtain a new connect request // handler once invocations are notified. // try { _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); } catch (Ice.CommunicatorDestroyedException) { // Ignore } foreach (ProxyOutgoingAsyncBase outAsync in _requests) { if (outAsync.exception(_exception)) { outAsync.invokeExceptionAsync(); } } _requests.Clear(); Monitor.PulseAll(this); } }
destroy(Ice.LocalException ex) { lock (this) { _exception = ex; } }
public void setException(Ice.LocalException ex) { _m.Lock(); try { Debug.Assert(!_initialized && _exception == null); Debug.Assert(_updateRequestHandler || _requests.Count == 0); _exception = ex; _proxy = null; // Break cyclic reference count. _delegate = null; // Break cyclic reference count. // // If some requests were queued, we notify them of the failure. This is done from a thread // from the client thread pool since this will result in ice_exception callbacks to be // called. // if (_requests.Count > 0) { _reference.getInstance().clientThreadPool().dispatch(delegate() { flushRequestsWithException(ex); }); } _m.NotifyAll(); } finally { _m.Unlock(); } }
public void connectException(Ice.LocalException ex) { lock (this) { _connectException = ex; } }
public void readException(Ice.LocalException ex) { lock (this) { _readException = ex; } }
public void finished(Ice.LocalException ex, bool sent) { _m.Lock(); try { _exception = ex; _m.Notify(); } finally { _m.Unlock(); } }
public void AsyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { Debug.Assert(_outAsync == outAsync); if (_communicator.CancelRetryTask(this)) { if (_communicator.TraceLevels.retry >= 1) { _communicator.Logger.Trace(_communicator.TraceLevels.retryCat, $"operation retry canceled\n{ex}"); } if (_outAsync.Exception(ex)) { _outAsync.InvokeExceptionAsync(); } } }
protected void cancel(Ice.LocalException ex) { CancellationHandler handler; lock (this) { _cancellationException = ex; if (_cancellationHandler == null) { return; } handler = _cancellationHandler; } handler.asyncRequestCanceled((OutgoingAsyncBase)this, ex); }
flushRequestsWithException(Ice.LocalException ex) { foreach (Request request in _requests) { if (request.@out != null) { [email protected]__(ex, false); } else if (request.batchOut != null) { request.batchOut.finished__(ex, false); } } _requests.Clear(); }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { Debug.Assert(_outAsync == outAsync); if (_retryQueue.cancel(this)) { if (_communicator.traceLevels().retry >= 1) { _communicator.initializationData().logger.trace(_communicator.traceLevels().retryCat, string.Format("operation retry canceled\n{0}", ex)); } if (_outAsync.exception(ex)) { _outAsync.invokeExceptionAsync(); } } }
public void abort(Ice.LocalException ex) { Debug.Assert(_state == StateUnsent); // // If we didn't finish a batch oneway or datagram request, // we must notify the connection about that we give up // ownership of the batch stream. // Reference.Mode mode = _handler.getReference().getMode(); if (mode == Reference.Mode.ModeBatchOneway || mode == Reference.Mode.ModeBatchDatagram) { _handler.abortBatchRequest(); } throw ex; }
protected void Cancel(Ice.LocalException ex) { ICancellationHandler handler; { lock (this) { if (_cancellationHandler == null) { _cancellationException = ex; return; } handler = _cancellationHandler; } } handler.AsyncRequestCanceled(this, ex); }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { Debug.Assert(_outAsync == outAsync); if (_retryQueue.cancel(this)) { if (_instance.traceLevels().retry >= 1) { string s = "operation retry canceled\n" + ex; _instance.initializationData().logger.trace(_instance.traceLevels().retryCat, s); } Ice.AsyncCallback cb = _outAsync.completed(ex); if (cb != null) { _outAsync.invokeCompletedAsync(cb); } } }
public void finished(Ice.LocalException ex, bool sent) { _m.Lock(); if (_remoteObserver != null) { _remoteObserver.failed(ex.ice_name()); _remoteObserver.detach(); } try { _exception = ex; _m.Notify(); } finally { _m.Unlock(); } }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { lock (this) { int requestId; if (_sendAsyncRequests.TryGetValue(outAsync, out requestId)) { if (requestId > 0) { _asyncRequests.Remove(requestId); } _sendAsyncRequests.Remove(outAsync); Ice.AsyncCallback cb = outAsync.completed(ex); if (cb != null) { outAsync.invokeCompletedAsync(cb); } _adapter.decDirectCount(); // invokeAll won't be called, decrease the direct count. return; } if (outAsync is OutgoingAsync) { OutgoingAsync o = (OutgoingAsync)outAsync; Debug.Assert(o != null); foreach (KeyValuePair <int, OutgoingAsyncBase> e in _asyncRequests) { if (e.Value == o) { _asyncRequests.Remove(e.Key); Ice.AsyncCallback cb = outAsync.completed(ex); if (cb != null) { outAsync.invokeCompletedAsync(cb); } return; } } } } }
public void finished(Ice.LocalException ex, bool sent) { _m.Lock(); try { Debug.Assert(_state <= StateInProgress); if (_remoteObserver != null) { _remoteObserver.failed(ex.ice_name()); _remoteObserver.detach(); _remoteObserver = null; } _state = StateFailed; _exception = ex; _sent = sent; _m.Notify(); } finally { _m.Unlock(); } }
public void AsyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { lock (this) { if (_sendAsyncRequests.TryGetValue(outAsync, out int requestId)) { if (requestId > 0) { _asyncRequests.Remove(requestId); } _sendAsyncRequests.Remove(outAsync); if (outAsync.Exception(ex)) { outAsync.InvokeExceptionAsync(); } _adapter.DecDirectCount(); // invokeAll won't be called, decrease the direct count. return; } if (outAsync is OutgoingAsync o) { Debug.Assert(o != null); foreach (KeyValuePair <int, OutgoingAsyncBase> e in _asyncRequests) { if (e.Value == o) { _asyncRequests.Remove(e.Key); if (outAsync.Exception(ex)) { outAsync.InvokeExceptionAsync(); } return; } } } } }
public static void throwWrapper(System.Exception ex) { Ice.UserException userException = ex as Ice.UserException; if (userException != null) { throw new LocalExceptionWrapper(new Ice.UnknownUserException(userException.ice_name()), false); } Ice.LocalException localException = ex as Ice.LocalException; if (localException != null) { if (ex is Ice.UnknownException || ex is Ice.ObjectNotExistException || ex is Ice.OperationNotExistException || ex is Ice.FacetNotExistException) { throw new LocalExceptionWrapper(localException, false); } throw new LocalExceptionWrapper(new Ice.UnknownLocalException(localException.ice_name()), false); } throw new LocalExceptionWrapper(new Ice.UnknownException(ex.GetType().FullName), false); }
public void asyncRequestCanceled(OutgoingAsyncBase outAsync, Ice.LocalException ex) { _connection.asyncRequestCanceled(outAsync, ex); }
public void exception(Ice.LocalException ex) { _callback.exception(ex); }
public int checkRetryAfterException(Ice.LocalException ex, Reference @ref, bool sleep, ref int cnt) { TraceLevels traceLevels = instance_.traceLevels(); Ice.Logger logger = instance_.initializationData().logger; // // We don't retry batch requests because the exception might have caused // the all the requests batched with the connection to be aborted and we // want the application to be notified. // if (@ref.getMode() == Reference.Mode.ModeBatchOneway || @ref.getMode() == Reference.Mode.ModeBatchDatagram) { throw ex; } Ice.ObjectNotExistException one = ex as Ice.ObjectNotExistException; if (one != null) { if (@ref.getRouterInfo() != null && one.operation.Equals("ice_add_proxy")) { // // If we have a router, an ObjectNotExistException with an // operation name "ice_add_proxy" indicates to the client // that the router isn't aware of the proxy (for example, // because it was evicted by the router). In this case, we // must *always* retry, so that the missing proxy is added // to the router. // @ref.getRouterInfo().clearCache(@ref); if (traceLevels.retry >= 1) { string s = "retrying operation call to add proxy to router\n" + ex; logger.trace(traceLevels.retryCat, s); } return(0); // We must always retry, so we don't look at the retry count. } else if (@ref.isIndirect()) { // // We retry ObjectNotExistException if the reference is // indirect. // if (@ref.isWellKnown()) { LocatorInfo li = @ref.getLocatorInfo(); if (li != null) { li.clearCache(@ref); } } } else { // // For all other cases, we don't retry ObjectNotExistException. // throw ex; } } else if (ex is Ice.RequestFailedException) { throw ex; } // // There is no point in retrying an operation that resulted in a // MarshalException. This must have been raised locally (because if // it happened in a server it would result in an UnknownLocalException // instead), which means there was a problem in this process that will // not change if we try again. // // The most likely cause for a MarshalException is exceeding the // maximum message size, which is represented by the subclass // MemoryLimitException. For example, a client can attempt to send a // message that exceeds the maximum memory size, or accumulate enough // batch requests without flushing that the maximum size is reached. // // This latter case is especially problematic, because if we were to // retry a batch request after a MarshalException, we would in fact // silently discard the accumulated requests and allow new batch // requests to accumulate. If the subsequent batched requests do not // exceed the maximum message size, it appears to the client that all // of the batched requests were accepted, when in reality only the // last few are actually sent. // if (ex is Ice.MarshalException) { throw ex; } ++cnt; Debug.Assert(cnt > 0); int interval; if (cnt == (_retryIntervals.Length + 1) && ex is Ice.CloseConnectionException) { // // A close connection exception is always retried at least once, even if the retry // limit is reached. // interval = 0; } else if (cnt > _retryIntervals.Length) { if (traceLevels.retry >= 1) { string s = "cannot retry operation call because retry limit has been exceeded\n" + ex; logger.trace(traceLevels.retryCat, s); } throw ex; } else { interval = _retryIntervals[cnt - 1]; } if (traceLevels.retry >= 1) { string s = "retrying operation call"; if (interval > 0) { s += " in " + interval + "ms"; } s += " because of exception\n" + ex; logger.trace(traceLevels.retryCat, s); } if (sleep && interval > 0) { // // Sleep before retrying. // System.Threading.Thread.Sleep(interval); } return(interval); }
private void flushRequests() { _m.Lock(); try { Debug.Assert(_connection != null && !_initialized); while(_batchRequestInProgress) { _m.Wait(); } // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. // _flushing = true; } finally { _m.Unlock(); } LinkedList<Request> sentCallbacks = new LinkedList<Request>(); try { LinkedListNode<Request> p = _requests.First; // _requests is immutable when _flushing = true while(p != null) { Request request = p.Value; if(request.@out != null) { if(_connection.sendAsyncRequest(request.@out, _compress, _response, out request.sentCallback)) { if(request.sentCallback != null) { sentCallbacks.AddLast(request); } } } else if(request.batchOut != null) { if(_connection.flushAsyncBatchRequests(request.batchOut, out request.sentCallback)) { if(request.sentCallback != null) { sentCallbacks.AddLast(request); } } } else { BasicStream os = new BasicStream(request.os.instance()); _connection.prepareBatchRequest(os); try { request.os.pos(0); os.writeBlob(request.os.readBlob(request.os.size())); } catch(Ice.LocalException) { _connection.abortBatchRequest(); throw; } _connection.finishBatchRequest(os, _compress); } LinkedListNode<Request> tmp = p; p = p.Next; _requests.Remove(tmp); } } catch(LocalExceptionWrapper ex) { _m.Lock(); try { Debug.Assert(_exception == null && _requests.Count > 0); _exception = ex.get(); _reference.getInstance().clientThreadPool().dispatch(delegate() { flushRequestsWithException(ex); }); } finally { _m.Unlock(); } } catch(Ice.LocalException ex) { _m.Lock(); try { Debug.Assert(_exception == null && _requests.Count > 0); _exception = ex; _reference.getInstance().clientThreadPool().dispatch(delegate() { flushRequestsWithException(ex); }); } finally { _m.Unlock(); } } if(sentCallbacks.Count > 0) { Instance instance = _reference.getInstance(); instance.clientThreadPool().dispatch(delegate() { foreach(Request r in sentCallbacks) { if(r.@out != null) { [email protected]__(r.sentCallback); } else if(r.batchOut != null) { r.batchOut.sent__(r.sentCallback); } } }); } // // We've finished sending the queued requests and the request handler now send // the requests over the connection directly. It's time to substitute the // request handler of the proxy with the more efficient connection request // handler which does not have any synchronization. This also breaks the cyclic // reference count with the proxy. // // NOTE: _updateRequestHandler is immutable once _flushing = true // if(_updateRequestHandler && _exception == null) { _proxy.setRequestHandler__(_delegate, new ConnectionRequestHandler(_reference, _connection, _compress)); } _m.Lock(); try { Debug.Assert(!_initialized); if(_exception == null) { _initialized = true; _flushing = false; } _proxy = null; // Break cyclic reference count. _delegate = null; // Break cyclic reference count. _m.NotifyAll(); } finally { _m.Unlock(); } }
public void setException(Ice.LocalException ex) { _m.Lock(); try { Debug.Assert(!_initialized && _exception == null); Debug.Assert(_updateRequestHandler || _requests.Count == 0); _exception = ex; _proxy = null; // Break cyclic reference count. _delegate = null; // Break cyclic reference count. // // If some requests were queued, we notify them of the failure. This is done from a thread // from the client thread pool since this will result in ice_exception callbacks to be // called. // if(_requests.Count > 0) { _reference.getInstance().clientThreadPool().dispatch(delegate() { flushRequestsWithException(ex); }); } _m.NotifyAll(); } finally { _m.Unlock(); } }
public RetryException(Ice.LocalException ex) { _ex = ex; }
public LocalExceptionWrapper(Ice.LocalException ex, bool retry) { _ex = ex; _retry = retry; }
private void flushRequests() { lock (this) { Debug.Assert(_connection != null && !_initialized); // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. // _flushing = true; } Ice.LocalException exception = null; foreach (ProxyOutgoingAsyncBase outAsync in _requests) { try { if ((outAsync.invokeRemote(_connection, _compress, _response) & OutgoingAsyncBase.AsyncStatusInvokeSentCallback) != 0) { outAsync.invokeSentAsync(); } } catch (RetryException ex) { exception = ex.get(); // Remove the request handler before retrying. _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); outAsync.retryException(ex.get()); } catch (Ice.LocalException ex) { exception = ex; if (outAsync.exception(ex)) { outAsync.invokeExceptionAsync(); } } } _requests.Clear(); // // If we aren't caching the connection, don't bother creating a // connection request handler. Otherwise, update the proxies // request handler to use the more efficient connection request // handler. // if (_reference.getCacheConnection() && exception == null) { _requestHandler = new ConnectionRequestHandler(_reference, _connection, _compress); foreach (Ice.ObjectPrxHelperBase prx in _proxies) { prx.updateRequestHandler__(this, _requestHandler); } } lock (this) { Debug.Assert(!_initialized); _exception = exception; _initialized = _exception == null; _flushing = false; // // Only remove once all the requests are flushed to // guarantee serialization. // _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); _proxies.Clear(); _proxy = null; // Break cyclic reference count. Monitor.PulseAll(this); } }
public void initializeException(Ice.LocalException ex) { lock(this) { _initializeException = ex; } }
public LocalExceptionWrapper(LocalExceptionWrapper ex) { _ex = ex.get(); _retry = ex._retry; }
public void readException(Ice.LocalException ex) { lock(this) { _readException = ex; } }
public void writeException(Ice.LocalException ex) { lock(this) { _writeException = ex; } }
public void connectorsException(Ice.LocalException ex) { lock(this) { _connectorsException = ex; } }
internal void deadRemoteLogger(Ice.RemoteLoggerPrx remoteLogger, Ice.Logger logger, Ice.LocalException ex, string operation) { // // No need to convert remoteLogger as we only use its identity // if (removeRemoteLogger(remoteLogger)) { if (_traceLevel > 0) { logger.trace(_traceCategory, "detached `" + remoteLogger.ToString() + "' because " + operation + " raised:\n" + ex.ToString()); } } }
public void finished(BasicStream istr) { _m.Lock(); try { Debug.Assert(_handler.getReference().getMode() == Reference.Mode.ModeTwoway); // Only for twoways. Debug.Assert(_state <= StateInProgress); _is.swap(istr); byte replyStatus = _is.readByte(); switch(replyStatus) { case ReplyStatus.replyOK: { _state = StateOK; // The state must be set last, in case there is an exception. break; } case ReplyStatus.replyUserException: { _state = StateUserException; // The state must be set last, in case there is an exception. break; } case ReplyStatus.replyObjectNotExist: case ReplyStatus.replyFacetNotExist: case ReplyStatus.replyOperationNotExist: { Ice.RequestFailedException ex = null; switch(replyStatus) { case ReplyStatus.replyObjectNotExist: { ex = new Ice.ObjectNotExistException(); break; } case ReplyStatus.replyFacetNotExist: { ex = new Ice.FacetNotExistException(); break; } case ReplyStatus.replyOperationNotExist: { ex = new Ice.OperationNotExistException(); break; } default: { Debug.Assert(false); break; } } ex.id = new Ice.Identity(); ex.id.read__(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.readStringSeq(); if(facetPath.Length > 0) { if(facetPath.Length > 1) { throw new Ice.MarshalException(); } ex.facet = facetPath[0]; } else { ex.facet = ""; } ex.operation = _is.readString(); _exception = ex; _state = StateLocalException; // The state must be set last, in case there is an exception. break; } case ReplyStatus.replyUnknownException: case ReplyStatus.replyUnknownLocalException: case ReplyStatus.replyUnknownUserException: { Ice.UnknownException ex = null; switch(replyStatus) { case ReplyStatus.replyUnknownException: { ex = new Ice.UnknownException(); break; } case ReplyStatus.replyUnknownLocalException: { ex = new Ice.UnknownLocalException(); break; } case ReplyStatus.replyUnknownUserException: { ex = new Ice.UnknownUserException(); break; } default: { Debug.Assert(false); break; } } ex.unknown = _is.readString(); _exception = ex; _state = StateLocalException; // The state must be set last, in case there is an exception. break; } default: { _exception = new Ice.UnknownReplyStatusException(); _state = StateLocalException; break; } } _m.Notify(); } finally { _m.Unlock(); } }
public int closing(bool initiator, Ice.LocalException ex) { return(_delegate.closing(initiator, ex)); }
public void setException(Ice.LocalException ex) { if(_exception == null) { _exception = ex; } if(_endpoints == null || ++_i == _endpoints.Length) { _callback.setException(_exception); return; } bool more = _i != _endpoints.Length - 1; EndpointI[] endpoint = new EndpointI[]{ _endpoints[_i] }; _rr.getInstance().outgoingConnectionFactory().create(endpoint, more, _rr.getEndpointSelection(), this); }
// // These functions allow this object to be reused, rather than reallocated. // public void reset(RequestHandler handler, string operation, Ice.OperationMode mode, Dictionary<string, string> context) { _state = StateUnsent; _exception = null; _sent = false; _handler = handler; writeHeader(operation, mode, context); }
public void setException(Ice.LocalException ex) { lock(this) { Debug.Assert(!_initialized && _exception == null); _exception = ex; _proxies.Clear(); _proxy = null; // Break cyclic reference count. // // NOTE: remove the request handler *before* notifying the // requests that the connection failed. It's important to ensure // that future invocations will obtain a new connect request // handler once invocations are notified. // try { _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); } catch(Ice.CommunicatorDestroyedException) { // Ignore } foreach(ProxyOutgoingAsyncBase outAsync in _requests) { Ice.AsyncCallback cb = outAsync.completed(_exception); if(cb != null) { outAsync.invokeCompletedAsync(cb); } } _requests.Clear(); System.Threading.Monitor.PulseAll(this); } }
invokeException(int requestId, Ice.LocalException ex, int invokeNum, bool amd) { handleException(requestId, ex, amd); _adapter.decDirectCount(); }
public void finished(Ice.LocalException ex, bool sent) { _m.Lock(); try { Debug.Assert(_state <= StateInProgress); _state = StateFailed; _exception = ex; _sent = sent; _m.Notify(); } finally { _m.Unlock(); } }
private void flushRequests() { lock(this) { Debug.Assert(_connection != null && !_initialized); // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. // _flushing = true; } Ice.LocalException exception = null; foreach(ProxyOutgoingAsyncBase outAsync in _requests) { try { Ice.AsyncCallback sentCallback = null; if(outAsync.invokeRemote(_connection, _compress, _response, out sentCallback)) { if(sentCallback != null) { outAsync.invokeSentAsync(sentCallback); } } } catch(RetryException ex) { exception = ex.get(); // Remove the request handler before retrying. _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); outAsync.retryException(ex.get()); } catch(Ice.LocalException ex) { exception = ex; Ice.AsyncCallback cb = outAsync.completed(ex); if(cb != null) { outAsync.invokeCompletedAsync(cb); } } } _requests.Clear(); // // If we aren't caching the connection, don't bother creating a // connection request handler. Otherwise, update the proxies // request handler to use the more efficient connection request // handler. // if(_reference.getCacheConnection() && exception == null) { _requestHandler = new ConnectionRequestHandler(_reference, _connection, _compress); foreach(Ice.ObjectPrxHelperBase prx in _proxies) { prx.updateRequestHandler__(this, _requestHandler); } } lock(this) { Debug.Assert(!_initialized); _exception = exception; _initialized = _exception == null; _flushing = false; // // Only remove once all the requests are flushed to // guarantee serialization. // _reference.getInstance().requestHandlerFactory().removeRequestHandler(_reference, this); _proxies.Clear(); _proxy = null; // Break cyclic reference count. System.Threading.Monitor.PulseAll(this); } }
public int closing(bool initiator, Ice.LocalException ex) { // If we are initiating the connection closure, wait for the peer // to close the TCP/IP connection. Otherwise, close immediately. return(initiator ? IceInternal.SocketOperation.Read : IceInternal.SocketOperation.None); }