Beispiel #1
0
 //
 // Only for use by Instance.
 //
 internal ObjectAdapterFactory(Instance instance, Ice.Communicator communicator)
 {
     instance_ = instance;
     _communicator = communicator;
     _adapterNamesInUse = new HashSet<string>();
     _adapters = new List<Ice.ObjectAdapterI>();
 }
Beispiel #2
0
        public void ConnectServer()
        {
            try
            {
                Ice.InitializationData initData = new Ice.InitializationData();
                initData.properties = Ice.Util.createProperties();

                string strConfigFile = GetProcessPath() + @"\..\Config\IceClientConfig.txt";
                try
                {
                    initData.properties.load(strConfigFile);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                communicator = Ice.Util.initialize(initData);
                string sProxy = strProxyKey + ".Proxy";
                string strProxy = initData.properties.getProperty(sProxy);
                m_objectPrx = communicator.stringToProxy(strProxy);

                GetProxy();

            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        /// <summary>
        /// Represents a connection to R2D2. On construction, this object creates a two-way
        /// connection with the bot. To properly shutdown the connection, make sure that
        /// the Dispose method is called; this is especially important if you wish to create a
        /// new BotConnection later.
        /// </summary>
        /// <param name="botToBase">Object implementing functions that receive from the bot</param>
        /// <param name="hostname">Hostname of the bo.</param>
        public BotConnection(BotToBaseDisp_ botToBase, string hostname = "R2D2")
        {
            try {
                Console.WriteLine("Starting server");
                communicator = Ice.Util.initialize();

                Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints(
                    "BotToBaseAdapter", "tcp -p " + BOT_TO_BASE_PORT);
                adapter.add(botToBase, communicator.stringToIdentity("BotToBaseImpl"));
                adapter.activate();

                Console.WriteLine("Connecting to R2D2");
                Ice.ObjectPrx prx = communicator.stringToProxy(
                    string.Format("BaseToBotImpl:tcp -h {0} -p {1}", hostname, BASE_TO_BOT_PORT));
                BotProxy = BaseToBotPrxHelper.checkedCast(prx);
                if (BotProxy == null)
                    throw new ApplicationException("Invalid proxy");

                // Pings are necessary to ensure that the connection is live.
                // We want R2D2 to stop immediately if the connection goes dead.
                new Thread(pinger).Start();

            } catch {
                if (communicator != null) { communicator.destroy(); }
                throw;
            }
        }
Beispiel #4
0
        public ServiceManagerI(Ice.Communicator communicator, string[] args)
        {
            _communicator = communicator;
            _logger = _communicator.getLogger();

            Ice.Properties props = _communicator.getProperties();

            if(props.getProperty("Ice.Admin.Enabled").Length == 0)
            {
            _adminEnabled = props.getProperty("Ice.Admin.Endpoints").Length > 0;
            }
            else
            {
            _adminEnabled = props.getPropertyAsInt("Ice.Admin.Enabled") > 0;
            }

            if(_adminEnabled)
            {
            string[] facetFilter = props.getPropertyAsList("Ice.Admin.Facets");
            if(facetFilter.Length > 0)
            {
                _adminFacetFilter = new HashSet<string>(facetFilter);
            }
            else
            {
                _adminFacetFilter = new HashSet<string>();
            }
            }

            _argv = args;
            _traceServiceObserver = _communicator.getProperties().getPropertyAsInt("IceBox.Trace.ServiceObserver");
        }
 static minie_backend_client()
 {
     string[] parray = new string[] {"--Ice.Plugin.IceSSL=IceSSL.dll:IceSSL.PluginFactory",
         "--IceSSL.DefaultDir=.",
         "--IceSSL.CAs=root.pem",
         "--IceSSL.CertFile=client.p12",
         "--IceSSL.VerifyPeer=2",
         "--Ice.ThreadPool.Server.SizeMax=8",
         "--Ice.ThreadPool.Client.SizeMax=16",
         "--Ice.MessageSizeMax=10485760",
         "--Ice.Override.ConnectTimeout=5000",
         "--Ice.Override.Timeout=5000"};
     //Ice.InitializationData inid = new Ice.InitializationData();
     //inid.properties = Ice.Util.createProperties();
     //inid.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.dll:IceSSL.PluginFactory");
     //inid.properties.setProperty("IceSSL.DefaultDir", ".");
     //inid.properties.setProperty("IceSSL.CAs", "root.pem");
     //inid.properties.setProperty("IceSSL.CertFile", "client.p12");
     //inid.properties.setProperty("IceSSL.VerifyPeer", "2");
     //inid.properties.setProperty("Ice.ThreadPool.Server.SizeMax", "8");
     //inid.properties.setProperty("Ice.ThreadPool.Client.SizeMax", "16");
     //inid.properties.setProperty("Ice.MessageSizeMax", "10485760");
     //inid.properties.setProperty("Ice.Override.ConnectTimeout", "5000");
     //inid.properties.setProperty("Ice.Override.Timeout", "5000");
     s_ic = Ice.Util.initialize(ref parray);
     s_adapter = s_ic.createObjectAdapter("");
     s_adapter.activate();
 }
Beispiel #6
0
 public ServiceManagerI(Ice.Communicator communicator, string[] args)
 {
     _communicator = communicator;
     _logger = _communicator.getLogger();
     _argv = args;
     _traceServiceObserver = _communicator.getProperties().getPropertyAsInt("IceBox.Trace.ServiceObserver");
 }
Beispiel #7
0
 protected override void OnClosed(EventArgs e)
 {
     base.OnClosed(e);
     if(_communicator == null)
     {
         return;
     }
     _communicator.destroy();
     _communicator = null;
 }
Beispiel #8
0
 public MainForm()
 {
     InitializeComponent();
     try
     {
         Ice.InitializationData initData = new Ice.InitializationData();
         initData.properties = Ice.Util.createProperties();
         initData.dispatcher = delegate(Ice.VoidAction action, Ice.Connection connection)
             {
                 this.BeginInvoke(action);
             };
         _communicator = Ice.Util.initialize(initData);
     }
     catch(Ice.LocalException ex)
     {
         lblStatus.Text = "Exception: " + ex.ice_name();
     }
 }
Beispiel #9
0
 internal SSLEngine(IceInternal.ProtocolPluginFacade facade)
 {
     _communicator = facade.getCommunicator();
     _logger = _communicator.getLogger();
     _facade = facade;
     _securityTraceLevel = _communicator.getProperties().getPropertyAsIntWithDefault("IceSSL.Trace.Security", 0);
     _securityTraceCategory = "Security";
     _initialized = false;
     _trustManager = new TrustManager(_communicator);
     _tls12Support = false;
     try
     {
         Enum.Parse(typeof(System.Security.Authentication.SslProtocols), "Tls12");
         _tls12Support = true;
     }
     catch(Exception)
     {
     }
 }
Beispiel #10
0
 internal TrustManager(Ice.Communicator communicator)
 {
     Debug.Assert(communicator != null);
     communicator_ = communicator;
     Ice.Properties properties = communicator.getProperties();
     traceLevel_ = properties.getPropertyAsInt("IceSSL.Trace.Security");
     string key = null;
     try
     {
         key = "IceSSL.TrustOnly";
         parse(properties.getProperty(key), rejectAll_, acceptAll_);
         key = "IceSSL.TrustOnly.Client";
         parse(properties.getProperty(key), rejectClient_, acceptClient_);
         key = "IceSSL.TrustOnly.Server";
         parse(properties.getProperty(key), rejectAllServer_, acceptAllServer_);
         Dictionary<string, string> dict = properties.getPropertiesForPrefix("IceSSL.TrustOnly.Server.");
         foreach(KeyValuePair<string, string> entry in dict)
         {
             key = entry.Key;
             string name = key.Substring("IceSSL.TrustOnly.Server.".Length);
             List<List<RFC2253.RDNPair>> reject = new List<List<RFC2253.RDNPair>>();
             List<List<RFC2253.RDNPair>> accept = new List<List<RFC2253.RDNPair>>();
             parse(entry.Value, reject, accept);
             if(reject.Count > 0)
             {
                 rejectServer_[name] = reject;
             }
             if(accept.Count > 0)
             {
                 acceptServer_[name] = accept;
             }
         }
     }
     catch(RFC2253.ParseException e)
     {
         Ice.PluginInitializationException ex = new Ice.PluginInitializationException();
         ex.reason = "IceSSL: invalid property " + key  + ":\n" + e.reason;
         throw ex;
     }
 }
Beispiel #11
0
        public void ConnectServer()
        {
            try
            {
                //Disconnect();
                //communicator = Ice.Util.initialize();
                //remote =
                 //   LogPrxHelper.checkedCast(communicator.stringToProxy("ICLog:tcp -p 15356"));

                //Init();
                Ice.InitializationData initData = new Ice.InitializationData();
                initData.properties = Ice.Util.createProperties();
                initData.properties.setProperty("ICLog.Proxy", "ICLog:tcp -p 15366");

                string strConfigFile = GetProcessPath() + @"\..\Config\IceClientConfig.txt";
                try
                {
                    initData.properties.load(strConfigFile);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                communicator = Ice.Util.initialize(initData);
                string strProxy = initData.properties.getProperty("ICLog.Proxy");
                remote =
                    LogPrxHelper.uncheckedCast(communicator.stringToProxy(strProxy));
                remote.ice_timeout(1000);
            }
            catch (System.Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #12
0
 public RemoteCommunicatorI(Ice.Communicator communicator)
 {
     _communicator = communicator;
 }
Beispiel #13
0
        public override void attachRemoteLogger(Ice.RemoteLoggerPrx prx, Ice.LogMessageType[] messageTypes, string[] categories, 
                       int messageMax, Ice.Current current)
        {
            if(prx == null)
            {
            return; // can't send this null RemoteLogger anything!
            }

            Ice.RemoteLoggerPrx remoteLogger = Ice.RemoteLoggerPrxHelper.uncheckedCast(prx.ice_twoway());

            Filters filters = new Filters(messageTypes, categories);
            LinkedList<Ice.LogMessage> initLogMessages = null;

            lock(this)
            {
            if(_sendLogCommunicator == null)
            {
                if(_destroyed)
                {
                    throw new Ice.ObjectNotExistException();
                }

                _sendLogCommunicator =
                    createSendLogCommunicator(current.adapter.getCommunicator(), _logger.getLocalLogger());
            }

            Ice.Identity remoteLoggerId = remoteLogger.ice_getIdentity();

            if(_remoteLoggerMap.ContainsKey(remoteLoggerId))
            {
                if(_traceLevel > 0)
                {
                    _logger.trace(_traceCategory, "rejecting `" + remoteLogger.ToString() +
                                 "' with RemoteLoggerAlreadyAttachedException");
                }

                throw new Ice.RemoteLoggerAlreadyAttachedException();
            }

            _remoteLoggerMap.Add(remoteLoggerId,
                                 new RemoteLoggerData(changeCommunicator(remoteLogger, _sendLogCommunicator), filters));

            if(messageMax != 0)
            {
                initLogMessages = new LinkedList<Ice.LogMessage>(_queue); // copy
            }
            else
            {
                initLogMessages = new LinkedList<Ice.LogMessage>();
            }
            }

            if(_traceLevel > 0)
            {
            _logger.trace(_traceCategory, "attached `" + remoteLogger.ToString() + "'");
            }

            if(initLogMessages.Count > 0)
            {
            filterLogMessages(initLogMessages, filters.messageTypes, filters.traceCategories, messageMax);
            }

            try
            {
            remoteLogger.begin_init(_logger.getPrefix(), initLogMessages.ToArray(), initCompleted, null);
            }
            catch(Ice.LocalException ex)
            {
            deadRemoteLogger(remoteLogger, _logger, ex, "init");
            throw;
            }
        }
Beispiel #14
0
            allTests(global::Test.TestHelper helper,
                     Ice.Communicator communicator,
                     Ice.Communicator communicator2,
                     string rf)
            {
                Instrumentation.testInvocationReset();

                var output = helper.getWriter();

                output.Write("testing stringToProxy... ");
                output.Flush();
                var base1 = communicator.stringToProxy(rf);

                test(base1 != null);
                var base2 = communicator.stringToProxy(rf);

                test(base2 != null);
                output.WriteLine("ok");

                output.Write("testing checked cast... ");
                output.Flush();
                Test.RetryPrx retry1 = Test.RetryPrxHelper.checkedCast(base1);
                test(retry1 != null);
                test(retry1.Equals(base1));
                Test.RetryPrx retry2 = Test.RetryPrxHelper.checkedCast(base2);
                test(retry2 != null);
                test(retry2.Equals(base2));
                output.WriteLine("ok");

                output.Write("calling regular operation with first proxy... ");
                output.Flush();
                retry1.op(false);
                output.WriteLine("ok");

                Instrumentation.testInvocationCount(3);

                output.Write("calling operation to kill connection with second proxy... ");
                output.Flush();
                try
                {
                    retry2.op(true);
                    test(false);
                }
                catch (Ice.UnknownLocalException)
                {
                    // Expected with collocation
                }
                catch (Ice.ConnectionLostException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling regular operation with first proxy again... ");
                output.Flush();
                retry1.op(false);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                Callback cb = new Callback();

                output.Write("calling regular AMI operation with first proxy... ");
                retry1.begin_op(false).whenCompleted(
                    () =>
                {
                    cb.called();
                },
                    (Ice.Exception ex) =>
                {
                    test(false);
                });
                cb.check();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling AMI operation to kill connection with second proxy... ");
                retry2.begin_op(true).whenCompleted(
                    () =>
                {
                    test(false);
                },
                    (Ice.Exception ex) =>
                {
                    test(ex is Ice.ConnectionLostException || ex is Ice.UnknownLocalException);
                    cb.called();
                });
                cb.check();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("calling regular AMI operation with first proxy again... ");
                retry1.begin_op(false).whenCompleted(
                    () =>
                {
                    cb.called();
                },
                    (Ice.Exception ex) =>
                {
                    test(false);
                });
                cb.check();
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                output.Write("testing idempotent operation... ");
                test(retry1.opIdempotent(4) == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(4);
                test(retry1.end_opIdempotent(retry1.begin_opIdempotent(4)) == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                Instrumentation.testRetryCount(4);
                output.WriteLine("ok");

                if (retry1.ice_getCachedConnection() != null)
                {
                    output.Write("testing non-idempotent operation with bi-dir proxy... ");
                    try
                    {
                        ((Test.RetryPrx)retry1.ice_fixed(retry1.ice_getCachedConnection())).opIdempotent(4);
                    }
                    catch (Ice.Exception)
                    {
                    }
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(1);
                    Instrumentation.testRetryCount(0);
                    test(retry1.opIdempotent(4) == 4);
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(0);
                    // It suceeded after 3 retry because of the failed opIdempotent on the fixed proxy above
                    Instrumentation.testRetryCount(3);
                    output.WriteLine("ok");
                }

                output.Write("testing non-idempotent operation... ");
                try
                {
                    retry1.opNotIdempotent();
                    test(false);
                }
                catch (Ice.LocalException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                try
                {
                    retry1.end_opNotIdempotent(retry1.begin_opNotIdempotent());
                    test(false);
                }
                catch (Ice.LocalException)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");

                if (retry1.ice_getConnection() == null)
                {
                    Instrumentation.testInvocationCount(1);

                    output.Write("testing system exception... ");
                    try
                    {
                        retry1.opSystemException();
                        test(false);
                    }
                    catch (SystemFailure)
                    {
                    }
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(1);
                    Instrumentation.testRetryCount(0);
                    try
                    {
                        retry1.end_opSystemException(retry1.begin_opSystemException());
                        test(false);
                    }
                    catch (SystemFailure)
                    {
                    }
                    Instrumentation.testInvocationCount(1);
                    Instrumentation.testFailureCount(1);
                    Instrumentation.testRetryCount(0);
                    output.WriteLine("ok");
                }

                {
                    output.Write("testing invocation timeout and retries... ");
                    output.Flush();

                    retry2 = Test.RetryPrxHelper.checkedCast(communicator2.stringToProxy(retry1.ToString()));
                    try
                    {
                        // No more than 2 retries before timeout kicks-in
                        ((Test.RetryPrx)retry2.ice_invocationTimeout(500)).opIdempotent(4);
                        test(false);
                    }
                    catch (Ice.InvocationTimeoutException)
                    {
                        Instrumentation.testRetryCount(2);
                        retry2.opIdempotent(-1); // Reset the counter
                        Instrumentation.testRetryCount(-1);
                    }
                    try
                    {
                        // No more than 2 retries before timeout kicks-in
                        Test.RetryPrx prx = (Test.RetryPrx)retry2.ice_invocationTimeout(500);
                        prx.end_opIdempotent(prx.begin_opIdempotent(4));
                        test(false);
                    }
                    catch (Ice.InvocationTimeoutException)
                    {
                        Instrumentation.testRetryCount(2);
                        retry2.opIdempotent(-1); // Reset the counter
                        Instrumentation.testRetryCount(-1);
                    }
                    if (retry1.ice_getConnection() != null)
                    {
                        // The timeout might occur on connection establishment or because of the sleep. What's
                        // important here is to make sure there are 4 retries and that no calls succeed to
                        // ensure retries with the old connection timeout semantics work.
                        Test.RetryPrx retryWithTimeout =
                            (Test.RetryPrx)retry1.ice_invocationTimeout(-2).ice_timeout(200);
                        try
                        {
                            retryWithTimeout.sleep(1000);
                            test(false);
                        }
                        catch (Ice.TimeoutException)
                        {
                        }
                        Instrumentation.testRetryCount(4);
                    }
                    output.WriteLine("ok");
                }
                return(retry1);
            }
Beispiel #15
0
    public void init()
    {
        _adapter = _com.createObjectAdapter(_serverACMTimeout, _serverACMClose, _serverACMHeartbeat);

        Ice.InitializationData initData = new Ice.InitializationData();
        initData.properties = _com.ice_getCommunicator().getProperties().ice_clone_();
        initData.logger = _logger;
        initData.properties.setProperty("Ice.ACM.Timeout", "1");
        if(_clientACMTimeout >= 0)
        {
            initData.properties.setProperty("Ice.ACM.Client.Timeout", _clientACMTimeout.ToString());
        }
        if(_clientACMClose >= 0)
        {
            initData.properties.setProperty("Ice.ACM.Client.Close", _clientACMClose.ToString());
        }
        if(_clientACMHeartbeat >= 0)
        {
            initData.properties.setProperty("Ice.ACM.Client.Heartbeat", _clientACMHeartbeat.ToString());
        }
        //initData.properties.setProperty("Ice.Trace.Protocol", "2");
        //initData.properties.setProperty("Ice.Trace.Network", "2");
        _communicator = Ice.Util.initialize(initData);
        _thread = new Thread(this.run);
    }
Beispiel #16
0
        public int run()
        {
            try
            {
            Ice.Properties properties = _communicator.getProperties();

            //
            // Create an object adapter. Services probably should NOT share
            // this object adapter, as the endpoint(s) for this object adapter
            // will most likely need to be firewalled for security reasons.
            //
            Ice.ObjectAdapter adapter = null;
            if(properties.getProperty("IceBox.ServiceManager.Endpoints").Length != 0)
            {
                adapter = _communicator.createObjectAdapter("IceBox.ServiceManager");

                Ice.Identity identity = new Ice.Identity();
                identity.category = properties.getPropertyWithDefault("IceBox.InstanceName", "IceBox");
                identity.name = "ServiceManager";
                adapter.add(this, identity);
            }

            //
            // Parse the property set with the prefix "IceBox.Service.". These
            // properties should have the following format:
            //
            // IceBox.Service.Foo=Package.Foo [args]
            //
            // We parse the service properties specified in IceBox.LoadOrder
            // first, then the ones from remaining services.
            //
            string prefix = "IceBox.Service.";
            Dictionary<string, string> services = properties.getPropertiesForPrefix(prefix);
            string[] loadOrder = properties.getPropertyAsList("IceBox.LoadOrder");
            List<StartServiceInfo> servicesInfo = new List<StartServiceInfo>();
            for(int i = 0; i < loadOrder.Length; ++i)
            {
                if(loadOrder[i].Length > 0)
                {
                    string key = prefix + loadOrder[i];
                    string value = services[key];
                    if(value == null)
                    {
                        FailureException ex = new FailureException();
                        ex.reason = "ServiceManager: no service definition for `" + loadOrder[i] + "'";
                        throw ex;
                    }
                    servicesInfo.Add(new StartServiceInfo(loadOrder[i], value, _argv));
                    services.Remove(key);
                }
            }
            foreach(KeyValuePair<string, string> entry in services)
            {
                string name = entry.Key.Substring(prefix.Length);
                string value = entry.Value;
                servicesInfo.Add(new StartServiceInfo(name, value, _argv));
            }

            //
            // Check if some services are using the shared communicator in which
            // case we create the shared communicator now with a property set which
            // is the union of all the service properties (services which are using
            // the shared communicator).
            //
            if(properties.getPropertiesForPrefix("IceBox.UseSharedCommunicator.").Count > 0)
            {
                Ice.InitializationData initData = new Ice.InitializationData();
                initData.properties = createServiceProperties("SharedCommunicator");
                foreach(StartServiceInfo service in servicesInfo)
                {
                    if(properties.getPropertyAsInt("IceBox.UseSharedCommunicator." + service.name) <= 0)
                    {
                        continue;
                    }

                    //
                    // Load the service properties using the shared communicator properties as
                    // the default properties.
                    //
                    Ice.Properties svcProperties = Ice.Util.createProperties(ref service.args, initData.properties);

                    //
                    // Erase properties from the shared communicator which don't exist in the
                    // service properties (which include the shared communicator properties
                    // overriden by the service properties).
                    //
                    Dictionary<string, string> allProps = initData.properties.getPropertiesForPrefix("");
                    foreach(string key in allProps.Keys)
                    {
                        if(svcProperties.getProperty(key).Length == 0)
                        {
                            initData.properties.setProperty(key, "");
                        }
                    }

                    //
                    // Add the service properties to the shared communicator properties.
                    //
                    foreach(KeyValuePair<string, string> entry in svcProperties.getPropertiesForPrefix(""))
                    {
                        initData.properties.setProperty(entry.Key, entry.Value);
                    }

                    //
                    // Parse <service>.* command line options (the Ice command line options
                    // were parsed by the createProperties above)
                    //
                    service.args = initData.properties.parseCommandLineOptions(service.name, service.args);
                }
                _sharedCommunicator = Ice.Util.initialize(initData);
            }

            foreach(StartServiceInfo s in servicesInfo)
            {
                startService(s.name, s.entryPoint, s.args);
            }

            //
            // We may want to notify external scripts that the services
            // have started. This is done by defining the property:
            //
            // PrintServicesReady=bundleName
            //
            // Where bundleName is whatever you choose to call this set of
            // services. It will be echoed back as "bundleName ready".
            //
            // This must be done after start() has been invoked on the
            // services.
            //
            string bundleName = properties.getProperty("IceBox.PrintServicesReady");
            if(bundleName.Length > 0)
            {
                Console.Out.WriteLine(bundleName + " ready");
            }

            //
            // Don't move after the adapter activation. This allows
            // applications to wait for the service manager to be
            // reachable before sending a signal to shutdown the
            //
            //
            Ice.Application.shutdownOnInterrupt();

            //
            // Register "this" as a facet to the Admin object and create Admin object
            //
            try
            {
                _communicator.addAdminFacet(this, "IceBox.ServiceManager");

                //
                // Add a Properties facet for each service
                //
                foreach(ServiceInfo info in _services)
                {
                    Ice.Communicator communicator = info.communicator != null ? info.communicator : _sharedCommunicator;
                    _communicator.addAdminFacet(new PropertiesAdminI(communicator.getProperties()),
                                                "IceBox.Service." + info.name + ".Properties");
                }

                _communicator.getAdmin();
            }
            catch(Ice.ObjectAdapterDeactivatedException)
            {
                //
                // Expected if the communicator has been shutdown.
                //
            }

            //
            // Start request dispatching after we've started the services.
            //
            if(adapter != null)
            {
                try
                {
                    adapter.activate();
                }
                catch(Ice.ObjectAdapterDeactivatedException)
                {
                    //
                    // Expected if the communicator has been shutdown.
                    //
                }
            }

            _communicator.waitForShutdown();
            // XXX:
            //Ice.Application.defaultInterrupt();

            //
            // Invoke stop() on the services.
            //
            stopAll();
            }
            catch(FailureException ex)
            {
            _logger.error(ex.ToString());
            stopAll();
            return 1;
            }
            catch(Exception ex)
            {
            _logger.error("ServiceManager: caught exception:\n" + ex.ToString());
            stopAll();
            return 1;
            }

            return 0;
        }
Beispiel #17
0
 public PluginOne(Ice.Communicator communicator) : base(communicator)
 {
 }
Beispiel #18
0
 public static Instance getInstance(Ice.Communicator communicator)
 {
     Ice.CommunicatorI p = (Ice.CommunicatorI)communicator;
     return(p.getInstance());
 }
Beispiel #19
0
 public Login(IRightsUploadServicePrx rightsUploadService, IRightsQueryServicePrx rightsQueryService, Ice.Communicator communicator)
 {
     _rightsUploadService = rightsUploadService;
     _rightsQueryService  = rightsQueryService;
     this.communicator    = communicator;
     InitializeComponent();
 }
Beispiel #20
0
 protected OutgoingAsyncBase(Ice.Communicator com, Instance instance, string op, object cookie,
                             Ice.OutputStream os) :
     base(com, instance, op, cookie)
 {
     os_ = os;
 }
Beispiel #21
0
 public ConnectionFlushBatch(Ice.ConnectionI con, Ice.Communicator communicator, Instance instance, string op,
                             object cookie) :
     base(communicator, instance, op, cookie)
 {
     _connection = con;
 }
Beispiel #22
0
 protected OutgoingAsyncBase(Ice.Communicator com, Instance instance, string op, object cookie) :
     base(com, instance, op, cookie)
 {
     os_ = new Ice.OutputStream(instance, Ice.Util.currentProtocolEncoding);
 }
Beispiel #23
0
 public abstract void run(Ice.Communicator communicator);
Beispiel #24
0
            internal static void twowaysAMI(Ice.Communicator communicator, Test.MyClassPrx p)
            {
                {
                    var i = Enumerable.Range(0, Length).Select(x => (byte)x).ToArray();
                    var r = p.opAByteSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (byte)x).ToList();
                    var r = p.opLByteSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <byte>(Enumerable.Range(0, Length).Select(x => (byte)x).ToArray());
                    var r = p.opKByteSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <byte>(Enumerable.Range(0, Length).Select(x => (byte)x).ToArray());
                    var r = p.opQByteSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <byte>(Enumerable.Range(0, Length).Select(x => (byte)x).ToArray());
                    var r = p.opSByteSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => x % 1 == 1).ToArray();
                    var r = p.opABoolSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => x % 1 == 1).ToList();
                    var r = p.opLBoolSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <bool>(Enumerable.Range(0, Length).Select(x => x % 1 == 1).ToArray());
                    var r = p.opKBoolSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <bool>(Enumerable.Range(0, Length).Select(x => x % 1 == 1).ToArray());
                    var r = p.opQBoolSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <bool>(Enumerable.Range(0, Length).Select(x => x % 1 == 1).ToArray());
                    var r = p.opSBoolSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (short)x).ToArray();
                    var r = p.opAShortSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (short)x).ToList();
                    var r = p.opLShortSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <short>(Enumerable.Range(0, Length).Select(x => (short)x).ToArray());
                    var r = p.opKShortSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <short>(Enumerable.Range(0, Length).Select(x => (short)x).ToArray());
                    var r = p.opQShortSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <short>(Enumerable.Range(0, Length).Select(x => (short)x).ToArray());
                    var r = p.opSShortSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).ToArray();
                    var r = p.opAIntSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).ToList();
                    var r = p.opLIntSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <int>(Enumerable.Range(0, Length).ToArray());
                    var r = p.opKIntSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <int>(Enumerable.Range(0, Length).ToArray());
                    var r = p.opQIntSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <int>(Enumerable.Range(0, Length).ToArray());
                    var r = p.opSIntSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (long)x).ToArray();
                    var r = p.opALongSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (long)x).ToList();
                    var r = p.opLLongSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <long>(Enumerable.Range(0, Length).Select(x => (long)x).ToArray());
                    var r = p.opKLongSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <long>(Enumerable.Range(0, Length).Select(x => (long)x).ToArray());
                    var r = p.opQLongSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <long>(Enumerable.Range(0, Length).Select(x => (long)x).ToArray());
                    var r = p.opSLongSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (float)x).ToArray();
                    var r = p.opAFloatSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (float)x).ToList();
                    var r = p.opLFloatSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <float>(Enumerable.Range(0, Length).Select(x => (float)x).ToArray());
                    var r = p.opKFloatSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <float>(Enumerable.Range(0, Length).Select(x => (float)x).ToArray());
                    var r = p.opQFloatSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <float>(Enumerable.Range(0, Length).Select(x => (float)x).ToArray());
                    var r = p.opSFloatSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (double)x).ToArray();
                    var r = p.opADoubleSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (double)x).ToList();
                    var r = p.opLDoubleSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <double>(Enumerable.Range(0, Length).Select(x => (double)x).ToArray());
                    var r = p.opKDoubleSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <double>(Enumerable.Range(0, Length).Select(x => (double)x).ToArray());
                    var r = p.opQDoubleSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <double>(Enumerable.Range(0, Length).Select(x => (double)x).ToArray());
                    var r = p.opSDoubleSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray();
                    var r = p.opAStringSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => x.ToString()).ToList();
                    var r = p.opLStringSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <string>(Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray());
                    var r = p.opKStringSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <string>(Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray());
                    var r = p.opQStringSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <string>(Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray());
                    var r = p.opSStringSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.CV(x) as Value).ToArray();
                    var r = p.opAObjectSAsync(i).Result;
                    test(r.o.SequenceEqual(i, new CVComparer()));
                    test(r.returnValue.SequenceEqual(i, new CVComparer()));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.CV(x) as Value).ToList();
                    var r = p.opLObjectSAsync(i).Result;
                    test(r.o.SequenceEqual(i, new CVComparer()));
                    test(r.returnValue.SequenceEqual(i, new CVComparer()));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(
                        x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray();
                    var r = p.opAObjectPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(
                        x => IObjectPrx.Parse(x.ToString(), communicator)).ToList();
                    var r = p.opLObjectPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <IObjectPrx>(Enumerable.Range(0, Length).Select(
                                                       x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray());
                    var r = p.opQObjectPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <IObjectPrx>(Enumerable.Range(0, Length).Select(
                                                       x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray());
                    var r = p.opSObjectPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.S(x)).ToArray();
                    var r = p.opAStructSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.S(x)).ToList();
                    var r = p.opLStructSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <Test.S>(Enumerable.Range(0, Length).Select(x => new Test.S(x)).ToArray());
                    var r = p.opKStructSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <Test.S>(Enumerable.Range(0, Length).Select(x => new Test.S(x)).ToArray());
                    var r = p.opQStructSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <Test.S>(Enumerable.Range(0, Length).Select(x => new Test.S(x)).ToArray());
                    var r = p.opSStructSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.CV(x)).ToArray();
                    var r = p.opACVSAsync(i).Result;
                    test(r.o.SequenceEqual(i, new CVComparer()));
                    test(r.returnValue.SequenceEqual(i, new CVComparer()));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.CV(x)).ToList();
                    var r = p.opLCVSAsync(i).Result;
                    test(r.o.SequenceEqual(i, new CVComparer()));
                    test(r.returnValue.SequenceEqual(i, new CVComparer()));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(
                        x => Test.IPrx.Parse(x.ToString(), communicator)).ToArray();
                    var r = p.opAIPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(
                        x => Test.IPrx.Parse(x.ToString(), communicator)).ToList();
                    var r = p.opLIPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <Test.IPrx>(Enumerable.Range(0, Length).Select(
                                                           x => Test.IPrx.Parse(x.ToString(), communicator)).ToArray());
                    var r = p.opKIPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <Test.IPrx>(Enumerable.Range(0, Length).Select(
                                                      x => Test.IPrx.Parse(x.ToString(), communicator)).ToArray());
                    var r = p.opQIPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <Test.IPrx>(Enumerable.Range(0, Length).Select(
                                                      x => Test.IPrx.Parse(x.ToString(), communicator)).ToArray());
                    var r = p.opSIPrxSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.CR(new Test.CV(x))).ToArray();
                    var r = p.opACRSAsync(i).Result;
                    test(r.o.SequenceEqual(i, new CRComparer()));
                    test(r.returnValue.SequenceEqual(i, new CRComparer()));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => new Test.CR(new Test.CV(x))).ToList();
                    var r = p.opLCRSAsync(i).Result;
                    test(r.o.SequenceEqual(i, new CRComparer()));
                    test(r.returnValue.SequenceEqual(i, new CRComparer()));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (Test.En)(x % 3)).ToArray();
                    var r = p.opAEnSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = Enumerable.Range(0, Length).Select(x => (Test.En)(x % 3)).ToList();
                    var r = p.opLEnSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new LinkedList <Test.En>(Enumerable.Range(0, Length).Select(
                                                         x => (Test.En)(x % 3)).ToArray());
                    var r = p.opKEnSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Queue <Test.En>(Enumerable.Range(0, Length).Select(x => (Test.En)(x % 3)).ToArray());
                    var r = p.opQEnSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Stack <Test.En>(Enumerable.Range(0, Length).Select(x => (Test.En)(x % 3)).ToArray());
                    var r = p.opSEnSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Custom <int>(Enumerable.Range(0, Length).ToList());
                    var r = p.opCustomIntSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Custom <Test.CV>(Enumerable.Range(0, Length).Select(x => new Test.CV(x)).ToList());
                    var r = p.opCustomCVSAsync(i).Result;
                    test(r.o.SequenceEqual(i, new CVComparer()));
                    test(r.returnValue.SequenceEqual(i, new CVComparer()));
                }

                {
                    var i = new Custom <Custom <int> >();
                    for (int c = 0; c < Length; ++c)
                    {
                        i.Add(new Custom <int>(Enumerable.Range(0, Length).ToList()));
                    }
                    var r = p.opCustomIntSSAsync(i).Result;
                    test(r.o.SequenceEqual(i));
                    test(r.returnValue.SequenceEqual(i));
                }

                {
                    var i = new Custom <Custom <Test.CV> >();
                    for (int c = 0; c < Length; ++c)
                    {
                        i.Add(new Custom <Test.CV>(Enumerable.Range(0, Length).Select(x => new Test.CV(x)).ToList()));
                    }
                    var r = p.opCustomCVSSAsync(i).Result;
                    for (int c = 0; c < Length; ++c)
                    {
                        test(r.o[c].SequenceEqual(i[c], new CVComparer()));
                        test(r.returnValue[c].SequenceEqual(i[c], new CVComparer()));
                    }
                }

                {
                    var r = p.opSerialSmallCSharpAsync(null).Result;
                    test(r.o == null);
                    test(r.returnValue == null);
                }

                {
                    var i = new Serialize.Small();
                    i.i = 99;

                    var r = p.opSerialSmallCSharpAsync(i).Result;
                    test(r.o.i == 99);
                    test(r.returnValue.i == 99);
                }

                {
                    var i = new Serialize.Large();
                    i.d1  = 1.0;
                    i.d2  = 2.0;
                    i.d3  = 3.0;
                    i.d4  = 4.0;
                    i.d5  = 5.0;
                    i.d6  = 6.0;
                    i.d7  = 7.0;
                    i.d8  = 8.0;
                    i.d9  = 9.0;
                    i.d10 = 10.0;

                    var r = p.opSerialLargeCSharpAsync(i).Result;

                    test(r.o.d1 == 1.0);
                    test(r.o.d2 == 2.0);
                    test(r.o.d3 == 3.0);
                    test(r.o.d4 == 4.0);
                    test(r.o.d5 == 5.0);
                    test(r.o.d6 == 6.0);
                    test(r.o.d7 == 7.0);
                    test(r.o.d8 == 8.0);
                    test(r.o.d9 == 9.0);
                    test(r.o.d10 == 10.0);

                    test(r.returnValue.d1 == 1.0);
                    test(r.returnValue.d2 == 2.0);
                    test(r.returnValue.d3 == 3.0);
                    test(r.returnValue.d4 == 4.0);
                    test(r.returnValue.d5 == 5.0);
                    test(r.returnValue.d6 == 6.0);
                    test(r.returnValue.d7 == 7.0);
                    test(r.returnValue.d8 == 8.0);
                    test(r.returnValue.d9 == 9.0);
                    test(r.returnValue.d10 == 10.0);
                }

                {
                    var i = new Serialize.Struct();
                    i.o  = null;
                    i.o2 = i;
                    i.s  = null;
                    i.s2 = "Hello";

                    var r = p.opSerialStructCSharpAsync(i).Result;

                    test(r.o.o == null);
                    test(r.o.o2 == r.o);
                    test(r.o.s == null);
                    test(r.o.s2 == "Hello");

                    test(r.returnValue.o == null);
                    test(r.returnValue.o2 == r.returnValue);
                    test(r.returnValue.s == null);
                    test(r.returnValue.s2 == "Hello");
                }
            }
