public void finished(BasicStream istr) { _m.Lock(); try { Debug.Assert(_handler.getReference().getMode() == Reference.Mode.ModeTwoway); // Only for twoways. Debug.Assert(_state <= StateInProgress); if(_remoteObserver != null) { _remoteObserver.reply(istr.size() - Protocol.headerSize - 4); _remoteObserver.detach(); _remoteObserver = null; } if(_is == null) { _is = new IceInternal.BasicStream(_handler.getReference().getInstance(), Ice.Util.currentProtocolEncoding); } _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: { if(_observer != null) { _observer.userException(); } _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 override bool Sent() => base.SentImpl(!Proxy.IsTwoway); // done = true if it's not a two-way proxy public override bool Response() { Debug.Assert(Is != null); // // NOTE: this method is called from ConnectionI.parseMessage // with the connection locked. Therefore, it must not invoke // any user callbacks. // Debug.Assert(Proxy.IsTwoway); // Can only be called for twoways. if (ChildObserver != null) { ChildObserver.Reply(Is.Size - Protocol.headerSize - 4); ChildObserver.Detach(); ChildObserver = null; } byte replyStatus; try { replyStatus = Is.ReadByte(); switch (replyStatus) { case ReplyStatus.replyOK: { break; } case ReplyStatus.replyUserException: { if (Observer != null) { Observer.UserException(); } break; } case ReplyStatus.replyObjectNotExist: case ReplyStatus.replyFacetNotExist: case ReplyStatus.replyOperationNotExist: { var ident = new Ice.Identity(Is); // // For compatibility with the old FacetPath. // string[] facetPath = Is.ReadStringSeq(); string facet; if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } facet = facetPath[0]; } else { facet = ""; } string operation = Is.ReadString(); Ice.RequestFailedException ex; 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); throw new System.InvalidOperationException(); } } ex.Id = ident; ex.Facet = facet; ex.Operation = operation; throw ex; } case ReplyStatus.replyUnknownException: case ReplyStatus.replyUnknownLocalException: case ReplyStatus.replyUnknownUserException: { string unknown = Is.ReadString(); Ice.UnknownException ex; 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); throw new System.InvalidOperationException(); } } ex.Unknown = unknown; throw ex; } default: { throw new Ice.UnknownReplyStatusException(); } } return(ResponseImpl(false, replyStatus == ReplyStatus.replyOK, true)); } catch (Ice.Exception ex) { return(Exception(ex)); } }
public Direct(Ice.Current current, RunDelegate run) { _current = current; _run = run; Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter; Debug.Assert(adapter != null); // // Must call incDirectCount() first, because it checks for // adapter deactivation, and prevents deactivation completion // until decDirectCount() is called. This is important, // because getServantManager() may not be called afer // deactivation completion. // adapter.incDirectCount(); ServantManager servantManager = adapter.getServantManager(); Debug.Assert(servantManager != null); _servant = servantManager.findServant(_current.id, _current.facet); if (_servant == null) { _locator = servantManager.findServantLocator(_current.id.category); if (_locator == null && _current.id.category.Length > 0) { _locator = servantManager.findServantLocator(""); } if (_locator != null) { try { _servant = _locator.locate(_current, out _cookie); } catch (System.Exception) { adapter.decDirectCount(); throw; } } } if (_servant == null) { adapter.decDirectCount(); if (servantManager != null && servantManager.hasServant(_current.id)) { Ice.FacetNotExistException ex = new Ice.FacetNotExistException(); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw ex; } else { Ice.ObjectNotExistException ex = new Ice.ObjectNotExistException(); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw 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); }
public override bool response() { // // NOTE: this method is called from ConnectionI.parseMessage // with the connection locked. Therefore, it must not invoke // any user callbacks. // Debug.Assert(proxy_.IsTwoway); // Can only be called for twoways. if (childObserver_ != null) { childObserver_.reply(is_.size() - Protocol.headerSize - 4); childObserver_.detach(); childObserver_ = null; } byte replyStatus; try { replyStatus = is_.ReadByte(); switch (replyStatus) { case ReplyStatus.replyOK: { break; } case ReplyStatus.replyUserException: { if (observer_ != null) { observer_.userException(); } break; } case ReplyStatus.replyObjectNotExist: case ReplyStatus.replyFacetNotExist: case ReplyStatus.replyOperationNotExist: { Ice.Identity ident = new Ice.Identity(); ident.ice_readMembers(is_); // // For compatibility with the old FacetPath. // string[] facetPath = is_.ReadStringSeq(); ; string facet; if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } facet = facetPath[0]; } else { facet = ""; } string operation = is_.ReadString(); 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 = ident; ex.facet = facet; ex.operation = operation; throw ex; } case ReplyStatus.replyUnknownException: case ReplyStatus.replyUnknownLocalException: case ReplyStatus.replyUnknownUserException: { string unknown = is_.ReadString(); 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 = unknown; throw ex; } default: { throw new Ice.UnknownReplyStatusException(); } } return(responseImpl(false, replyStatus == ReplyStatus.replyOK, true)); } catch (Ice.Exception ex) { return(exception(ex)); } }
public void finished(BasicStream istr) { _m.Lock(); try { Debug.Assert(_handler.getReference().getMode() == Reference.Mode.ModeTwoway); // Only for twoways. Debug.Assert(_state <= StateInProgress); if (_remoteObserver != null) { _remoteObserver.reply(istr.size() - Protocol.headerSize - 4); _remoteObserver.detach(); _remoteObserver = null; } if (_is == null) { _is = new IceInternal.BasicStream(_handler.getReference().getInstance(), Ice.Util.currentProtocolEncoding); } _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: { if (_observer != null) { _observer.userException(); } _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(); } }
override public Ice.AsyncCallback completed() { Debug.Assert(_is != null); // _is has been initialized prior to this call // // NOTE: this method is called from ConnectionI.parseMessage // with the connection locked. Therefore, it must not invoke // any user callbacks. // Debug.Assert(proxy_.ice_isTwoway()); // Can only be called for twoways. if (childObserver_ != null) { childObserver_.reply(_is.size() - Protocol.headerSize - 4); childObserver_.detach(); childObserver_ = null; } byte replyStatus; try { replyStatus = _is.readByte(); switch (replyStatus) { case ReplyStatus.replyOK: { break; } case ReplyStatus.replyUserException: { if (observer_ != null) { observer_.userException(); } break; } case ReplyStatus.replyObjectNotExist: case ReplyStatus.replyFacetNotExist: case ReplyStatus.replyOperationNotExist: { Ice.Identity id = new Ice.Identity(); id.read__(_is); // // For compatibility with the old FacetPath. // string[] facetPath = _is.readStringSeq(); string facet; if (facetPath.Length > 0) { if (facetPath.Length > 1) { throw new Ice.MarshalException(); } facet = facetPath[0]; } else { facet = ""; } string operation = _is.readString(); 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 = id; ex.facet = facet; ex.operation = operation; throw ex; } case ReplyStatus.replyUnknownException: case ReplyStatus.replyUnknownLocalException: case ReplyStatus.replyUnknownUserException: { string unknown = _is.readString(); 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 = unknown; throw ex; } default: { throw new Ice.UnknownReplyStatusException(); } } return(finished(replyStatus == ReplyStatus.replyOK)); } catch (Ice.Exception ex) { return(completed(ex)); } }
public int checkRetryAfterException(Ice.LocalException ex, Reference @ref, ref int cnt) { TraceLevels traceLevels = _instance.traceLevels(); Ice.Logger logger = _instance.initializationData().logger; if (@ref.getMode() == Reference.Mode.ModeBatchOneway || @ref.getMode() == Reference.Mode.ModeBatchDatagram) { Debug.Assert(false); // batch no longer implemented anyway 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. // if (ex is Ice.MarshalException) { throw ex; } // // Don't retry if the communicator is destroyed, object adapter is deactivated, // or connection is manually closed. // if (ex is Ice.CommunicatorDestroyedException || ex is Ice.ObjectAdapterDeactivatedException || ex is Ice.ConnectionManuallyClosedException) { throw ex; } // // Don't retry invocation timeouts. // if (ex is Ice.InvocationTimeoutException || ex is Ice.InvocationCanceledException) { 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); } return(interval); }
public Direct(Ice.Current current, RunDelegate run) { _current = current; _run = run; Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter; Debug.Assert(adapter != null); // // Must call incDirectCount() first, because it checks for // adapter deactivation, and prevents deactivation completion // until decDirectCount() is called. This is important, // because getServantManager() may not be called afer // deactivation completion. // adapter.incDirectCount(); ServantManager servantManager = adapter.getServantManager(); Debug.Assert(servantManager != null); _servant = servantManager.findServant(_current.id, _current.facet); if(_servant == null) { _locator = servantManager.findServantLocator(_current.id.category); if(_locator == null && _current.id.category.Length > 0) { _locator = servantManager.findServantLocator(""); } if(_locator != null) { try { _servant = _locator.locate(_current, out _cookie); } catch(System.Exception) { adapter.decDirectCount(); throw; } } } if(_servant == null) { adapter.decDirectCount(); if(servantManager != null && servantManager.hasServant(_current.id)) { Ice.FacetNotExistException ex = new Ice.FacetNotExistException(); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw ex; } else { Ice.ObjectNotExistException ex = new Ice.ObjectNotExistException(); ex.id = _current.id; ex.facet = _current.facet; ex.operation = _current.operation; throw ex; } } }