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


Java MiniZooKeeperCluster.setDefaultClientPort方法代码示例

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


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

示例1: setUpBeforeClass

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {

    ZK_DIR = new File(System.getProperty("java.io.tmpdir") + File.separator + "resulttosolrmapperfactory.zktest");
    ZK_CLIENT_PORT = getFreePort();

    ZK_CLUSTER = new MiniZooKeeperCluster();
    ZK_CLUSTER.setDefaultClientPort(ZK_CLIENT_PORT);
    ZK_CLUSTER.startup(ZK_DIR);

    SOLR_TEST_UTILITY = new SolrTestingUtility(ZK_CLIENT_PORT, NetUtils.getFreePort());
    SOLR_TEST_UTILITY.start();
    SOLR_TEST_UTILITY.uploadConfig("config1",
            Resources.toByteArray(Resources.getResource(ResultToSolrMapperFactoryTest.class, "schema.xml")),
            Resources.toByteArray(Resources.getResource(ResultToSolrMapperFactoryTest.class, "solrconfig.xml")));
    SOLR_TEST_UTILITY.createCore("collection1_core1", "collection1", "config1", 1);

    COLLECTION1 = new CloudSolrClient.Builder().withZkHost(SOLR_TEST_UTILITY.getZkConnectString()).build();
    COLLECTION1.setDefaultCollection("collection1");
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:21,代码来源:ResultToSolrMapperFactoryTest.java

示例2: testMiniZooKeeper

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@Test public void testMiniZooKeeper() throws Exception {
  HBaseTestingUtility hbt = new HBaseTestingUtility();
  MiniZooKeeperCluster cluster1 = hbt.startMiniZKCluster();
  try {
    assertEquals(0, cluster1.getBackupZooKeeperServerNum());
    assertTrue((cluster1.killCurrentActiveZooKeeperServer() == -1));
  } finally {
    hbt.shutdownMiniZKCluster();
  }

  // set up zookeeper cluster with 5 zk servers
  MiniZooKeeperCluster cluster2 = hbt.startMiniZKCluster(5);
  int defaultClientPort = 21818;
  cluster2.setDefaultClientPort(defaultClientPort);
  try {
    assertEquals(4, cluster2.getBackupZooKeeperServerNum());

    // killing the current active zk server
    assertTrue((cluster2.killCurrentActiveZooKeeperServer() >= defaultClientPort));
    assertTrue((cluster2.killCurrentActiveZooKeeperServer() >= defaultClientPort));
    assertEquals(2, cluster2.getBackupZooKeeperServerNum());
    assertEquals(3, cluster2.getZooKeeperServerNum());

    // killing the backup zk servers
    cluster2.killOneBackupZooKeeperServer();
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(0, cluster2.getBackupZooKeeperServerNum());
    assertEquals(1, cluster2.getZooKeeperServerNum());

    // killing the last zk server
    assertTrue((cluster2.killCurrentActiveZooKeeperServer() == -1));
    // this should do nothing.
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(-1, cluster2.getBackupZooKeeperServerNum());
    assertEquals(0, cluster2.getZooKeeperServerNum());
  } finally {
    hbt.shutdownMiniZKCluster();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:40,代码来源:TestHBaseTestingUtility.java

示例3: setUpBeforeClass

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ZK_DIR = new File(System.getProperty("java.io.tmpdir") + File.separator + "hbaseindexer.zktest");
    ZK_CLIENT_PORT = getFreePort();

    ZK_CLUSTER = new MiniZooKeeperCluster();
    ZK_CLUSTER.setDefaultClientPort(ZK_CLIENT_PORT);
    ZK_CLUSTER.startup(ZK_DIR);
    
    ZK = ZkUtil.connect("localhost:" + ZK_CLIENT_PORT, 15000);
    INDEXER_MODEL = new IndexerModelImpl(ZK, "/ngdata/hbaseindexer");
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:13,代码来源:HBaseIndexingOptionsTest.java

示例4: setUpBeforeClass

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ZK_DIR = new File(System.getProperty("java.io.tmpdir") + File.separator + "hbaseindexer.zklocktest");
    FileUtils.deleteDirectory(ZK_DIR);
    ZK_CLIENT_PORT = getFreePort();

    ZK_CLUSTER = new MiniZooKeeperCluster();
    ZK_CLUSTER.setDefaultClientPort(ZK_CLIENT_PORT);
    ZK_CLUSTER.startup(ZK_DIR);
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:11,代码来源:IndexerModelImplTest.java

示例5: testMiniZooKeeperWithMultipleServers

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@Test
public void testMiniZooKeeperWithMultipleServers() throws Exception {
  HBaseTestingUtility hbt = new HBaseTestingUtility();
  // set up zookeeper cluster with 5 zk servers
  MiniZooKeeperCluster cluster2 = hbt.startMiniZKCluster(5);
  int defaultClientPort = 21818;
  cluster2.setDefaultClientPort(defaultClientPort);
  try {
    assertEquals(4, cluster2.getBackupZooKeeperServerNum());

    // killing the current active zk server
    int currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    // Check if the client port is returning a proper value
    assertTrue(cluster2.getClientPort() == currentActivePort);

    // kill another active zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    assertTrue(cluster2.getClientPort() == currentActivePort);      
    assertEquals(2, cluster2.getBackupZooKeeperServerNum());
    assertEquals(3, cluster2.getZooKeeperServerNum());

    // killing the backup zk servers
    cluster2.killOneBackupZooKeeperServer();
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(0, cluster2.getBackupZooKeeperServerNum());
    assertEquals(1, cluster2.getZooKeeperServerNum());

    // killing the last zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort == -1);
    assertTrue(cluster2.getClientPort() == currentActivePort);
    // this should do nothing.
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(-1, cluster2.getBackupZooKeeperServerNum());
    assertEquals(0, cluster2.getZooKeeperServerNum());
  } finally {
    hbt.shutdownMiniZKCluster();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:42,代码来源:TestHBaseTestingUtility.java

示例6: startMaster

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
private int startMaster() {
  Configuration conf = getConf();
  try {
    // If 'local', defer to LocalHBaseCluster instance.  Starts master
    // and regionserver both in the one JVM.
    if (LocalHBaseCluster.isLocal(conf)) {
      final MiniZooKeeperCluster zooKeeperCluster =
        new MiniZooKeeperCluster();
      File zkDataPath = new File(conf.get(HConstants.ZOOKEEPER_DATA_DIR));
      int zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
      if (zkClientPort == 0) {
        throw new IOException("No config value for "
            + HConstants.ZOOKEEPER_CLIENT_PORT);
      }
      zooKeeperCluster.setDefaultClientPort(zkClientPort);

      // login the zookeeper server principal (if using security)
      ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file",
        "hbase.zookeeper.server.kerberos.principal", null);

      int clientPort = zooKeeperCluster.startup(zkDataPath);
      if (clientPort != zkClientPort) {
        String errorMsg = "Could not start ZK at requested port of " +
          zkClientPort + ".  ZK was started at port: " + clientPort +
          ".  Aborting as clients (e.g. shell) will not be able to find " +
          "this ZK quorum.";
        System.err.println(errorMsg);
        throw new IOException(errorMsg);
      }
      conf.set(HConstants.ZOOKEEPER_CLIENT_PORT,
               Integer.toString(clientPort));
      // Need to have the zk cluster shutdown when master is shutdown.
      // Run a subclass that does the zk cluster shutdown on its way out.
      LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1, 1,
                                                        LocalHMaster.class, HRegionServer.class);
      ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
      cluster.startup();
      waitOnMasterThreads(cluster);
    } else {
      HMaster master = HMaster.constructMaster(masterClass, conf);
      if (master.isStopped()) {
        LOG.info("Won't bring the Master up as a shutdown is requested");
        return -1;
      }
      master.start();
      master.join();
      if(master.isAborted())
        throw new RuntimeException("HMaster Aborted");
    }
  } catch (Throwable t) {
    LOG.error("Failed to start master", t);
    return -1;
  }
  return 0;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:56,代码来源:HMasterCommandLine.java

示例7: startMaster

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
private int startMaster() {
    Configuration conf = getConf();
    try {
        // If 'local', defer to LocalHBaseCluster instance.  Starts master
        // and regionserver both in the one JVM.
        if (LocalHBaseCluster.isLocal(conf)) {
            DefaultMetricsSystem.setMiniClusterMode(true);
            final MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster(conf);
            File zkDataPath = new File(conf.get(HConstants.ZOOKEEPER_DATA_DIR));
            int zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
            if (zkClientPort == 0) {
                throw new IOException("No config value for "
                        + HConstants.ZOOKEEPER_CLIENT_PORT);
            }
            zooKeeperCluster.setDefaultClientPort(zkClientPort);

            // login the zookeeper server principal (if using security)
            ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file",
                    "hbase.zookeeper.server.kerberos.principal", null);
            int localZKClusterSessionTimeout =
                    conf.getInt(HConstants.ZK_SESSION_TIMEOUT + ".localHBaseCluster", 10 * 1000);
            conf.setInt(HConstants.ZK_SESSION_TIMEOUT, localZKClusterSessionTimeout);
            LOG.info("Starting a zookeeper cluster");
            int clientPort = zooKeeperCluster.startup(zkDataPath);
            if (clientPort != zkClientPort) {
                String errorMsg = "Could not start ZK at requested port of " +
                        zkClientPort + ".  ZK was started at port: " + clientPort +
                        ".  Aborting as clients (e.g. shell) will not be able to find " +
                        "this ZK quorum.";
                System.err.println(errorMsg);
                throw new IOException(errorMsg);
            }
            conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(clientPort));
            // Need to have the zk cluster shutdown when master is shutdown.
            // Run a subclass that does the zk cluster shutdown on its way out.
            int mastersCount = conf.getInt("hbase.masters", 1);
            int regionServersCount = conf.getInt("hbase.regionservers", 1);
            LOG.info("Starting up instance of localHBaseCluster; master=" + mastersCount +
                    ", regionserversCount=" + regionServersCount);
            LocalHBaseCluster cluster = new LocalHBaseCluster(conf, mastersCount, regionServersCount,
                    LocalHMaster.class, HRegionServer.class);
            ((LocalHMaster) cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
            cluster.startup();
            waitOnMasterThreads(cluster);
        } else {
            logProcessInfo(getConf());//将系统的运行配置参数以及JVM的状态存到日志中
            CoordinatedStateManager csm =
                    CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
            HMaster master = HMaster.constructMaster(masterClass, conf, csm);
            if (master.isStopped()) {
                LOG.info("Won't bring the Master up as a shutdown is requested");
                return 1;
            }
            master.start();
            master.join();
            if (master.isAborted())
                throw new RuntimeException("HMaster Aborted");
        }
    } catch (Throwable t) {
        LOG.error("Master exiting", t);
        return 1;
    }
    return 0;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:65,代码来源:HMasterCommandLine.java

示例8: testMiniZooKeeper

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@Test public void testMiniZooKeeper() throws Exception {
  HBaseTestingUtility hbt = new HBaseTestingUtility();
  MiniZooKeeperCluster cluster1 = hbt.startMiniZKCluster();
  try {
    assertEquals(0, cluster1.getBackupZooKeeperServerNum());
    assertTrue((cluster1.killCurrentActiveZooKeeperServer() == -1));
  } finally {
    hbt.shutdownMiniZKCluster();
  }

  // set up zookeeper cluster with 5 zk servers
  MiniZooKeeperCluster cluster2 = hbt.startMiniZKCluster(5);
  int defaultClientPort = 21818;
  cluster2.setDefaultClientPort(defaultClientPort);
  try {
    assertEquals(4, cluster2.getBackupZooKeeperServerNum());

    // killing the current active zk server
    int currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    // Check if the client port is returning a proper value
    assertTrue(cluster2.getClientPort() == currentActivePort);

    // kill another active zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    assertTrue(cluster2.getClientPort() == currentActivePort);      
    assertEquals(2, cluster2.getBackupZooKeeperServerNum());
    assertEquals(3, cluster2.getZooKeeperServerNum());

    // killing the backup zk servers
    cluster2.killOneBackupZooKeeperServer();
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(0, cluster2.getBackupZooKeeperServerNum());
    assertEquals(1, cluster2.getZooKeeperServerNum());

    // killing the last zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort == -1);
    assertTrue(cluster2.getClientPort() == currentActivePort);
    // this should do nothing.
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(-1, cluster2.getBackupZooKeeperServerNum());
    assertEquals(0, cluster2.getZooKeeperServerNum());
  } finally {
    hbt.shutdownMiniZKCluster();
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:49,代码来源:TestHBaseTestingUtility.java

示例9: startMaster

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
private int startMaster() {
  Configuration conf = getConf();
  try {
    // If 'local', defer to LocalHBaseCluster instance.  Starts master
    // and regionserver both in the one JVM.
    if (LocalHBaseCluster.isLocal(conf)) {
      final MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster(conf);
      File zkDataPath = new File(conf.get(HConstants.ZOOKEEPER_DATA_DIR));
      int zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
      if (zkClientPort == 0) {
        throw new IOException("No config value for "
            + HConstants.ZOOKEEPER_CLIENT_PORT);
      }
      zooKeeperCluster.setDefaultClientPort(zkClientPort);

      // login the zookeeper server principal (if using security)
      ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file",
        "hbase.zookeeper.server.kerberos.principal", null);

      int clientPort = zooKeeperCluster.startup(zkDataPath);
      if (clientPort != zkClientPort) {
        String errorMsg = "Could not start ZK at requested port of " +
          zkClientPort + ".  ZK was started at port: " + clientPort +
          ".  Aborting as clients (e.g. shell) will not be able to find " +
          "this ZK quorum.";
        System.err.println(errorMsg);
        throw new IOException(errorMsg);
      }
      conf.set(HConstants.ZOOKEEPER_CLIENT_PORT,
               Integer.toString(clientPort));
      conf.setInt(HConstants.ZK_SESSION_TIMEOUT, 10 *1000);
      // Need to have the zk cluster shutdown when master is shutdown.
      // Run a subclass that does the zk cluster shutdown on its way out.
      LocalHBaseCluster cluster = new LocalHBaseCluster(conf, conf.getInt("hbase.masters", 1),
        conf.getInt("hbase.regionservers", 1), LocalHMaster.class, HRegionServer.class);
      ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
      cluster.startup();
      waitOnMasterThreads(cluster);
    } else {
      logProcessInfo(getConf());
      HMaster master = HMaster.constructMaster(masterClass, conf);
      if (master.isStopped()) {
        LOG.info("Won't bring the Master up as a shutdown is requested");
        return 1;
      }
      master.start();
      master.join();
      if(master.isAborted())
        throw new RuntimeException("HMaster Aborted");
    }
  } catch (Throwable t) {
    LOG.error("Master exiting", t);
    return 1;
  }
  return 0;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:57,代码来源:HMasterCommandLine.java

示例10: testMiniZooKeeperWithMultipleServers

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@Test
public void testMiniZooKeeperWithMultipleServers() throws Exception {
  HBaseTestingUtility hbt = new HBaseTestingUtility();
  // set up zookeeper cluster with 5 zk servers
  MiniZooKeeperCluster cluster2 = hbt.startMiniZKCluster(5);
  int defaultClientPort = 21818;
  cluster2.setDefaultClientPort(defaultClientPort);
  try {
    assertEquals(4, cluster2.getBackupZooKeeperServerNum());

    // killing the current active zk server
    int currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    // Check if the client port is returning a proper value
    assertTrue(cluster2.getClientPort() == currentActivePort);

    // kill another active zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort >= defaultClientPort);
    assertTrue(cluster2.getClientPort() == currentActivePort);
    assertEquals(2, cluster2.getBackupZooKeeperServerNum());
    assertEquals(3, cluster2.getZooKeeperServerNum());

    // killing the backup zk servers
    cluster2.killOneBackupZooKeeperServer();
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(0, cluster2.getBackupZooKeeperServerNum());
    assertEquals(1, cluster2.getZooKeeperServerNum());

    // killing the last zk server
    currentActivePort = cluster2.killCurrentActiveZooKeeperServer();
    assertTrue(currentActivePort == -1);
    assertTrue(cluster2.getClientPort() == currentActivePort);
    // this should do nothing.
    cluster2.killOneBackupZooKeeperServer();
    assertEquals(-1, cluster2.getBackupZooKeeperServerNum());
    assertEquals(0, cluster2.getZooKeeperServerNum());
  } finally {
    hbt.shutdownMiniZKCluster();
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:42,代码来源:TestHBaseTestingUtility.java

示例11: startMaster

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
private int startMaster() {
  Configuration conf = getConf();
  try {
    // If 'local', defer to LocalHBaseCluster instance.  Starts master
    // and regionserver both in the one JVM.
    if (LocalHBaseCluster.isLocal(conf)) {
      final MiniZooKeeperCluster zooKeeperCluster =
        new MiniZooKeeperCluster();
      File zkDataPath = new File(conf.get("hbase.zookeeper.property.dataDir"));
      int zkClientPort = conf.getInt("hbase.zookeeper.property.clientPort", 0);
      if (zkClientPort == 0) {
        throw new IOException("No config value for hbase.zookeeper.property.clientPort");
      }
      zooKeeperCluster.setDefaultClientPort(zkClientPort);
      int clientPort = zooKeeperCluster.startup(zkDataPath);
      if (clientPort != zkClientPort) {
        String errorMsg = "Couldnt start ZK at requested address of " +
          zkClientPort + ", instead got: " + clientPort + ". Aborting. Why? " +
          "Because clients (eg shell) wont be able to find this ZK quorum";
        System.err.println(errorMsg);
        throw new IOException(errorMsg);
      }
      conf.set("hbase.zookeeper.property.clientPort",
               Integer.toString(clientPort));
      // Need to have the zk cluster shutdown when master is shutdown.
      // Run a subclass that does the zk cluster shutdown on its way out.
      LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1, 1,
                                                        LocalHMaster.class, HRegionServer.class);
      ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
      cluster.startup();
      waitOnMasterThreads(cluster);
    } else {
      HMaster master = HMaster.constructMaster(masterClass, conf);
      if (master.isStopped()) {
        LOG.info("Won't bring the Master up as a shutdown is requested");
        return -1;
      }
      master.start();
      master.join();
      if(master.isAborted())
        throw new RuntimeException("HMaster Aborted");
    }
  } catch (Throwable t) {
    LOG.error("Failed to start master", t);
    return -1;
  }
  return 0;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:49,代码来源:HMasterCommandLine.java

示例12: startMaster

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
private int startMaster() {
  Configuration conf = getConf();
  try {
    // If 'local', defer to LocalHBaseCluster instance.  Starts master
    // and regionserver both in the one JVM.
    if (LocalHBaseCluster.isLocal(conf)) {
      DefaultMetricsSystem.setMiniClusterMode(true);
      conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
      final MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster(conf);
      File zkDataPath = new File(conf.get(HConstants.ZOOKEEPER_DATA_DIR));
      int zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
      if (zkClientPort == 0) {
        throw new IOException("No config value for "
            + HConstants.ZOOKEEPER_CLIENT_PORT);
      }
      zooKeeperCluster.setDefaultClientPort(zkClientPort);

      // login the zookeeper server principal (if using security)
      ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file",
        "hbase.zookeeper.server.kerberos.principal", null);

      int clientPort = zooKeeperCluster.startup(zkDataPath);
      if (clientPort != zkClientPort) {
        String errorMsg = "Could not start ZK at requested port of " +
          zkClientPort + ".  ZK was started at port: " + clientPort +
          ".  Aborting as clients (e.g. shell) will not be able to find " +
          "this ZK quorum.";
        System.err.println(errorMsg);
        throw new IOException(errorMsg);
      }
      conf.set(HConstants.ZOOKEEPER_CLIENT_PORT,
               Integer.toString(clientPort));
      // Need to have the zk cluster shutdown when master is shutdown.
      // Run a subclass that does the zk cluster shutdown on its way out.
      LocalHBaseCluster cluster = new LocalHBaseCluster(conf, conf.getInt("hbase.masters", 1),
        conf.getInt("hbase.regionservers", 0), LocalHMaster.class, HRegionServer.class);
      ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
      cluster.startup();
      waitOnMasterThreads(cluster);
    } else {
      logProcessInfo(getConf());
      CoordinatedStateManager csm =
        CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
      HMaster master = HMaster.constructMaster(masterClass, conf, csm);
      if (master.isStopped()) {
        LOG.info("Won't bring the Master up as a shutdown is requested");
        return 1;
      }
      master.start();
      master.join();
      if(master.isAborted())
        throw new RuntimeException("HMaster Aborted");
    }
  } catch (Throwable t) {
    LOG.error("Master exiting", t);
    return 1;
  }
  return 0;
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:60,代码来源:HMasterCommandLine.java

示例13: startMaster

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
private int startMaster() {
  Configuration conf = getConf();
  try {
    // If 'local', defer to LocalHBaseCluster instance.  Starts master
    // and regionserver both in the one JVM.
    if (LocalHBaseCluster.isLocal(conf)) {
      final MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster(conf);
      File zkDataPath = new File(conf.get(HConstants.ZOOKEEPER_DATA_DIR));
      int zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
      if (zkClientPort == 0) {
        throw new IOException("No config value for "
            + HConstants.ZOOKEEPER_CLIENT_PORT);
      }
      zooKeeperCluster.setDefaultClientPort(zkClientPort);

      // login the zookeeper server principal (if using security)
      ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file",
        "hbase.zookeeper.server.kerberos.principal", null);

      int clientPort = zooKeeperCluster.startup(zkDataPath);
      if (clientPort != zkClientPort) {
        String errorMsg = "Could not start ZK at requested port of " +
          zkClientPort + ".  ZK was started at port: " + clientPort +
          ".  Aborting as clients (e.g. shell) will not be able to find " +
          "this ZK quorum.";
        System.err.println(errorMsg);
        throw new IOException(errorMsg);
      }
      conf.set(HConstants.ZOOKEEPER_CLIENT_PORT,
               Integer.toString(clientPort));
      // Need to have the zk cluster shutdown when master is shutdown.
      // Run a subclass that does the zk cluster shutdown on its way out.
      LocalHBaseCluster cluster = new LocalHBaseCluster(conf, conf.getInt("hbase.masters", 1),
        conf.getInt("hbase.regionservers", 1), LocalHMaster.class, HRegionServer.class);
      ((LocalHMaster)cluster.getMaster(0)).setZKCluster(zooKeeperCluster);
      cluster.startup();
      waitOnMasterThreads(cluster);
    } else {
      logProcessInfo(getConf());
      HMaster master = HMaster.constructMaster(masterClass, conf);
      if (master.isStopped()) {
        LOG.info("Won't bring the Master up as a shutdown is requested");
        return 1;
      }
      master.start();
      master.join();
      if(master.isAborted())
        throw new RuntimeException("HMaster Aborted");
    }
  } catch (Throwable t) {
    LOG.error("Master exiting", t);
    return 1;
  }
  return 0;
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:56,代码来源:HMasterCommandLine.java

示例14: setup

import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster; //导入方法依赖的package包/类
@Override
public void setup() {
	try {
		LOG.info("Setting up Hbase mini cluster!");
		File clusterTestDirRoot = new File("target/zookeeper");
		clusterTestDirRoot.delete();
		File clusterTestDir = new File(clusterTestDirRoot, "/dfscluster_"
				+ UUID.randomUUID().toString()).getAbsoluteFile();

		LOG.info("Setting up Hbase zookeeper mini cluster!");
		int clientPort = 10235;
		miniZooKeeperCluster = new MiniZooKeeperCluster();
		miniZooKeeperCluster.setDefaultClientPort(clientPort);
		miniZooKeeperCluster.startup(clusterTestDir);
		LOG.info("Setting up Hbase zookeeper mini cluster done!");

		LOG.info("Setting up Hbase mini cluster master!");
		Configuration config = HBaseConfiguration.create();
		config.set("hbase.tmp.dir",
				new File("target/hbasetom").getAbsolutePath());
		config.set("hbase.rootdir", hadoopClusterService.getHDFSUri()
				+ "/hbase");
		config.set("hbase.master.port", "44335");
		config.set("hbase.master.info.port", "44345");
		config.set("hbase.regionserver.port", "44435");
		config.set("hbase.regionserver.info.port", "44445");
		config.set("hbase.master.distributed.log.replay", "false");
		config.set("hbase.cluster.distributed", "false");
		config.set("hbase.master.distributed.log.splitting", "false");
		// hbase.zookeeper.peerport
		// hbase.zookeeper.leaderport
		config.set("hbase.zookeeper.property.clientPort",
				Integer.toString(clientPort));
		config.set("zookeeper.znode.parent", "/hbase");
		
		miniHBaseCluster = new MiniHBaseCluster(config, 1);
		miniHBaseCluster.startMaster();

		LOG.info("Setting up Hbase mini cluster done!");
	} catch (IOException | InterruptedException e) {
		String errMsg = "Error occured starting Mini Hbase cluster";
		LOG.error(errMsg);
		throw new RuntimeException(errMsg, e);
	}

	setupSearchEventsTable();
}
 
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:48,代码来源:HbaseServiceImpl.java


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