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

Java ZkClient类代码示例

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

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



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

示例1: setup

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
@BeforeTest
public void setup() throws Exception {
  ZkStarter.startLocalZkServer();
  _zkClient = new ZkClient(ZK_STR);

  _pinotHelixResourceManager =
      new PinotHelixResourceManager(ZK_STR, HELIX_CLUSTER_NAME, CONTROLLER_INSTANCE_NAME, null, 10000L, true);
  _pinotHelixResourceManager.start();
  ControllerRequestBuilderUtil.addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);
  ControllerRequestBuilderUtil.addFakeBrokerInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);

  _helixAdmin = _pinotHelixResourceManager.getHelixAdmin();
  _helixZkManager = _pinotHelixResourceManager.getHelixZkManager();

  String OfflineTableConfigJson =
      ControllerRequestBuilderUtil.buildCreateOfflineTableJSON(_testTableName, null, null, 2).toString();
  AbstractTableConfig offlineTableConfig = AbstractTableConfig.init(OfflineTableConfigJson);
  _pinotHelixResourceManager.addTable(offlineTableConfig);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:20,代码来源:RetentionManagerTest.java


示例2: getInstanceErrorsRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName,
    String resourceGroup) throws JsonGenerationException, JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
  Builder keyBuilder = new PropertyKey.Builder(clusterName);
  String message =
      ClusterRepresentationUtil.getInstancePropertiesAsString(zkClient, clusterName,
          keyBuilder.stateTransitionErrors(instanceName, instanceSessionId, resourceGroup),
          // instanceSessionId
          // + "__"
          // + resourceGroup,
          MediaType.APPLICATION_JSON);
  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);
  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:ErrorResource.java


示例3: getInstanceErrorsRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName)
    throws JsonGenerationException, JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ;

  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);

  String message =
      ClusterRepresentationUtil
          .getInstancePropertyNameListAsString(zkClient, clusterName, instanceName,
              PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON);

  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);

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


示例4: getInstanceCurrentStatesRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getInstanceCurrentStatesRepresentation(String clusterName,
    String instanceName) throws JsonGenerationException, JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ;
  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);

  String message =
      ClusterRepresentationUtil
          .getInstancePropertyNameListAsString(zkClient, clusterName, instanceName,
              PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON);

  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);

  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:CurrentStatesResource.java


示例5: startController

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
protected void startController(ControllerConf config) {
  Assert.assertNotNull(config);
  Assert.assertNull(_controllerStarter);

  _controllerPort = Integer.valueOf(config.getControllerPort());
  _controllerBaseApiUrl = "http://localhost:" + _controllerPort;
  _controllerRequestURLBuilder = ControllerRequestURLBuilder.baseUrl(_controllerBaseApiUrl);
  _controllerDataDir = config.getDataDir();

  String helixClusterName = getHelixClusterName();
  config.setHelixClusterName(helixClusterName);

  String zkStr = config.getZkStr();
  _zkClient = new ZkClient(zkStr);
  if (_zkClient.exists("/" + helixClusterName)) {
    _zkClient.deleteRecursive("/" + helixClusterName);
  }

  _controllerStarter = new ControllerStarter(config);
  _controllerStarter.start();

  _helixResourceManager = _controllerStarter.getHelixResourceManager();
  _helixManager = _helixResourceManager.getHelixZkManager();
  _helixAdmin = _helixResourceManager.getHelixAdmin();
  _propertyStore = _helixResourceManager.getPropertyStore();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:27,代码来源:ControllerTest.java


示例6: getInstanceStatusUpdateRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getInstanceStatusUpdateRepresentation(String clusterName,
    String instanceName, String resourceGroup) throws JsonGenerationException,
    JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);

  Builder keyBuilder = new PropertyKey.Builder(clusterName);
  String message =
      ClusterRepresentationUtil.getInstancePropertiesAsString(zkClient, clusterName,
          keyBuilder.stateTransitionStatus(instanceName, instanceSessionId, resourceGroup),
          // instanceSessionId
          // + "__"
          // + resourceGroup,
          MediaType.APPLICATION_JSON);
  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);
  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:21,代码来源:StatusUpdateResource.java


示例7: beforeSuite

import org.apache.helix.manager.zk.ZkClient; //导入依赖的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


