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


Java ZkClient.setZkSerializer方法代码示例

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


在下文中一共展示了ZkClient.setZkSerializer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: post

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public void post(String zkServer, Message message, String clusterName, String instanceName) {
  ZkClient client = new ZkClient(zkServer);
  client.setZkSerializer(new ZNRecordSerializer());
  String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
  client.delete(path);
  ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
  message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()));
  message.setTgtName(record.getId());
  // System.out.println(message);
  client.createPersistent(path, message.getRecord());
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:MessagePoster.java

示例4: ZKDumper

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public ZKDumper(String zkAddress) {
  client = new ZkClient(zkAddress, ZkClient.DEFAULT_CONNECTION_TIMEOUT);

  ZkSerializer zkSerializer = new ByteArraySerializer();
  client.setZkSerializer(zkSerializer);
  filter = new FilenameFilter() {

    @Override
    public boolean accept(File dir, String name) {
      return !name.startsWith(".");
    }
  };
}
 
开发者ID:apache,项目名称:helix,代码行数:14,代码来源:ZKDumper.java

示例5: beforeClass

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeClass()
public void beforeClass() {
  System.out.println("START " + getShortClassName() + " at "
      + new Date(System.currentTimeMillis()));

  _zkClient = new ZkClient(ZK_ADDR);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
  if (_zkClient.exists(PREFIX)) {
    _zkClient.deleteRecursive(PREFIX);
  }

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

示例6: verifyEmptyCurStateAndExtView

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static boolean verifyEmptyCurStateAndExtView(String clusterName, String resourceName,
    Set<String> instanceNames, String zkAddr) {
  ZkClient zkClient = new ZkClient(zkAddr);
  zkClient.setZkSerializer(new ZNRecordSerializer());

  try {
    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
    Builder keyBuilder = accessor.keyBuilder();

    for (String instanceName : instanceNames) {
      List<String> sessionIds = accessor.getChildNames(keyBuilder.sessions(instanceName));

      for (String sessionId : sessionIds) {
        CurrentState curState =
            accessor.getProperty(keyBuilder.currentState(instanceName, sessionId, resourceName));

        if (curState != null && curState.getRecord().getMapFields().size() != 0) {
          return false;
        }
      }

      ExternalView extView = accessor.getProperty(keyBuilder.externalView(resourceName));

      if (extView != null && extView.getRecord().getMapFields().size() != 0) {
        return false;
      }

    }

    return true;
  } finally {
    zkClient.close();
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:36,代码来源:TestHelper.java

示例7: verifyState

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
/**
 * @param stateMap
 *          : "ResourceName/partitionKey" -> setOf(instances)
 * @param state
 *          : MASTER|SLAVE|ERROR...
 */
public static void verifyState(String clusterName, String zkAddr,
    Map<String, Set<String>> stateMap, String state) {
  ZkClient zkClient = new ZkClient(zkAddr);
  zkClient.setZkSerializer(new ZNRecordSerializer());

  try {
    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
    Builder keyBuilder = accessor.keyBuilder();

    for (String resGroupPartitionKey : stateMap.keySet()) {
      Map<String, String> retMap = getResourceAndPartitionKey(resGroupPartitionKey);
      String resGroup = retMap.get("RESOURCE");
      String partitionKey = retMap.get("PARTITION");

      ExternalView extView = accessor.getProperty(keyBuilder.externalView(resGroup));
      for (String instance : stateMap.get(resGroupPartitionKey)) {
        String actualState = extView.getStateMap(partitionKey).get(instance);
        Assert.assertNotNull(actualState, "externalView doesn't contain state for " + resGroup
            + "/" + partitionKey + " on " + instance + " (expect " + state + ")");

        Assert
            .assertEquals(actualState, state, "externalView for " + resGroup + "/" + partitionKey
                + " on " + instance + " is " + actualState + " (expect " + state + ")");
      }
    }
  } finally {
    zkClient.close();
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:37,代码来源:TestHelper.java

示例8: beforeClass

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeClass()
public void beforeClass() throws Exception {
  _zkClient = new ZkClient(ZK_ADDR);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
  if (_zkClient.exists("/" + clusterName)) {
    _zkClient.deleteRecursive("/" + clusterName);
  }

  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addCluster "
      + clusterName));
  // ClusterSetup
  // .processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR +
  // " -addCluster relay-cluster-12345"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addResource "
      + clusterName + " db-12345 120 MasterSlave"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8900"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8901"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8902"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8903"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -addNode " + clusterName
      + " localhost:8904"));
  ClusterSetup.processCommandLineArgs(createArgs("-zkSvr " + ZK_ADDR + " -rebalance "
      + clusterName + " db-12345 3"));
}
 
开发者ID:apache,项目名称:helix,代码行数:29,代码来源:TestZKCallback.java

示例9: beforeClass

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeClass()
public void beforeClass() throws IOException, Exception {
  System.out.println("START TestClusterSetup.beforeClass() "
      + new Date(System.currentTimeMillis()));

  _zkClient = new ZkClient(ZK_ADDR);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
}
 
开发者ID:apache,项目名称:helix,代码行数:9,代码来源:TestClusterSetup.java

示例10: beforeSuite

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@BeforeSuite(alwaysRun = true)
public void beforeSuite() throws Exception {
  _zkServer = TestHelper.startZkServer(ZK_ADDR);
  AssertJUnit.assertTrue(_zkServer != null);
  ZKClientPool.reset();

  // System.out.println("Number of open zkClient before ZkUnitTests: "
  // + ZkClient.getNumberOfConnections());

  _gZkClient = new ZkClient(ZK_ADDR);
  _gZkClient.setZkSerializer(new ZNRecordSerializer());
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:ZkUnitTestBase.java

示例11: getInstancePropertiesAsString

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static String getInstancePropertiesAsString(ZkClient zkClient, String clusterName,
    PropertyKey propertyKey, MediaType mediaType) throws JsonGenerationException,
    JsonMappingException, IOException {
  zkClient.setZkSerializer(new ZNRecordSerializer());
  ZKHelixDataAccessor accessor =
      new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));

  List<ZNRecord> records = HelixProperty.convertToList(accessor.getChildValues(propertyKey));
  return ObjectToJson(records);
}
 