Beispiel #25
0
 private void InitBlock(Ice.Communicator comm)
 {
     callback = new Callback();
     communicator = comm;
 }
Beispiel #26
0
 public static ProtocolPluginFacade getProtocolPluginFacade(Ice.Communicator communicator)
 {
     return(new ProtocolPluginFacadeI(communicator));
 }
Beispiel #27
0
        /// <summary>
        /// Disconnect from Qwerk device.
        /// </summary>
        /// 
        public void Disconnect( )
        {
            hostAddress = null;

            if ( video != null )
            {
                video.SignalToStop( );
                // wait for aroung 250 ms
                for ( int i = 0; ( i < 5 ) && ( video.IsRunning ); i++ )
                {
                    System.Threading.Thread.Sleep( 50 );
                }
                // abort camera if it can not be stopped
                if ( video.IsRunning )
                {
                    video.Stop( );
                }
            }

            leds        = null;
            digitalOuts = null;
            digitalIns  = null;
            analogIns   = null;
            video       = null;
            motors      = null;
            servos      = null;

            // destroy ICE communicator
            if ( iceCommunicator != null )
            {
                iceCommunicator.destroy( );
                iceCommunicator = null;
            }
        }
Beispiel #28
0
        public ThreadPool(Ice.Communicator communicator, string prefix, int timeout)
        {
            _communicator   = communicator;
            _dispatcher     = communicator.Dispatcher;
            _destroyed      = false;
            _prefix         = prefix;
            _threadIndex    = 0;
            _inUse          = 0;
            _serialize      = _communicator.GetPropertyAsInt($"{_prefix}.Serialize") > 0;
            _serverIdleTime = timeout;

            string?programName = _communicator.GetProperty("Ice.ProgramName");

            if (programName != null)
            {
                _threadPrefix = programName + "-" + _prefix;
            }
            else
            {
                _threadPrefix = _prefix;
            }

            //
            // We use just one thread as the default. This is the fastest
            // possible setting, still allows one level of nesting, and
            // doesn't require to make the servants thread safe.
            //
            int size = _communicator.GetPropertyAsInt($"{_prefix}.Size") ?? 1;

            if (size < 1)
            {
                string s = _prefix + ".Size < 1; Size adjusted to 1";
                _communicator.Logger.warning(s);
                size = 1;
            }

            int sizeMax = _communicator.GetPropertyAsInt($"{_prefix}.SizeMax") ?? size;

            if (sizeMax < size)
            {
                _communicator.Logger.warning($"{_prefix}.SizeMax < {_prefix}.Size; SizeMax adjusted to Size ({size})");
                sizeMax = size;
            }

            int sizeWarn = _communicator.GetPropertyAsInt($"{_prefix}.SizeWarn") ?? 0;

            if (sizeWarn != 0 && sizeWarn < size)
            {
                _communicator.Logger.warning(
                    $"{_prefix}.SizeWarn < {_prefix}.Size; adjusted SizeWarn to Size ({size})");
                sizeWarn = size;
            }
            else if (sizeWarn > sizeMax)
            {
                _communicator.Logger.warning(
                    "${_prefix}.SizeWarn > {_prefix}.SizeMax; adjusted SizeWarn to SizeMax ({sizeMax})");
                sizeWarn = sizeMax;
            }

            int threadIdleTime = _communicator.GetPropertyAsInt($"{_prefix}.ThreadIdleTime") ?? 60;

            if (threadIdleTime < 0)
            {
                _communicator.Logger.warning($"{_prefix}.ThreadIdleTime < 0; ThreadIdleTime adjusted to 0");
                threadIdleTime = 0;
            }

            _size           = size;
            _sizeMax        = sizeMax;
            _sizeWarn       = sizeWarn;
            _threadIdleTime = threadIdleTime;

            int stackSize = communicator.GetPropertyAsInt($"{_prefix }.StackSize") ?? 0;

            if (stackSize < 0)
            {
                _communicator.Logger.warning($"{_prefix}.StackSize < 0; Size adjusted to OS default");
                stackSize = 0;
            }
            _stackSize = stackSize;

            _priority = Util.stringToThreadPriority(_communicator.GetProperty($"{_prefix}.ThreadPriority") ??
                                                    _communicator.GetProperty("Ice.ThreadPriority"));

            if (_communicator.traceLevels().threadPool >= 1)
            {
                _communicator.Logger.trace(_communicator.traceLevels().threadPoolCat,
                                           $"creating {_prefix}: Size = {_size}, SizeMax = {_sizeMax}, SizeWarn = {_sizeWarn}");
            }

            _workItems = new Queue <ThreadPoolWorkItem>();

            try
            {
                _threads = new List <WorkerThread>();
                for (int i = 0; i < _size; ++i)
                {
                    WorkerThread thread = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++);
                    thread.start(_priority);
                    _threads.Add(thread);
                }
            }
            catch (System.Exception ex)
            {
                string s = "cannot create thread for `" + _prefix + "':\n" + ex;
                _communicator.Logger.error(s);

                destroy();
                joinWithAllThreads();
                throw;
            }
        }
