Exemple #1
0
 public void start(string name, Ice.Communicator communicator,  string[] args)
 {
     Console.WriteLine("STARTING Service: {0}", name);
     string prop =  communicator.getProperties().getProperty("IDHT.Master");
     bool isMasterNode = (prop == null)? false: prop.Equals("1");
     if (isMasterNode)
     {
         Console.WriteLine("Is master node");
     }
     _node = new DHTNodeI(communicator.getProperties().getProperty(name+".AdapterId"), isMasterNode, communicator);
     _adapter = communicator.createObjectAdapter(name);
     _adapter.add(_node, Ice.Util.stringToIdentity(Constants.SERVICE_NAME));
     _adapter.activate();
 }
Exemple #2
0
        public override async Task RunAsync(string[] args)
        {
            await Communicator.ActivateAsync();

            Communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = Communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("test-1", new Interceptor(new TestIntf(), compressed: true));
            adapter.Add("test-2", new Interceptor(new TestIntf(), compressed: false));
            await adapter.ActivateAsync();

            ServerReady();
            await Communicator.ShutdownComplete;
        }
Exemple #3
0
        public override async Task RunAsync(string[] args)
        {
            await Communicator.ActivateAsync();

            Communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = Communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("communicator", new RemoteCommunicator());
            await adapter.ActivateAsync();

            ServerReady();
            Communicator.SetProperty("Ice.PrintAdapterReady", "0");
            await Communicator.WaitForShutdownAsync();
        }
Exemple #4
0
        public override async Task RunAsync(string[] args)
        {
            Dictionary <string, string> properties = CreateTestProperties(ref args);

            properties["Ice.ServerIdleTime"]      = "30";
            await using Communicator communicator = Initialize(properties);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("communicator", new RemoteCommunicator());
            await adapter.ActivateAsync();

            ServerReady();
            await communicator.WaitForShutdownAsync();
        }
Exemple #5
0
            public override void run(string[] args)
            {
                using var communicator = initialize(createTestProperties(ref args),
                                                    typeIdNamespaces: new string[] { "Ice.scope.TypeId" });
                communicator.SetProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");

                adapter.Add(new I1(), "i1");
                adapter.Add(new I2(), "i2");
                adapter.Add(new I3(), "i3");
                adapter.Add(new I4(), "i4");
                adapter.Activate();
                serverReady();
                communicator.waitForShutdown();
            }
Exemple #6
0
        public override async Task RunAsync(string[] args)
        {
            await using Communicator communicator = Initialize(ref args);
            await communicator.ActivateAsync();

            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");
            var           initial = new InitialI(adapter);

            adapter.Add("initial", initial);
            await adapter.ActivateAsync();

            ServerReady();
            await communicator.WaitForShutdownAsync();
        }
Exemple #7
0
        public override async Task RunAsync(string[] args)
        {
            await Communicator.ActivateAsync();

            Communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = Communicator.CreateObjectAdapter("TestAdapter");
            var           initial = new InitialI(adapter);

            adapter.Add("initial", initial);
            await adapter.ActivateAsync();

            ServerReady();
            await Communicator.ShutdownComplete;
        }
Exemple #8
0
        public override async Task RunAsync(string[] args)
        {
            var properties = new Dictionary <string, string>();

            properties.ParseArgs(ref args, "TestAdapter");
            properties.Add("Test.Protocol", "ice1");

            await using Communicator communicator = Initialize(ref args, properties);
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add(communicator.GetProperty("Identity") ?? "test", new TestIntf());
            await adapter.ActivateAsync();

            await communicator.WaitForShutdownAsync();
        }
Exemple #9
0
        public override void Run(string[] args)
        {
            string[] typeIdNamespaces = new string[] { "Ice.exceptions.TypeId" };
            Dictionary <string, string> properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Connections"] = "0";
            properties["Ice.Warn.Dispatch"]    = "0";
            properties["Ice.MessageSizeMax"]   = "10"; // 10KB max
            using Communicator communicator    = Initialize(properties, typeIdNamespaces: typeIdNamespaces);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("thrower", new Thrower());
            AllTests.allTests(this);
        }
Exemple #10
0
            public override void run(string[] args)
            {
                Properties properties = createTestProperties(ref args);

                properties.setProperty("Ice.ServerIdleTime", "30");
                using (var communicator = initialize(properties))
                {
                    communicator.Properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(0));
                    ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
                    adapter.Add(new RemoteCommunicatorI(), "communicator");
                    adapter.Activate();
                    serverReady();
                    communicator.waitForShutdown();
                }
            }
