Example #1
0
 public Ice.Instrumentation.DispatchObserver getDispatchObserver(Ice.Current c, int size)
 {
     if (_dispatch.isEnabled())
     {
         try
         {
             Ice.Instrumentation.DispatchObserver del = null;
             if (_delegate != null)
             {
                 del = _delegate.getDispatchObserver(c, size);
             }
             return(_dispatch.getObserver(new DispatchHelper(c, size), del));
         }
         catch (Exception ex)
         {
             _metrics.getLogger().error("unexpected exception trying to obtain observer:\n" + ex);
         }
     }
     return(null);
 }
Example #2
0
        protected bool servantLocatorFinished__(bool amd)
        {
            Debug.Assert(locator_ != null && servant_ != null);
            try
            {
                locator_.finished(current_, servant_, cookie_);
                return true;
            }
            catch(Ice.UserException ex)
            {
                Debug.Assert(responseHandler_ != null);

                if(observer_ != null)
                {
                    observer_.userException();
                }

                //
                // The operation may have already marshaled a reply; we must overwrite that reply.
                //
                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUserException);
                    os_.startEncapsulation(current_.encoding, Ice.FormatType.DefaultFormat);
                    os_.writeException(ex);
                    os_.endEncapsulation();
                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }

                if(observer_ != null)
                {
                    observer_.detach();
                    observer_ = null;
                }
                responseHandler_ = null;
            }
            catch(System.Exception ex)
            {
                handleException__(ex, amd);
            }
            return false;
        }
Example #3
0
        internal void adopt(IncomingBase inc)
        {
            instance_ = inc.instance_;
            //inc.instance_ = null; // Don't reset instance_.

            observer_ = inc.observer_;
            inc.observer_ = null;

            servant_ = inc.servant_;
            inc.servant_ = null;

            locator_ = inc.locator_;
            inc.locator_ = null;

            cookie_ = inc.cookie_;
            inc.cookie_ = null;

            response_ = inc.response_;
            inc.response_ = false;

            compress_ = inc.compress_;
            inc.compress_ = 0;

            //
            // Adopt the stream - it creates less garbage.
            //
            os_ = inc.os_;
            inc.os_ = null;

            responseHandler_ = inc.responseHandler_;
            inc.responseHandler_ = null;
        }
Example #4
0
        protected internal void handleException__(System.Exception exc, bool amd)
        {
            Debug.Assert(responseHandler_ != null);

            try
            {
                throw exc;
            }
            catch(Ice.RequestFailedException ex)
            {
                if(ex.id == null || ex.id.name == null || ex.id.name.Length == 0)
                {
                    ex.id = current_.id;
                }

                if(ex.facet == null || ex.facet.Length == 0)
                {
                    ex.facet = current_.facet;
                }

                if(ex.operation == null || ex.operation.Length == 0)
                {
                    ex.operation = current_.operation;
                }

                if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
                {
                    warning__(ex);
                }

                if(observer_ != null)
                {
                    observer_.failed(ex.ice_id());
                }

                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    if(ex is Ice.ObjectNotExistException)
                    {
                        os_.writeByte(ReplyStatus.replyObjectNotExist);
                    }
                    else if(ex is Ice.FacetNotExistException)
                    {
                        os_.writeByte(ReplyStatus.replyFacetNotExist);
                    }
                    else if(ex is Ice.OperationNotExistException)
                    {
                        os_.writeByte(ReplyStatus.replyOperationNotExist);
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                    ex.id.write__(os_);

                    //
                    // For compatibility with the old FacetPath.
                    //
                    if(ex.facet == null || ex.facet.Length == 0)
                    {
                        os_.writeStringSeq(null);
                    }
                    else
                    {
                        string[] facetPath2 = { ex.facet };
                        os_.writeStringSeq(facetPath2);
                    }

                    os_.writeString(ex.operation);

                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }
            }
            catch(Ice.UnknownLocalException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(observer_ != null)
                {
                    observer_.failed(ex.ice_id());
                }

                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownLocalException);
                    os_.writeString(ex.unknown);
                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }
            }
            catch(Ice.UnknownUserException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(observer_ != null)
                {
                    observer_.failed(ex.ice_id());
                }

                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownUserException);
                    os_.writeString(ex.unknown);
                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }
            }
            catch(Ice.UnknownException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(observer_ != null)
                {
                    observer_.failed(ex.ice_id());
                }

                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownException);
                    os_.writeString(ex.unknown);
                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }
            }
            catch(Ice.UserException ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(observer_ != null)
                {
                    observer_.failed(ex.ice_id());
                }

                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownUserException);
                    os_.writeString(ex.ice_id() + "\n" + ex.StackTrace);
                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }
            }
            catch(Ice.Exception ex)
            {
                if(ex is Ice.SystemException)
                {
                    if(responseHandler_.systemException(current_.requestId, (Ice.SystemException)ex, amd))
                    {
                        return;
                    }
                }

                if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(observer_ != null)
                {
                    observer_.failed(ex.ice_id());
                }

                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownLocalException);
                    os_.writeString(ex.ice_id() + "\n" + ex.StackTrace);
                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }
            }
            catch(System.Exception ex)
            {
                if(instance_.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning__(ex);
                }

                if(observer_ != null)
                {
                    observer_.failed(ex.GetType().FullName);
                }

                if(response_)
                {
                    os_.resize(Protocol.headerSize + 4); // Reply status position.
                    os_.writeByte(ReplyStatus.replyUnknownException);
                    os_.writeString(ex.ToString());
                    if(observer_ != null)
                    {
                        observer_.reply(os_.size() - Protocol.headerSize - 4);
                    }
                    responseHandler_.sendResponse(current_.requestId, os_, compress_, amd);
                }
                else
                {
                    responseHandler_.sendNoResponse();
                }
            }

            if(observer_ != null)
            {
                observer_.detach();
                observer_ = null;
            }
            responseHandler_ = null;
        }
Example #5
0
        public virtual void reclaim()
        {
            servant_ = null;

            locator_ = null;

            cookie_ = null;

            observer_ = null;

            if(os_ != null)
            {
                os_.reset();
            }

            interceptorAsyncCallbackList_ = null;
        }