Beispiel #29
0
 //
 // Only for use by Instance
 //
 internal ReferenceFactory(Instance instance, Ice.Communicator communicator)
 {
     instance_ = instance;
     _communicator = communicator;
 }
Beispiel #30
0
 //
 // Only for use by Instance
 //
 internal ReferenceFactory(Instance instance, Ice.Communicator communicator)
 {
     instance_     = instance;
     _communicator = communicator;
 }
Beispiel #31
0
 public HelloPluginI(Ice.Communicator communicator)
 {
     _communicator = communicator;
 }
Beispiel #32
0
            internal static void batchOneways(global::Test.TestHelper helper, Test.MyClassPrx p)
            {
                byte[] bs1 = new byte[10 * 1024];

                Test.MyClassPrx batch = Test.MyClassPrxHelper.uncheckedCast(p.ice_batchOneway());
                batch.ice_flushBatchRequests(); // Empty flush

                p.opByteSOnewayCallCount();     // Reset the call count

                for (int i = 0; i < 30; ++i)
                {
                    try
                    {
                        batch.opByteSOneway(bs1);
                    }
                    catch (Ice.MemoryLimitException)
                    {
                        test(false);
                    }
                }

                int count = 0;

                while (count < 27) // 3 * 9 requests auto-flushed.
                {
                    count += p.opByteSOnewayCallCount();
                    System.Threading.Thread.Sleep(10);
                }

                if (batch.ice_getConnection() != null)
                {
                    Test.MyClassPrx batch1 = Test.MyClassPrxHelper.uncheckedCast(p.ice_batchOneway());
                    Test.MyClassPrx batch2 = Test.MyClassPrxHelper.uncheckedCast(p.ice_batchOneway());

                    batch1.ice_ping();
                    batch2.ice_ping();
                    batch1.ice_flushBatchRequests();
                    batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
                    batch1.ice_ping();
                    batch2.ice_ping();

                    batch1.ice_getConnection();
                    batch2.ice_getConnection();

                    batch1.ice_ping();
                    batch1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
                    batch1.ice_ping();
                    batch2.ice_ping();
                }

                Ice.Identity identity = new Ice.Identity();
                identity.name = "invalid";
                Ice.ObjectPrx batch3 = batch.ice_identity(identity);
                batch3.ice_ping();
                batch3.ice_flushBatchRequests();

                // Make sure that a bogus batch request doesn't cause troubles to other ones.
                batch3.ice_ping();
                batch.ice_ping();
                batch.ice_flushBatchRequests();
                batch.ice_ping();

                if (batch.ice_getConnection() != null)
                {
                    Ice.InitializationData initData = new Ice.InitializationData();
                    initData.properties = p.ice_getCommunicator().getProperties().ice_clone_();
                    BatchRequestInterceptorI interceptor = new BatchRequestInterceptorI();
                    initData.batchRequestInterceptor = interceptor.enqueue;
                    Ice.Communicator ic = helper.initialize(initData);

                    batch = Test.MyClassPrxHelper.uncheckedCast(ic.stringToProxy(p.ToString()).ice_batchOneway());

                    test(interceptor.count() == 0);
                    batch.ice_ping();
                    batch.ice_ping();
                    batch.ice_ping();
                    test(interceptor.count() == 0);

                    interceptor.setEnqueue(true);
                    batch.ice_ping();
                    batch.ice_ping();
                    batch.ice_ping();
                    test(interceptor.count() == 3);

                    batch.ice_flushBatchRequests();
                    batch.ice_ping();
                    test(interceptor.count() == 1);

                    batch.opByteSOneway(bs1);
                    test(interceptor.count() == 2);
                    batch.opByteSOneway(bs1);
                    test(interceptor.count() == 3);

                    batch.opByteSOneway(bs1); // This should trigger the flush
                    batch.ice_ping();
                    test(interceptor.count() == 2);

                    ic.destroy();
                }

                p.ice_ping();

                bool supportsCompress = true;

                try
                {
                    supportsCompress = p.supportsCompress();
                }
                catch (Ice.OperationNotExistException)
                {
                }

                if (supportsCompress && p.ice_getConnection() != null &&
                    p.ice_getCommunicator().getProperties().getProperty("Ice.Override.Compress").Equals(""))
                {
                    Ice.ObjectPrx prx = p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway();

                    Test.MyClassPrx batchC1 = Test.MyClassPrxHelper.uncheckedCast(prx.ice_compress(false));
                    Test.MyClassPrx batchC2 = Test.MyClassPrxHelper.uncheckedCast(prx.ice_compress(true));
                    Test.MyClassPrx batchC3 = Test.MyClassPrxHelper.uncheckedCast(prx.ice_identity(identity));

                    batchC1.opByteSOneway(bs1);
                    batchC1.opByteSOneway(bs1);
                    batchC1.opByteSOneway(bs1);
                    batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.Yes);

                    batchC2.opByteSOneway(bs1);
                    batchC2.opByteSOneway(bs1);
                    batchC2.opByteSOneway(bs1);
                    batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.No);

                    batchC1.opByteSOneway(bs1);
                    batchC1.opByteSOneway(bs1);
                    batchC1.opByteSOneway(bs1);
                    batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy);

                    batchC1.opByteSOneway(bs1);
                    batchC2.opByteSOneway(bs1);
                    batchC1.opByteSOneway(bs1);
                    batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy);

                    batchC1.opByteSOneway(bs1);
                    batchC3.opByteSOneway(bs1);
                    batchC1.opByteSOneway(bs1);
                    batchC1.ice_getConnection().flushBatchRequests(Ice.CompressBatch.BasedOnProxy);
                }
            }