Exemple #11
0
        public override async Task RunAsync(string[] args)
        {
            var properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Dispatch"]       = "0";
            await using Communicator communicator = Initialize(properties);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0) + " -t 2000");
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("Test", new TestIntfAsync());
            adapter.Add("Test2", new TestIntf2Async());
            await adapter.ActivateAsync();

            await communicator.WaitForShutdownAsync();
        }
Exemple #12
0
        public override async Task RunAsync(string[] args)
        {
            Dictionary <string, string>?properties = CreateTestProperties(ref args);

            // This test kills connections, so we don't want warnings.
            properties["Ice.Warn.Connections"] = "0";

            // The client sends large messages to cause the transport buffers to fill up.
            properties["Ice.IncomingFrameMaxSize"] = "20M";

            // Limit the recv buffer size, this test relies on the socket send() blocking after sending a given
            // amount of data.
            properties["Ice.TCP.RcvSize"] = "50K";

            await using Communicator communicator = Initialize(properties);
            await communicator.ActivateAsync();

            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            communicator.SetProperty("ControllerAdapter.Endpoints", GetTestEndpoint(1));

            var           schedulerPair = new ConcurrentExclusiveSchedulerPair(TaskScheduler.Default);
            ObjectAdapter adapter       = communicator.CreateObjectAdapter("TestAdapter",
                                                                           taskScheduler: schedulerPair.ExclusiveScheduler);

            adapter.Add("timeout", new Timeout());
            adapter.DispatchInterceptors = ImmutableList.Create <DispatchInterceptor>(
                (request, current, next, cancel) =>
            {
                if (current.Operation == "checkDeadline")
                {
                    if (request.BinaryContext.TryGetValue(10, out ReadOnlyMemory <byte> value))
                    {
                        current.Context["deadline"] = value.Read(istr => istr.ReadVarLong()).ToString();
                    }
                }
                return(next(request, current, cancel));
            });

            await adapter.ActivateAsync();

            ObjectAdapter controllerAdapter = communicator.CreateObjectAdapter("ControllerAdapter");

            controllerAdapter.Add("controller", new Controller(schedulerPair.ExclusiveScheduler));
            await controllerAdapter.ActivateAsync();

            ServerReady();
            await communicator.WaitForShutdownAsync();
        }
Exemple #13
0
        /// <summary>
        /// Solves the maze.
        /// </summary>
        /// <param name="name">The maze's name.</param>
        /// <param name="algorithm">The algorithm type to solve the maze.</param>
        /// <returns></returns>
        public string SolveMaze(string name, ISearcher <Position> algorithm)
        {
            Solution <Position> sol;

            if (!this.solutions.ContainsKey(mazes[name]))
            {
                ObjectAdapter mazeAdapter = new ObjectAdapter(mazes[name]);
                sol = algorithm.Search(mazeAdapter);
                sol.EvaluatedNodes = algorithm.GetNumberOfNodesEvaluated();
                this.solutions.Add(this.mazes[name], sol);
            }

            sol = this.solutions[this.mazes[name]];
            StringBuilder    way = new StringBuilder(string.Empty);
            State <Position> first, second;

            for (int i = 0; i < sol.Trace.Count() - 1; ++i)
            {
                first  = sol.Trace.ElementAt(i);
                second = sol.Trace.ElementAt(i + 1);

                // left
                if (first.myState.Col < second.myState.Col)
                {
                    way.Append(0);
                }

                // right
                else if (first.myState.Col > second.myState.Col)
                {
                    way.Append(1);
                }

                // up
                else if (first.myState.Row < second.myState.Row)
                {
                    way.Append(2);
                }

                // down
                else if (first.myState.Row > second.myState.Row)
                {
                    way.Append(3);
                }
            }

            return(way.ToString());
        }
Exemple #14
0
        public override async Task RunAsync(string[] args)
        {
            await Communicator.ActivateAsync();

            Communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = Communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("initial", new Initial(adapter));
            adapter.Add("F21", new F2());
            var uoet = new UnexpectedObjectExceptionTest();

            adapter.Add("uoet", uoet);

            await AllTests.RunAsync(this);
        }
