• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ZkBaseDataAccessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.helix.manager.zk.ZkBaseDataAccessor的典型用法代码示例。如果您正苦于以下问题:Java ZkBaseDataAccessor类的具体用法?Java ZkBaseDataAccessor怎么用?Java ZkBaseDataAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ZkBaseDataAccessor类属于org.apache.helix.manager.zk包,在下文中一共展示了ZkBaseDataAccessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: beforeSuite

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@BeforeSuite
public void beforeSuite() throws Exception {
  // TODO: use logging.properties file to config java.util.logging.Logger levels
  java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
  topJavaLogger.setLevel(Level.WARNING);

  // Due to ZOOKEEPER-2693 fix, we need to specify whitelist for execute zk commends
  System.setProperty("zookeeper.4lw.commands.whitelist", "*");

  _zkServer = TestHelper.startZkServer(ZK_ADDR);
  AssertJUnit.assertTrue(_zkServer != null);
  ZKClientPool.reset();

  _gZkClient = new ZkClient(ZK_ADDR);
  _gZkClient.setZkSerializer(new ZNRecordSerializer());
  _gSetupTool = new ClusterSetup(_gZkClient);
  _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:ZkIntegrationTestBase.java


示例2: verify

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@Override
public boolean verify() {
  HelixDataAccessor accessor =
      new ZKHelixDataAccessor(_clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  Builder keyBuilder = accessor.keyBuilder();
  int numberOfPartitions =
      accessor.getProperty(keyBuilder.idealStates(_resourceName)).getRecord().getListFields()
          .size();
  ClusterDataCache cache = new ClusterDataCache();
  cache.refresh(accessor);
  String masterValue =
      cache.getStateModelDef(cache.getIdealState(_resourceName).getStateModelDefRef())
          .getStatesPriorityList().get(0);
  int replicas = Integer.parseInt(cache.getIdealState(_resourceName).getReplicas());
  return verifyBalanceExternalView(accessor.getProperty(keyBuilder.externalView(_resourceName))
      .getRecord(), numberOfPartitions, masterValue, replicas, cache.getLiveInstances().size(),
      cache.getIdealState(_resourceName).getMaxPartitionsPerInstance());
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:TestAutoRebalancePartitionLimit.java


示例3: setupStateModel

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
protected void setupStateModel(String clusterName) {
  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  Builder keyBuilder = accessor.keyBuilder();

  StateModelDefinition masterSlave =
      new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
  accessor.setProperty(keyBuilder.stateModelDef(masterSlave.getId()), masterSlave);

  StateModelDefinition leaderStandby =
      new StateModelDefinition(StateModelConfigGenerator.generateConfigForLeaderStandby());
  accessor.setProperty(keyBuilder.stateModelDef(leaderStandby.getId()), leaderStandby);

  StateModelDefinition onlineOffline =
      new StateModelDefinition(StateModelConfigGenerator.generateConfigForOnlineOffline());
  accessor.setProperty(keyBuilder.stateModelDef(onlineOffline.getId()), onlineOffline);

}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:ZkUnitTestBase.java


示例4: beforeSuite

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@BeforeSuite
public void beforeSuite() throws Exception {
  if (!_init) {
    // TODO: use logging.properties file to config java.util.logging.Logger levels
    java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
    topJavaLogger.setLevel(Level.WARNING);

    _gZkClient = new ZkClient(ZK_ADDR, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
        ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
    _gZkClientTestNS = new ZkClient(_zkAddrTestNS, ZkClient.DEFAULT_CONNECTION_TIMEOUT, ZkClient.DEFAULT_SESSION_TIMEOUT,
        new ZNRecordSerializer());
    _gSetupTool = new ClusterSetup(_gZkClient);
    _configAccessor = new ConfigAccessor(_gZkClient);
    _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
    _baseAccessorTestNS = new ZkBaseDataAccessor<>(_gZkClientTestNS);

    // wait for the web service to start
    Thread.sleep(100);

    setup();
    _init = true;
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:24,代码来源:AbstractTestClass.java


示例5: readZkChildrenAsBytesMap

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
public static Map<String, String> readZkChildrenAsBytesMap(ZkClient zkclient, PropertyKey propertyKey) {
  BaseDataAccessor<byte[]> baseAccessor = new ZkBaseDataAccessor<byte[]>(zkclient);
  String parentPath = propertyKey.getPath();
  List<String> childNames = baseAccessor.getChildNames(parentPath, 0);
  if (childNames == null) {
    return null;
  }
  List<String> paths = new ArrayList<String>();
  for (String childName : childNames) {
    paths.add(parentPath + "/" + childName);
  }
  List<byte[]> values = baseAccessor.get(paths, null, 0);
  Map<String, String> ret = new HashMap<String, String>();
  for (int i = 0; i < childNames.size(); i++) {
    ret.put(childNames.get(i), new String(values.get(i)));
  }
  return ret;
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:ResourceUtil.java


示例6: HelixNotifier

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
/**
 * A constructor that gets a {@link HelixNotifier} based on {@link HelixPropertyStoreConfig}.
 * @param storeConfig A {@link HelixPropertyStore} used to instantiate a {@link HelixNotifier}. Cannot be {@code null}.
 */
public HelixNotifier(HelixPropertyStoreConfig storeConfig) {
  if (storeConfig == null) {
    throw new IllegalArgumentException("storeConfig cannot be null");
  }
  long startTimeMs = System.currentTimeMillis();
  logger.info("Starting a HelixNotifier");
  ZkClient zkClient = new ZkClient(storeConfig.zkClientConnectString, storeConfig.zkClientSessionTimeoutMs,
      storeConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer());
  List<String> subscribedPaths = Collections.singletonList(storeConfig.rootPath + HelixNotifier.TOPIC_PATH);
  HelixPropertyStore<ZNRecord> helixStore =
      new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), storeConfig.rootPath, subscribedPaths);
  logger.info("HelixPropertyStore started with zkClientConnectString={}, zkClientSessionTimeoutMs={}, "
          + "zkClientConnectionTimeoutMs={}, rootPath={}, subscribedPaths={}", storeConfig.zkClientConnectString,
      storeConfig.zkClientSessionTimeoutMs, storeConfig.zkClientConnectionTimeoutMs, storeConfig.rootPath,
      subscribedPaths);
  this.helixStore = helixStore;
  long startUpTimeInMs = System.currentTimeMillis() - startTimeMs;
  logger.info("HelixNotifier started, took {} ms", startUpTimeInMs);
}
 
开发者ID:linkedin,项目名称:ambry,代码行数:24,代码来源:HelixNotifier.java


示例7: HelixStoreOperator

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
/**
 * A constructor that gets a {@link HelixStoreOperator} based on the {@link HelixPropertyStoreConfig}.
 * @param storeConfig A {@link HelixPropertyStore} used to instantiate a {@link HelixStoreOperator}.
 */
public HelixStoreOperator(HelixPropertyStoreConfig storeConfig) {
  if (storeConfig == null) {
    throw new IllegalArgumentException("storeConfig cannot be null");
  }
  long startTimeMs = System.currentTimeMillis();
  logger.info("Starting a HelixStoreOperator");
  ZkClient zkClient = new ZkClient(storeConfig.zkClientConnectString, storeConfig.zkClientSessionTimeoutMs,
      storeConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer());
  List<String> subscribedPaths = Collections.singletonList(storeConfig.rootPath);
  HelixPropertyStore<ZNRecord> helixStore =
      new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), storeConfig.rootPath, subscribedPaths);
  logger.info("HelixPropertyStore started with zkClientConnectString={}, zkClientSessionTimeoutMs={}, "
          + "zkClientConnectionTimeoutMs={}, rootPath={}, subscribedPaths={}", storeConfig.zkClientConnectString,
      storeConfig.zkClientSessionTimeoutMs, storeConfig.zkClientConnectionTimeoutMs, storeConfig.rootPath,
      subscribedPaths);
  this.helixStore = helixStore;
  logger.info("HelixStoreOperator started, took {}ms", System.currentTimeMillis() - startTimeMs);
}
 
开发者ID:linkedin,项目名称:ambry,代码行数:23,代码来源:HelixStoreOperator.java


示例8: getAccountService

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@Override
public AccountService getAccountService() {
  try {
    long startTimeMs = System.currentTimeMillis();
    logger.info("Starting a HelixAccountService");
    ZkClient zkClient = new ZkClient(storeConfig.zkClientConnectString, storeConfig.zkClientSessionTimeoutMs,
        storeConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer());
    HelixPropertyStore<ZNRecord> helixStore =
        new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), storeConfig.rootPath, null);
    logger.info("HelixPropertyStore started with zkClientConnectString={}, zkClientSessionTimeoutMs={}, "
            + "zkClientConnectionTimeoutMs={}, rootPath={}", storeConfig.zkClientConnectString,
        storeConfig.zkClientSessionTimeoutMs, storeConfig.zkClientConnectionTimeoutMs, storeConfig.rootPath);
    ScheduledExecutorService scheduler =
        accountServiceConfig.updaterPollingIntervalMs > 0 ? Utils.newScheduler(1, HELIX_ACCOUNT_UPDATER_PREFIX, false)
            : null;
    HelixAccountService helixAccountService =
        new HelixAccountService(helixStore, accountServiceMetrics, notifier, scheduler, accountServiceConfig);
    long spentTimeMs = System.currentTimeMillis() - startTimeMs;
    logger.info("HelixAccountService started, took {} ms", spentTimeMs);
    accountServiceMetrics.startupTimeInMs.update(spentTimeMs);
    return helixAccountService;
  } catch (Exception e) {
    throw new IllegalStateException("Could not instantiate HelixAccountService", e);
  }
}
 
开发者ID:linkedin,项目名称:ambry,代码行数:26,代码来源:HelixAccountServiceFactory.java


示例9: getZkPropertyStore

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
public static ZkHelixPropertyStore<ZNRecord> getZkPropertyStore(HelixManager helixManager,
    String clusterName) {
  ZkBaseDataAccessor<ZNRecord> baseAccessor =
      (ZkBaseDataAccessor<ZNRecord>) helixManager.getHelixDataAccessor().getBaseDataAccessor();
  String propertyStorePath = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName);

  ZkHelixPropertyStore<ZNRecord> propertyStore = new ZkHelixPropertyStore<ZNRecord>(baseAccessor,
      propertyStorePath, Arrays.asList(propertyStorePath));

  return propertyStore;
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:12,代码来源:HelixUtils.java


示例10: beforeTest

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@BeforeTest
public void beforeTest() {
  ZkStarter.startLocalZkServer();

  _zkClient =
      new ZkClient(StringUtil.join("/", StringUtils.chomp(ZkStarter.DEFAULT_ZK_STR, "/")),
          ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
  String helixClusterName = "TestTimeBoundaryService";
  _zkClient.deleteRecursive("/" + helixClusterName + "/PROPERTYSTORE");
  _zkClient.createPersistent("/" + helixClusterName + "/PROPERTYSTORE", true);
  _propertyStore =
      new ZkHelixPropertyStore<ZNRecord>(new ZkBaseDataAccessor<ZNRecord>(_zkClient), "/" + helixClusterName
          + "/PROPERTYSTORE", null);

}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:16,代码来源:TimeBoundaryServiceTest.java


示例11: getZkPropertyStore

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
/**
 * Returns a handle to the propertyStore, setting up a watch on all nodes under PROPERTYSTORE/clusterName, if
 * setWatch is specified as true.
 *
 * @param helixManager * A valid helix manager bound to a cluster.
 * @param clusterName The pathname under propertyStore that we want a handle for
 * @param setWatch Must be set to true if it is desired to set up a watch on all nodes under the PROPERTYSTORE node.
 * @return A handle to the propertyStore.
 *
 * @note: Setting up a watch can lead to connection problems with zookeeper during a re-connect from the client. The
 * client ends up sending all the path names in the session request, and that can exceed the max size of a session
 * request if there are too many nodes, causing the connection to be dropped and retried (with the same parameters).
 */
public static ZkHelixPropertyStore<ZNRecord> getZkPropertyStore(HelixManager helixManager, String clusterName, boolean setWatch) {
  ZkBaseDataAccessor<ZNRecord> baseAccessor =
      (ZkBaseDataAccessor<ZNRecord>) helixManager.getHelixDataAccessor().getBaseDataAccessor();
  String propertyStorePath = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName);

  List<String> watchList = null;
  if (setWatch) {
    watchList = Arrays.asList(propertyStorePath);
  }

  ZkHelixPropertyStore<ZNRecord> propertyStore = new ZkHelixPropertyStore<ZNRecord>(baseAccessor, propertyStorePath, watchList);

  return propertyStore;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:28,代码来源:ZkUtils.java


示例12: verify

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@Override
public boolean verify() {
  try {
    HelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));

    return verifyBestPossAndExtView(accessor, errStates, clusterName, resources);
  } catch (Exception e) {
    LOG.error("exception in verification", e);
  }
  return false;
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:ClusterStateVerifier.java


示例13: ZkHelixClusterVerifier

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
public ZkHelixClusterVerifier(ZkClient zkClient, String clusterName) {
  if (zkClient == null || clusterName == null) {
    throw new IllegalArgumentException("requires zkClient|clusterName");
  }
  _zkClient = zkClient;
  _clusterName = clusterName;
  _accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
  _keyBuilder = _accessor.keyBuilder();
}
 
开发者ID:apache,项目名称:helix,代码行数:10,代码来源:ZkHelixClusterVerifier.java


示例14: AutoFallbackPropertyStore

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
public AutoFallbackPropertyStore(ZkBaseDataAccessor<T> accessor, String root, String fallbackRoot) {
  super(accessor, root, null);

  if (accessor.exists(fallbackRoot, 0)) {
    _fallbackStore = new ZkHelixPropertyStore<T>(accessor, fallbackRoot, null);
  } else {
    LOG.info("fallbackRoot: " + fallbackRoot
        + " doesn't exist, skip creating fallback property store");
    _fallbackStore = null;
  }

}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:AutoFallbackPropertyStore.java


示例15: testSelectiveUpdates

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@Test(dependsOnMethods = {"testUpdateOnNotification"})
public void testSelectiveUpdates() throws Exception {
  MockZkHelixDataAccessor accessor =
      new MockZkHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));

  ClusterDataCache cache =
      new ClusterDataCache("CLUSTER_" + TestHelper.getTestClassName());
  cache.refresh(accessor);

  Assert.assertEquals(accessor.getReadCount(PropertyType.IDEALSTATES), 1);
  Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), NODE_NR);
  Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), NODE_NR);
  Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), NODE_NR + 1);

  accessor.clearReadCounters();

  // refresh again should read nothing
  cache.refresh(accessor);
  Assert.assertEquals(accessor.getReadCount(PropertyType.IDEALSTATES), 0);
  Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), 0);
  Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), 0);
  Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 1);

  // add a new resource
  _setupTool.addResourceToCluster(CLUSTER_NAME, "TestDB_1", _PARTITIONS, STATE_MODEL);
  _setupTool.rebalanceStorageCluster(CLUSTER_NAME, "TestDB_1", _replica);

  Thread.sleep(100);
  HelixClusterVerifier _clusterVerifier =
      new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
  Assert.assertTrue(_clusterVerifier.verify());

  accessor.clearReadCounters();

  // refresh again should read only new current states
  cache.refresh(accessor);
  Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), NODE_NR);
}
 
