Esempio n. 1
0
        private List <OpResult> doOperation(AtomicBoolean firstTime)
        {
            bool localFirstTime = firstTime.getAndSet(false);

            if (!localFirstTime)
            {
            }

            List <OpResult> opResults = client.getZooKeeper().multi(transaction);

            if (opResults.Count > 0)
            {
                OpResult firstResult = opResults[0];
                if (firstResult is OpResult.ErrorResult)
                {
                    OpResult.ErrorResult error = (OpResult.ErrorResult)firstResult;
                    KeeperException.Code code  = KeeperException.Code.get(error.getErr());
                    if (code == null)
                    {
                        code = KeeperException.Code.UNIMPLEMENTED;
                    }
                    throw KeeperException.create(code);
                }
            }
            return(opResults);
        }
Esempio n. 2
0
 public void testCodeOKInSwitch()
 {
     KeeperException.Code test = KeeperException.Code.OK;
     switch (test)
     {
     case KeeperException.Code.OK:
         Assert.assertTrue(true);
         break;
     }
 }
Esempio n. 3
0
        public void ProcessResult(KeeperException.Code rc, String path, Object ctx, Stat stat)
        {
            bool exists;

            switch (rc)
            {
            case KeeperException.Code.OK:
                exists = true;
                break;

            case KeeperException.Code.NONODE:
                exists = false;
                break;

            case KeeperException.Code.SESSIONEXPIRED:
            case KeeperException.Code.NOAUTH:
                Dead = true;
                _listener.Closing(rc);
                return;

            default:
                // Retry errors
                _zk.Exists(_znode, true);
                return;
            }

            byte[] b = null;
            if (exists)
            {
                try
                {
                    b = _zk.GetData(_znode, false, null);
                }
                catch (KeeperException e)
                {
                    // We don't need to worry about recovering now. The watch
                    // callbacks will kick off any exception handling
                    //TODO
                }
                catch (Exception e)
                {
                    return;
                }
            }
            if ((b == null && b != _prevData) ||
                (b != null && !Equals(_prevData, b)))
            {
                _listener.Exists(b);
                _prevData = b;
            }
        }
Esempio n. 4
0
 public void ProcessResult(int rc, string path, object ctx, string name)
 {
     if (KeeperException.Code.Ok.IntValue() == rc || KeeperException.Code.Nodeexists.IntValue
             () == rc)
     {
         Org.Apache.Hadoop.Contrib.Bkjournal.BookKeeperJournalManager.Log.Info("Successfully created bookie available path : "
                                                                               + zkAvailablePath);
         success.Set(true);
     }
     else
     {
         KeeperException.Code code = KeeperException.Code.Get(rc);
         Org.Apache.Hadoop.Contrib.Bkjournal.BookKeeperJournalManager.Log.Error("Error : "
                                                                                + KeeperException.Create(code, path).Message + ", failed to create bookie available path : "
                                                                                + zkAvailablePath);
     }
     zkPathLatch.CountDown();
 }