Exemple #15
0
        public override async Task RunAsync(string[] args)
        {
            await using Communicator communicator = Initialize(ref args);
            await communicator.ActivateAsync();

            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("test", new Interface2());
            await adapter.ActivateAsync();

            ServerReady();

            await communicator.ShutdownComplete;
        }
Exemple #16
0
        public override async Task RunAsync(string[] args)
        {
            var properties = CreateTestProperties(ref args);

            // We don't want connection warnings because of the timeout test.
            properties["Ice.Warn.Connections"] = "0";
            await using var communicator       = Initialize(properties);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("test", new AsyncMyDerivedClass());
            await adapter.ActivateAsync();

            ServerReady();
            await communicator.WaitForShutdownAsync();
        }
Exemple #17
0
 internal void RemoveObjectAdapter(ObjectAdapter adapter)
 {
     // Called by the object adapter to remove itself once destroyed.
     lock (_mutex)
     {
         if (_shutdownTask == null)
         {
             _adapters.Remove(adapter);
             if (adapter.Name.Length > 0)
             {
                 _adapterNamesInUse.Remove(adapter.Name);
             }
         }
         // TODO clear outgoing connections adapter?
     }
 }
Exemple #18
0
        public override async Task RunAsync(string[] args)
        {
            Dictionary <string, string> properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Connections"]     = "0";
            properties["Ice.Warn.Dispatch"]        = "0";
            properties["Ice.IncomingFrameMaxSize"] = "10K";
            await using Communicator communicator  = Initialize(properties);
            await communicator.ActivateAsync();

            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("thrower", new Thrower());
            _ = await AllTests.RunAsync(this);
        }
Exemple #19
0
 /// <summary>Creates a new nameless object adapter. Such an object adapter has no configuration and can be
 /// associated with a bi-directional connection.</summary>
 /// <param name="serializeDispatch">Indicates whether or not this object adapter serializes the dispatching of
 /// of requests received over the same connection.</param>
 /// <param name="taskScheduler">The optional task scheduler to use for dispatching requests.</param>
 /// <param name="protocol">The protocol used for this object adapter.</param>
 /// <returns>The new object adapter.</returns>
 public ObjectAdapter CreateObjectAdapter(
     bool serializeDispatch      = false,
     TaskScheduler?taskScheduler = null,
     Protocol protocol           = Protocol.Ice2)
 {
     lock (_mutex)
     {
         if (IsDisposed)
         {
             throw new CommunicatorDisposedException();
         }
         var adapter = new ObjectAdapter(this, serializeDispatch, taskScheduler, protocol);
         _adapters.Add(adapter);
         return(adapter);
     }
 }
Exemple #20
0
        public override void run(string[] args)
        {
            var properties = createTestProperties(ref args);

            properties["Ice.Warn.Dispatch"] = "0";
            using var communicator          = initialize(properties, typeIdNamespaces: new string[] { "Ice.objects.TypeId" });
            communicator.SetProperty("TestAdapter.Endpoints", getTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add(new Initial(adapter), "initial");
            adapter.Add(new F2(), "F21");
            var uoet = new UnexpectedObjectExceptionTest();

            adapter.Add(uoet.Dispatch, "uoet");
            Test.AllTests.allTests(this);
        }
Exemple #21
0
        public override async Task RunAsync(string[] args)
        {
            await Communicator.ActivateAsync();

            Communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

            ObjectAdapter adapter = Communicator.CreateObjectAdapter("TestAdapter");
            var           blob    = new BlobjectI();

            adapter.AddDefault(blob);
            adapter.Add("__echo", new Echo());
            await adapter.ActivateAsync();

            ServerReady();
            await Communicator.ShutdownComplete;
        }
Exemple #22
0
            public override void Run(string[] args)
            {
                using Communicator communicator = Initialize(ref args);
                communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));

                // 2 threads are necessary to dispatch the collocated transient() call with AMI
                communicator.SetProperty("TestAdapter.ThreadPool.Size", "2");

                ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

                adapter.AddDefault(new Servant());

                AllTests.allTests(this);

                adapter.WaitForDeactivate();
            }
Exemple #23
0
        public override async Task RunAsync(string[] args)
        {
            Dictionary <string, string>?properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Dispatch"] = "0";

            await using Communicator communicator = Initialize(properties);
            await communicator.ActivateAsync();

            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("test", new MyDerivedClass());
            // Don't activate OA to ensure collocation is used.
            await AllTests.RunAsync(this);
        }