Beispiel #33
0
                public static Test.InitialPrx allTests(global::Test.TestHelper helper)
                {
                    Ice.Communicator communicator = helper.communicator();

                    var output = helper.getWriter();

                    var initial = InitialPrx.Parse($"initial:{helper.getTestEndpoint(0)}", communicator);

                    output.Write("getting B1... ");
                    output.Flush();
                    B b1 = initial.getB1();

                    test(b1 != null);
                    output.WriteLine("ok");

                    output.Write("getting B2... ");
                    output.Flush();
                    B b2 = initial.getB2();

                    test(b2 != null);
                    output.WriteLine("ok");

                    output.Write("getting C... ");
                    output.Flush();
                    C c = initial.getC();

                    test(c != null);
                    output.WriteLine("ok");

                    output.Write("getting D... ");
                    output.Flush();
                    D d = initial.getD();

                    test(d != null);
                    output.WriteLine("ok");

                    output.Write("checking consistency... ");
                    output.Flush();
                    test(b1 != b2);
                    //test(b1 != c);
                    //test(b1 != d);
                    //test(b2 != c);
                    //test(b2 != d);
                    //test(c != d);
                    test(b1.theB == b1);
                    test(b1.theC == null);
                    test(b1.theA is B);
                    test(((B)b1.theA).theA == b1.theA);
                    test(((B)b1.theA).theB == b1);
                    //test(((B)b1.theA).theC is C); // Redundant -- theC is always of type C
                    test(((C)(((B)b1.theA).theC)).theB == b1.theA);

                    // More tests possible for b2 and d, but I think this is already
                    // sufficient.
                    test(b2.theA == b2);
                    test(d.theC == null);
                    output.WriteLine("ok");

                    output.Write("getting B1, B2, C, and D all at once... ");
                    output.Flush();
                    B b1out;
                    B b2out;
                    C cout;
                    D dout;

                    initial.getAll(out b1out, out b2out, out cout, out dout);
                    test(b1out != null);
                    test(b2out != null);
                    test(cout != null);
                    test(dout != null);
                    output.WriteLine("ok");

                    output.Write("checking consistency... ");
                    output.Flush();
                    test(b1out != b2out);
                    test(b1out.theA == b2out);
                    test(b1out.theB == b1out);
                    test(b1out.theC == null);
                    test(b2out.theA == b2out);
                    test(b2out.theB == b1out);
                    test(b2out.theC == cout);
                    test(cout.theB == b2out);
                    test(dout.theA == b1out);
                    test(dout.theB == b2out);
                    test(dout.theC == null);

                    output.WriteLine("ok");

                    output.Write("getting K... ");
                    {
                        output.Flush();
                        var k = initial.getK();
                        var l = k.value as L;
                        test(l != null);
                        test(l.data.Equals("l"));
                    }
                    output.WriteLine("ok");

                    output.Write("testing Value as parameter... ");
                    output.Flush();
                    {
                        Ice.Value v1 = new L("l");
                        Ice.Value v2;
                        Ice.Value v3 = initial.opValue(v1, out v2);
                        test(((L)v2).data.Equals("l"));
                        test(((L)v3).data.Equals("l"));
                    }
                    {
                        L           l  = new L("l");
                        Ice.Value[] v1 = new Ice.Value[] { l };
                        Ice.Value[] v2;
                        Ice.Value[] v3 = initial.opValueSeq(v1, out v2);
                        test(((L)v2[0]).data.Equals("l"));
                        test(((L)v3[0]).data.Equals("l"));
                    }
                    {
                        L l = new L("l");
                        Dictionary <string, Ice.Value> v1 = new Dictionary <string, Ice.Value> {
                            { "l", l }
                        };
                        Dictionary <string, Ice.Value> v2;
                        Dictionary <string, Ice.Value> v3 = initial.opValueMap(v1, out v2);
                        test(((L)v2["l"]).data.Equals("l"));
                        test(((L)v3["l"]).data.Equals("l"));
                    }
                    output.WriteLine("ok");

                    output.Write("getting D1... ");
                    output.Flush();
                    D1 d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4"));

                    d1 = initial.getD1(d1);
                    test(d1.a1.name.Equals("a1"));
                    test(d1.a2.name.Equals("a2"));
                    test(d1.a3.name.Equals("a3"));
                    test(d1.a4.name.Equals("a4"));
                    output.WriteLine("ok");

                    output.Write("throw EDerived... ");
                    output.Flush();
                    try
                    {
                        initial.throwEDerived();
                        test(false);
                    }
                    catch (EDerived ederived)
                    {
                        test(ederived.a1.name.Equals("a1"));
                        test(ederived.a2.name.Equals("a2"));
                        test(ederived.a3.name.Equals("a3"));
                        test(ederived.a4.name.Equals("a4"));
                    }
                    output.WriteLine("ok");

                    output.Write("setting G... ");
                    output.Flush();
                    try
                    {
                        initial.setG(new G(new S("hello"), "g"));
                    }
                    catch (Ice.OperationNotExistException)
                    {
                    }
                    output.WriteLine("ok");

                    output.Write("testing sequences...");
                    output.Flush();
                    try
                    {
                        Base[] inS = new Test.Base[0];
                        Base[] outS;
                        Base[] retS;
                        retS = initial.opBaseSeq(inS, out outS);

                        inS    = new Test.Base[1];
                        inS[0] = new Test.Base(new S(), "");
                        retS   = initial.opBaseSeq(inS, out outS);
                        test(retS.Length == 1 && outS.Length == 1);
                    }
                    catch (Ice.OperationNotExistException)
                    {
                    }
                    output.WriteLine("ok");

                    output.Write("testing recursive type... ");
                    output.Flush();
                    var top   = new Test.Recursive();
                    var p     = top;
                    int depth = 0;

                    try
                    {
                        for (; depth <= 1000; ++depth)
                        {
                            p.v = new Test.Recursive();
                            p   = p.v;
                            if ((depth < 10 && (depth % 10) == 0) ||
                                (depth < 1000 && (depth % 100) == 0) ||
                                (depth < 10000 && (depth % 1000) == 0) ||
                                (depth % 10000) == 0)
                            {
                                initial.setRecursive(top);
                            }
                        }
                        test(!initial.supportsClassGraphDepthMax());
                    }
                    catch (Ice.UnknownLocalException)
                    {
                        // Expected marshal exception from the server(max class graph depth reached)
                    }
                    catch (Ice.UnknownException)
                    {
                        // Expected stack overflow from the server(Java only)
                    }
                    initial.setRecursive(new Test.Recursive());
                    output.WriteLine("ok");

                    output.Write("testing compact ID...");
                    output.Flush();
                    try
                    {
                        test(initial.getCompact() != null);
                    }
                    catch (Ice.OperationNotExistException)
                    {
                    }
                    output.WriteLine("ok");

                    output.Write("testing marshaled results...");
                    output.Flush();
                    b1 = initial.getMB();
                    test(b1 != null && b1.theB == b1);
                    b1 = initial.getAMDMBAsync().Result;
                    test(b1 != null && b1.theB == b1);
                    output.WriteLine("ok");

                    output.Write("testing UnexpectedObjectException...");
                    output.Flush();
                    var uoet = UnexpectedObjectExceptionTestPrx.Parse($"uoet:{helper.getTestEndpoint(0)}", communicator);

                    try
                    {
                        uoet.op();
                        test(false);
                    }
                    catch (UnexpectedObjectException ex)
                    {
                        test(ex.type.Equals("::Test::AlsoEmpty"));
                        test(ex.expectedType.Equals("::Test::Empty"));
                    }
                    catch (System.Exception ex)
                    {
                        output.WriteLine(ex.ToString());
                        test(false);
                    }
                    output.WriteLine("ok");

                    output.Write("testing partial ice_initialize...");
                    output.Flush();
                    var ib1 = new IBase();

                    test(ib1.id.Equals("My id"));
                    var id1 = new IDerived();

                    test(id1.id.Equals("My id"));
                    test(id1.name.Equals("My name"));

                    var id2 = new Test.IDerived2();

                    test(id2.id.Equals("My id"));
                    var i2 = new I2();

                    test(i2.called);

                    var s1 = new S1();

                    // The struct default constructor do not call ice_initialize
                    test(s1.id == 0);
                    s1 = new S1(2);
                    // The id should have the value set by ice_initialize and not 2
                    test(s1.id == 1);

                    var sc1 = new SC1();

                    test(sc1.id.Equals("My id"));
                    output.WriteLine("ok");

                    output.Write("testing class containing complex dictionary... ");
                    output.Flush();
                    {
                        var m = new Test.M();
                        m.v = new Dictionary <StructKey, L>();
                        var k1 = new StructKey(1, "1");
                        m.v[k1] = new L("one");
                        var k2 = new StructKey(2, "2");
                        m.v[k2] = new L("two");
                        Test.M m1;
                        var    m2 = initial.opM(m, out m1);
                        test(m1.v.Count == 2);
                        test(m2.v.Count == 2);

                        test(m1.v[k1].data.Equals("one"));
                        test(m2.v[k1].data.Equals("one"));

                        test(m1.v[k2].data.Equals("two"));
                        test(m2.v[k2].data.Equals("two"));
                    }
                    output.WriteLine("ok");

                    output.Write("testing forward declared types... ");
                    output.Flush();
                    {
                        F1 f12;
                        F1 f11 = initial.opF1(new F1("F11"), out f12);
                        test(f11.name.Equals("F11"));
                        test(f12.name.Equals("F12"));

                        F2Prx f22;
                        F2Prx f21 = initial.opF2(F2Prx.Parse($"F21:{helper.getTestEndpoint()}", communicator), out f22);
                        test(f21.Identity.name.Equals("F21"));
                        f21.op();
                        test(f22.Identity.name.Equals("F22"));

                        if (initial.hasF3())
                        {
                            F3 f32;
                            F3 f31 = initial.opF3(new F3(new F1("F11"), F2Prx.Parse("F21", communicator)), out f32);

                            test(f31.f1.name.Equals("F11"));
                            test(f31.f2.Identity.name.Equals("F21"));

                            test(f32.f1.name.Equals("F12"));
                            test(f32.f2.Identity.name.Equals("F22"));
                        }
                    }
                    output.WriteLine("ok");

                    return(initial);
                }
