public void Test_ConnectionStateChanges()
        {
            var target = new DefaultConnectionMonitor((cm, state) =>
            {
                Assert.IsTrue(cm.IsConnected);
                Assert.IsTrue(state);
            });

            target.IsConnected = true;
            Assert.IsTrue(target.IsConnected);
        }
Ejemplo n.º 2
0
        public override void startup()
        {
            base.startup();

            if (addressParser == null)
            {
                addressParser = new RpcAddressParser();
            }

            ConnectionSelectStrategy connectionSelectStrategy = (ConnectionSelectStrategy)option(BoltGenericOption.CONNECTION_SELECT_STRATEGY);

            if (connectionSelectStrategy == null)
            {
                connectionSelectStrategy = new RandomSelectStrategy(switches());
            }
            connectionManager = new DefaultClientConnectionManager(connectionSelectStrategy, new RpcConnectionFactory(userProcessors, this), connectionEventHandler, connectionEventListener, switches());
            connectionManager.AddressParser = addressParser;
            connectionManager.startup();
            rpcRemoting = new RpcClientRemoting(new RpcCommandFactory(), addressParser, connectionManager);
            taskScanner.add(connectionManager);
            taskScanner.startup();

            if (switches().isOn(GlobalSwitch.CONN_MONITOR_SWITCH))
            {
                if (monitorStrategy == null)
                {
                    connectionMonitor = new DefaultConnectionMonitor(new ScheduledDisconnectStrategy(), connectionManager);
                }
                else
                {
                    connectionMonitor = new DefaultConnectionMonitor(monitorStrategy, connectionManager);
                }
                connectionMonitor.startup();
                logger.LogWarning("Switch on connection monitor");
            }
            if (switches().isOn(GlobalSwitch.CONN_RECONNECT_SWITCH))
            {
                reconnectManager = new ReconnectManager(connectionManager);
                reconnectManager.startup();

                connectionEventHandler.Reconnector = reconnectManager;
                logger.LogWarning("Switch on reconnect manager");
            }
        }