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


Java ZkClient.DEFAULT_SESSION_TIMEOUT属性代码示例

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


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

示例1: beforeSuite

@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,代码行数:23,代码来源:AbstractTestClass.java

示例2: beforeSuite

@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);

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

  _gZkClient =
      new ZkClient(ZK_ADDR, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
          ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
  _gSetupTool = new ClusterSetup(_gZkClient);

  // start admin
  _adminThread = new AdminThread(ZK_ADDR, ADMIN_PORT);
  _adminThread.start();

  // create a client
  _gClient = new Client(Protocol.HTTP);

  // wait for the web service to start
  Thread.sleep(100);
}
 
开发者ID:apache,项目名称:helix,代码行数:26,代码来源:AdminTestBase.java

示例3: start

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,代码行数:24,代码来源:PinotRealtimeSegmentManager.java

示例4: beforeTest

@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,代码行数:15,代码来源:TimeBoundaryServiceTest.java

示例5: testWatchRenew

/**
 * test zk watchers are renewed automatically after session expiry
 * zookeeper-client side keeps all registered watchers see ZooKeeper.WatchRegistration.register()
 * after session expiry, all watchers are renewed
 * if a path that has watches on it has been removed during session expiry,
 * the watchers on that path will still get callbacks after session renewal, especially:
 * a data-watch will get data-deleted callback
 * a child-watch will get a child-change callback with current-child-list = null
 * this can be used for cleanup watchers on the zookeeper-client side
 */