Beispiel #34
0
 public Ice.Plugin create(Ice.Communicator communicator, string name, string[] args)
 {
     return(new Ice.LoggerPlugin(communicator, new LoggerI()));
 }
Beispiel #35
0
            public static Test.TestIntfPrx allTests(global::Test.TestHelper helper)
            {
                Ice.Communicator communicator = helper.communicator();
                string           sref         = "test:" + helper.getTestEndpoint(0);
                var obj = IObjectPrx.Parse(sref, communicator);

                test(obj != null);
                var proxy = Test.TestIntfPrx.UncheckedCast(obj);

                test(proxy != null);

                var output = helper.getWriter();

                output.Write("testing enum values... ");
                output.Flush();

                test((int)Test.ByteEnum.benum1 == 0);
                test((int)Test.ByteEnum.benum2 == 1);
                test((int)Test.ByteEnum.benum3 == Test.ByteConst1.value);
                test((int)Test.ByteEnum.benum4 == Test.ByteConst1.value + 1);
                test((int)Test.ByteEnum.benum5 == Test.ShortConst1.value);
                test((int)Test.ByteEnum.benum6 == Test.ShortConst1.value + 1);
                test((int)Test.ByteEnum.benum7 == Test.IntConst1.value);
                test((int)Test.ByteEnum.benum8 == Test.IntConst1.value + 1);
                test((int)Test.ByteEnum.benum9 == Test.LongConst1.value);
                test((int)Test.ByteEnum.benum10 == Test.LongConst1.value + 1);
                test((int)Test.ByteEnum.benum11 == Test.ByteConst2.value);

                test((int)Test.ShortEnum.senum1 == 3);
                test((int)Test.ShortEnum.senum2 == 4);
                test((int)Test.ShortEnum.senum3 == Test.ByteConst1.value);
                test((int)Test.ShortEnum.senum4 == Test.ByteConst1.value + 1);
                test((int)Test.ShortEnum.senum5 == Test.ShortConst1.value);
                test((int)Test.ShortEnum.senum6 == Test.ShortConst1.value + 1);
                test((int)Test.ShortEnum.senum7 == Test.IntConst1.value);
                test((int)Test.ShortEnum.senum8 == Test.IntConst1.value + 1);
                test((int)Test.ShortEnum.senum9 == Test.LongConst1.value);
                test((int)Test.ShortEnum.senum10 == Test.LongConst1.value + 1);
                test((int)Test.ShortEnum.senum11 == Test.ShortConst2.value);

                test((int)Test.IntEnum.ienum1 == 0);
                test((int)Test.IntEnum.ienum2 == 1);
                test((int)Test.IntEnum.ienum3 == Test.ByteConst1.value);
                test((int)Test.IntEnum.ienum4 == Test.ByteConst1.value + 1);
                test((int)Test.IntEnum.ienum5 == Test.ShortConst1.value);
                test((int)Test.IntEnum.ienum6 == Test.ShortConst1.value + 1);
                test((int)Test.IntEnum.ienum7 == Test.IntConst1.value);
                test((int)Test.IntEnum.ienum8 == Test.IntConst1.value + 1);
                test((int)Test.IntEnum.ienum9 == Test.LongConst1.value);
                test((int)Test.IntEnum.ienum10 == Test.LongConst1.value + 1);
                test((int)Test.IntEnum.ienum11 == Test.IntConst2.value);
                test((int)Test.IntEnum.ienum12 == Test.LongConst2.value);

                test((int)Test.SimpleEnum.red == 0);
                test((int)Test.SimpleEnum.green == 1);
                test((int)Test.SimpleEnum.blue == 2);

                output.WriteLine("ok");

                output.Write("testing enum streaming... ");
                output.Flush();

                Ice.OutputStream ostr;
                byte[]           bytes;

                bool encoding_1_0 = communicator.GetProperty("Ice.Default.EncodingVersion") == "1.0";

                ostr = new OutputStream(communicator);
                ostr.WriteEnum((int)Test.ByteEnum.benum11, (int)Test.ByteEnum.benum11);
                bytes = ostr.Finished();
                test(bytes.Length == 1); // ByteEnum should require one byte

                ostr = new OutputStream(communicator);
                ostr.WriteEnum((int)Test.ShortEnum.senum11, (int)Test.ShortEnum.senum11);
                bytes = ostr.Finished();
                test(bytes.Length == (encoding_1_0 ? 2 : 5));

                ostr = new OutputStream(communicator);
                ostr.WriteEnum((int)Test.IntEnum.ienum11, (int)Test.IntEnum.ienum12);
                bytes = ostr.Finished();
                test(bytes.Length == (encoding_1_0 ? 4 : 5));

                ostr = new OutputStream(communicator);
                ostr.WriteEnum((int)Test.SimpleEnum.blue, (int)Test.SimpleEnum.blue);
                bytes = ostr.Finished();
                test(bytes.Length == 1); // SimpleEnum should require one byte

                output.WriteLine("ok");

                output.Write("testing enum operations... ");
                output.Flush();

                Test.ByteEnum byteEnum;
                test(proxy.opByte(Test.ByteEnum.benum1, out byteEnum) == Test.ByteEnum.benum1);
                test(byteEnum == Test.ByteEnum.benum1);
                test(proxy.opByte(Test.ByteEnum.benum11, out byteEnum) == Test.ByteEnum.benum11);
                test(byteEnum == Test.ByteEnum.benum11);

                Test.ShortEnum shortEnum;
                test(proxy.opShort(Test.ShortEnum.senum1, out shortEnum) == Test.ShortEnum.senum1);
                test(shortEnum == Test.ShortEnum.senum1);
                test(proxy.opShort(Test.ShortEnum.senum11, out shortEnum) == Test.ShortEnum.senum11);
                test(shortEnum == Test.ShortEnum.senum11);

                Test.IntEnum intEnum;
                test(proxy.opInt(Test.IntEnum.ienum1, out intEnum) == Test.IntEnum.ienum1);
                test(intEnum == Test.IntEnum.ienum1);
                test(proxy.opInt(Test.IntEnum.ienum11, out intEnum) == Test.IntEnum.ienum11);
                test(intEnum == Test.IntEnum.ienum11);
                test(proxy.opInt(Test.IntEnum.ienum12, out intEnum) == Test.IntEnum.ienum12);
                test(intEnum == Test.IntEnum.ienum12);

                Test.SimpleEnum s;
                test(proxy.opSimple(Test.SimpleEnum.green, out s) == Test.SimpleEnum.green);
                test(s == Test.SimpleEnum.green);

                output.WriteLine("ok");

                output.Write("testing enum sequences operations... ");
                output.Flush();

                {
                    var b1 = new Test.ByteEnum[11]
                    {
                        Test.ByteEnum.benum1,
                        Test.ByteEnum.benum2,
                        Test.ByteEnum.benum3,
                        Test.ByteEnum.benum4,
                        Test.ByteEnum.benum5,
                        Test.ByteEnum.benum6,
                        Test.ByteEnum.benum7,
                        Test.ByteEnum.benum8,
                        Test.ByteEnum.benum9,
                        Test.ByteEnum.benum10,
                        Test.ByteEnum.benum11
                    };

                    Test.ByteEnum[] b2;
                    Test.ByteEnum[] b3 = proxy.opByteSeq(b1, out b2);

                    for (int i = 0; i < b1.Length; ++i)
                    {
                        test(b1[i] == b2[i]);
                        test(b1[i] == b3[i]);
                    }
                }

                {
                    var s1 = new Test.ShortEnum[11]
                    {
                        Test.ShortEnum.senum1,
                        Test.ShortEnum.senum2,
                        Test.ShortEnum.senum3,
                        Test.ShortEnum.senum4,
                        Test.ShortEnum.senum5,
                        Test.ShortEnum.senum6,
                        Test.ShortEnum.senum7,
                        Test.ShortEnum.senum8,
                        Test.ShortEnum.senum9,
                        Test.ShortEnum.senum10,
                        Test.ShortEnum.senum11
                    };

                    Test.ShortEnum[] s2;
                    Test.ShortEnum[] s3 = proxy.opShortSeq(s1, out s2);

                    for (int i = 0; i < s1.Length; ++i)
                    {
                        test(s1[i] == s2[i]);
                        test(s1[i] == s3[i]);
                    }
                }

                {
                    Test.IntEnum[] i1 = new Test.IntEnum[11]
                    {
                        Test.IntEnum.ienum1,
                        Test.IntEnum.ienum2,
                        Test.IntEnum.ienum3,
                        Test.IntEnum.ienum4,
                        Test.IntEnum.ienum5,
                        Test.IntEnum.ienum6,
                        Test.IntEnum.ienum7,
                        Test.IntEnum.ienum8,
                        Test.IntEnum.ienum9,
                        Test.IntEnum.ienum10,
                        Test.IntEnum.ienum11
                    };

                    Test.IntEnum[] i2;
                    Test.IntEnum[] i3 = proxy.opIntSeq(i1, out i2);

                    for (int i = 0; i < i1.Length; ++i)
                    {
                        test(i1[i] == i2[i]);
                        test(i1[i] == i3[i]);
                    }
                }

                {
                    var s1 = new Test.SimpleEnum[3]
                    {
                        Test.SimpleEnum.red,
                        Test.SimpleEnum.green,
                        Test.SimpleEnum.blue
                    };

                    Test.SimpleEnum[] s2;
                    Test.SimpleEnum[] s3 = proxy.opSimpleSeq(s1, out s2);

                    for (int i = 0; i < s1.Length; ++i)
                    {
                        test(s1[i] == s2[i]);
                        test(s1[i] == s3[i]);
                    }
                }

                output.WriteLine("ok");
                return(proxy);
            }
Beispiel #36
0
 public RetryTask(Ice.Communicator communicator, RetryQueue retryQueue, ProxyOutgoingAsyncBase outAsync)
 {
     _communicator = communicator;
     _retryQueue   = retryQueue;
     _outAsync     = outAsync;
 }
Beispiel #37
0
 internal ServerI(Ice.Communicator communicator)
 {
     communicator_ = communicator;
 }
Beispiel #38
0
 public RetryQueue(Ice.Communicator communicator)
 {
     _communicator = communicator;
 }
Beispiel #39
0
        internal void destroy()
        {
            Ice.Communicator sendLogCommunicator = null;

            lock(this)
            {
            if(!_destroyed)
            {
                _destroyed = true;
                sendLogCommunicator = _sendLogCommunicator;
                _sendLogCommunicator = null;
            }
            }

            //
            // Destroy outside lock to avoid deadlock when there are outstanding two-way log calls sent to
            // remote logggers
            //
            if(sendLogCommunicator != null)
            {
            sendLogCommunicator.destroy();
            }
        }
