Java Code Examples for org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster#setDefaultClientPort()
The following examples show how to use
org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster#setDefaultClientPort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSeparateClientZKCluster.java From hbase with Apache License 2.0 | 6 votes |
@BeforeClass public static void beforeAllTests() throws Exception { int clientZkPort = 21828; clientZkCluster = new MiniZooKeeperCluster(TEST_UTIL.getConfiguration()); clientZkCluster.setDefaultClientPort(clientZkPort); clientZkCluster.startup(clientZkDir); // reduce the retry number and start log counter TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2); TEST_UTIL.getConfiguration().setInt("hbase.client.start.log.errors.counter", -1); TEST_UTIL.getConfiguration().setInt("zookeeper.recovery.retry", 1); // core settings for testing client ZK cluster TEST_UTIL.getConfiguration().set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST); TEST_UTIL.getConfiguration().setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT, clientZkPort); // reduce zk session timeout to easier trigger session expiration TEST_UTIL.getConfiguration().setInt(HConstants.ZK_SESSION_TIMEOUT, ZK_SESSION_TIMEOUT); // Start a cluster with 2 masters and 3 regionservers. StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(2).numRegionServers(3).numDataNodes(3).build(); TEST_UTIL.startMiniCluster(option); }
Example 2
Source File: ResultToSolrMapperFactoryTest.java From hbase-indexer with Apache License 2.0 | 6 votes |
@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"); }
Example 3
Source File: HBaseIndexingOptionsTest.java From hbase-indexer with Apache License 2.0 | 5 votes |
@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"); }
Example 4
Source File: IndexerModelImplTest.java From hbase-indexer with Apache License 2.0 | 5 votes |
@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); }
Example 5
Source File: TestHBaseTestingUtility.java From hbase with Apache License 2.0 | 4 votes |
@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(); } }
Example 6
Source File: HbaseServiceImpl.java From searchanalytics-bigdata with MIT License | 4 votes |
@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(); }