コード例 #1
0
        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);
        }
コード例 #2
0
 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;
 }
コード例 #3
0
 public OutgoingAsyncT(Ice.IObjectPrx prx,
                       IOutgoingAsyncCompletionCallback completionCallback,
                       Ice.OutputStream?os = null,
                       Ice.InputStream?iss = null) :
     base(prx, completionCallback, os, iss)
 {
 }
コード例 #4
0
 public ConnectRequestHandler(Reference @ref, Ice.IObjectPrx proxy)
 {
     _reference      = @ref;
     _response       = _reference.getMode() == Ice.InvocationMode.Twoway;
     _proxy          = proxy;
     _initialized    = false;
     _flushing       = false;
     _requestHandler = this;
 }
コード例 #5
0
 public RequestHandler connect(Ice.IObjectPrx proxy)
 {
     lock (this)
     {
         if (!initialized())
         {
             _proxies.Add(proxy);
         }
         return(_requestHandler);
     }
 }
コード例 #6
0
 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;
 }
コード例 #7
0
ファイル: ObserverHelper.cs プロジェクト: yuwenyong/ice
 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);
 }
コード例 #8
0
 GetInvocationObserver(Ice.IObjectPrx p, string op, Dictionary <string, string> ctx)
 {
     lock (this)
     {
         if (invocationObserver == null)
         {
             invocationObserver = new InvocationObserver();
             invocationObserver.reset();
         }
         return(invocationObserver);
     }
 }
コード例 #9
0
 SetAdapterDirectProxyAsync(string adapter, Ice.IObjectPrx obj, Ice.Current current)
 {
     if (obj != null)
     {
         _adapters[adapter] = obj;
     }
     else
     {
         _adapters.Remove(adapter);
     }
     return(null);
 }
コード例 #10
0
ファイル: ServerLocatorRegistry.cs プロジェクト: yssource/ice
 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));
 }
コード例 #11
0
 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);
 }
コード例 #12
0
ファイル: AllTests.cs プロジェクト: motuii/ice
            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());
            }
コード例 #13
0
ファイル: RequestHandlerFactory.cs プロジェクト: xingx001/ice
        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)));
        }
コード例 #14
0
ファイル: ObserverHelper.cs プロジェクト: xingx001/ice
        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);
        }
コード例 #15
0
ファイル: ObserverHelper.cs プロジェクト: yzun/ice
        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);
        }
コード例 #16
0
ファイル: ObserverHelper.cs プロジェクト: xingx001/ice
 public static InvocationObserver get(Ice.IObjectPrx proxy, string op)
 {
     return(get(proxy, op, null));
 }
コード例 #17
0
ファイル: AllTests.cs プロジェクト: shawvi/ice
    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");
        }
    }
コード例 #18
0
ファイル: MyDerivedClassI.cs プロジェクト: xingx001/ice
 public Ice.IObjectPrx echo(Ice.IObjectPrx obj, Ice.Current c)
 {
     return(obj);
 }
コード例 #19
0
 public Task <Ice.IObjectPrx> echoAsync(Ice.IObjectPrx obj, Ice.Current c)
 {
     return(Task.FromResult(obj));
 }
コード例 #20
0
            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);
            }
コード例 #21
0
 public void addObject(Ice.IObjectPrx obj)
 {
     _objects[obj.Identity] = obj;
 }
コード例 #22
0
 public void addObject(Ice.IObjectPrx obj, Ice.Current current)
 {
     addObject(obj);
 }
コード例 #23
0
 public ProxyGetConnection(Ice.IObjectPrx prx, OutgoingAsyncCompletionCallback completionCallback) :
     base(prx, completionCallback)
 {
 }
コード例 #24
0
 getInvocationObserver(Ice.IObjectPrx p, string o, Dictionary <string, string> c)
 {
     return(invocationObserver);
 }