Beispiel #40
0
        private void stopAll()
        {
            _m.Lock();
            try
            {
            //
            // First wait for any active startService/stopService calls to complete.
            //
            while(_pendingStatusChanges)
            {
                _m.Wait();
            }

            //
            // First, for each service, we call stop on the service and flush its database environment to
            // the disk. Services are stopped in the reverse order of which they were started.
            //
            _services.Reverse();
            List<string> stoppedServices = new List<string>();
            foreach(ServiceInfo info in _services)
            {
                if(info.status == ServiceStatus.Started)
                {
                    try
                    {
                        info.service.stop();
                        stoppedServices.Add(info.name);
                    }
                    catch(System.Exception e)
                    {
                        _logger.warning("IceBox.ServiceManager: exception while stopping service " + info.name + ":\n" +
                                        e.ToString());
                    }
                }

                try
                {
                    _communicator.removeAdminFacet("IceBox.Service." + info.name + ".Properties");
                }
                catch(Ice.LocalException)
                {
                    // Ignored
                }

                if(info.communicator != null)
                {
                    try
                    {
                        info.communicator.shutdown();
                        info.communicator.waitForShutdown();
                    }
                    catch(Ice.CommunicatorDestroyedException)
                    {
                        //
                        // Ignore, the service might have already destroyed
                        // the communicator for its own reasons.
                        //
                    }
                    catch(Exception e)
                    {
                        _logger.warning("ServiceManager: exception while stopping service " + info.name + ":\n" +
                                        e.ToString());
                    }

                    try
                    {
                        info.communicator.destroy();
                    }
                    catch(System.Exception e)
                    {
                        _logger.warning("ServiceManager: exception while stopping service " + info.name + ":\n" +
                                        e.ToString());
                    }
                }
            }

            if(_sharedCommunicator != null)
            {
                try
                {
                    _sharedCommunicator.destroy();
                }
                catch(System.Exception e)
                {
                    _logger.warning("ServiceManager: exception while destroying shared communicator:\n" + e.ToString());
                }
                _sharedCommunicator = null;
            }

            _services.Clear();
            servicesStopped(stoppedServices, _observers.Keys);
            }
            finally
            {
            _m.Unlock();
            }
        }
Beispiel #41
0
 public AsyncCallback(Ice.Communicator c)
 {
     _communicator = c;
     callback = new Callback();
 }
Beispiel #42
0
            public static void allTests(global::Test.TestHelper helper)
            {
                Ice.Communicator communicator = helper.communicator();
                var output = helper.getWriter();

                output.Write("testing communicator operations... ");
                output.Flush();
                {
                    //
                    // Test: Exercise addAdminFacet, findAdminFacet, removeAdminFacet with a typical configuration.
                    //
                    Ice.InitializationData init = new Ice.InitializationData();
                    init.properties = Ice.Util.createProperties();
                    init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    init.properties.setProperty("Ice.Admin.InstanceName", "Test");
                    Ice.Communicator com = Ice.Util.initialize(init);
                    testFacets(com, true);
                    com.destroy();
                }
                {
                    //
                    // Test: Verify that the operations work correctly in the presence of facet filters.
                    //
                    Ice.InitializationData init = new Ice.InitializationData();
                    init.properties = Ice.Util.createProperties();
                    init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    init.properties.setProperty("Ice.Admin.InstanceName", "Test");
                    init.properties.setProperty("Ice.Admin.Facets", "Properties");
                    Ice.Communicator com = Ice.Util.initialize(init);
                    testFacets(com, false);
                    com.destroy();
                }
                {
                    //
                    // Test: Verify that the operations work correctly with the Admin object disabled.
                    //
                    Ice.Communicator com = Ice.Util.initialize();
                    testFacets(com, false);
                    com.destroy();
                }
                {
                    //
                    // Test: Verify that the operations work correctly with Ice.Admin.Enabled=1
                    //
                    Ice.InitializationData init = new Ice.InitializationData();
                    init.properties = Ice.Util.createProperties();
                    init.properties.setProperty("Ice.Admin.Enabled", "1");
                    Ice.Communicator com = Ice.Util.initialize(init);
                    test(com.getAdmin() == null);
                    Ice.Identity id = Ice.Util.stringToIdentity("test-admin");
                    try
                    {
                        com.createAdmin(null, id);
                        test(false);
                    }
                    catch (Ice.InitializationException)
                    {
                    }

                    Ice.ObjectAdapter adapter = com.createObjectAdapter("");
                    test(com.createAdmin(adapter, id) != null);
                    test(com.getAdmin() != null);

                    testFacets(com, true);
                    com.destroy();
                }
                {
                    //
                    // Test: Verify that the operations work correctly when creation of the Admin object is delayed.
                    //
                    Ice.InitializationData init = new Ice.InitializationData();
                    init.properties = Ice.Util.createProperties();
                    init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    init.properties.setProperty("Ice.Admin.InstanceName", "Test");
                    init.properties.setProperty("Ice.Admin.DelayCreation", "1");
                    Ice.Communicator com = Ice.Util.initialize(init);
                    testFacets(com, true);
                    com.getAdmin();
                    testFacets(com, true);
                    com.destroy();
                }
                output.WriteLine("ok");

                string @ref = "factory:" + helper.getTestEndpoint(0) + " -t 10000";

                Test.RemoteCommunicatorFactoryPrx factory =
                    Test.RemoteCommunicatorFactoryPrxHelper.uncheckedCast(communicator.stringToProxy(@ref));

                output.Write("testing process facet... ");
                output.Flush();
                {
                    //
                    // Test: Verify that Process::shutdown() operation shuts down the communicator.
                    //
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    var            com  = factory.createCommunicator(props);
                    Ice.ObjectPrx  obj  = com.getAdmin();
                    Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
                    proc.shutdown();
                    com.waitForShutdown();
                    com.destroy();
                }
                output.WriteLine("ok");

                output.Write("testing properties facet... ");
                output.Flush();
                {
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    props.Add("Prop1", "1");
                    props.Add("Prop2", "2");
                    props.Add("Prop3", "3");
                    var                    com = factory.createCommunicator(props);
                    Ice.ObjectPrx          obj = com.getAdmin();
                    Ice.PropertiesAdminPrx pa  = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");

                    //
                    // Test: PropertiesAdmin::getProperty()
                    //
                    test(pa.getProperty("Prop2").Equals("2"));
                    test(pa.getProperty("Bogus").Equals(""));

                    //
                    // Test: PropertiesAdmin::getProperties()
                    //
                    Dictionary <string, string> pd = pa.getPropertiesForPrefix("");
                    test(pd.Count == 5);
                    test(pd["Ice.Admin.Endpoints"].Equals("tcp -h 127.0.0.1"));
                    test(pd["Ice.Admin.InstanceName"].Equals("Test"));
                    test(pd["Prop1"].Equals("1"));
                    test(pd["Prop2"].Equals("2"));
                    test(pd["Prop3"].Equals("3"));

                    Dictionary <string, string> changes;

                    //
                    // Test: PropertiesAdmin::setProperties()
                    //
                    Dictionary <string, string> setProps = new Dictionary <string, string>();
                    setProps.Add("Prop1", "10"); // Changed
                    setProps.Add("Prop2", "20"); // Changed
                    setProps.Add("Prop3", "");   // Removed
                    setProps.Add("Prop4", "4");  // Added
                    setProps.Add("Prop5", "5");  // Added
                    pa.setProperties(setProps);
                    test(pa.getProperty("Prop1").Equals("10"));
                    test(pa.getProperty("Prop2").Equals("20"));
                    test(pa.getProperty("Prop3").Equals(""));
                    test(pa.getProperty("Prop4").Equals("4"));
                    test(pa.getProperty("Prop5").Equals("5"));
                    changes = com.getChanges();
                    test(changes.Count == 5);
                    test(changes["Prop1"].Equals("10"));
                    test(changes["Prop2"].Equals("20"));
                    test(changes["Prop3"].Equals(""));
                    test(changes["Prop4"].Equals("4"));
                    test(changes["Prop5"].Equals("5"));
                    pa.setProperties(setProps);
                    changes = com.getChanges();
                    test(changes.Count == 0);

                    com.destroy();
                }
                output.WriteLine("ok");

                output.Write("testing logger facet... ");
                output.Flush();
                {
                    Dictionary <String, String> props = new Dictionary <String, String>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    props.Add("NullLogger", "1");
                    var com = factory.createCommunicator(props);

                    com.trace("testCat", "trace");
                    com.warning("warning");
                    com.error("error");
                    com.print("print");

                    Ice.ObjectPrx      obj    = com.getAdmin();
                    Ice.LoggerAdminPrx logger = Ice.LoggerAdminPrxHelper.checkedCast(obj, "Logger");
                    test(logger != null);

                    string prefix = null;

                    //
                    // Get all
                    //
                    Ice.LogMessage[] logMessages = logger.getLog(null, null, -1, out prefix);

                    test(logMessages.Length == 4);
                    test(prefix.Equals("NullLogger"));
                    test(logMessages[0].traceCategory.Equals("testCat") && logMessages[0].message.Equals("trace"));
                    test(logMessages[1].message.Equals("warning"));
                    test(logMessages[2].message.Equals("error"));
                    test(logMessages[3].message.Equals("print"));

                    //
                    // Get only errors and warnings
                    //
                    com.error("error2");
                    com.print("print2");
                    com.trace("testCat", "trace2");
                    com.warning("warning2");

                    Ice.LogMessageType[] messageTypes =
                    {
                        Ice.LogMessageType.ErrorMessage,
                        Ice.LogMessageType.WarningMessage
                    };

                    logMessages = logger.getLog(messageTypes, null, -1, out prefix);

                    test(logMessages.Length == 4);
                    test(prefix.Equals("NullLogger"));

                    foreach (var msg in logMessages)
                    {
                        test(msg.type == Ice.LogMessageType.ErrorMessage ||
                             msg.type == Ice.LogMessageType.WarningMessage);
                    }

                    //
                    // Get only errors and traces with Cat = "testCat"
                    //
                    com.trace("testCat2", "A");
                    com.trace("testCat", "trace3");
                    com.trace("testCat2", "B");

                    messageTypes = new Ice.LogMessageType[] {
                        Ice.LogMessageType.ErrorMessage,
                        Ice.LogMessageType.TraceMessage
                    };
                    string[] categories = { "testCat" };
                    logMessages = logger.getLog(messageTypes, categories, -1, out prefix);
                    test(logMessages.Length == 5);
                    test(prefix.Equals("NullLogger"));

                    foreach (var msg in logMessages)
                    {
                        test(msg.type == Ice.LogMessageType.ErrorMessage ||
                             (msg.type == Ice.LogMessageType.TraceMessage && msg.traceCategory.Equals("testCat")));
                    }

                    //
                    // Same, but limited to last 2 messages(trace3 + error3)
                    //
                    com.error("error3");

                    logMessages = logger.getLog(messageTypes, categories, 2, out prefix);
                    test(logMessages.Length == 2);
                    test(prefix.Equals("NullLogger"));

                    test(logMessages[0].message.Equals("trace3"));
                    test(logMessages[1].message.Equals("error3"));

                    //
                    // Now, test RemoteLogger
                    //
                    Ice.ObjectAdapter adapter =
                        communicator.createObjectAdapterWithEndpoints("RemoteLoggerAdapter", "tcp -h localhost");

                    RemoteLoggerI remoteLogger = new RemoteLoggerI();

                    Ice.RemoteLoggerPrx myProxy =
                        Ice.RemoteLoggerPrxHelper.uncheckedCast(adapter.addWithUUID(remoteLogger));

                    adapter.activate();

                    //
                    // No filtering
                    //
                    logMessages = logger.getLog(null, null, -1, out prefix);
                    remoteLogger.checkNextInit(prefix, logMessages);

                    logger.attachRemoteLogger(myProxy, null, null, -1);
                    remoteLogger.wait(1);

                    remoteLogger.checkNextLog(Ice.LogMessageType.TraceMessage, "rtrace", "testCat");
                    remoteLogger.checkNextLog(Ice.LogMessageType.WarningMessage, "rwarning", "");
                    remoteLogger.checkNextLog(Ice.LogMessageType.ErrorMessage, "rerror", "");
                    remoteLogger.checkNextLog(Ice.LogMessageType.PrintMessage, "rprint", "");

                    com.trace("testCat", "rtrace");
                    com.warning("rwarning");
                    com.error("rerror");
                    com.print("rprint");

                    remoteLogger.wait(4);

                    test(logger.detachRemoteLogger(myProxy));
                    test(!logger.detachRemoteLogger(myProxy));

                    //
                    // Use Error + Trace with "traceCat" filter with 4 limit
                    //
                    logMessages = logger.getLog(messageTypes, categories, 4, out prefix);
                    test(logMessages.Length == 4);
                    remoteLogger.checkNextInit(prefix, logMessages);

                    logger.attachRemoteLogger(myProxy, messageTypes, categories, 4);
                    remoteLogger.wait(1);

                    remoteLogger.checkNextLog(Ice.LogMessageType.TraceMessage, "rtrace2", "testCat");
                    remoteLogger.checkNextLog(Ice.LogMessageType.ErrorMessage, "rerror2", "");

                    com.warning("rwarning2");
                    com.trace("testCat", "rtrace2");
                    com.warning("rwarning3");
                    com.error("rerror2");
                    com.print("rprint2");

                    remoteLogger.wait(2);

                    //
                    // Attempt reconnection with slightly different proxy
                    //
                    try
                    {
                        logger.attachRemoteLogger(Ice.RemoteLoggerPrxHelper.uncheckedCast(myProxy.ice_oneway()),
                                                  messageTypes, categories, 4);
                        test(false);
                    }
                    catch (Ice.RemoteLoggerAlreadyAttachedException)
                    {
                        // expected
                    }

                    com.destroy();
                }
                output.WriteLine("ok");

                output.Write("testing custom facet... ");
                output.Flush();
                {
                    //
                    // Test: Verify that the custom facet is present.
                    //
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    var           com = factory.createCommunicator(props);
                    Ice.ObjectPrx obj = com.getAdmin();
                    var           tf  = Test.TestFacetPrxHelper.checkedCast(obj, "TestFacet");
                    tf.op();
                    com.destroy();
                }
                output.WriteLine("ok");

                output.Write("testing facet filtering... ");
                output.Flush();
                {
                    //
                    // Test: Set Ice.Admin.Facets to expose only the Properties facet,
                    // meaning no other facet is available.
                    //
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    props.Add("Ice.Admin.Facets", "Properties");
                    var            com  = factory.createCommunicator(props);
                    Ice.ObjectPrx  obj  = com.getAdmin();
                    Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
                    test(proc == null);
                    var tf = Test.TestFacetPrxHelper.checkedCast(obj, "TestFacet");
                    test(tf == null);
                    com.destroy();
                }
                {
                    //
                    // Test: Set Ice.Admin.Facets to expose only the Process facet,
                    // meaning no other facet is available.
                    //
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    props.Add("Ice.Admin.Facets", "Process");
                    var                    com = factory.createCommunicator(props);
                    Ice.ObjectPrx          obj = com.getAdmin();
                    Ice.PropertiesAdminPrx pa  = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
                    test(pa == null);
                    var tf = Test.TestFacetPrxHelper.checkedCast(obj, "TestFacet");
                    test(tf == null);
                    com.destroy();
                }
                {
                    //
                    // Test: Set Ice.Admin.Facets to expose only the TestFacet facet,
                    // meaning no other facet is available.
                    //
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    props.Add("Ice.Admin.Facets", "TestFacet");
                    var                    com = factory.createCommunicator(props);
                    Ice.ObjectPrx          obj = com.getAdmin();
                    Ice.PropertiesAdminPrx pa  = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
                    test(pa == null);
                    Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
                    test(proc == null);
                    com.destroy();
                }
                {
                    //
                    // Test: Set Ice.Admin.Facets to expose two facets. Use whitespace to separate the
                    // facet names.
                    //
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    props.Add("Ice.Admin.Facets", "Properties TestFacet");
                    var                    com = factory.createCommunicator(props);
                    Ice.ObjectPrx          obj = com.getAdmin();
                    Ice.PropertiesAdminPrx pa  = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
                    test(pa.getProperty("Ice.Admin.InstanceName").Equals("Test"));
                    var tf = Test.TestFacetPrxHelper.checkedCast(obj, "TestFacet");
                    tf.op();
                    Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
                    test(proc == null);
                    com.destroy();
                }
                {
                    //
                    // Test: Set Ice.Admin.Facets to expose two facets. Use a comma to separate the
                    // facet names.
                    //
                    Dictionary <string, string> props = new Dictionary <string, string>();
                    props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1");
                    props.Add("Ice.Admin.InstanceName", "Test");
                    props.Add("Ice.Admin.Facets", "TestFacet, Process");
                    var                    com = factory.createCommunicator(props);
                    Ice.ObjectPrx          obj = com.getAdmin();
                    Ice.PropertiesAdminPrx pa  = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties");
                    test(pa == null);
                    var tf = Test.TestFacetPrxHelper.checkedCast(obj, "TestFacet");
                    tf.op();
                    Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process");
                    proc.shutdown();
                    com.waitForShutdown();
                    com.destroy();
                }
                output.WriteLine("ok");

                factory.shutdown();
            }