开发者ID:apache,项目名称:helix,代码行数:39,代码来源:TestClusterDataCacheSelectiveUpdate.java


示例16: assertEmptyCSandEV

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
/**
 * Assert externalView and currentState for each participant are empty
 * @param clusterName
 * @param db
 * @param participants
 */
private void assertEmptyCSandEV(String clusterName, String db, MockParticipantManager[] participants) {
  HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  PropertyKey.Builder keyBuilder = accessor.keyBuilder();
  Assert.assertNull(accessor.getProperty(keyBuilder.externalView(db)));

  for (MockParticipantManager participant : participants) {
    String instanceName = participant.getInstanceName();
    String sessionId = participant.getSessionId();
    Assert.assertNull(accessor.getProperty(keyBuilder.currentState(instanceName, sessionId, db)));
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:TestDrop.java


示例17: testStandAloneCMMain

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@Test()
public void testStandAloneCMMain() throws Exception {
  logger.info("RUN testStandAloneCMMain() at " + new Date(System.currentTimeMillis()));
  ClusterControllerManager newController = null;
  for (int i = 1; i <= 2; i++) {
    String controllerName = "controller_" + i;
    newController =
        new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
    newController.syncStart();
  }

  // stopCurrentLeader(_zkClient, CLUSTER_NAME, _startCMResultMap);
  _controller.syncStop();

  final HelixDataAccessor accessor =
      new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  final PropertyKey.Builder keyBuilder = accessor.keyBuilder();
  final String newControllerName = newController.getInstanceName();
  TestHelper.verify(new Verifier() {

    @Override
    public boolean verify() throws Exception {
      LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
      if (leader == null) {
        return false;
      }
      return leader.getInstanceName().equals(newControllerName);

    }
  }, 30 * 1000);

  boolean result =
      ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
          ZK_ADDR, CLUSTER_NAME));
  Assert.assertTrue(result);

  logger.info("STOP testStandAloneCMMain() at " + new Date(System.currentTimeMillis()));
}
 