Exemple #24
0
        public override async Task RunAsync(string[] args)
        {
            await using Communicator communicator = Initialize(ref args);
            await communicator.ActivateAsync();

            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");
            var           d       = new D();

            adapter.Add("d", d);
            adapter.Add("d#facetABCD", d);
            adapter.Add("d#facetEF", new F());
            adapter.Add("d#facetGH", new H(communicator));

            _ = await AllTests.RunAsync(this);
        }
Exemple #25
0
        public override async Task RunAsync(string[] args)
        {
            var properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Dispatch"]       = "0";
            await using Communicator communicator = Initialize(properties);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("initial", new Initial(adapter));
            adapter.Add("F21", new F2());
            var uoet = new UnexpectedObjectExceptionTest();

            adapter.Add("uoet", uoet);
            AllTests.allTests(this);
        }
Exemple #26
0
        public override void Run(string[] args)
        {
            Dictionary <string, string> properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Connections"] = "0";
            properties["Ice.ACM.Timeout"]      = "1s";
            using Communicator communicator    = Initialize(properties);
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            communicator.SetProperty("TestAdapter.ACM.Timeout", "0s");
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("communicator", new RemoteCommunicator());
            adapter.Activate();
            ServerReady();
            communicator.SetProperty("Ice.PrintAdapterReady", "0");
            communicator.WaitForShutdown();
        }
Exemple #27
0
        internal void RemoveObjectAdapter(ObjectAdapter adapter)
        {
            // Called by the object adapter to remove itself once destroyed.
            lock (this)
            {
                if (_isShutdown)
                {
                    return;
                }

                _adapters.Remove(adapter);
                if (adapter.Name.Length > 0)
                {
                    _adapterNamesInUse.Remove(adapter.Name);
                }
            }
        }
Exemple #28
0
        public override void Run(string[] args)
        {
            using var communicator = Initialize(ref args);
            communicator.SetProperty("TestAdapter.AdapterId", "test");
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");
            var           prx     = adapter.Add("test", new MyDerivedClass(), IMyDerivedClassPrx.Factory);

            //adapter.activate(); // Don't activate OA to ensure collocation is used.

            if (prx.GetConnection() != null)
            {
                Assert(false);
                throw new System.Exception();
            }
            AllTests.allTests(this);
        }
Exemple #29
0
        public override void Run(string[] args)
        {
            var properties = CreateTestProperties(ref args);

            //
            // We don't want connection warnings because of the timeout test.
            //
            properties["Ice.Warn.Connections"] = "0";
            using var communicator             = Initialize(properties, typeIdNamespaces: new string[] { "Ice.operations.TypeId" });
            communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("TestAdapter");

            adapter.Add("test", new MyDerivedClass());
            adapter.Activate();
            ServerReady();
            communicator.WaitForShutdown();
        }
        public override int run(string[] args)
        {
            Ice.ObjectPrx obj = communicator().stringToProxy("VerySeriousMiddleware:default -p 5432");

            Server = VSServerPrxHelper.checkedCast(obj);
            if (Server == null)
                throw new ApplicationException("Invalid proxy");
            MonoBehaviour.print("Server link ok");
            Adapter = communicator().createObjectAdapterWithEndpoints("Unity", "default -p 5433");
            MonoBehaviour.print("trololol2");
            Adapter.activate();
            MonoBehaviour.print("Server link okidoci");

            communicator().waitForShutdown();

            return 0;
        }
