public ProxyGetConnection(Ice.ObjectPrxHelperBase prx, string operation, ProxyTwowayCallback <Ice.Callback_Object_ice_getConnection> cb, object cookie) : base(prx, operation, cookie) { observer_ = ObserverHelper.get(prx, operation); _completed = cb; }
public TwowayOutgoingAsync(Ice.ObjectPrxHelperBase prx, string operation, ProxyTwowayCallback <T> cb, object cookie) : base(prx, operation, cookie) { Debug.Assert(cb != null); _completed = cb; }
public OutgoingAsync(Ice.ObjectPrxHelperBase prx, OutgoingAsyncCompletionCallback completionCallback, Ice.OutputStream os = null, Ice.InputStream iss = null) : base(prx, completionCallback, os, iss) { encoding_ = Protocol.getCompatibleEncoding(proxy_.iceReference().getEncoding()); synchronous_ = false; }
public RequestHandler connect(Ice.ObjectPrxHelperBase proxy) { lock (this) { try { if (!initialized()) { _proxies.Add(proxy); } } catch (Ice.LocalException ex) { // // Only throw if the connection didn't get established. If // it died after being established, we allow the caller to // retry the connection establishment by not throwing here. // if (_connection == null) { throw ex; } } return(proxy.setRequestHandler__(_requestHandler)); } }
public OnewayOutgoingAsync(Ice.ObjectPrxHelperBase prx, string operation, ProxyOnewayCallback <T> cb, object cookie, BasicStream iss, BasicStream os) : base(prx, operation, cookie, iss, os) { Debug.Assert(cb != null); _completed = cb; }
public OutgoingAsyncT(Ice.ObjectPrxHelperBase prx, OutgoingAsyncCompletionCallback completionCallback, Ice.OutputStream os = null, Ice.InputStream iss = null) : base(prx, completionCallback, os, iss) { }
protected ProxyOutgoingAsyncBase(Ice.ObjectPrxHelperBase prx, string op, object cookie, BasicStream os) : base(prx.ice_getCommunicator(), prx.reference__().getInstance(), op, cookie, os) { proxy_ = prx; mode_ = Ice.OperationMode.Normal; _cnt = 0; _sent = false; }
public ConnectRequestHandler(Reference @ref, Ice.ObjectPrx proxy) { _reference = @ref; _response = _reference.getMode() == Reference.Mode.ModeTwoway; _proxy = (Ice.ObjectPrxHelperBase)proxy; _initialized = false; _flushing = false; _requestHandler = this; }
protected ProxyOutgoingAsyncBase(Ice.ObjectPrxHelperBase prx, OutgoingAsyncCompletionCallback completionCallback, Ice.OutputStream os = null, Ice.InputStream iss = null) : base(prx.iceReference().getInstance(), completionCallback, os, iss) { proxy_ = prx; mode_ = Ice.OperationMode.Normal; _cnt = 0; _sent = false; }
public RequestHandler connect(Ice.ObjectPrxHelperBase proxy) { lock (this) { if (!initialized()) { _proxies.Add(proxy); } return(_requestHandler); } }
public string proxyToString(Ice.ObjectPrx proxy) { if (proxy != null) { Ice.ObjectPrxHelperBase h = (Ice.ObjectPrxHelperBase)proxy; return(h.reference__().ToString()); } else { return(""); } }
proxyToProperty(Ice.ObjectPrx proxy, string prefix) { if (proxy != null) { Ice.ObjectPrxHelperBase h = (Ice.ObjectPrxHelperBase)proxy; return(h.reference__().toProperty(prefix)); } else { return(new Dictionary <string, string>()); } }
finishRequest(Reference @ref, List <Reference> wellKnownRefs, Ice.ObjectPrx proxy, bool notRegistered) { Ice.ObjectPrxHelperBase @base = proxy as Ice.ObjectPrxHelperBase; if (proxy == null || @base.iceReference().isIndirect()) { // // Remove the cached references of well-known objects for which we tried // to resolved the endpoints if these endpoints are empty. // foreach (Reference r in wellKnownRefs) { _table.removeObjectReference(r.getIdentity()); } } if ([email protected]()) { if (proxy != null && [email protected]().isIndirect()) { // Cache the adapter endpoints. _table.addAdapterEndpoints(@ref.getAdapterId(), @base.iceReference().getEndpoints()); } else if (notRegistered) // If the adapter isn't registered anymore, remove it from the cache. { _table.removeAdapterEndpoints(@ref.getAdapterId()); } lock (this) { Debug.Assert(_adapterRequests.ContainsKey(@ref.getAdapterId())); _adapterRequests.Remove(@ref.getAdapterId()); } } else { if (proxy != null && [email protected]().isWellKnown()) { // Cache the well-known object reference. _table.addObjectReference(@ref.getIdentity(), @base.iceReference()); } else if (notRegistered) // If the well-known object isn't registered anymore, remove it from the cache. { _table.removeObjectReference(@ref.getIdentity()); } lock (this) { Debug.Assert(_objectRequests.ContainsKey(@ref.getIdentity())); _objectRequests.Remove(@ref.getIdentity()); } } }
public Ice.ObjectPrx referenceToProxy(Reference r) { if (r != null) { Ice.ObjectPrxHelperBase proxy = new Ice.ObjectPrxHelperBase(); proxy.setup(r); return(proxy); } else { return(null); } }
public Ice.ObjectPrx referenceToProxy(Reference r) { if(r != null) { Ice.ObjectPrxHelperBase proxy = new Ice.ObjectPrxHelperBase(); proxy.setup(r); return proxy; } else { return null; } }
public ConnectRequestHandler(Reference @ref, Ice.ObjectPrx proxy, Ice.ObjectDelM_ del) { _reference = @ref; _response = _reference.getMode() == Reference.Mode.ModeTwoway; _proxy = (Ice.ObjectPrxHelperBase)proxy; _delegate = del; _batchAutoFlush = @ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault( "Ice.BatchAutoFlush", 1) > 0 ? true : false; _initialized = false; _flushing = false; _batchRequestInProgress = false; _batchRequestsSize = Protocol.requestBatchHdr.Length; _batchStream = new BasicStream(@ref.getInstance(), _batchAutoFlush); _updateRequestHandler = false; }
public void proxyToStream(Ice.ObjectPrx proxy, BasicStream s) { if (proxy != null) { Ice.ObjectPrxHelperBase h = (Ice.ObjectPrxHelperBase)proxy; Reference r = h.reference__(); r.getIdentity().write__(s); r.streamWrite(s); } else { Ice.Identity ident = new Ice.Identity(); ident.name = ""; ident.category = ""; ident.write__(s); } }
getRequestHandler(RoutableReference rf, Ice.ObjectPrxHelperBase proxy) { if (rf.getCollocationOptimized()) { Ice.ObjectAdapter adapter = _instance.objectAdapterFactory().findObjectAdapter(proxy); if (adapter != null) { return(proxy.iceSetRequestHandler(new CollocatedRequestHandler(rf, adapter))); } } bool connect = false; ConnectRequestHandler handler; if (rf.getCacheConnection()) { lock (this) { if (!_handlers.TryGetValue(rf, out handler)) { handler = new ConnectRequestHandler(rf, proxy); _handlers.Add(rf, handler); connect = true; } } } else { handler = new ConnectRequestHandler(rf, proxy); connect = true; } if (connect) { rf.getConnection(handler); } return(proxy.iceSetRequestHandler(handler.connect(proxy))); }
public ProxyFlushBatch(Ice.ObjectPrxHelperBase prx, string operation, object cookie) : base(prx, operation, cookie) { observer_ = ObserverHelper.get(prx, operation); _batchRequestNum = prx.getBatchRequestQueue__().swap(os_); }
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 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); } }
public ProxyGetConnection(Ice.ObjectPrxHelperBase prx, OutgoingAsyncCompletionCallback completionCallback) : base(prx, completionCallback) { }
private static void writeValue(string name, object val, Dictionary <Ice.Object, object> objectTable, OutputBase output) { if (val == null) { writeName(name, output); output.print("(null)"); } else { System.Type c = val.GetType(); if (c.Equals(typeof(byte)) || c.Equals(typeof(short)) || c.Equals(typeof(int)) || c.Equals(typeof(long)) || c.Equals(typeof(double)) || c.Equals(typeof(float)) || c.Equals(typeof(bool))) { writeName(name, output); output.print(val.ToString()); } else if (c.Equals(typeof(string))) { writeName(name, output); output.print("\""); output.print(val.ToString()); output.print("\""); } else if (val is IList) { int n = 0; IEnumerator i = ((IList)val).GetEnumerator(); while (i.MoveNext()) { string elem = (name != null ? name : ""); elem += "[" + n++ + "]"; writeValue(elem, i.Current, objectTable, output); } } else if (val is IDictionary) { foreach (DictionaryEntry entry in (IDictionary)val) { string elem = name != null ? name + "." : ""; writeValue(elem + "key", entry.Key, objectTable, output); writeValue(elem + "value", entry.Value, objectTable, output); } } else if (val is Ice.ObjectPrxHelperBase) { writeName(name, output); Ice.ObjectPrxHelperBase proxy = (Ice.ObjectPrxHelperBase)val; output.print(proxy.iceReference().ToString()); } else if (val is Ice.Object) { // // Check for recursion. // if (objectTable != null && objectTable.ContainsKey((Ice.Object)val)) { writeName(name, output); output.print("(recursive)"); } else { if (objectTable == null) { objectTable = new Dictionary <Ice.Object, object>(); } objectTable[(Ice.Object)val] = null; writeFields(name, val, c, objectTable, output); } } else if (c.IsEnum) { writeName(name, output); output.print(val.ToString()); } else { // // Must be struct. // writeFields(name, val, c, objectTable, output); } } }
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(); } }
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(); } }