示例8: getInstanceCurrentStateRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getInstanceCurrentStateRepresentation(String clusterName,
    String instanceName, String resourceGroup) throws JsonGenerationException,
    JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getRequest().getAttributes().get(RestAdminApplication.ZKCLIENT);
  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
  Builder keyBuilder = new PropertyKey.Builder(clusterName);

  String message =
      ClusterRepresentationUtil.getInstancePropertyAsString(zkClient, clusterName,
          keyBuilder.currentState(instanceName, instanceSessionId, resourceGroup),
          MediaType.APPLICATION_JSON);
  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);
  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:17,代码来源:CurrentStateResource.java


示例9: start

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
public void start(ControllerMetrics controllerMetrics) {
  _controllerMetrics = controllerMetrics;

  LOGGER.info("Starting realtime segments manager, adding a listener on the property store table configs path.");
  String zkUrl = _pinotHelixResourceManager.getHelixZkURL();
  _zkClient = new ZkClient(zkUrl, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
  _zkClient.waitUntilConnected();

  // Subscribe to any data/child changes to property
  _zkClient.subscribeChildChanges(_tableConfigPath, this);
  _zkClient.subscribeDataChanges(_tableConfigPath, this);

  // Subscribe to leadership changes
  _pinotHelixResourceManager.getHelixZkManager().addControllerListener(new ControllerChangeListener() {
    @Override
    public void onControllerChange(NotificationContext changeContext) {
      processPropertyStoreChange(CONTROLLER_LEADER_CHANGE);
    }
  });

  // Setup change listeners for already existing tables, if any.
  processPropertyStoreChange(_tableConfigPath);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:25,代码来源:PinotRealtimeSegmentManager.java


示例10: delete

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
/**
 * Remove constraints
 * <p>
 * Usage:
 * <code>curl -X DELETE http://{host:port}/clusters/{cluster}/constraints/MESSAGE_CONSTRAINT/{constraintId}
 */
@Override
public Representation delete() {
  String clusterName =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
  String constraintTypeStr =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CONSTRAINT_TYPE);
  String constraintId =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CONSTRAINT_ID);

  try {
    ZkClient zkClient =
        ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
    ClusterSetup setupTool = new ClusterSetup(zkClient);

    setupTool.removeConstraint(clusterName, constraintTypeStr, constraintId);
  } catch (Exception e) {
    LOG.error("Error in delete constraint", e);
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:30,代码来源:ConstraintResource.java


示例11: getStateModelsRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getStateModelsRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName = (String) getRequest().getAttributes().get("clusterName");
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);

  List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName);

  ZNRecord modelDefinitions = new ZNRecord("modelDefinitions");
  modelDefinitions.setListField("models", models);

  StringRepresentation representation =
      new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(modelDefinitions),
          MediaType.APPLICATION_JSON);

  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:StateModelsResource.java


示例12: readZkRecursive

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
public static void readZkRecursive(String path, Map<String, ZNode> map, ZkClient zkclient) {
  try {
    Stat stat = new Stat();
    ZNRecord record = zkclient.readData(path, stat);
    List<String> childNames = zkclient.getChildren(path);
    ZNode node = new ZNode(path, record, stat);
    node.addChildren(childNames);
    map.put(path, node);

    for (String childName : childNames) {
      String childPath = path + "/" + childName;
      readZkRecursive(childPath, map, zkclient);
    }
  } catch (ZkNoNodeException e) {
    // OK
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:TestHelper.java


示例13: setUp

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
@BeforeClass
public void setUp() throws Exception {
  _zookeeperInstance = ZkStarter.startLocalZkServer();
  _zkClient = new ZkClient(ZK_STR);
  Thread.sleep(1000);

  _pinotHelixResourceManager =
      new PinotHelixResourceManager(ZK_STR, HELIX_CLUSTER_NAME, CONTROLLER_INSTANCE_NAME, null, 1000L, true, /*isUpdateStateModel=*/
          false);
  _pinotHelixResourceManager.start();

  ControllerRequestBuilderUtil.addFakeDataInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);
  ControllerRequestBuilderUtil.addFakeBrokerInstancesToAutoJoinHelixCluster(HELIX_CLUSTER_NAME, ZK_STR, 2, true);

  _offlineTableConfig = new TableConfig.Builder(CommonConstants.Helix.TableType.OFFLINE).setTableName(TEST_TABLE_NAME)
      .setNumReplicas(2)
      .build();

  final String instanceId = "localhost_helixController";
  _helixManager = HelixSetupUtils.setup(HELIX_CLUSTER_NAME, ZK_STR, instanceId, /*isUpdateStateModel=*/false);
  _pinotHelixResourceManager.addTable(_offlineTableConfig);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:23,代码来源:ValidationManagerTest.java


示例14: getInstanceRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getInstanceRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
  String instanceName =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.INSTANCE_NAME);
  Builder keyBuilder = new PropertyKey.Builder(clusterName);
  ZkClient zkclient =
      ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.RAW_ZKCLIENT);

  String instanceCfgStr =
      ResourceUtil.readZkAsBytes(zkclient, keyBuilder.instanceConfig(instanceName));
  StringRepresentation representation =
      new StringRepresentation(instanceCfgStr, MediaType.APPLICATION_JSON);

  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:InstanceResource.java