Exemple #31
0
        public static void PaintPictureOnMGRObjectAdapter()
        {
            ModernGraphicsRenderer renderer      = new ModernGraphicsRenderer(Console.Out);
            ObjectAdapter          objectAdapter = new ObjectAdapter(renderer);
            CanvasPainter          painter       = new CanvasPainter(objectAdapter);

            try
            {
                renderer.BeginDraw();
                PaintPicture(painter);
                renderer.EndDraw();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #32
0
        public override void Run(string[] args)
        {
            Dictionary <string, string> properties = CreateTestProperties(ref args);

            properties["Ice.Default.Protocol"] = "ice1";
            using Communicator communicator    = Initialize(properties);
            communicator.SetProperty("DeactivatedAdapter.Endpoints", GetTestEndpoint(1));
            communicator.CreateObjectAdapter("DeactivatedAdapter");

            communicator.SetProperty("CallbackAdapter.Endpoints", GetTestEndpoint(0));
            ObjectAdapter adapter   = communicator.CreateObjectAdapter("CallbackAdapter");
            var           callbackI = new Callback();

            adapter.Add("callback", callbackI);
            adapter.Activate();
            communicator.WaitForShutdown();
        }
Exemple #33
0
        internal ConnectionI(Communicator communicator, IceInternal.Instance instance,
                             IceInternal.ConnectionReaper reaper, IceInternal.Transceiver transceiver,
                             IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapter adapter)
        {
            _communicator = communicator;
            _instance = instance;
            _reaper = reaper;
            InitializationData initData = instance.initializationData();
            _transceiver = transceiver;
            _desc = transceiver.ToString();
            _type = transceiver.type();
            _connector = connector;
            _endpoint = endpoint;
            _adapter = adapter;
            _dispatcher = initData.dispatcher; // Cached for better performance.
            _logger = initData.logger; // Cached for better performance.
            _traceLevels = instance.traceLevels(); // Cached for better performance.
            _timer = instance.timer();
            _writeTimeout = new TimeoutCallback(this);
            _writeTimeoutScheduled = false;
            _writeStreamPos = -1;
            _readTimeout = new TimeoutCallback(this);
            _readTimeoutScheduled = false;
            _readStreamPos = -1;
            _warn = initData.properties.getPropertyAsInt("Ice.Warn.Connections") > 0;
            _warnUdp = initData.properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
            _cacheBuffers = initData.properties.getPropertyAsIntWithDefault("Ice.CacheMessageBuffers", 1) == 1;
            _acmAbsoluteTimeoutMillis = 0;
            _nextRequestId = 1;
            _batchAutoFlush = initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0;
            _batchStream = new IceInternal.BasicStream(instance, Util.currentProtocolEncoding, _batchAutoFlush);
            _batchStreamInUse = false;
            _batchRequestNum = 0;
            _batchRequestCompress = false;
            _batchMarker = 0;
            _readStream = new IceInternal.BasicStream(instance, Util.currentProtocolEncoding);
            _readHeader = false;
            _writeStream = new IceInternal.BasicStream(instance, Util.currentProtocolEncoding);
            _dispatchCount = 0;
            _state = StateNotInitialized;

            _compressionLevel = initData.properties.getPropertyAsIntWithDefault("Ice.Compression.Level", 1);
            if(_compressionLevel < 1)
            {
                _compressionLevel = 1;
            }
            else if(_compressionLevel > 9)
            {
                _compressionLevel = 9;
            }

            ObjectAdapterI adapterImpl = _adapter as ObjectAdapterI;
            if(adapterImpl != null)
            {
                _servantManager = adapterImpl.getServantManager();
            }

            try
            {
                if(_endpoint.datagram())
                {
                    _acmTimeout = 0;
                }
                else
                {
                    if(adapterImpl != null)
                    {
                        _acmTimeout = adapterImpl.getACM();
                    }
                    else
                    {
                        _acmTimeout = _instance.clientACM();
                    }
                }

                if(adapterImpl != null)
                {
                    _threadPool = adapterImpl.getThreadPool();
                }
                else
                {
                    _threadPool = instance.clientThreadPool();
                }
                _threadPool.initialize(this);
            }
            catch(LocalException)
            {
                throw;
            }
            catch(System.Exception ex)
            {
                throw new SyscallException(ex);
            }
        }
Exemple #34
0
        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.
                //
            }
        }
Exemple #35
0
        private IceInternal.Incoming getIncoming(ObjectAdapter adapter, bool response, byte compress, int requestId)
        {
            IceInternal.Incoming inc = null;

            if(_cacheBuffers)
            {
                lock(_incomingCacheMutex)
                {
                    if(_incomingCache == null)
                    {
                        inc = new IceInternal.Incoming(_instance, this, this, adapter, response, compress, requestId);
                    }
                    else
                    {
                        inc = _incomingCache;
                        _incomingCache = _incomingCache.next;
                        inc.reset(_instance, this, this, adapter, response, compress, requestId);
                        inc.next = null;
                    }
                }
            }
            else
            {
                inc = new IceInternal.Incoming(_instance, this, this, adapter, response, compress, requestId);
            }

            return inc;
        }