Beispiel #43
0
        /// <summary>
        /// Connect to Qwerk.
        /// </summary>
        /// 
        /// <param name="hostAddress">Qwerk's address or host name to connect to.</param>
        /// 
        /// <exception cref="ConnectionFailedException">Failed connecting to Qwerk.</exception>
        /// <exception cref="ServiceAccessFailedException">Failed accessing to the requested service,
        /// which may be due to the fact that something is wrong with Qwerk device or connection
        /// was initiated not with Qwerk.</exception>
        /// 
        public void Connect( string hostAddress )
        {
            // close previous connection
            Disconnect( );

            try
            {
                // initialize ICE communication
                iceCommunicator = Ice.Util.initialize( );
                

                // get Qwerk object
                Ice.ObjectPrx obj = iceCommunicator.stringToProxy( "'::TeRK::TerkUser':tcp -h " + hostAddress + " -p 10101" );
                obj = obj.ice_timeout( TimeOut );
                qwerk = TeRKIceLib.QwerkPrxHelper.checkedCast( obj );

            }
            catch
            {
                Disconnect( );

                throw new ConnectionFailedException( "Failed connecting to the requested service." );
            }

            // check if qwerk's object was obtained successfully
            if ( qwerk == null )
            {
                Disconnect( );

                throw new ServiceAccessFailedException( "Failed accessing to the requested service." );
            }
            else
            {
                // save host address
                this.hostAddress = hostAddress;
            }
        }
Beispiel #44
0
            testFacets(Ice.Communicator com, bool builtInFacets)
            {
                if (builtInFacets)
                {
                    test(com.findAdminFacet("Properties") != null);
                    test(com.findAdminFacet("Process") != null);
                    test(com.findAdminFacet("Logger") != null);
                    test(com.findAdminFacet("Metrics") != null);
                }

                Test.TestFacet f1 = new TestFacetI();
                Test.TestFacet f2 = new TestFacetI();
                Test.TestFacet f3 = new TestFacetI();

                com.addAdminFacet(f1, "Facet1");
                com.addAdminFacet(f2, "Facet2");
                com.addAdminFacet(f3, "Facet3");

                test(com.findAdminFacet("Facet1") == f1);
                test(com.findAdminFacet("Facet2") == f2);
                test(com.findAdminFacet("Facet3") == f3);
                test(com.findAdminFacet("Bogus") == null);

                Dictionary <string, Ice.Object> facetMap = com.findAllAdminFacets();

                if (builtInFacets)
                {
                    test(facetMap.Count == 7);
                    test(facetMap.ContainsKey("Properties"));
                    test(facetMap.ContainsKey("Process"));
                    test(facetMap.ContainsKey("Logger"));
                    test(facetMap.ContainsKey("Metrics"));
                }
                else
                {
                    test(facetMap.Count >= 3);
                }
                test(facetMap.ContainsKey("Facet1"));
                test(facetMap.ContainsKey("Facet2"));
                test(facetMap.ContainsKey("Facet3"));

                try
                {
                    com.addAdminFacet(f1, "Facet1");
                    test(false);
                }
                catch (Ice.AlreadyRegisteredException)
                {
                    // Expected
                }

                try
                {
                    com.removeAdminFacet("Bogus");
                    test(false);
                }
                catch (Ice.NotRegisteredException)
                {
                    // Expected
                }

                com.removeAdminFacet("Facet1");
                com.removeAdminFacet("Facet2");
                com.removeAdminFacet("Facet3");

                try
                {
                    com.removeAdminFacet("Facet1");
                    test(false);
                }
                catch (Ice.NotRegisteredException)
                {
                    // Expected
                }
            }
Beispiel #45
0
 internal FactoryACMMonitor(Ice.Communicator communicator, ACMConfig config)
 {
     _communicator = communicator;
     _config       = config;
 }
Beispiel #46
0
 public ProtocolPluginFacadeI(Ice.Communicator communicator)
 {
     _communicator = communicator;
     _instance = IceInternal.Util.getInstance(communicator);
 }
Beispiel #47
0
        private void stopAll()
        {
            lock(this)
            {
            //
            // First wait for any active startService/stopService calls to complete.
            //
            while(_pendingStatusChanges)
            {
                System.Threading.Monitor.Wait(this);
            }

            //
            // For each service, we call stop on the service and flush its database environment to
            // the disk. Services are stopped in the reverse order of the order they were started.
            //
            _services.Reverse();
            List<string> stoppedServices = new List<string>();
            foreach(ServiceInfo info in _services)
            {
                if(info.status == ServiceStatus.Started)
                {
                    try
                    {
                        info.service.stop();
                        stoppedServices.Add(info.name);
                    }
                    catch(System.Exception e)
                    {
                        _logger.warning("IceBox.ServiceManager: exception while stopping service " + info.name + ":\n" +
                                        e.ToString());
                    }
                }

                if(info.communicator != null)
                {
                    destroyServiceCommunicator(info.name, info.communicator);
                }
            }

            if(_sharedCommunicator != null)
            {
                removeAdminFacets("IceBox.SharedCommunicator.");

                try
                {
                    _sharedCommunicator.destroy();
                }
                catch(System.Exception e)
                {
                    _logger.warning("ServiceManager: exception while destroying shared communicator:\n" + e.ToString());
                }
                _sharedCommunicator = null;
            }

            _services.Clear();
            servicesStopped(stoppedServices, _observers.Keys);
            }
        }
Beispiel #48
0
        internal DefaultsAndOverrides(Ice.Communicator communicator, Ice.ILogger logger)
        {
            string?val;

            // TODO: rename property to Ice.Default.Transport, or remove property and always map default to tcp.
            DefaultTransport = communicator.GetProperty("Ice.Default.Protocol") ?? "tcp";

            DefaultHost = communicator.GetProperty("Ice.Default.Host");

            val = communicator.GetProperty("Ice.Default.SourceAddress");
            if (val != null)
            {
                DefaultSourceAddress = Network.GetNumericAddress(val);
                if (DefaultSourceAddress == null)
                {
                    throw new Ice.InitializationException($"invalid IP address set for Ice.Default.SourceAddress: `{val}'");
                }
            }
            else
            {
                DefaultSourceAddress = null;
            }

            val = communicator.GetProperty("Ice.Override.Timeout");
            if (val != null)
            {
                OverrideTimeout      = true;
                OverrideTimeoutValue = communicator.GetPropertyAsInt("Ice.Override.Timeout") ?? 0;
                if (OverrideTimeoutValue < 1 && OverrideTimeoutValue != -1)
                {
                    OverrideTimeoutValue = -1;
                    var msg = new StringBuilder("invalid value for Ice.Override.Timeout `");
                    msg.Append(communicator.GetProperty("Ice.Override.Timeout"));
                    msg.Append("': defaulting to -1");
                    logger.Warning(msg.ToString());
                }
            }
            else
            {
                OverrideTimeout      = false;
                OverrideTimeoutValue = -1;
            }

            val = communicator.GetProperty("Ice.Override.ConnectTimeout");
            if (val != null)
            {
                OverrideConnectTimeout      = true;
                OverrideConnectTimeoutValue = communicator.GetPropertyAsInt("Ice.Override.ConnectTimeout") ?? -1;
                if (OverrideConnectTimeoutValue < 1 && OverrideConnectTimeoutValue != -1)
                {
                    OverrideConnectTimeoutValue = -1;
                    var msg = new StringBuilder("invalid value for Ice.Override.ConnectTimeout `");
                    msg.Append(communicator.GetProperty("Ice.Override.ConnectTimeout"));
                    msg.Append("': defaulting to -1");
                    logger.Warning(msg.ToString());
                }
            }
            else
            {
                OverrideConnectTimeout      = false;
                OverrideConnectTimeoutValue = -1;
            }

            val = communicator.GetProperty("Ice.Override.CloseTimeout");
            if (val != null)
            {
                OverrideCloseTimeout      = true;
                OverrideCloseTimeoutValue = communicator.GetPropertyAsInt("Ice.Override.CloseTimeout") ?? -1;
                if (OverrideCloseTimeoutValue < 1 && OverrideCloseTimeoutValue != -1)
                {
                    OverrideCloseTimeoutValue = -1;
                    var msg = new StringBuilder("invalid value for Ice.Override.CloseTimeout `");
                    msg.Append(communicator.GetProperty("Ice.Override.CloseTimeout"));
                    msg.Append("': defaulting to -1");
                    logger.Warning(msg.ToString());
                }
            }
            else
            {
                OverrideCloseTimeout      = false;
                OverrideCloseTimeoutValue = -1;
            }

            val = communicator.GetProperty("Ice.Override.Compress");
            if (val != null)
            {
                OverrideCompress      = true;
                OverrideCompressValue = communicator.GetPropertyAsInt("Ice.Override.Compress") > 0;
                if (!BZip2.Supported() && OverrideCompressValue)
                {
                    string lib = AssemblyUtil.IsWindows ? "bzip2.dll" : "libbz2.so.1";
                    Console.Error.WriteLine("warning: " + lib + " not found, Ice.Override.Compress ignored.");
                    OverrideCompressValue = false;
                }
            }
            else
            {
                OverrideCompress      = !BZip2.Supported();
                OverrideCompressValue = false;
            }

            val = communicator.GetProperty("Ice.Override.Secure");
            if (val != null)
            {
                OverrideSecure      = true;
                OverrideSecureValue = communicator.GetPropertyAsInt("Ice.Override.Secure") > 0;
            }
            else
            {
                OverrideSecure      = false;
                OverrideSecureValue = false;
            }

            DefaultCollocationOptimization = (communicator.GetPropertyAsInt("Ice.Default.CollocationOptimized") ?? 1) > 0;

            val = communicator.GetProperty("Ice.Default.EndpointSelection") ?? "Random";
            if (val.Equals("Random"))
            {
                DefaultEndpointSelection = Ice.EndpointSelectionType.Random;
            }
            else if (val.Equals("Ordered"))
            {
                DefaultEndpointSelection = Ice.EndpointSelectionType.Ordered;
            }
            else
            {
                throw new ArgumentException($"illegal value `{val}'; expected `Random' or `Ordered'");
            }

            DefaultTimeout = communicator.GetPropertyAsInt("Ice.Default.Timeout") ?? 60000;
            if (DefaultTimeout < 1 && DefaultTimeout != -1)
            {
                DefaultTimeout = 60000;
                var msg = new StringBuilder("invalid value for Ice.Default.Timeout `");
                msg.Append(communicator.GetProperty("Ice.Default.Timeout"));
                msg.Append("': defaulting to 60000");
                logger.Warning(msg.ToString());
            }

            DefaultLocatorCacheTimeout = communicator.GetPropertyAsInt("Ice.Default.LocatorCacheTimeout") ?? -1;
            if (DefaultLocatorCacheTimeout < -1)
            {
                DefaultLocatorCacheTimeout = -1;
                var msg = new StringBuilder("invalid value for Ice.Default.LocatorCacheTimeout `");
                msg.Append(communicator.GetProperty("Ice.Default.LocatorCacheTimeout"));
                msg.Append("': defaulting to -1");
                logger.Warning(msg.ToString());
            }

            DefaultInvocationTimeout = communicator.GetPropertyAsInt("Ice.Default.InvocationTimeout") ?? -1;
            if (DefaultInvocationTimeout < 1 && DefaultInvocationTimeout != -1 && DefaultInvocationTimeout != -2)
            {
                DefaultInvocationTimeout = -1;
                var msg = new StringBuilder("invalid value for Ice.Default.InvocationTimeout `");
                msg.Append(communicator.GetProperty("Ice.Default.InvocationTimeout"));
                msg.Append("': defaulting to -1");
                logger.Warning(msg.ToString());
            }

            DefaultPreferSecure = communicator.GetPropertyAsInt("Ice.Default.PreferSecure") > 0;

            val             = communicator.GetProperty("Ice.Default.EncodingVersion") ?? Ice.Util.EncodingVersionToString(Ice.Util.CurrentEncoding);
            DefaultEncoding = Ice.Util.StringToEncodingVersion(val);
            Protocol.checkSupportedEncoding(DefaultEncoding);

            bool slicedFormat = communicator.GetPropertyAsInt("Ice.Default.SlicedFormat") > 0;

            DefaultFormat = slicedFormat ? Ice.FormatType.SlicedFormat : Ice.FormatType.CompactFormat;
        }
