private void invokeAll(Ice.OutputStream os, int requestId) { if (_traceLevels.protocol >= 1) { fillInValue(os, 10, os.size()); if (requestId > 0) { fillInValue(os, Protocol.headerSize, requestId); } TraceUtil.traceSend(os, _logger, _traceLevels); } Ice.InputStream iss = new Ice.InputStream(os.communicator(), os.GetEncoding(), os.GetBuffer(), false); iss.pos(Protocol.requestHdr.Length); int invokeNum = 1; ServantManager servantManager = _adapter.getServantManager(); try { while (invokeNum > 0) { // // Increase the direct count for the dispatch. We increase it again here for // each dispatch. It's important for the direct count to be > 0 until the last // collocated request response is sent to make sure the thread pool isn't // destroyed before. // try { _adapter.incDirectCount(); } catch (Ice.ObjectAdapterDeactivatedException ex) { handleException(requestId, ex, false); break; } Incoming inS = new Incoming(_reference.getCommunicator(), this, null, _adapter, _response, 0, requestId); inS.invoke(servantManager, iss); --invokeNum; } } catch (Ice.LocalException ex) { invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception } _adapter.decDirectCount(); }
public void invoke(ServantManager servantManager, Ice.InputStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // var id = new Ice.Identity(); id.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(); byte mode = _is.ReadByte(); Dictionary <string, string> context = new Dictionary <string, string>(); int sz = _is.ReadSize(); while (sz-- > 0) { string first = _is.ReadString(); string second = _is.ReadString(); context[first] = second; } _current = new Ice.Current(_adapter, id, facet, operation, (Ice.OperationMode)mode, context, _requestId, _connection); Ice.Instrumentation.CommunicatorObserver?obsv = _communicator.Observer; if (obsv != null) { // Read the encapsulation size. int size = _is.ReadInt(); _is.pos(_is.pos() - 4); _observer = obsv.getDispatchObserver(_current, _is.pos() - start + size); if (_observer != null) { _observer.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if (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) { Debug.Assert(_locator != null); try { _servant = _locator.locate(_current, out _cookie); } catch (Exception ex) { skipReadParams(); // Required for batch requests. handleException(ex, false); return; } } } } if (_servant == null) { try { if (servantManager != null && servantManager.hasServant(_current.Id)) { throw new Ice.FacetNotExistException(_current.Id, _current.Facet, _current.Operation); } else { throw new Ice.ObjectNotExistException(_current.Id, _current.Facet, _current.Operation); } } catch (Exception ex) { skipReadParams(); // Required for batch requests handleException(ex, false); return; } } try { Task <Ice.OutputStream>?task = _servant(this, _current); if (task == null) { completed(null, false); } else { if (task.IsCompleted) { _os = task.GetAwaiter().GetResult(); // Get the response completed(null, false); } else { task.ContinueWith((Task <Ice.OutputStream> t) => { try { _os = t.GetAwaiter().GetResult(); completed(null, true); // true = asynchronous } catch (Exception ex) { completed(ex, true); // true = asynchronous } }, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, scheduler: TaskScheduler.Current); } } } catch (Exception ex) { completed(ex, false); } }
// // Only for use by ObjectAdapterFactory // public ObjectAdapterI(Instance instance, Communicator communicator, ObjectAdapterFactory objectAdapterFactory, string name, RouterPrx router, bool noConfig) { instance_ = instance; _communicator = communicator; _objectAdapterFactory = objectAdapterFactory; _servantManager = new ServantManager(instance, name); _name = name; _incomingConnectionFactories = new List<IncomingConnectionFactory>(); _publishedEndpoints = new List<EndpointI>(); _routerEndpoints = new List<EndpointI>(); _routerInfo = null; _directCount = 0; _noConfig = noConfig; if(_noConfig) { _id = ""; _replicaGroupId = ""; _reference = instance_.referenceFactory().create("dummy -t", ""); _acm = instance_.serverACM(); return; } Properties properties = instance_.initializationData().properties; List<string> unknownProps = new List<string>(); bool noProps = filterProperties(unknownProps); // // Warn about unknown object adapter properties. // if(unknownProps.Count != 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { StringBuilder message = new StringBuilder("found unknown properties for object adapter `"); message.Append(_name); message.Append("':"); foreach(string s in unknownProps) { message.Append("\n "); message.Append(s); } instance_.initializationData().logger.warning(message.ToString()); } // // Make sure named adapter has configuration. // if(router == null && noProps) { // // These need to be set to prevent warnings/asserts in the destructor. // state_ = StateDestroyed; instance_ = null; _incomingConnectionFactories = null; InitializationException ex = new InitializationException(); ex.reason = "object adapter `" + _name + "' requires configuration"; throw ex; } _id = properties.getProperty(_name + ".AdapterId"); _replicaGroupId = properties.getProperty(_name + ".ReplicaGroupId"); // // Setup a reference to be used to get the default proxy options // when creating new proxies. By default, create twoway proxies. // string proxyOptions = properties.getPropertyWithDefault(_name + ".ProxyOptions", "-t"); try { _reference = instance_.referenceFactory().create("dummy " + proxyOptions, ""); } catch(ProxyParseException) { InitializationException ex = new InitializationException(); ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + _name + "'"; throw ex; } _acm = new ACMConfig(properties, communicator.getLogger(), _name + ".ACM", instance_.serverACM()); { int defaultMessageSizeMax = instance.messageSizeMax() / 1024; int num = properties.getPropertyAsIntWithDefault(_name + ".MessageSizeMax", defaultMessageSizeMax); if(num < 1 || num > 0x7fffffff / 1024) { _messageSizeMax = 0x7fffffff; } else { _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes } } try { int threadPoolSize = properties.getPropertyAsInt(_name + ".ThreadPool.Size"); int threadPoolSizeMax = properties.getPropertyAsInt(_name + ".ThreadPool.SizeMax"); if(threadPoolSize > 0 || threadPoolSizeMax > 0) { _threadPool = new ThreadPool(instance_, _name + ".ThreadPool", 0); } if(router == null) { router = RouterPrxHelper.uncheckedCast( instance_.proxyFactory().propertyToProxy(_name + ".Router")); } if(router != null) { _routerInfo = instance_.routerManager().get(router); if(_routerInfo != null) { // // Make sure this router is not already registered with another adapter. // if(_routerInfo.getAdapter() != null) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "object adapter with router"; ex.id = instance_.identityToString(router.ice_getIdentity()); throw ex; } // // Add the router's server proxy endpoints to this object // adapter. // EndpointI[] endpoints = _routerInfo.getServerEndpoints(); for(int i = 0; i < endpoints.Length; ++i) { _routerEndpoints.Add(endpoints[i]); } _routerEndpoints.Sort(); // Must be sorted. // // Remove duplicate endpoints, so we have a list of unique endpoints. // for(int i = 0; i < _routerEndpoints.Count-1;) { EndpointI e1 = _routerEndpoints[i]; EndpointI e2 = _routerEndpoints[i + 1]; if(e1.Equals(e2)) { _routerEndpoints.RemoveAt(i); } else { ++i; } } // // Associate this object adapter with the router. This way, // new outgoing connections to the router's client proxy will // use this object adapter for callbacks. // _routerInfo.setAdapter(this); // // Also modify all existing outgoing connections to the // router's client proxy to use this object adapter for // callbacks. // instance_.outgoingConnectionFactory().setRouterInfo(_routerInfo); } } else { // // Parse the endpoints, but don't store them in the adapter. The connection // factory might change it, for example, to fill in the real port number. // List<EndpointI> endpoints = parseEndpoints(properties.getProperty(_name + ".Endpoints"), true); foreach(EndpointI endp in endpoints) { IncomingConnectionFactory factory = new IncomingConnectionFactory(instance, endp, this); _incomingConnectionFactories.Add(factory); } if(endpoints.Count == 0) { TraceLevels tl = instance_.traceLevels(); if(tl.network >= 2) { instance_.initializationData().logger.trace(tl.networkCat, "created adapter `" + _name + "' without endpoints"); } } // // Parse published endpoints. // _publishedEndpoints = parsePublishedEndpoints(); } if(properties.getProperty(_name + ".Locator").Length > 0) { setLocator(LocatorPrxHelper.uncheckedCast( instance_.proxyFactory().propertyToProxy(_name + ".Locator"))); } else { setLocator(instance_.referenceFactory().getDefaultLocator()); } } catch(LocalException) { destroy(); throw; } }
public void invoke(ServantManager servantManager, BasicStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // current_.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(); } current_.facet = facetPath[0]; } else { current_.facet = ""; } current_.operation = _is.readString(); current_.mode = (Ice.OperationMode)(int) _is.readByte(); current_.ctx = new Dictionary <string, string>(); int sz = _is.readSize(); while (sz-- > 0) { string first = _is.readString(); string second = _is.readString(); current_.ctx[first] = second; } Ice.Instrumentation.CommunicatorObserver obsv = instance_.getObserver(); if (obsv != null) { // Read the encapsulation size. int size = _is.readInt(); _is.pos(_is.pos() - 4); observer_ = obsv.getDispatchObserver(current_, _is.pos() - start + size); if (observer_ != null) { observer_.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if (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 (Ice.UserException ex) { Ice.EncodingVersion encoding = _is.skipEncaps(); // Required for batch requests. if (observer_ != null) { observer_.userException(); } if (response_) { os_.writeByte(ReplyStatus.replyUserException); os_.startWriteEncaps(encoding, Ice.FormatType.DefaultFormat); os_.writeUserException(ex); os_.endWriteEncaps(); if (observer_ != null) { observer_.reply(os_.size() - Protocol.headerSize - 4); } connection_.sendResponse(os_, compress_); } else { connection_.sendNoResponse(); } if (observer_ != null) { observer_.detach(); observer_ = null; } connection_ = null; return; } catch (System.Exception ex) { _is.skipEncaps(); // Required for batch requests. handleException__(ex); return; } } } } try { if (servant_ != null) { // // DispatchAsync is a "pseudo dispatch status", used internally only // to indicate async dispatch. // if (servant_.dispatch__(this, current_) == Ice.DispatchStatus.DispatchAsync) { // // If this was an asynchronous dispatch, we're done here. // return; } if (locator_ != null && !servantLocatorFinished__()) { return; } } else { // // Skip the input parameters, this is required for reading // the next batch request if dispatching batch requests. // _is.skipEncaps(); if (servantManager != null && servantManager.hasServant(current_.id)) { throw new Ice.FacetNotExistException(current_.id, current_.facet, current_.operation); } else { throw new Ice.ObjectNotExistException(current_.id, current_.facet, current_.operation); } } } catch (System.Exception ex) { if (servant_ != null && locator_ != null && !servantLocatorFinished__()) { return; } handleException__(ex); return; } // // Don't put the code below into the try block above. Exceptions // in the code below are considered fatal, and must propagate to // the caller of this operation. // Debug.Assert(connection_ != null); if (response_) { if (observer_ != null) { observer_.reply(os_.size() - Protocol.headerSize - 4); } connection_.sendResponse(os_, compress_); } else { connection_.sendNoResponse(); } if (observer_ != null) { observer_.detach(); observer_ = null; } connection_ = null; }
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 void invoke(ServantManager servantManager, Ice.InputStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // current_.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(); } current_.facet = facetPath[0]; } else { current_.facet = ""; } current_.operation = _is.readString(); current_.mode = (Ice.OperationMode)(int)_is.readByte(); current_.ctx = new Dictionary<string, string>(); int sz = _is.readSize(); while(sz-- > 0) { string first = _is.readString(); string second = _is.readString(); current_.ctx[first] = second; } Ice.Instrumentation.CommunicatorObserver obsv = instance_.initializationData().observer; if(obsv != null) { // Read the encapsulation size. int size = _is.readInt(); _is.pos(_is.pos() - 4); observer_ = obsv.getDispatchObserver(current_, _is.pos() - start + size); if(observer_ != null) { observer_.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if(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(Ice.UserException ex) { Ice.EncodingVersion encoding = _is.skipEncapsulation(); // Required for batch requests. if(observer_ != null) { observer_.userException(); } if(response_) { os_.writeByte(ReplyStatus.replyUserException); os_.startEncapsulation(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_, false); } else { responseHandler_.sendNoResponse(); } if(observer_ != null) { observer_.detach(); observer_ = null; } responseHandler_ = null; return; } catch(System.Exception ex) { _is.skipEncapsulation(); // Required for batch requests. handleException__(ex, false); return; } } } } try { if(servant_ != null) { // // DispatchAsync is a "pseudo dispatch status", used internally only // to indicate async dispatch. // if(servant_.dispatch__(this, current_) == Ice.DispatchStatus.DispatchAsync) { // // If this was an asynchronous dispatch, we're done here. // return; } if(locator_ != null && !servantLocatorFinished__(false)) { return; } } else { // // Skip the input parameters, this is required for reading // the next batch request if dispatching batch requests. // _is.skipEncapsulation(); if(servantManager != null && servantManager.hasServant(current_.id)) { throw new Ice.FacetNotExistException(current_.id, current_.facet, current_.operation); } else { throw new Ice.ObjectNotExistException(current_.id, current_.facet, current_.operation); } } } catch(System.Exception ex) { if(servant_ != null && locator_ != null && !servantLocatorFinished__(false)) { return; } handleException__(ex, false); return; } // // Don't put the code below into the try block above. Exceptions // in the code below are considered fatal, and must propagate to // the caller of this operation. // Debug.Assert(responseHandler_ != null); if(response_) { if(observer_ != null) { observer_.reply(os_.size() - Protocol.headerSize - 4); } responseHandler_.sendResponse(current_.requestId, os_, compress_, false); } else { responseHandler_.sendNoResponse(); } if(observer_ != null) { observer_.detach(); observer_ = null; } responseHandler_ = null; }
public void invoke(ServantManager servantManager) { // // Read the current. // current_.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(); } current_.facet = facetPath[0]; } else { current_.facet = ""; } current_.operation = _is.readString(); current_.mode = (Ice.OperationMode)(int)_is.readByte(); current_.ctx = new Dictionary<string, string>(); int sz = _is.readSize(); while(sz-- > 0) { string first = _is.readString(); string second = _is.readString(); current_.ctx[first] = second; } if(response_) { Debug.Assert(os_.size() == Protocol.headerSize + 4); // Reply status position. os_.writeByte(ReplyStatus.replyOK); os_.startWriteEncaps(); } byte replyStatus = ReplyStatus.replyOK; Ice.DispatchStatus dispatchStatus = Ice.DispatchStatus.DispatchOK; // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if(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(Ice.UserException ex) { os_.writeUserException(ex); replyStatus = ReplyStatus.replyUserException; } catch(System.Exception ex) { handleException__(ex); return; } } } } if(servant_ != null) { try { Debug.Assert(replyStatus == ReplyStatus.replyOK); dispatchStatus = servant_.dispatch__(this, current_); if(dispatchStatus == Ice.DispatchStatus.DispatchUserException) { replyStatus = ReplyStatus.replyUserException; } if(dispatchStatus != Ice.DispatchStatus.DispatchAsync) { if(locator_ != null && !servantLocatorFinished__()) { return; } } } catch(System.Exception ex) { if(locator_ != null && !servantLocatorFinished__()) { return; } handleException__(ex); return; } } else if(replyStatus == ReplyStatus.replyOK) { if(servantManager != null && servantManager.hasServant(current_.id)) { replyStatus = ReplyStatus.replyFacetNotExist; } else { replyStatus = ReplyStatus.replyObjectNotExist; } } // // Don't put the code below into the try block above. Exceptions // in the code below are considered fatal, and must propagate to // the caller of this operation. // // // Async dispatch // if(dispatchStatus == Ice.DispatchStatus.DispatchAsync) { // // If this was an asynchronous dispatch, we're done // here. // return; } Debug.Assert(connection_ != null); if(response_) { os_.endWriteEncaps(); if(replyStatus != ReplyStatus.replyOK && replyStatus != ReplyStatus.replyUserException) { Debug.Assert(replyStatus == ReplyStatus.replyObjectNotExist || replyStatus == ReplyStatus.replyFacetNotExist); os_.resize(Protocol.headerSize + 4, false); // Reply status position. os_.writeByte(replyStatus); current_.id.write__(os_); // // For compatibility with the old FacetPath. // if(current_.facet == null || current_.facet.Length == 0) { os_.writeStringSeq(null); } else { string[] facetPath2 = { current_.facet }; os_.writeStringSeq(facetPath2); } os_.writeString(current_.operation); } else { int save = os_.pos(); os_.pos(Protocol.headerSize + 4); // Reply status position. os_.writeByte(replyStatus); os_.pos(save); } connection_.sendResponse(os_, compress_); } else { connection_.sendNoResponse(); } connection_ = null; }
public void setAdapter(ObjectAdapter adapter) { lock(this) { if(_state <= StateNotValidated || _state >= StateClosing) { return; } _adapter = adapter; if(_adapter != null) { _servantManager = ((ObjectAdapterI) _adapter).getServantManager(); if(_servantManager == null) { _adapter = null; } } else { _servantManager = null; } // // We never change the thread pool with which we were initially // registered, even if we add or remove an object adapter. // } }
internal ConnectionI(Communicator communicator, IceInternal.Instance instance, IceInternal.ACMMonitor monitor, IceInternal.Transceiver transceiver, IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapterI adapter) { _communicator = communicator; _instance = instance; _monitor = monitor; _transceiver = transceiver; _desc = transceiver.ToString(); _type = transceiver.protocol(); _connector = connector; _endpoint = endpoint; _adapter = adapter; InitializationData initData = instance.initializationData(); _logger = initData.logger; // Cached for better performance. _traceLevels = instance.traceLevels(); // Cached for better performance. _timer = instance.timer(); _writeTimeout = new TimeoutCallback(this); _writeTimeoutScheduled = false; _readTimeout = new TimeoutCallback(this); _readTimeoutScheduled = false; _warn = initData.properties.getPropertyAsInt("Ice.Warn.Connections") > 0; _warnUdp = initData.properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0; _cacheBuffers = instance.cacheMessageBuffers() > 0; if(_monitor != null && _monitor.getACM().timeout > 0) { _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis(); } else { _acmLastActivity = -1; } _nextRequestId = 1; _messageSizeMax = adapter != null ? adapter.messageSizeMax() : instance.messageSizeMax(); _batchRequestQueue = new IceInternal.BatchRequestQueue(instance, _endpoint.datagram()); _readStream = new InputStream(instance, Util.currentProtocolEncoding); _readHeader = false; _readStreamPos = -1; _writeStream = new OutputStream(instance, Util.currentProtocolEncoding); _writeStreamPos = -1; _dispatchCount = 0; _state = StateNotInitialized; _compressionLevel = initData.properties.getPropertyAsIntWithDefault("Ice.Compression.Level", 1); if(_compressionLevel < 1) { _compressionLevel = 1; } else if(_compressionLevel > 9) { _compressionLevel = 9; } if(adapter != null) { _servantManager = adapter.getServantManager(); } try { if(adapter != null) { _threadPool = adapter.getThreadPool(); } else { _threadPool = instance.clientThreadPool(); } _threadPool.initialize(this); } catch(LocalException) { throw; } catch(System.Exception ex) { throw new SyscallException(ex); } }
public void invoke(ServantManager servantManager, Ice.InputStream stream) { _is = stream; int start = _is.pos(); // // Read the current. // _current.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(); } _current.facet = facetPath[0]; } else { _current.facet = ""; } _current.operation = _is.readString(); _current.mode = (Ice.OperationMode)(int) _is.readByte(); _current.ctx = new Dictionary <string, string>(); int sz = _is.readSize(); while (sz-- > 0) { string first = _is.readString(); string second = _is.readString(); _current.ctx[first] = second; } Ice.Instrumentation.CommunicatorObserver obsv = _instance.initializationData().observer; if (obsv != null) { // Read the encapsulation size. int size = _is.readInt(); _is.pos(_is.pos() - 4); _observer = obsv.getDispatchObserver(_current, _is.pos() - start + size); if (_observer != null) { _observer.attach(); } } // // Don't put the code above into the try block below. Exceptions // in the code above are considered fatal, and must propagate to // the caller of this operation. // if (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) { Debug.Assert(_locator != null); try { _servant = _locator.locate(_current, out _cookie); } catch (System.Exception ex) { skipReadParams(); // Required for batch requests. handleException(ex, false); return; } } } } if (_servant == null) { try { // // Skip the input parameters, this is required for reading // the next batch request if dispatching batch requests. // _is.skipEncapsulation(); if (servantManager != null && servantManager.hasServant(_current.id)) { throw new Ice.FacetNotExistException(_current.id, _current.facet, _current.operation); } else { throw new Ice.ObjectNotExistException(_current.id, _current.facet, _current.operation); } } catch (System.Exception ex) { handleException(ex, false); return; } } try { Task <Ice.OutputStream> task = _servant.dispatch__(this, _current); if (task == null) { completed(null, false); } else { if (task.IsCompleted) { _os = task.GetAwaiter().GetResult(); // Get the response completed(null, false); } else { task.ContinueWith((Task <Ice.OutputStream> t) => { try { _os = t.GetAwaiter().GetResult(); completed(null, true); // true = asynchronous } catch (Exception ex) { completed(ex, true); // true = asynchronous } }, TaskContinuationOptions.ExecuteSynchronously); } } } catch (System.Exception ex) { completed(ex, false); } }
private void invokeAll(BasicStream os, int requestId, int batchRequestNum) { if (batchRequestNum > 0) { os.pos(Protocol.requestBatchHdr.Length); } else { os.pos(Protocol.requestHdr.Length); } if (_traceLevels.protocol >= 1) { fillInValue(os, 10, os.size()); if (requestId > 0) { fillInValue(os, Protocol.headerSize, requestId); } else if (batchRequestNum > 0) { fillInValue(os, Protocol.headerSize, batchRequestNum); } TraceUtil.traceSend(os, _logger, _traceLevels); } int invokeNum = batchRequestNum > 0 ? batchRequestNum : 1; ServantManager servantManager = _adapter.getServantManager(); try { while (invokeNum > 0) { // // Increase the direct count for the dispatch. We increase it again here for // each dispatch. It's important for the direct count to be > 0 until the last // collocated request response is sent to make sure the thread pool isn't // destroyed before. // try { _adapter.incDirectCount(); } catch (Ice.ObjectAdapterDeactivatedException ex) { handleException(requestId, ex, false); break; } Incoming @in = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0, requestId); @in.invoke(servantManager, os); --invokeNum; } } catch (Ice.LocalException ex) { invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception } _adapter.decDirectCount(); }