gpt4 book ai didi

com.twitter.distributedlog.exceptions.ZKException.getKeeperExceptionCode()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:08:43 28 4
gpt4 key购买 nike

本文整理了Java中com.twitter.distributedlog.exceptions.ZKException.getKeeperExceptionCode()方法的一些代码示例,展示了ZKException.getKeeperExceptionCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKException.getKeeperExceptionCode()方法的具体详情如下:
包路径:com.twitter.distributedlog.exceptions.ZKException
类名称:ZKException
方法名:getKeeperExceptionCode

ZKException.getKeeperExceptionCode介绍

暂无

代码示例

代码示例来源:origin: twitter/distributedlog

public static boolean isRetryableZKException(ZKException zke) {
    KeeperException.Code code = zke.getKeeperExceptionCode();
    return KeeperException.Code.CONNECTIONLOSS == code ||
        KeeperException.Code.OPERATIONTIMEOUT == code ||
        KeeperException.Code.SESSIONEXPIRED == code ||
        KeeperException.Code.SESSIONMOVED == code;
  }
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testAclModifyPermsDlmConflict() throws Exception {
  String streamName = "test-stream";
  // Reopening and writing again with the same un will succeed.
  initDlogMeta("/" + runtime.getMethodName(), "test-un", streamName);
  try {
    // Reopening and writing again with a different un will fail.
    initDlogMeta("/" + runtime.getMethodName(), "not-test-un", streamName);
    fail("write should have failed due to perms");
  } catch (ZKException ex) {
    LOG.info("caught exception trying to write with no perms {}", ex);
    assertEquals(KeeperException.Code.NOAUTH, ex.getKeeperExceptionCode());
  } catch (Exception ex) {
    LOG.info("caught wrong exception trying to write with no perms {}", ex);
    fail("wrong exception " + ex.getClass().getName() + " expected " + LockingException.class.getName());
  }
  // Should work again.
  initDlogMeta("/" + runtime.getMethodName(), "test-un", streamName);
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testToolCreateZkAclId() throws Exception {
  createStream(defaultUri, "0", "CreateAclStream", defaultPrivilegedZkAclId);
  try {
    DistributedLogManager dlm = DLMTestUtil.createNewDLM("0CreateAclStream", conf, defaultUri);
    DLMTestUtil.generateCompletedLogSegments(dlm, conf, 3, 1000);
    dlm.close();
  } catch (ZKException ex) {
    assertEquals(KeeperException.Code.NOAUTH, ex.getKeeperExceptionCode());
  }
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testUpdateNonExistentLogSegment() throws Exception {
  LogSegmentMetadata segment = createLogSegment(1L);
  Transaction<Object> updateTxn = lsmStore.transaction();
  lsmStore.updateLogSegment(updateTxn, segment);
  try {
    FutureUtils.result(updateTxn.execute());
    fail("Should fail update if log segment doesn't exist");
  } catch (Throwable t) {
    assertTrue("Should throw NoNodeException if log segment doesn't exist",
        t instanceof ZKException);
    ZKException zke = (ZKException) t;
    assertEquals("Should throw NoNodeException if log segment doesn't exist",
        KeeperException.Code.NONODE, zke.getKeeperExceptionCode());
  }
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testDeleteNonExistentLogSegment() throws Exception {
  LogSegmentMetadata segment = createLogSegment(1L);
  Transaction<Object> deleteTxn = lsmStore.transaction();
  lsmStore.deleteLogSegment(deleteTxn, segment);
  try {
    FutureUtils.result(deleteTxn.execute());
    fail("Should fail deletion if log segment doesn't exist");
  } catch (Throwable t) {
    assertTrue("Should throw NoNodeException if log segment doesn't exist",
        t instanceof ZKException);
    ZKException zke = (ZKException) t;
    assertEquals("Should throw NoNodeException if log segment doesn't exist",
        KeeperException.Code.NONODE, zke.getKeeperExceptionCode());
  }
}

代码示例来源:origin: twitter/distributedlog

fail("Should fail allocating on second allocator as allocator1 is starting allocating something.");
} catch (ZKException zke) {
  assertEquals(KeeperException.Code.BADVERSION, zke.getKeeperExceptionCode());

代码示例来源:origin: twitter/distributedlog

fail("Should fail on storing log segment sequence number if providing bad version");
} catch (ZKException zke) {
  assertEquals(KeeperException.Code.BADVERSION, zke.getKeeperExceptionCode());

代码示例来源:origin: twitter/distributedlog

fail("Should fail on storing log record transaction id if providing bad version");
} catch (ZKException zke) {
  assertEquals(KeeperException.Code.BADVERSION, zke.getKeeperExceptionCode());

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testCreateLogSegment() throws Exception {
  LogSegmentMetadata segment = createLogSegment(1L);
  Transaction<Object> createTxn = lsmStore.transaction();
  lsmStore.createLogSegment(createTxn, segment);
  FutureUtils.result(createTxn.execute());
  // the log segment should be created
  assertNotNull("LogSegment " + segment + " should be created",
      zkc.get().exists(segment.getZkPath(), false));
  LogSegmentMetadata segment2 = createLogSegment(1L);
  Transaction<Object> createTxn2 = lsmStore.transaction();
  lsmStore.createLogSegment(createTxn2, segment2);
  try {
    FutureUtils.result(createTxn2.execute());
    fail("Should fail if log segment exists");
  } catch (Throwable t) {
    // expected
    assertTrue("Should throw NodeExistsException if log segment exists",
        t instanceof ZKException);
    ZKException zke = (ZKException) t;
    assertEquals("Should throw NodeExistsException if log segment exists",
        KeeperException.Code.NODEEXISTS, zke.getKeeperExceptionCode());
  }
}

代码示例来源:origin: twitter/distributedlog

ZKException zke = (ZKException) t;
assertEquals("Transaction is aborted",
    KeeperException.Code.NONODE, zke.getKeeperExceptionCode());

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testStoreMaxLogSegmentSequenceNumberOnNonExistentPath() throws Exception {
  Transaction<Object> updateTxn = lsmStore.transaction();
  Versioned<Long> value = new Versioned<Long>(999L, new ZkVersion(10));
  final Promise<Version> result = new Promise<Version>();
  String nonExistentPath = rootZkPath + "/non-existent";
  lsmStore.storeMaxLogSegmentSequenceNumber(updateTxn, nonExistentPath, value,
      new Transaction.OpListener<Version>() {
        @Override
        public void onCommit(Version r) {
          result.setValue(r);
        }
        @Override
        public void onAbort(Throwable t) {
          result.setException(t);
        }
      });
  try {
    FutureUtils.result(updateTxn.execute());
    fail("Should fail on storing log segment sequence number if path doesn't exist");
  } catch (ZKException zke) {
    assertEquals(KeeperException.Code.NONODE, zke.getKeeperExceptionCode());
  }
  try {
    Await.result(result);
    fail("Should fail on storing log segment sequence number if path doesn't exist");
  } catch (KeeperException ke) {
    assertEquals(KeeperException.Code.NONODE, ke.code());
  }
}

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testStoreMaxTxnIdOnNonExistentPath() throws Exception {
  Transaction<Object> updateTxn = lsmStore.transaction();
  Versioned<Long> value = new Versioned<Long>(999L, new ZkVersion(10));
  final Promise<Version> result = new Promise<Version>();
  String nonExistentPath = rootZkPath + "/non-existent";
  lsmStore.storeMaxLogSegmentSequenceNumber(updateTxn, nonExistentPath, value,
      new Transaction.OpListener<Version>() {
        @Override
        public void onCommit(Version r) {
          result.setValue(r);
        }
        @Override
        public void onAbort(Throwable t) {
          result.setException(t);
        }
      });
  try {
    FutureUtils.result(updateTxn.execute());
    fail("Should fail on storing log record transaction id if path doesn't exist");
  } catch (ZKException zke) {
    assertEquals(KeeperException.Code.NONODE, zke.getKeeperExceptionCode());
  }
  try {
    Await.result(result);
    fail("Should fail on storing log record transaction id if path doesn't exist");
  } catch (KeeperException ke) {
    assertEquals(KeeperException.Code.NONODE, ke.code());
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com