开发者ID:apache,项目名称:helix,代码行数:11,代码来源:ClusterRepresentationUtil.java

示例12: fromZookeeper

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
@Deprecated
public static PinotThirdEyeDataSource fromZookeeper(String controllerHost, int controllerPort, String zkUrl) {
  ZkClient zkClient = new ZkClient(zkUrl);
  zkClient.setZkSerializer(new ZNRecordSerializer());
  zkClient.waitUntilConnected();
  PinotThirdEyeDataSource pinotThirdEyeDataSource = new PinotThirdEyeDataSource(controllerHost, controllerPort);
  LOG.info("Created PinotThirdEyeDataSource to zookeeper: {} controller: {}:{}", zkUrl, controllerHost, controllerPort);
  return pinotThirdEyeDataSource;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:10,代码来源:PinotThirdEyeDataSource.java

示例13: init

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
/**
 * Initializes the cache loader using the given data source config.
 *
 * @param pinotThirdEyeDataSourceConfig the data source config that provides controller's information.
 *
 * @throws Exception when an error occurs connecting to the Pinot controller.
 */
private void init(PinotThirdEyeDataSourceConfig pinotThirdEyeDataSourceConfig) throws Exception {
  if (pinotThirdEyeDataSourceConfig.getBrokerUrl() != null
      && pinotThirdEyeDataSourceConfig.getBrokerUrl().trim().length() > 0) {
    ZkClient zkClient = new ZkClient(pinotThirdEyeDataSourceConfig.getZookeeperUrl());
    zkClient.setZkSerializer(new ZNRecordSerializer());
    zkClient.waitUntilConnected();
    ZKHelixAdmin helixAdmin = new ZKHelixAdmin(zkClient);
    List<String> thirdeyeBrokerList = helixAdmin.getInstancesInClusterWithTag(
        pinotThirdEyeDataSourceConfig.getClusterName(), pinotThirdEyeDataSourceConfig.getTag());

    String[] thirdeyeBrokers = new String[thirdeyeBrokerList.size()];
    for (int i = 0; i < thirdeyeBrokerList.size(); i++) {
      String instanceName = thirdeyeBrokerList.get(i);
      InstanceConfig instanceConfig =
          helixAdmin.getInstanceConfig(pinotThirdEyeDataSourceConfig.getClusterName(), instanceName);
      thirdeyeBrokers[i] = instanceConfig.getHostName().replaceAll(BROKER_PREFIX, "") + ":"
          + instanceConfig.getPort();
    }
    this.connections = fromHostList(thirdeyeBrokers);
    LOG.info("Created PinotControllerResponseCacheLoader with brokers {}", thirdeyeBrokers);
  } else {
    this.connections = fromZookeeper(pinotThirdEyeDataSourceConfig);
    LOG.info("Created PinotControllerResponseCacheLoader with controller {}:{}",
        pinotThirdEyeDataSourceConfig.getControllerHost(), pinotThirdEyeDataSourceConfig.getControllerPort());
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:34,代码来源:PinotControllerResponseCacheLoader.java

示例14: setupCluster

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public static void setupCluster(String uniqClusterName, String zkAddr, int numResources,
    int numPartitionsPerResource, int numInstances, int replica, boolean doRebalance)
    throws Exception {
  ZkClient zkClient = new ZkClient(zkAddr);
  zkClient.setZkSerializer(new ZNRecordSerializer());

  // String clusterName = CLUSTER_PREFIX + "_" + uniqClusterName;
  String clusterName = uniqClusterName;
  if (zkClient.exists("/" + clusterName)) {
    LOG.warn("test cluster already exists:" + clusterName + ", test name:" + uniqClusterName
        + " is not unique or test has been run without cleaning up zk; deleting it");
    zkClient.deleteRecursive("/" + clusterName);
  }

  if (_testInfoMap.containsKey(uniqClusterName)) {
    LOG.warn("test info already exists:" + uniqClusterName
        + " is not unique or test has been run without cleaning up test info map; removing it");
    _testInfoMap.remove(uniqClusterName);
  }
  TestInfo testInfo =
      new TestInfo(clusterName, zkClient, numResources, numPartitionsPerResource, numInstances,
          replica);
  _testInfoMap.put(uniqClusterName, testInfo);

  ClusterSetup setupTool = new ClusterSetup(zkAddr);
  setupTool.addCluster(clusterName, true);

  for (int i = 0; i < numInstances; i++) {
    int port = START_PORT + i;
    setupTool.addInstanceToCluster(clusterName, PARTICIPANT_PREFIX + "_" + port);
  }

  for (int i = 0; i < numResources; i++) {
    String dbName = TEST_DB_PREFIX + i;
    setupTool.addResourceToCluster(clusterName, dbName, numPartitionsPerResource, STATE_MODEL);
    if (doRebalance) {
      setupTool.rebalanceStorageCluster(clusterName, dbName, replica);

      // String idealStatePath = "/" + clusterName + "/" +
      // PropertyType.IDEALSTATES.toString() + "/"
      // + dbName;
      // ZNRecord idealState = zkClient.<ZNRecord> readData(idealStatePath);
      // testInfo._idealStateMap.put(dbName, idealState);
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:47,代码来源:TestDriver.java

示例15: MockController

import org.apache.helix.manager.zk.ZkClient; //导入方法依赖的package包/类
public MockController(String src, String zkServer, String cluster) {
  srcName = src;
  clusterName = cluster;
  client = new ZkClient(zkServer);
  client.setZkSerializer(new ZNRecordSerializer());
}
 
开发者ID:apache,项目名称:helix,代码行数:7,代码来源:MockController.java


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