当前位置: 首页>>代码示例>>Java>>正文


Java ZkClient类代码示例

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


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


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