开发者ID:apache,项目名称:helix,代码行数:39,代码来源:TestStandAloneCMMain.java


示例18: testDisableExternalView

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
@Test
public void testDisableExternalView() throws InterruptedException {
  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  PropertyKey.Builder keyBuilder = accessor.keyBuilder();

  // verify external view for TEST_DB1 does not exist
  ExternalView externalView = null;
  externalView = accessor.getProperty(keyBuilder.externalView(TEST_DB1));
  Assert.assertNull(externalView,
      "There should be no external-view for " + TEST_DB1 + ", but is: " + externalView);

  // verify external view for TEST_DB2 exists
  externalView = accessor.getProperty(keyBuilder.externalView(TEST_DB2));
  Assert.assertNotNull(externalView,
      "Could not find external-view for " + TEST_DB2);

  // disable external view in IS
  IdealState idealState = _admin.getResourceIdealState(CLUSTER_NAME, TEST_DB2);
  idealState.setDisableExternalView(true);
  _admin.setResourceIdealState(CLUSTER_NAME, TEST_DB2, idealState);

  // touch liveinstance to trigger externalview compute stage
  String instance = PARTICIPANT_PREFIX + "_" + START_PORT;
  HelixProperty liveInstance = accessor.getProperty(keyBuilder.liveInstance(instance));
  accessor.setProperty(keyBuilder.liveInstance(instance), liveInstance);

  // verify the external view for the db got removed
  for (int i = 0; i < 10; i++) {
    Thread.sleep(100);
    externalView = accessor.getProperty(keyBuilder.externalView(TEST_DB2));
    if (externalView == null) {
      break;
    }
  }

  Assert.assertNull(externalView, "external-view for " + TEST_DB2 + " should be removed, but was: "
      + externalView);
}
 