Beispiel #49
0
 public GI(Ice.Communicator communicator)
 {
     _communicator = communicator;
 }
Beispiel #50
0
 public Ice.Plugin create(Ice.Communicator communicator, string name, string[] args)
 {
     return(new PluginOne(communicator));
 }
Beispiel #51
0
 public PluginTwo(Ice.Communicator communicator) : base(communicator)
 {
 }
Beispiel #52
0
        allTests(global::Test.TestHelper helper,
                 Ice.Communicator communicator,
                 Ice.Communicator communicator2,
                 string rf)
        {
            Instrumentation.testInvocationReset();

            var output = helper.getWriter();

            output.Write("testing stringToProxy... ");
            output.Flush();
            var base1 = IObjectPrx.Parse(rf, communicator);
            var base2 = IObjectPrx.Parse(rf, communicator);

            output.WriteLine("ok");

            output.Write("testing checked cast... ");
            output.Flush();
            Test.IRetryPrx retry1 = Test.IRetryPrx.CheckedCast(base1);
            test(retry1.Equals(base1));
            Test.IRetryPrx retry2 = Test.IRetryPrx.CheckedCast(base2);
            test(retry2.Equals(base2));
            output.WriteLine("ok");

            output.Write("calling regular operation with first proxy... ");
            output.Flush();
            retry1.op(false);
            output.WriteLine("ok");

            Instrumentation.testInvocationCount(3);

            output.Write("calling operation to kill connection with second proxy... ");
            output.Flush();
            try
            {
                retry2.op(true);
                test(false);
            }
            catch (UnknownLocalException)
            {
                // Expected with collocation
            }
            catch (ConnectionLostException)
            {
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling regular operation with first proxy again... ");
            output.Flush();
            retry1.op(false);
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling regular AMI operation with first proxy... ");
            retry1.opAsync(false).Wait();
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling AMI operation to kill connection with second proxy... ");
            try
            {
                retry2.opAsync(true).Wait();
                test(false);
            }
            catch (System.AggregateException ex)
            {
                test(ex.InnerException is ConnectionLostException ||
                     ex.InnerException is UnknownLocalException);
            }

            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("calling regular AMI operation with first proxy again... ");
            retry1.opAsync(false).Wait();
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            output.Write("testing idempotent operation... ");
            test(retry1.opIdempotent(4) == 4);
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(4);
            test(retry1.opIdempotentAsync(4).Result == 4);
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(0);
            Instrumentation.testRetryCount(4);
            output.WriteLine("ok");

            if (retry1.GetCachedConnection() != null)
            {
                output.Write("testing non-idempotent operation with bi-dir proxy... ");
                try
                {
                    retry1.Clone(fixedConnection: retry1.GetCachedConnection()).opIdempotent(4);
                }
                catch (Ice.Exception)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                test(retry1.opIdempotent(4) == 4);
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(0);
                // It suceeded after 3 retry because of the failed opIdempotent on the fixed proxy above
                Instrumentation.testRetryCount(3);
                output.WriteLine("ok");
            }

            output.Write("testing non-idempotent operation... ");
            try
            {
                retry1.opNotIdempotent();
                test(false);
            }
            catch (Ice.LocalException)
            {
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            try
            {
                retry1.opNotIdempotentAsync().Wait();
                test(false);
            }
            catch (System.AggregateException ex)
            {
                test(ex.InnerException is LocalException);
            }
            Instrumentation.testInvocationCount(1);
            Instrumentation.testFailureCount(1);
            Instrumentation.testRetryCount(0);
            output.WriteLine("ok");

            if (retry1.GetConnection() == null)
            {
                Instrumentation.testInvocationCount(1);

                output.Write("testing system exception... ");
                try
                {
                    retry1.opSystemException();
                    test(false);
                }
                catch (SystemFailure)
                {
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                try
                {
                    retry1.opSystemExceptionAsync().Wait();
                    test(false);
                }
                catch (System.AggregateException ex)
                {
                    test(ex.InnerException is SystemFailure);
                }
                Instrumentation.testInvocationCount(1);
                Instrumentation.testFailureCount(1);
                Instrumentation.testRetryCount(0);
                output.WriteLine("ok");
            }

            {
                output.Write("testing invocation timeout and retries... ");
                output.Flush();

                retry2 = Test.IRetryPrx.Parse(retry1.ToString(), communicator2);
                try
                {
                    // No more than 2 retries before timeout kicks-in
                    retry2.Clone(invocationTimeout: 500).opIdempotent(4);
                    test(false);
                }
                catch (InvocationTimeoutException)
                {
                    Instrumentation.testRetryCount(2);
                    retry2.opIdempotent(-1); // Reset the counter
                    Instrumentation.testRetryCount(-1);
                }
                try
                {
                    // No more than 2 retries before timeout kicks-in
                    Test.IRetryPrx prx = retry2.Clone(invocationTimeout: 500);
                    prx.opIdempotentAsync(4).Wait();
                    test(false);
                }
                catch (System.AggregateException ex)
                {
                    test(ex.InnerException is InvocationTimeoutException);
                    Instrumentation.testRetryCount(2);
                    retry2.opIdempotent(-1); // Reset the counter
                    Instrumentation.testRetryCount(-1);
                }
                if (retry1.GetConnection() != null)
                {
                    // The timeout might occur on connection establishment or because of the sleep. What's
                    // important here is to make sure there are 4 retries and that no calls succeed to
                    // ensure retries with the old connection timeout semantics work.
                    Test.IRetryPrx retryWithTimeout = retry1.Clone(invocationTimeout: -2, connectionTimeout: 200);
                    try
                    {
                        retryWithTimeout.sleep(500);
                        test(false);
                    }
                    catch (Ice.TimeoutException)
                    {
                    }
                    Instrumentation.testRetryCount(4);
                }
                output.WriteLine("ok");
            }
            return(retry1);
        }
Beispiel #53
0
 public Callback(Ice.Communicator communicator, bool useCookie)
 {
     _communicator = communicator;
     _useCookie = useCookie;
 }
Beispiel #54
0
 create(Ice.Communicator communicator, string name, string[] args)
 {
     return(new PluginI(communicator));
 }
Beispiel #55
0
        public void shutdown()
        {
            List<Ice.ObjectAdapterI> adapters;
            lock(this)
            {
                //
                // Ignore shutdown requests if the object adapter factory has
                // already been shut down.
                //
                if(instance_ == null)
                {
                    return;
                }

                adapters = new List<Ice.ObjectAdapterI>(_adapters);

                instance_ = null;
                _communicator = null;

                System.Threading.Monitor.PulseAll(this);
            }

            //
            // Deactivate outside the thread synchronization, to avoid
            // deadlocks.
            //
            foreach(Ice.ObjectAdapter adapter in adapters)
            {
                adapter.deactivate();
            }
        }
Beispiel #56
0
 PluginI(Ice.Communicator communicator)
 {
     _communicator = communicator;
 }
Beispiel #57
0
 public PluginI(Ice.Communicator communicator)
 {
     _communicator = communicator;
 }
Beispiel #58
0
 LocatorRegistryI(Ice.Communicator com)
 {
     _wellKnownProxy = com.stringToProxy("p").ice_locator(null).ice_router(null).ice_collocationOptimized(true);
 }
        public static void LoginAsync(string username, string password,
            LoginCallback.LoginSuccessful onSuccess, LoginCallback.LoginFailed onFailure)
        {
            successCallback = onSuccess;
            failureCallback = onFailure;

            string[] args = new string[] { "--Ice.Config=" + CONFIG_FILE };
            comm = Ice.Util.initialize(ref args);

            Ice.ObjectPrx routerPrx = comm.getDefaultRouter();
            router = Glacier2.RouterPrxHelper.checkedCast(routerPrx);
            if (router == null)
            {
                throw new InvalidOperationException(
                    "The target host does not use a Glacier2 router.");
            }

            Glacier2.SessionPrx sessionProxy = router.createSession("CaptainVTank", "");
            sessionFactoryPrx = Main.SessionFactoryPrxHelper.uncheckedCast(sessionProxy);
            sessionFactoryPrx.AdminLogin_async(new LoginCallback(OnLoginSuccess, OnLoginFailure),
                username, password, version); // TODO: Use real version.
        }
Beispiel #60
0
            public static void allTests(global::Test.TestHelper helper)
            {
                Ice.Communicator communicator = helper.communicator();
                var output = helper.getWriter();

                output.Write("testing stringToProxy... ");
                output.Flush();
                String @ref = "hold:" + helper.getTestEndpoint(0);

                Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
                test(@base != null);
                String refSerialized = "hold:" + helper.getTestEndpoint(1);

                Ice.ObjectPrx baseSerialized = communicator.stringToProxy(refSerialized);
                test(baseSerialized != null);
                output.WriteLine("ok");

                output.Write("testing checked cast... ");
                output.Flush();
                var hold       = Test.HoldPrxHelper.checkedCast(@base);
                var holdOneway = Test.HoldPrxHelper.uncheckedCast(@base.ice_oneway());

                test(hold != null);
                test(hold.Equals(@base));
                var holdSerialized       = Test.HoldPrxHelper.checkedCast(baseSerialized);
                var holdSerializedOneway = Test.HoldPrxHelper.uncheckedCast(baseSerialized.ice_oneway());

                test(holdSerialized != null);
                test(holdSerialized.Equals(baseSerialized));
                output.WriteLine("ok");

                output.Write("changing state between active and hold rapidly... ");
                output.Flush();
                for (int i = 0; i < 100; ++i)
                {
                    hold.putOnHold(0);
                }
                for (int i = 0; i < 100; ++i)
                {
                    holdOneway.putOnHold(0);
                }
                for (int i = 0; i < 100; ++i)
                {
                    holdSerialized.putOnHold(0);
                }
                for (int i = 0; i < 100; ++i)
                {
                    holdSerializedOneway.putOnHold(0);
                }
                output.WriteLine("ok");

                output.Write("testing without serialize mode... ");
                output.Flush();
                Random rand = new Random();

                {
                    Condition       cond   = new Condition(true);
                    int             value  = 0;
                    Ice.AsyncResult result = null;
                    while (cond.value())
                    {
                        SetCB cb = new SetCB(cond, value);
                        result = hold.begin_set(++value, value < 500 ? rand.Next(5) : 0).whenCompleted(cb.response,
                                                                                                       cb.exception);
                        if (value % 100 == 0)
                        {
                            result.waitForSent();
                        }

                        if (value > 100000)
                        {
                            // Don't continue, it's possible that out-of-order dispatch doesn't occur
                            // after 100000 iterations and we don't want the test to last for too long
                            // when this occurs.
                            break;
                        }
                    }
                    test(value > 100000 || !cond.value());
                    result.waitForSent();
                }
                output.WriteLine("ok");

                output.Write("testing with serialize mode... ");
                output.Flush();
                {
                    Condition       cond   = new Condition(true);
                    int             value  = 0;
                    Ice.AsyncResult result = null;
                    while (value < 3000 && cond.value())
                    {
                        SetCB cb = new SetCB(cond, value);
                        result = holdSerialized.begin_set(++value, 0).whenCompleted(cb.response, cb.exception);
                        if (value % 100 == 0)
                        {
                            result.waitForSent();
                        }
                    }
                    result.waitForCompleted();
                    test(cond.value());

                    for (int i = 0; i < 10000; ++i)
                    {
                        holdSerializedOneway.setOneway(value + 1, value);
                        ++value;
                        if ((i % 100) == 0)
                        {
                            holdSerializedOneway.putOnHold(1);
                        }
                    }
                }
                output.WriteLine("ok");

                output.Write("testing serialization... ");
                output.Flush();
                {
                    int value = 0;
                    holdSerialized.set(value, 0);
                    Ice.AsyncResult result = null;
                    for (int i = 0; i < 10000; ++i)
                    {
                        // Create a new proxy for each request
                        result = ((Test.HoldPrx)holdSerialized.ice_oneway()).begin_setOneway(value + 1, value);
                        ++value;
                        if ((i % 100) == 0)
                        {
                            result.waitForSent();
                            holdSerialized.ice_ping(); // Ensure everything's dispatched.
                            holdSerialized.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait);
                        }
                    }
                    result.waitForCompleted();
                }
                output.WriteLine("ok");

                output.Write("testing waitForHold... ");
                output.Flush();
                {
                    hold.waitForHold();
                    hold.waitForHold();
                    for (int i = 0; i < 1000; ++i)
                    {
                        holdOneway.ice_ping();
                        if ((i % 20) == 0)
                        {
                            hold.putOnHold(0);
                        }
                    }
                    hold.putOnHold(-1);
                    hold.ice_ping();
                    hold.putOnHold(-1);
                    hold.ice_ping();
                }
                output.WriteLine("ok");

                output.Write("changing state to hold and shutting down server... ");
                output.Flush();
                hold.shutdown();
                output.WriteLine("ok");
            }