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


Java MasterAddressTracker.start方法代码示例

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


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

示例1: setupMasterTracker

import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入方法依赖的package包/类
/**
 * create an address tracker instance
 * @param sn if not-null set the active master
 * @param infoPort if there is an active master, set its info port.
 */
private MasterAddressTracker setupMasterTracker(final ServerName sn, final int infoPort)
    throws Exception {
  ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
      name.getMethodName(), null);
  ZKUtil.createAndFailSilent(zk, zk.baseZNode);

  // Should not have a master yet
  MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
  addressTracker.start();
  assertFalse(addressTracker.hasMaster());
  zk.registerListener(addressTracker);

  // Use a listener to capture when the node is actually created
  NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
  zk.registerListener(listener);

  if (sn != null) {
    LOG.info("Creating master node");
    MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn, infoPort);

    // Wait for the node to be created
    LOG.info("Waiting for master address manager to be notified");
    listener.waitForCreation();
    LOG.info("Master node created");
  }
  return addressTracker;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:TestMasterAddressTracker.java

示例2: testMasterAddressTrackerFromZK

import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入方法依赖的package包/类
/**
 * Unit tests that uses ZooKeeper but does not use the master-side methods
 * but rather acts directly on ZK.
 * @throws Exception
 */
@Test
public void testMasterAddressTrackerFromZK() throws Exception {

  ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
      "testMasterAddressTrackerFromZK", null);
  ZKUtil.createAndFailSilent(zk, zk.baseZNode);

  // Should not have a master yet
  MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
  addressTracker.start();
  assertFalse(addressTracker.hasMaster());
  zk.registerListener(addressTracker);

  // Use a listener to capture when the node is actually created
  NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
  zk.registerListener(listener);

  // Create the master node with a dummy address
  String host = "localhost";
  int port = 1234;
  int infoPort = 1235;
  ServerName sn = ServerName.valueOf(host, port, System.currentTimeMillis());
  LOG.info("Creating master node");
  MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn, infoPort);

  // Wait for the node to be created
  LOG.info("Waiting for master address manager to be notified");
  listener.waitForCreation();
  LOG.info("Master node created");
  assertTrue(addressTracker.hasMaster());
  ServerName pulledAddress = addressTracker.getMasterAddress();
  assertTrue(pulledAddress.equals(sn));
  assertEquals(infoPort, addressTracker.getMasterInfoPort());
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:40,代码来源:TestMasterAddressTracker.java

示例3: testMasterAddressTrackerFromZK

import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入方法依赖的package包/类
/**
 * Unit tests that uses ZooKeeper but does not use the master-side methods
 * but rather acts directly on ZK.
 * @throws Exception
 */
@Test
public void testMasterAddressTrackerFromZK() throws Exception {

  ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
      "testMasterAddressTrackerFromZK", null);
  ZKUtil.createAndFailSilent(zk, zk.baseZNode);

  // Should not have a master yet
  MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
  addressTracker.start();
  assertFalse(addressTracker.hasMaster());
  zk.registerListener(addressTracker);

  // Use a listener to capture when the node is actually created
  NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
  zk.registerListener(listener);

  // Create the master node with a dummy address
  String host = "localhost";
  int port = 1234;
  ServerName sn = ServerName.valueOf(host, port, System.currentTimeMillis());
  LOG.info("Creating master node");
  MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn);

  // Wait for the node to be created
  LOG.info("Waiting for master address manager to be notified");
  listener.waitForCreation();
  LOG.info("Master node created");
  assertTrue(addressTracker.hasMaster());
  ServerName pulledAddress = addressTracker.getMasterAddress();
  assertTrue(pulledAddress.equals(sn));

}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:39,代码来源:TestMasterAddressTracker.java

示例4: setupMasterTracker

import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入方法依赖的package包/类
/**
 * create an address tracker instance
 * @param sn if not-null set the active master
 * @param infoPort if there is an active master, set its info port.
 */