@Test
public void testWatchRenew() throws Exception {

  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String testName = className + "_" + methodName;

  final ZkClient client =
      new ZkClient(ZK_ADDR, ZkClient.DEFAULT_SESSION_TIMEOUT,
          ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
  // make sure "/testName/test" doesn't exist
  final String path = "/" + testName + "/test";
  client.delete(path);

  ZkListener listener = new ZkListener();
  client.subscribeDataChanges(path, listener);
  client.subscribeChildChanges(path, listener);

  ZkTestHelper.expireSession(client);

  boolean succeed = listener._childChangeCountDown.await(10, TimeUnit.SECONDS);
  Assert.assertTrue(succeed,
      "fail to wait on child-change count-down in 10 seconds after session-expiry");
  Assert.assertEquals(listener._parentPath, path,
      "fail to get child-change callback after session-expiry");
  Assert.assertNull(listener._currentChilds,
      "fail to get child-change callback with currentChilds=null after session expiry");

  succeed = listener._dataDeleteCountDown.await(10, TimeUnit.SECONDS);
  Assert.assertTrue(succeed,
      "fail to wait on data-delete count-down in 10 seconds after session-expiry");
  Assert.assertEquals(listener._dataDeletePath, path,
      "fail to get data-delete callback after session-expiry");

  client.close();
}
 
开发者ID:apache,项目名称:helix,代码行数:46,代码来源:TestZkBasis.java

示例6: TaskCluster

public TaskCluster(String zkAddr, String clusterName) throws Exception {
  _clusterName = clusterName;
  _zkclient =
      new ZkClient(zkAddr, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
          new ZNRecordSerializer());
  _admin = new ZKHelixAdmin(_zkclient);
}
 
开发者ID:apache,项目名称:helix,代码行数:7,代码来源:TaskCluster.java

示例7: beforeTest

@BeforeTest
public void beforeTest() {
  _zookeeperInstance = 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<>(new ZkBaseDataAccessor<ZNRecord>(_zkClient),
      "/" + helixClusterName + "/PROPERTYSTORE", null);
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:12,代码来源:TimeBoundaryServiceTest.java

示例8: HelixBrokerStarter

public HelixBrokerStarter(String helixClusterName, String zkServer, Configuration pinotHelixProperties)
    throws Exception {
  _liveInstancesListener = new LiveInstancesChangeListenerImpl(helixClusterName);

  _pinotHelixProperties = DefaultHelixBrokerConfig.getDefaultBrokerConf(pinotHelixProperties);
  final String brokerId =
      _pinotHelixProperties.getString(
              "instanceId",
              CommonConstants.Helix.PREFIX_OF_BROKER_INSTANCE
                      + NetUtil.getHostAddress()
                      + "_"
                      + _pinotHelixProperties.getInt(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT,
                  CommonConstants.Helix.DEFAULT_BROKER_QUERY_PORT));

  _pinotHelixProperties.addProperty("pinot.broker.id", brokerId);
  RoutingTableBuilder defaultOfflineRoutingTableBuilder =
      getRoutingTableBuilder(_pinotHelixProperties.subset(DEFAULT_OFFLINE_ROUTING_TABLE_BUILDER_KEY));
  RoutingTableBuilder defaultRealtimeRoutingTableBuilder =
      getRoutingTableBuilder(_pinotHelixProperties.subset(DEFAULT_REALTIME_ROUTING_TABLE_BUILDER_KEY));
  Map<String, RoutingTableBuilder> tableToRoutingTableBuilderMap =
      getTableToRoutingTableBuilderMap(_pinotHelixProperties.subset(ROUTING_TABLE_BUILDER_KEY));

  // Remove all white-spaces from the list of zkServers (if any).
  String zkServers = zkServer.replaceAll("\\s+", "");

  _zkClient =
      new ZkClient(getZkAddressForBroker(zkServers, helixClusterName),
          ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
  _propertyStore = new ZkHelixPropertyStore<ZNRecord>(new ZkBaseDataAccessor<ZNRecord>(_zkClient), "/", null);
  _helixExternalViewBasedRouting =
      new HelixExternalViewBasedRouting(defaultOfflineRoutingTableBuilder, defaultRealtimeRoutingTableBuilder,
          tableToRoutingTableBuilderMap, _propertyStore);

  // _brokerServerBuilder = startBroker();
  _brokerServerBuilder = startBroker(_pinotHelixProperties);
  _helixManager =
      HelixManagerFactory.getZKHelixManager(helixClusterName, brokerId, InstanceType.PARTICIPANT, zkServers);
  final StateMachineEngine stateMachineEngine = _helixManager.getStateMachineEngine();
  final StateModelFactory<?> stateModelFactory =
      new BrokerResourceOnlineOfflineStateModelFactory(_helixManager, _helixExternalViewBasedRouting);
  stateMachineEngine.registerStateModelFactory(BrokerResourceOnlineOfflineStateModelFactory.getStateModelDef(),
      stateModelFactory);
  _helixManager.connect();
  _helixAdmin = _helixManager.getClusterManagmentTool();
  _helixBrokerRoutingTable = new HelixBrokerRoutingTable(_helixExternalViewBasedRouting, brokerId, _helixManager);
  addInstanceTagIfNeeded(helixClusterName, brokerId);
  _helixManager.addExternalViewChangeListener(_helixBrokerRoutingTable);
  _helixManager.addInstanceConfigChangeListener(_helixBrokerRoutingTable);
  _helixManager.addLiveInstanceChangeListener(_liveInstancesListener);

  _brokerServerBuilder.getBrokerMetrics().addCallbackGauge(
      "helix.connected", () -> _helixManager.isConnected() ? 1L : 0L);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:53,代码来源:HelixBrokerStarter.java

示例9: testWatchRemove

/**
 * after calling zkclient#unsubscribeXXXListener()
 * an already registered watch will not be removed from ZooKeeper#watchManager#XXXWatches
 * immediately.
 * the watch will get removed on the following conditions:
 * 1) there is a set/delete on the listening path via the zkclient
 * 2) session expiry on the zkclient (i.e. the watch will not be renewed after session expiry)
 * @throws Exception
 */
@Test
public void testWatchRemove() throws Exception {
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String testName = className + "_" + methodName;

  final ZkClient client =
      new ZkClient(ZK_ADDR, ZkClient.DEFAULT_SESSION_TIMEOUT,
          ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
  // make sure "/testName/test" doesn't exist
  final String path = "/" + testName + "/test";
  client.createPersistent(path, true);

  ZkListener listener = new ZkListener();
  client.subscribeDataChanges(path, listener);
  client.subscribeChildChanges(path, listener);

  // listener should be in both ZkClient#_dataListener and ZkClient#_childListener set
  Map<String, Set<IZkDataListener>> dataListenerMap = ZkTestHelper.getZkDataListener(client);
  Assert.assertEquals(dataListenerMap.size(), 1, "ZkClient#_dataListener should have 1 listener");
  Set<IZkDataListener> dataListenerSet = dataListenerMap.get(path);
  Assert.assertNotNull(dataListenerSet, "ZkClient#_dataListener should have 1 listener on path: "
      + path);
  Assert.assertEquals(dataListenerSet.size(), 1,
      "ZkClient#_dataListener should have 1 listener on path: " + path);

  Map<String, Set<IZkChildListener>> childListenerMap = ZkTestHelper.getZkChildListener(client);
  Assert.assertEquals(childListenerMap.size(), 1,
      "ZkClient#_childListener should have 1 listener");
  Set<IZkChildListener> childListenerSet = childListenerMap.get(path);
  Assert.assertNotNull(childListenerSet,
      "ZkClient#_childListener should have 1 listener on path: " + path);
  Assert.assertEquals(childListenerSet.size(), 1,
      "ZkClient#_childListener should have 1 listener on path: " + path);

  // watch should be in ZooKeeper#watchManager#XXXWatches
  Map<String, List<String>> watchMap = ZkTestHelper.getZkWatch(client);
  // System.out.println("watchMap1: " + watchMap);
  List<String> dataWatch = watchMap.get("dataWatches");
  Assert.assertNotNull(dataWatch,
      "ZooKeeper#watchManager#dataWatches should have 1 data watch on path: " + path);
  Assert.assertEquals(dataWatch.size(), 1,
      "ZooKeeper#watchManager#dataWatches should have 1 data watch on path: " + path);
  Assert.assertEquals(dataWatch.get(0), path,
      "ZooKeeper#watchManager#dataWatches should have 1 data watch on path: " + path);

  List<String> childWatch = watchMap.get("childWatches");
  Assert.assertNotNull(childWatch,
      "ZooKeeper#watchManager#childWatches should have 1 child watch on path: " + path);
  Assert.assertEquals(childWatch.size(), 1,
      "ZooKeeper#watchManager#childWatches should have 1 child watch on path: " + path);
  Assert.assertEquals(childWatch.get(0), path,
      "ZooKeeper#watchManager#childWatches should have 1 child watch on path: " + path);

  client.unsubscribeDataChanges(path, listener);
  client.unsubscribeChildChanges(path, listener);
  // System.out.println("watchMap2: " + watchMap);
  ZkTestHelper.expireSession(client);

  // after session expiry, those watches should be removed
  watchMap = ZkTestHelper.getZkWatch(client);
  // System.out.println("watchMap3: " + watchMap);
  dataWatch = watchMap.get("dataWatches");
  Assert.assertTrue(dataWatch.isEmpty(), "ZooKeeper#watchManager#dataWatches should be empty");
  childWatch = watchMap.get("childWatches");
  Assert.assertTrue(childWatch.isEmpty(), "ZooKeeper#watchManager#childWatches should be empty");

  client.close();
}
 
开发者ID:apache,项目名称:helix,代码行数:78,代码来源:TestZkBasis.java


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