當前位置: 首頁>>代碼示例>>Java>>正文


Java KeeperException.AuthFailedException方法代碼示例

本文整理匯總了Java中org.apache.zookeeper.KeeperException.AuthFailedException方法的典型用法代碼示例。如果您正苦於以下問題:Java KeeperException.AuthFailedException方法的具體用法?Java KeeperException.AuthFailedException怎麽用?Java KeeperException.AuthFailedException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.zookeeper.KeeperException的用法示例。


在下文中一共展示了KeeperException.AuthFailedException方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testBadAuthNotifiesWatch

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@Test
public void testBadAuthNotifiesWatch() throws Exception {
    ZooKeeper zk = createClient();
    try {
        zk.addAuthInfo("FOO", "BAR".getBytes());
        zk.getData("/path1", false, null);
        Assert.fail("Should get auth state error");
    } catch(KeeperException.AuthFailedException e) {
        if(!authFailed.await(CONNECTION_TIMEOUT,
                TimeUnit.MILLISECONDS))
        {
            Assert.fail("Should have called my watcher");
        }
    }
    finally {
        zk.close();
    }
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:19,代碼來源:AuthTest.java

示例2: testBadAuthThenSendOtherCommands

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
@Test
public void testBadAuthThenSendOtherCommands() throws Exception {
    ZooKeeper zk = createClient();     
    try {        
        zk.addAuthInfo("INVALID", "BAR".getBytes());
        zk.exists("/foobar", false);             
        zk.getData("/path1", false, null);
        Assert.fail("Should get auth state error");
    } catch(KeeperException.AuthFailedException e) {
        if(!authFailed.await(CONNECTION_TIMEOUT,
                TimeUnit.MILLISECONDS))
        {
            Assert.fail("Should have called my watcher");
        }
    }
    finally {
        zk.close();          
    }
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:20,代碼來源:AuthTest.java

示例3: validAuth

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
public void validAuth() throws Exception {
    ZooKeeper zk = createClient();
    // any multiple of 5 will do...
    zk.addAuthInfo("key", "25".getBytes());
    try {
        createNodePrintAcl(zk, "/valid", "testValidAuth");
        zk.getData("/abc", false, null);
        zk.setData("/abc", "testData3".getBytes(), -1);
    } catch (KeeperException.AuthFailedException e) {
        Assert.fail("test failed :" + e);
    } finally {
        zk.close();
    }
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:15,代碼來源:KeyAuthClientTest.java

示例4: validAuth2

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
public void validAuth2() throws Exception {
    ZooKeeper zk = createClient();
    // any multiple of 5 will do...
    zk.addAuthInfo("key", "125".getBytes());
    try {
        createNodePrintAcl(zk, "/valid2", "testValidAuth2");
        zk.getData("/abc", false, null);
        zk.setData("/abc", "testData3".getBytes(), -1);
    } catch (KeeperException.AuthFailedException e) {
        Assert.fail("test failed :" + e);
    } finally {
        zk.close();
    }
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:15,代碼來源:KeyAuthClientTest.java

示例5: blockUntilAvailable

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
public static byte[] blockUntilAvailable(
  final ZooKeeperWatcher zkw, final String znode, final long timeout)
  throws InterruptedException {
  if (timeout < 0) throw new IllegalArgumentException();
  if (zkw == null) throw new IllegalArgumentException();
  if (znode == null) throw new IllegalArgumentException();

  byte[] data = null;
  boolean finished = false;
  final long endTime = System.currentTimeMillis() + timeout;
  while (!finished) {
    try {
      data = ZKUtil.getData(zkw, znode);
    } catch(KeeperException e) {
      if (e instanceof KeeperException.SessionExpiredException
          || e instanceof KeeperException.AuthFailedException) {
        // non-recoverable errors so stop here
        throw new InterruptedException("interrupted due to " + e);
      }
      LOG.warn("Unexpected exception handling blockUntilAvailable", e);
    }

    if (data == null && (System.currentTimeMillis() +
      HConstants.SOCKET_RETRY_WAIT_MS < endTime)) {
      Thread.sleep(HConstants.SOCKET_RETRY_WAIT_MS);
    } else {
      finished = true;
    }
  }

  return data;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:33,代碼來源:ZKUtil.java

示例6: testGetActiveData

import org.apache.zookeeper.KeeperException; //導入方法依賴的package包/類
/**
 * verify that receiveActiveData gives data when active exists, tells that
 * active does not exist and reports error in getting active information
 * 
 * @throws IOException
 * @throws InterruptedException
 * @throws KeeperException
 * @throws ActiveNotFoundException
 */
@Test
public void testGetActiveData() throws ActiveNotFoundException,
    KeeperException, InterruptedException, IOException {
  // get valid active data
  byte[] data = new byte[8];
  Mockito.when(
      mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
          Mockito.<Stat> anyObject())).thenReturn(data);
  Assert.assertEquals(data, elector.getActiveData());
  Mockito.verify(mockZK, Mockito.times(1)).getData(
      Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
      Mockito.<Stat> anyObject());

  // active does not exist
  Mockito.when(
      mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
          Mockito.<Stat> anyObject())).thenThrow(
      new KeeperException.NoNodeException());
  try {
    elector.getActiveData();
    Assert.fail("ActiveNotFoundException expected");
  } catch(ActiveNotFoundException e) {
    Mockito.verify(mockZK, Mockito.times(2)).getData(
        Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
        Mockito.<Stat> anyObject());
  }

  // error getting active data rethrows keeperexception
  try {
    Mockito.when(
        mockZK.getData(Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
            Mockito.<Stat> anyObject())).thenThrow(
        new KeeperException.AuthFailedException());
    elector.getActiveData();
    Assert.fail("KeeperException.AuthFailedException expected");
  } catch(KeeperException.AuthFailedException ke) {
    Mockito.verify(mockZK, Mockito.times(3)).getData(
        Mockito.eq(ZK_LOCK_NAME), Mockito.eq(false),
        Mockito.<Stat> anyObject());
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:51,代碼來源:TestActiveStandbyElector.java


注:本文中的org.apache.zookeeper.KeeperException.AuthFailedException方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。