private MasterAddressTracker setupMasterTracker(final ServerName sn, final int infoPort)
    throws Exception {
  ZKWatcher zk = new ZKWatcher(TEST_UTIL.getConfiguration(),
      name.getMethodName(), null);
  ZKUtil.createAndFailSilent(zk, zk.znodePaths.baseZNode);

  // Should not have a master yet
  MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
  addressTracker.start();
  assertFalse(addressTracker.hasMaster());
  zk.registerListener(addressTracker);

  // Use a listener to capture when the node is actually created
  NodeCreationListener listener = new NodeCreationListener(zk, zk.znodePaths.masterAddressZNode);
  zk.registerListener(listener);

  if (sn != null) {
    LOG.info("Creating master node");
    MasterAddressTracker.setMasterAddress(zk, zk.znodePaths.masterAddressZNode, sn, infoPort);

    // Wait for the node to be created
    LOG.info("Waiting for master address manager to be notified");
    listener.waitForCreation();
    LOG.info("Master node created");
  }
  return addressTracker;
}
 
开发者ID:apache,项目名称:hbase,代码行数:33,代码来源:TestMasterAddressTracker.java

示例5: testMasterAddressManagerFromZK

import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入方法依赖的package包/类
/**
 * Unit tests that uses ZooKeeper but does not use the master-side methods
 * but rather acts directly on ZK.
 * @throws Exception
 */
@Test
public void testMasterAddressManagerFromZK() throws Exception {

  ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
      "testMasterAddressManagerFromZK", null);
  ZKUtil.createAndFailSilent(zk, zk.baseZNode);

  // Should not have a master yet
  MasterAddressTracker addressManager = new MasterAddressTracker(zk, null);
  addressManager.start();
  assertFalse(addressManager.hasMaster());
  zk.registerListener(addressManager);

  // Use a listener to capture when the node is actually created
  NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
  zk.registerListener(listener);

  // Create the master node with a dummy address
  String host = "localhost";
  int port = 1234;
  ServerName sn = ServerName.valueOf(host, port, System.currentTimeMillis());
  LOG.info("Creating master node");
  MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn);

  // Wait for the node to be created
  LOG.info("Waiting for master address manager to be notified");
  listener.waitForCreation();
  LOG.info("Master node created");
  assertTrue(addressManager.hasMaster());
  ServerName pulledAddress = addressManager.getMasterAddress();
  assertTrue(pulledAddress.equals(sn));

}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:39,代码来源:TestMasterAddressManager.java

示例6: testMasterAddressManagerFromZK

import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; //导入方法依赖的package包/类
/**
 * Unit tests that uses ZooKeeper but does not use the master-side methods
 * but rather acts directly on ZK.
 * @throws Exception
 */
@Test
public void testMasterAddressManagerFromZK() throws Exception {

  ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
      "testMasterAddressManagerFromZK", null);
  ZKUtil.createAndFailSilent(zk, zk.baseZNode);

  // Should not have a master yet
  MasterAddressTracker addressManager = new MasterAddressTracker(zk, null);
  addressManager.start();
  assertFalse(addressManager.hasMaster());
  zk.registerListener(addressManager);

  // Use a listener to capture when the node is actually created
  NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
  zk.registerListener(listener);

  // Create the master node with a dummy address
  String host = "localhost";
  int port = 1234;
  ServerName sn = new ServerName(host, port, System.currentTimeMillis());
  LOG.info("Creating master node");
  MasterAddressTracker.setMasterAddress(zk, zk.getMasterAddressZNode(), sn);

  // Wait for the node to be created
  LOG.info("Waiting for master address manager to be notified");
  listener.waitForCreation();
  LOG.info("Master node created");
  assertTrue(addressManager.hasMaster());
  ServerName pulledAddress = addressManager.getMasterAddress();
  assertTrue(pulledAddress.equals(sn));

}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:39,代码来源:TestMasterAddressManager.java


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