gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 10:57:51 27 4
gpt4 key购买 nike

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

ZKStoreHelper.checkExists介绍

暂无

代码示例

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

@Override
public CompletableFuture<String> getScopeConfiguration(final String scopeName) {
  return storeHelper.checkExists(String.format("/store/%s", scopeName))
      .thenApply(scopeExists -> {
        if (scopeExists) {
          return scopeName;
        } else {
          throw StoreException.create(StoreException.Type.DATA_NOT_FOUND, scopeName);
        }
      });
}

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

/**
 * Method to check whether a scope exists before creating a stream under that scope.
 *
 * @return A future either returning a result or an exception.
 */
@Override
public CompletableFuture<Void> checkScopeExists() {
  return store.checkExists(scopePath)
        .thenAccept(x -> {
          if (!x) {
            throw StoreException.create(StoreException.Type.DATA_NOT_FOUND, scopePath);
          }
        });
}

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

@Override
public CompletableFuture<Boolean> checkStreamExists(final String scopeName,
                          final String streamName) {
  ZKStream stream = newStream(scopeName, streamName);
  return storeHelper.checkExists(stream.getStreamPath());
}

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

@Override
public CompletableFuture<CreateStreamResponse> checkStreamExists(final StreamConfiguration configuration, final long creationTime, final int startingSegmentNumber) {
  // If stream exists, but is in a partially complete state, then fetch its creation time and configuration and any
  // metadata that is available from a previous run. If the existing stream has already been created successfully earlier,
  return store.checkExists(creationPath).thenCompose(exists -> {
    if (!exists) {
      return CompletableFuture.completedFuture(new CreateStreamResponse(CreateStreamResponse.CreateStatus.NEW,
          configuration, creationTime, startingSegmentNumber));
    }
    return getCreationTime().thenCompose(storedCreationTime ->
        store.checkExists(configurationPath).thenCompose(configExists -> {
          if (configExists) {
            return handleConfigExists(storedCreationTime, startingSegmentNumber, storedCreationTime == creationTime);
          } else {
            return CompletableFuture.completedFuture(new CreateStreamResponse(CreateStreamResponse.CreateStatus.NEW,
                configuration, storedCreationTime, startingSegmentNumber));
          }
        }));
  });
}

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

private CompletableFuture<CreateStreamResponse> handleConfigExists(long creationTime, int startingSegmentNumber, boolean creationTimeMatched) {
  CreateStreamResponse.CreateStatus status = creationTimeMatched ?
      CreateStreamResponse.CreateStatus.NEW : CreateStreamResponse.CreateStatus.EXISTS_CREATING;
  return getConfiguration().thenCompose(config -> store.checkExists(statePath)
                             .thenCompose(stateExists -> {
                               if (!stateExists) {
                                 return CompletableFuture.completedFuture(new CreateStreamResponse(status, config, creationTime, startingSegmentNumber));
                               }
                               return getState(false).thenApply(state -> {
                                 if (state.equals(State.UNKNOWN) || state.equals(State.CREATING)) {
                                   return new CreateStreamResponse(status, config, creationTime, startingSegmentNumber);
                                 } else {
                                   return new CreateStreamResponse(CreateStreamResponse.CreateStatus.EXISTS_ACTIVE,
                                       config, creationTime, startingSegmentNumber);
                                 }
                               });
                             }));
}

代码示例来源: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());
  }
}

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