gpt4 book ai didi

io.pravega.controller.store.stream.ZKStoreHelper.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:59:00 26 4
gpt4 key购买 nike

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

ZKStoreHelper.<init>介绍

暂无

代码示例

代码示例来源:origin: pravega/pravega

@VisibleForTesting
ZKStreamMetadataStore(CuratorFramework client, int bucketCount, Executor executor, Duration gcPeriod) {
  super(new ZKHostIndex(client, "/hostTxnIndex", executor), bucketCount);
  storeHelper = new ZKStoreHelper(client, executor);
  bucketCacheMap = new ConcurrentHashMap<>();
  bucketOwnershipCacheRef = new AtomicReference<>();
  this.lock = new Object();
  this.counter = new AtomicInt96();
  this.limit = new AtomicInt96();
  this.refreshFutureRef = null;
  this.completedTxnGC = new ZKGarbageCollector(COMPLETED_TXN_GC_NAME, storeHelper, this::gcCompletedTxn, gcPeriod);
  this.completedTxnGC.startAsync();
  this.completedTxnGC.awaitRunning();
}

代码示例来源:origin: pravega/pravega

@Override
public void setup() throws Exception {
  zkServer = new TestingServerStarter().start();
  zkServer.start();
  int sessionTimeout = 8000;
  int connectionTimeout = 5000;
  cli = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), sessionTimeout, connectionTimeout, new RetryOneTime(2000));
  cli.start();
  storeHelper = new ZKStoreHelper(cli, executor);
  store = new ZKStreamMetadataStore(cli, 1, executor, Duration.ofSeconds(1));
}

代码示例来源:origin: pravega/pravega

@Before
public void setup() throws Exception {
  zkServer = new TestingServerStarter().start();
  cli = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), 100, 100, new RetryNTimes(0, 0));
  cli.start();
  zkStoreHelper = new ZKStoreHelper(cli, executor);
}

代码示例来源:origin: pravega/pravega

@Test(timeout = 10000)
public void testZkCreateStream() throws ExecutionException, InterruptedException {
  ZKStoreHelper zkStoreHelper = new ZKStoreHelper(cli, executor);
  ZKStream zkStream = new ZKStream("test", "test", zkStoreHelper);
  testStream(zkStream);
}

代码示例来源:origin: pravega/pravega

@Test
public void verifyBucketInitialization() {
  ZKStoreHelper zkStoreHelper = new ZKStoreHelper(cli, executor);
  // Verify that buckets are not initialized.
  assertFalse(zkStoreHelper.checkExists(ZKStreamMetadataStore.BUCKET_ROOT_PATH).join());
  // Execute the initialization of buckets in ZKStreamMetadataStore.
  store.createBucketsRoot().join();
  // Verify that the expected buckets are created after the execution of createBucketsRoot().
  assertTrue(zkStoreHelper.checkExists(ZKStreamMetadataStore.BUCKET_ROOT_PATH).join());
  assertTrue(zkStoreHelper.checkExists(ZKStreamMetadataStore.BUCKET_OWNERSHIP_PATH).join());
  for (int i = 0; i < ((AbstractStreamMetadataStore) store).getBucketCount(); i++) {
    assertTrue(zkStoreHelper.checkExists(String.format(ZKStreamMetadataStore.BUCKET_PATH, i)).join());
  }
}

代码示例来源:origin: pravega/pravega

store.createScope(scopeName).get();
ZKStoreHelper zkStoreHelper = new ZKStoreHelper(cli, executor);

代码示例来源:origin: pravega/pravega

@Test
  public void testEphemeralNode() {
    CuratorFramework cli2 = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new RetryNTimes(0, 0));
    cli2.start();
    ZKStoreHelper zkStoreHelper2 = new ZKStoreHelper(cli2, executor);

    Assert.assertTrue(zkStoreHelper2.createEphemeralZNode("/testEphemeral", new byte[0]).join());
    Assert.assertNotNull(zkStoreHelper2.getData("/testEphemeral").join());
    zkStoreHelper2.getClient().close();
    // let session get expired.
    // now read the data again. Verify that node no longer exists
    AssertExtensions.assertFutureThrows("", Futures.delayedFuture(() -> zkStoreHelper.getData("/testEphemeral"), 1000, executor),
        e -> e instanceof StoreException.DataNotFoundException);
  }
}

