public virtual void testCheckConnectionException()
        {
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final com.alipay.remoting.Url addr = new com.alipay.remoting.Url(ip, port);
            Url addr = new Url(ip, port);

            Connection conn = null;

            try
            {
                cm.check(conn);
                Assert.True(false);
            }
            catch (RemotingException e)
            {
                logger.LogError("Connection null", e);
                Assert.True(true);
            }

            try
            {
                this.addressParser.initUrlArgs(addr);
                conn = cm.getAndCreateIfAbsent(addr);
                Assert.Equal(1, cm.count(addr.UniqueKey));
                conn.close();
                Thread.Sleep(100);
                cm.check(conn);
                Assert.True(false);
            }
            catch (RemotingException)
            {
                // test  remove success when do check
                Assert.Equal(0, cm.count(addr.UniqueKey));
                Assert.True(true);
            }
            catch (ThreadInterruptedException e)
            {
                logger.LogError("", e);
            }
        }
Ejemplo n.º 2
0
        public override bool checkConnection(string address)
        {
            Url        url  = addressParser.parse(address);
            Connection conn = connectionManager.get(url.UniqueKey);

            try
            {
                connectionManager.check(conn);
            }
            catch (Exception e)
            {
                logger.LogWarning("check failed. connection: {}", conn, e);
                return(false);
            }
            return(true);
        }