示例15: delete

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
@Override
public Representation delete() {
  String zkPath = getZKPath();
  try {
    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
    zkClient.deleteRecursive(zkPath);

    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in delete zkPath: " + zkPath, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:ZkPathResource.java


示例16: delete

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
@Override
public Representation delete() {
  String zkPath = getZKPath();
  try {
    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

    List<String> childNames = zkClient.getChildren(zkPath);
    if (childNames != null) {
      for (String childName : childNames) {
        String childPath = zkPath.equals("/") ? "/" + childName : zkPath + "/" + childName;
        zkClient.deleteRecursive(childPath);
      }
    }

    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in delete zkChild: " + zkPath, e);
  }
  return null;
}
 
开发者ID:apache,项目名称:helix,代码行数:25,代码来源:ZkChildResource.java


示例17: beforeSuite

import org.apache.helix.manager.zk.ZkClient; //导入依赖的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


示例18: getSchedulerTasksRepresentation

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
StringRepresentation getSchedulerTasksRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName = (String) getRequest().getAttributes().get("clusterName");
  String instanceName = (String) getRequest().getAttributes().get("instanceName");
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);
  List<String> instances =
      setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);

  HelixDataAccessor accessor =
      ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
  LiveInstance liveInstance =
      accessor.getProperty(accessor.keyBuilder().liveInstance(instanceName));
  String sessionId = liveInstance.getSessionId();

  StringRepresentation representation = new StringRepresentation("");// (ClusterRepresentationUtil.ObjectToJson(instanceConfigs),
                                                                     // MediaType.APPLICATION_JSON);

  return representation;
}
 
开发者ID:apache,项目名称:helix,代码行数:21,代码来源:SchedulerTasksResource.java


示例19: setUpHelixCluster

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
private void setUpHelixCluster(String zookeeperQuorum, String clusterName) {
  ZkClient zkClient = ZKClientPool.getZkClient(zookeeperQuorum);
  HelixAdmin helixAdmin = new ZKHelixAdmin(zkClient);
  try {
    if(!ImmutableSet.copyOf(helixAdmin.getClusters()).contains(clusterName)) {
      ClusterSetup helixClusterSetUp = new ClusterSetup(zkClient);
      helixClusterSetUp.addCluster(clusterName, false);
      helixClusterSetUp.setConfig(HelixConfigScope.ConfigScopeProperty.CLUSTER, clusterName,
          "allowParticipantAutoJoin=true");
    }
  } finally {
    zkClient.close();
  }
}
 
开发者ID:pinterest-attic,项目名称:terrapin,代码行数:15,代码来源:TerrapinControllerHandler.java


示例20: execute

import org.apache.helix.manager.zk.ZkClient; //导入依赖的package包/类
@Override
public boolean execute() throws Exception {
  LOGGER.info("Connecting to Zookeeper at address: {}", _zkAddress);
  ZkClient zkClient = new ZkClient(_zkAddress, 5000);
  String helixClusterName = "/" + _clusterName;

  LOGGER.info("Executing command: " + toString());
  if (!zkClient.exists(helixClusterName)) {
    LOGGER.error("Cluster {} does not exist.", _clusterName);
    return false;
  }

  zkClient.deleteRecursive(helixClusterName);
  return true;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:16,代码来源:DeleteClusterCommand.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DocumentSecurityAttribute类代码示例发布时间:2022-05-22
下一篇:
Java EncodedField类代码示例发布时间: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