代码示例来源:origin: pravega/pravega

@Test(timeout = 10000)
public void testGetActiveTxn() throws Exception {
  ZKStoreHelper storeHelper = spy(new ZKStoreHelper(cli, executor));
  ZKStream stream = new ZKStream("scope", "stream", storeHelper);
  final int startingSegmentNumber = 0;
  storeHelper.createZNodeIfNotExist("/store/scope").join();
  final ScalingPolicy policy1 = ScalingPolicy.fixed(2);
  final StreamConfiguration configuration1 = StreamConfiguration.builder().scalingPolicy(policy1).build();
  stream.create(configuration1, System.currentTimeMillis(), startingSegmentNumber).join();
  stream.updateState(State.ACTIVE).join();
  UUID txId = stream.generateNewTxnId(0, 0L).join();
  stream.createTransaction(txId, 1000L, 1000L).join();
  String activeTxPath = stream.getActiveTxPath(0, txId.toString());
  // throw DataNotFoundException for txn path
  doReturn(Futures.failedFuture(StoreException.create(StoreException.Type.DATA_NOT_FOUND, "txn data not found")))
      .when(storeHelper).getData(eq(activeTxPath));
  Map<String, Data> result = stream.getCurrentTxns().join();
  // verify that call succeeds and no active txns were found
  assertTrue(result.isEmpty());
  // throw generic exception for txn path
  doReturn(Futures.failedFuture(new RuntimeException())).when(storeHelper).getData(eq(activeTxPath));
  ZKStream stream2 = new ZKStream("scope", "stream", storeHelper);
  // verify that the call fails
  AssertExtensions.assertFutureThrows("", stream2.getCurrentTxns(), e -> Exceptions.unwrap(e) instanceof RuntimeException);
  reset(storeHelper);
  ZKStream stream3 = new ZKStream("scope", "stream", storeHelper);
  result = stream3.getCurrentTxns().join();
  assertEquals(1, result.size());
}

代码示例来源:origin: pravega/pravega

@Test(timeout = 30000)
public void testGC() {
  ZKStoreHelper zkStoreHelper = new ZKStoreHelper(cli, executor);
  String gcName = "testGC";
  Duration gcPeriod = Duration.ofSeconds(2);

代码示例来源:origin: pravega/pravega

@Test
public void testCounterConcurrentUpdates() {
  ZKStoreHelper storeHelper = spy(new ZKStoreHelper(cli, executor));
  storeHelper.createZNodeIfNotExist("/store/scope").join();
  ZKStreamMetadataStore zkStore = spy((ZKStreamMetadataStore) this.store);
  ZKStreamMetadataStore zkStore2 = spy((ZKStreamMetadataStore) this.store);
  ZKStreamMetadataStore zkStore3 = spy((ZKStreamMetadataStore) this.store);
  zkStore.setStoreHelperForTesting(storeHelper);
  // first call should get the new range from store
  Int96 counter = zkStore.getNextCounter().join();
  // verify that the generated counter is from new range
  assertEquals(0, counter.getMsb());
  assertEquals(1L, counter.getLsb());
  assertEquals(zkStore.getCounterForTesting(), counter);
  Int96 limit = zkStore.getLimitForTesting();
  assertEquals(ZKStreamMetadataStore.COUNTER_RANGE, limit.getLsb());
  zkStore3.getRefreshFuture().join();
  assertEquals(ZKStreamMetadataStore.COUNTER_RANGE, zkStore3.getCounterForTesting().getLsb());
  assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 2, zkStore3.getLimitForTesting().getLsb());
  zkStore2.getRefreshFuture().join();
  assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 2, zkStore2.getCounterForTesting().getLsb());
  assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 3, zkStore2.getLimitForTesting().getLsb());
  zkStore.getRefreshFuture().join();
  assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 3, zkStore.getCounterForTesting().getLsb());
  assertEquals(ZKStreamMetadataStore.COUNTER_RANGE * 4, zkStore.getLimitForTesting().getLsb());
}

代码示例来源:origin: pravega/pravega

@Test
public void testCounter() throws Exception {
  ZKStoreHelper storeHelper = spy(new ZKStoreHelper(cli, executor));
  storeHelper.createZNodeIfNotExist("/store/scope").join();

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