开发者ID:apache,项目名称:helix,代码行数:40,代码来源:TestDisableExternalView.java


示例19: clearStatusUpdate

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
private void clearStatusUpdate(String clusterName, String instance, String resource,
    String partition) {
  // clear status update for error partition so verify() will not fail on old
  // errors
  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  Builder keyBuilder = accessor.keyBuilder();

  LiveInstance liveInstance = accessor.getProperty(keyBuilder.liveInstance(instance));
  accessor.removeProperty(keyBuilder.stateTransitionStatus(instance, liveInstance.getSessionId(),
      resource, partition));

}
 
开发者ID:apache,项目名称:helix,代码行数:14,代码来源:TestResetPartitionState.java


示例20: checkExternalView

import org.apache.helix.manager.zk.ZkBaseDataAccessor; //导入依赖的package包/类
/**
 * Check all partitions are in OFFLINE state
 * @param clusterName
 * @throws Exception
 */
private void checkExternalView(String clusterName) throws Exception {
  BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
  final HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, baseAccessor);

  // verify that states of TestDB0 are all OFFLINE
  boolean result = TestHelper.verify(new TestHelper.Verifier() {

    @Override
    public boolean verify() throws Exception {
      PropertyKey.Builder keyBuilder = accessor.keyBuilder();

      ExternalView extView = accessor.getProperty(keyBuilder.externalView("TestDB0"));
      if (extView == null) {
        return false;
      }
      Set<String> partitionSet = extView.getPartitionSet();
      if (partitionSet == null || partitionSet.size() != PARTITION_NUM) {
        return false;
      }
      for (String partition : partitionSet) {
        Map<String, String> instanceStates = extView.getStateMap(partition);
        for (String state : instanceStates.values()) {
          if (!"OFFLINE".equals(state)) {
            return false;
          }
        }
      }
      return true;
    }
  }, 10 * 1000);
  Assert.assertTrue(result);
}
 
开发者ID:apache,项目名称:helix,代码行数:38,代码来源:TestDisableResource.java



注:本文中的org.apache.helix.manager.zk.ZkBaseDataAccessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OkHeaders类代码示例发布时间:2022-05-22
下一篇:
Java ChainingStrategy类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap