public Ice.ObjectAdapter findObjectAdapter(Ice.IObjectPrx proxy) { List <Ice.ObjectAdapter> adapters; lock (this) { if (_communicator == null) { return(null); } adapters = new List <Ice.ObjectAdapter>(_adapters); } foreach (Ice.ObjectAdapter adapter in adapters) { try { if (adapter.isLocal(proxy)) { return(adapter); } } catch (Ice.ObjectAdapterDeactivatedException) { // Ignore. } } return(null); }
public OutgoingAsync(Ice.IObjectPrx prx, IOutgoingAsyncCompletionCallback completionCallback, Ice.OutputStream?os = null, Ice.InputStream?iss = null) : base(prx, completionCallback, os, iss) { Encoding = Protocol.getCompatibleEncoding(Proxy.IceReference.GetEncoding()); Synchronous = false; }
public OutgoingAsyncT(Ice.IObjectPrx prx, IOutgoingAsyncCompletionCallback completionCallback, Ice.OutputStream?os = null, Ice.InputStream?iss = null) : base(prx, completionCallback, os, iss) { }
public ConnectRequestHandler(Reference @ref, Ice.IObjectPrx proxy) { _reference = @ref; _response = _reference.getMode() == Ice.InvocationMode.Twoway; _proxy = proxy; _initialized = false; _flushing = false; _requestHandler = this; }
public RequestHandler connect(Ice.IObjectPrx proxy) { lock (this) { if (!initialized()) { _proxies.Add(proxy); } return(_requestHandler); } }
protected ProxyOutgoingAsyncBase(Ice.IObjectPrx prx, IOutgoingAsyncCompletionCallback completionCallback, Ice.OutputStream?os = null, Ice.InputStream?iss = null) : base(prx.Communicator, completionCallback, os, iss) { Proxy = prx; Mode = Ice.OperationMode.Normal; _cnt = 0; _sent = false; }
internal static IInvocationObserver?GetInvocationObserver(Ice.IObjectPrx proxy, string op, IReadOnlyDictionary <string, string> context) { if (proxy.Communicator.Observer is ICommunicatorObserver communicatorObserver) { IInvocationObserver?observer = communicatorObserver.GetInvocationObserver(proxy, op, context); observer?.Attach(); return(observer); } return(null); }
GetInvocationObserver(Ice.IObjectPrx p, string op, Dictionary <string, string> ctx) { lock (this) { if (invocationObserver == null) { invocationObserver = new InvocationObserver(); invocationObserver.reset(); } return(invocationObserver); } }
SetAdapterDirectProxyAsync(string adapter, Ice.IObjectPrx obj, Ice.Current current) { if (obj != null) { _adapters[adapter] = obj; } else { _adapters.Remove(adapter); } return(null); }
public ValueTask SetAdapterDirectProxyAsync(string adapter, Ice.IObjectPrx obj, Ice.Current current) { if (obj != null) { _adapters[adapter] = obj; } else { _adapters.Remove(adapter); } return(new ValueTask(Task.CompletedTask)); }
SetReplicatedAdapterDirectProxyAsync(string adapter, string replica, Ice.IObjectPrx obj, Ice.Current current) { if (obj != null) { _adapters[adapter] = obj; _adapters[replica] = obj; } else { _adapters.Remove(adapter); _adapters.Remove(replica); } return(null); }
private static Connection connect(Ice.IObjectPrx prx) { int nRetry = 10; while (--nRetry > 0) { try { prx.GetConnection(); break; } catch (ConnectTimeoutException) { // Can sporadically occur with slow machines } } return(prx.GetConnection()); }
getRequestHandler(RoutableReference rf, Ice.IObjectPrx proxy) { if (rf.getCollocationOptimized()) { Ice.ObjectAdapter adapter = _communicator.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 static InvocationObserver get(Ice.IObjectPrx proxy, string op, Dictionary <string, string> context) { CommunicatorObserver obsv = proxy.Communicator.initializationData().observer; if (obsv != null) { InvocationObserver observer; if (context == null) { observer = obsv.getInvocationObserver(proxy, op, _emptyContext); } else { observer = obsv.getInvocationObserver(proxy, op, context); } if (observer != null) { observer.attach(); } return(observer); } return(null); }
public static IInvocationObserver?get(Ice.IObjectPrx proxy, string op, Dictionary <string, string>?context) { ICommunicatorObserver?obsv = proxy.Communicator.Observer; if (obsv != null) { IInvocationObserver observer; if (context == null) { observer = obsv.GetInvocationObserver(proxy, op, _emptyContext); } else { observer = obsv.GetInvocationObserver(proxy, op, context); } if (observer != null) { observer.Attach(); } return(observer); } return(null); }
public static InvocationObserver get(Ice.IObjectPrx proxy, string op) { return(get(proxy, op, null)); }
public static void allTests(Test.TestHelper helper, List <int> ports) { Ice.Communicator communicator = helper.communicator(); var output = helper.getWriter(); output.Write("testing stringToProxy... "); output.Flush(); string refString = "test"; for (int i = 0; i < ports.Count; i++) { refString += ":" + helper.getTestEndpoint(ports[i]); } Ice.IObjectPrx basePrx = Ice.IObjectPrx.Parse(refString, communicator); test(basePrx != null); output.WriteLine("ok"); output.Write("testing checked cast... "); output.Flush(); ITestIntfPrx obj = ITestIntfPrx.CheckedCast(basePrx); test(obj != null); test(obj.Equals(basePrx)); output.WriteLine("ok"); int oldPid = 0; bool ami = false; for (int i = 1, j = 0; i <= ports.Count; ++i, ++j) { if (j > 3) { j = 0; ami = !ami; } if (!ami) { output.Write("testing server #" + i + "... "); output.Flush(); int pid = obj.pid(); test(pid != oldPid); output.WriteLine("ok"); oldPid = pid; } else { output.Write("testing server #" + i + " with AMI... "); output.Flush(); var pid = obj.pidAsync().Result; test(pid != oldPid); output.WriteLine("ok"); oldPid = pid; } if (j == 0) { if (!ami) { output.Write("shutting down server #" + i + "... "); output.Flush(); obj.shutdown(); output.WriteLine("ok"); } else { output.Write("shutting down server #" + i + " with AMI... "); obj.shutdownAsync().Wait(); output.WriteLine("ok"); } } else if (j == 1 || i + 1 > ports.Count) { if (!ami) { output.Write("aborting server #" + i + "... "); output.Flush(); try { obj.abort(); test(false); } catch (Ice.ConnectionLostException) { output.WriteLine("ok"); } catch (Ice.ConnectFailedException) { output.WriteLine("ok"); } catch (Ice.TransportException) { output.WriteLine("ok"); } } else { output.Write("aborting server #" + i + " with AMI... "); output.Flush(); try { obj.abortAsync().Wait(); test(false); } catch (AggregateException ex) { exceptAbortI(ex.InnerException, output); } output.WriteLine("ok"); } } else if (j == 2 || j == 3) { if (!ami) { output.Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent call... "); output.Flush(); try { obj.idempotentAbort(); test(false); } catch (Ice.ConnectionLostException) { output.WriteLine("ok"); } catch (Ice.ConnectFailedException) { output.WriteLine("ok"); } catch (Ice.TransportException) { output.WriteLine("ok"); } } else { output.Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent AMI call... "); output.Flush(); try { obj.idempotentAbortAsync().Wait(); test(false); } catch (AggregateException ex) { exceptAbortI(ex.InnerException, output); } output.WriteLine("ok"); } ++i; } else { Debug.Assert(false); } } output.Write("testing whether all servers are gone... "); output.Flush(); try { obj.IcePing(); test(false); } catch (System.Exception) { output.WriteLine("ok"); } }
public Ice.IObjectPrx echo(Ice.IObjectPrx obj, Ice.Current c) { return(obj); }
public Task <Ice.IObjectPrx> echoAsync(Ice.IObjectPrx obj, Ice.Current c) { return(Task.FromResult(obj)); }
public static Test.ITestIntfPrx allTests(global::Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); var output = helper.getWriter(); output.Write("testing stringToProxy... "); output.Flush(); string @ref = "test:" + helper.getTestEndpoint(0); Ice.IObjectPrx @base = IObjectPrx.Parse(@ref, communicator); test(@base != null); output.WriteLine("ok"); output.Write("testing checked cast... "); output.Flush(); var obj = Test.ITestIntfPrx.CheckedCast(@base); test(obj != null); test(obj.Equals(@base)); output.WriteLine("ok"); { output.Write("creating/destroying/recreating object adapter... "); output.Flush(); ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default"); try { communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default"); test(false); } catch (ArgumentException) { } adapter.Destroy(); // // Use a different port than the first adapter to avoid an "address already in use" error. // adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default"); adapter.Destroy(); output.WriteLine("ok"); } output.Write("creating/activating/deactivating object adapter in one operation... "); output.Flush(); obj.transient(); obj.transientAsync().Wait(); output.WriteLine("ok"); { output.Write("testing connection closure... "); output.Flush(); for (int i = 0; i < 10; ++i) { var comm = new Communicator(communicator.GetProperties()); IObjectPrx.Parse($"test:{helper.getTestEndpoint(0)}", communicator).IcePingAsync(); comm.destroy(); } output.WriteLine("ok"); } output.Write("testing object adapter published endpoints... "); output.Flush(); { communicator.SetProperty("PAdapter.PublishedEndpoints", "tcp -h localhost -p 12345 -t 30000"); var adapter = communicator.createObjectAdapter("PAdapter"); test(adapter.GetPublishedEndpoints().Length == 1); var endpt = adapter.GetPublishedEndpoints()[0]; test(endpt.ToString().Equals("tcp -h localhost -p 12345 -t 30000")); var prx = IObjectPrx.Parse("dummy:tcp -h localhost -p 12346 -t 20000:tcp -h localhost -p 12347 -t 10000", communicator); adapter.SetPublishedEndpoints(prx.Endpoints); test(adapter.GetPublishedEndpoints().Length == 2); test(Collections.Equals(adapter.CreateProxy(new Identity("dummy", "")).Endpoints, prx.Endpoints)); test(Collections.Equals(adapter.GetPublishedEndpoints(), prx.Endpoints)); adapter.RefreshPublishedEndpoints(); test(adapter.GetPublishedEndpoints().Length == 1); test(adapter.GetPublishedEndpoints()[0].Equals(endpt)); communicator.SetProperty("PAdapter.PublishedEndpoints", "tcp -h localhost -p 12345 -t 20000"); adapter.RefreshPublishedEndpoints(); test(adapter.GetPublishedEndpoints().Length == 1); test(adapter.GetPublishedEndpoints()[0].ToString().Equals("tcp -h localhost -p 12345 -t 20000")); adapter.Destroy(); test(adapter.GetPublishedEndpoints().Length == 0); } output.WriteLine("ok"); if (obj.GetConnection() != null) { output.Write("testing object adapter with bi-dir connection... "); output.Flush(); var adapter = communicator.createObjectAdapter(""); obj.GetConnection().setAdapter(adapter); obj.GetConnection().setAdapter(null); adapter.Deactivate(); try { obj.GetConnection().setAdapter(adapter); test(false); } catch (ObjectAdapterDeactivatedException) { } output.WriteLine("ok"); } output.Write("testing object adapter with router... "); output.Flush(); { var routerId = new Identity(); routerId.name = "router"; var router = IRouterPrx.UncheckedCast(@base.Clone(routerId, connectionId: "rc")); var adapter = communicator.createObjectAdapterWithRouter("", router); test(adapter.GetPublishedEndpoints().Length == 1); test(adapter.GetPublishedEndpoints()[0].ToString().Equals("tcp -h localhost -p 23456 -t 30000")); adapter.RefreshPublishedEndpoints(); test(adapter.GetPublishedEndpoints().Length == 1); test(adapter.GetPublishedEndpoints()[0].ToString().Equals("tcp -h localhost -p 23457 -t 30000")); try { adapter.SetPublishedEndpoints(router.Endpoints); test(false); } catch (ArgumentException) { // Expected. } adapter.Destroy(); try { routerId.name = "test"; router = IRouterPrx.UncheckedCast(@base.Clone(routerId)); communicator.createObjectAdapterWithRouter("", router); test(false); } catch (OperationNotExistException) { // Expected: the "test" object doesn't implement Ice::Router! } try { router = IRouterPrx.Parse($"test:{helper.getTestEndpoint(1)}", communicator); communicator.createObjectAdapterWithRouter("", router); test(false); } catch (ConnectFailedException) { } } output.WriteLine("ok"); output.Write("testing object adapter creation with port in use... "); output.Flush(); { var adapter1 = communicator.createObjectAdapterWithEndpoints("Adpt1", helper.getTestEndpoint(10)); try { communicator.createObjectAdapterWithEndpoints("Adpt2", helper.getTestEndpoint(10)); test(false); } catch (LocalException) { // Expected can't re-use the same endpoint. } adapter1.Destroy(); } output.WriteLine("ok"); output.Write("deactivating object adapter in the server... "); output.Flush(); obj.deactivate(); output.WriteLine("ok"); output.Write("testing whether server is gone... "); output.Flush(); try { obj.Clone(connectionTimeout: 100).IcePing(); // Use timeout to speed up testing on Windows test(false); } catch (LocalException) { output.WriteLine("ok"); } return(obj); }
public void addObject(Ice.IObjectPrx obj) { _objects[obj.Identity] = obj; }
public void addObject(Ice.IObjectPrx obj, Ice.Current current) { addObject(obj); }
public ProxyGetConnection(Ice.IObjectPrx prx, OutgoingAsyncCompletionCallback completionCallback) : base(prx, completionCallback) { }
getInvocationObserver(Ice.IObjectPrx p, string o, Dictionary <string, string> c) { return(invocationObserver); }