Exemple #1
0
        public static bool WaitForServerDown(string hp, long timeout)
        {
            long start = Time.Now();

            while (true)
            {
                try
                {
                    ClientBaseWithFixes.HostPort hpobj = ParseHostPortList(hp)[0];
                    Send4LetterWord(hpobj.host, hpobj.port, "stat");
                }
                catch (IOException)
                {
                    return(true);
                }
                if (Time.Now() > start + timeout)
                {
                    break;
                }
                try
                {
                    Thread.Sleep(250);
                }
                catch (Exception)
                {
                }
            }
            // ignore
            return(false);
        }
Exemple #2
0
        public static bool WaitForServerUp(string hp, long timeout)
        {
            long start = Time.Now();

            while (true)
            {
                try
                {
                    // if there are multiple hostports, just take the first one
                    ClientBaseWithFixes.HostPort hpobj = ParseHostPortList(hp)[0];
                    string result = Send4LetterWord(hpobj.host, hpobj.port, "stat");
                    if (result.StartsWith("Zookeeper version:") && !result.Contains("READ-ONLY"))
                    {
                        return(true);
                    }
                }
                catch (IOException e)
                {
                    // ignore as this is expected
                    Log.Info("server " + hp + " not up " + e);
                }
                if (Time.Now() > start + timeout)
                {
                    break;
                }
                try
                {
                    Thread.Sleep(250);
                }
                catch (Exception)
                {
                }
            }
            // ignore
            return(false);
        }