Exemple #36
0
        private void invokeAll(IceInternal.BasicStream stream, int invokeNum, int requestId, byte compress,
                               IceInternal.ServantManager servantManager, ObjectAdapter adapter)
        {
            //
            // Note: In contrast to other private or protected methods, this
            // operation must be called *without* the mutex locked.
            //

            IceInternal.Incoming inc = null;
            try
            {
                while(invokeNum > 0)
                {
                    //
                    // Prepare the invocation.
                    //
                    bool response = !_endpoint.datagram() && requestId != 0;
                    Debug.Assert(!response || invokeNum == 1);

                    inc = getIncoming(adapter, response, compress, requestId);

                    //
                    // Dispatch the invocation.
                    //
                    inc.invoke(servantManager, stream);

                    --invokeNum;

                    reclaimIncoming(inc);
                    inc = null;
                }

                stream.clear();
            }
            catch(LocalException ex)
            {
                invokeException(requestId, ex, invokeNum, false);
            }
            finally
            {
                if(inc != null)
                {
                    reclaimIncoming(inc);
                }
            }
        }
Exemple #37
0
        private void invokeAll(IceInternal.BasicStream stream, int invokeNum, int requestId, byte compress,
                               IceInternal.ServantManager servantManager, ObjectAdapter adapter)
        {
            //
            // Note: In contrast to other private or protected methods, this
            // operation must be called *without* the mutex locked.
            //

            IceInternal.Incoming inc = null;
            try
            {
                while(invokeNum > 0)
                {
                    //
                    // Prepare the invocation.
                    //
                    bool response = !_endpoint.datagram() && requestId != 0;
                    inc = getIncoming(adapter, response, compress, requestId);
                    IceInternal.BasicStream ins = inc.istr();
                    stream.swap(ins);
                    IceInternal.BasicStream os = inc.ostr();

                    //
                    // Prepare the response if necessary.
                    //
                    if(response)
                    {
                        Debug.Assert(invokeNum == 1); // No further invocations if a response is expected.
                        os.writeBlob(IceInternal.Protocol.replyHdr);

                        //
                        // Add the request ID.
                        //
                        os.writeInt(requestId);
                    }

                    inc.invoke(servantManager);

                    //
                    // If there are more invocations, we need the stream back.
                    //
                    if(--invokeNum > 0)
                    {
                        stream.swap(ins);
                    }

                    reclaimIncoming(inc);
                    inc = null;
                }
            }
            catch(LocalException ex)
            {
                invokeException(ex, invokeNum);
            }
            finally
            {
                if(inc != null)
                {
                    reclaimIncoming(inc);
                }
            }
        }
Exemple #38
0
        public virtual void setup(IceInternal.Reference rf, ObjectAdapter adapter)
        {
            //
            // No need to synchronize, as this operation is only called
            // upon initialization.
            //

            Debug.Assert(reference__ == null);
            Debug.Assert(adapter__ == null);

            reference__ = rf;
            adapter__ = adapter;
        }
Exemple #39
0
        //
        // Only for use by ObjectPrx.
        //
        internal void copyFrom__(ObjectDelD_ from)
        {
            //
            // No need to synchronize "from", as the delegate is immutable
            // after creation.
            //

            //
            // No need to synchronize, as this operation is only called
            // upon initialization.
            //

            Debug.Assert(reference__ == null);
            Debug.Assert(adapter__ == null);

            reference__ = from.reference__;
            adapter__ = from.adapter__;
        }
Exemple #40
0
 public ObjectPrx createAdmin(ObjectAdapter adminAdapter, Identity adminIdentity)
 {
     return instance_.createAdmin(adminAdapter, adminIdentity);
 }
Exemple #41
0
        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);
            }
        }
 /// <summary>
 /// Method destroy
 /// </summary>
 /// <param name="adapter">An ObjectAdapter</param>
 public void destroy(ObjectAdapter adapter)
 {
     if(propertyValuePrx != null && propertySetByValue)
         adapter.remove(propertyValuePrx.ice_getIdentity());
 }
Exemple #43
0
        public void waitUntilFinished()
        {
            lock(this)
            {
                //
                // We wait indefinitely until the connection is finished and all
                // outstanding requests are completed. Otherwise we couldn't
                // guarantee that there are no outstanding calls when deactivate()
                // is called on the servant locators.
                //
                while(_state < StateFinished || _dispatchCount > 0)
                {
                    System.Threading.Monitor.Wait(this);
                }

                Debug.Assert(_state == StateFinished);

                //
                // Clear the OA. See bug 1673 for the details of why this is necessary.
                //
                _adapter = null;
            }
        }