org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster.getClientPort()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster.getClientPort()方法的一些代码示例,展示了MiniZooKeeperCluster.getClientPort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MiniZooKeeperCluster.getClientPort()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster
类名称:MiniZooKeeperCluster
方法名:getClientPort

MiniZooKeeperCluster.getClientPort介绍

[英]Get the list of client ports.
[中]获取客户端端口列表。

代码示例

代码示例来源:origin: apache/hbase

public void setZkCluster(MiniZooKeeperCluster zkCluster) {
 this.passedZkCluster = true;
 this.zkCluster = zkCluster;
 conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkCluster.getClientPort());
}

代码示例来源:origin: apache/hbase

MiniZooKeeperCluster cluster5 =
   hbt.startMiniZKCluster(clientPortList5.length, clientPortList5);
 assertTrue(cluster5.getClientPort() == -1); // expected failure
} catch (Exception e) {

代码示例来源:origin: apache/hbase

private String getZKClusterKey() {
 return String.format("127.0.0.1:%d:%s", UTIL.getZkCluster().getClientPort(),
  CONF.get(HConstants.ZOOKEEPER_ZNODE_PARENT));
}

代码示例来源:origin: apache/hbase

@Test(timeout = 60000)
public void testMasterInitWithSameClientServerZKQuorum() throws Exception {
 Configuration conf = new Configuration(TESTUTIL.getConfiguration());
 conf.set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
 conf.setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT, TESTUTIL.getZkCluster().getClientPort());
 HMaster master = new HMaster(conf);
 master.start();
 // the master will abort due to IllegalArgumentException so we should finish within 60 seconds
 master.join();
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUp() throws Exception {
 PORT = UTIL.startMiniZKCluster().getClientPort();
 ZooKeeper zk = ZooKeeperHelper.getConnectedZooKeeper("localhost:" + PORT, 10000);
 DATA = new byte[10];
 ThreadLocalRandom.current().nextBytes(DATA);
 zk.create(PATH, DATA, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 for (int i = 0; i < CHILDREN; i++) {
  zk.create(PATH + "/c" + i, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 }
 zk.close();
 Configuration conf = UTIL.getConfiguration();
 conf.set(HConstants.ZOOKEEPER_QUORUM, "localhost:" + PORT);
 conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY, 3);
 conf.setInt(ReadOnlyZKClient.RECOVERY_RETRY_INTERVAL_MILLIS, 100);
 conf.setInt(ReadOnlyZKClient.KEEPALIVE_MILLIS, 3000);
 RO_ZK = new ReadOnlyZKClient(conf);
 // only connect when necessary
 assertNull(RO_ZK.zookeeper);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUp() throws Exception {
 UTIL.startMiniZKCluster().getClientPort();
 ZKW = new ZKWatcher(new Configuration(UTIL.getConfiguration()), TestZKUtil.class.getName(),
   new WarnOnlyAbortable());
}

代码示例来源:origin: apache/hive

conf.setInt(ConfVars.HIVE_ZOOKEEPER_CLIENT_PORT.varname, miniZooKeeperCluster.getClientPort());
clusterSpecificConfiguration.setInt(ConfVars.HIVE_ZOOKEEPER_CLIENT_PORT.varname, miniZooKeeperCluster.getClientPort());

代码示例来源:origin: apache/hbase

@Test(timeout = 60000)
 public void testMasterInitWithObserverModeClientZKQuorum() throws Exception {
  Configuration conf = new Configuration(TESTUTIL.getConfiguration());
  Assert.assertFalse(Boolean.getBoolean(HConstants.CLIENT_ZOOKEEPER_OBSERVER_MODE));
  // set client ZK to some non-existing address and make sure server won't access client ZK
  // (server start should not be affected)
  conf.set(HConstants.CLIENT_ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
  conf.setInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT,
   TESTUTIL.getZkCluster().getClientPort() + 1);
  // settings to allow us not to start additional RS
  conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
  conf.setBoolean(LoadBalancer.TABLES_ON_MASTER, true);
  // main setting for this test case
  conf.setBoolean(HConstants.CLIENT_ZOOKEEPER_OBSERVER_MODE, true);
  HMaster master = new HMaster(conf);
  master.start();
  while (!master.isInitialized()) {
   Threads.sleep(200);
  }
  Assert.assertNull(master.metaLocationSyncer);
  Assert.assertNull(master.masterAddressSyncer);
  master.stopMaster();
  master.join();
 }
}

代码示例来源:origin: apache/hbase

addPeerAndWait(peerId2,
 ReplicationPeerConfig.newBuilder()
  .setClusterKey("localhost:" + utility.getZkCluster().getClientPort() + ":/hbase").build(),
 true);
try {

代码示例来源:origin: apache/hbase

/**
 * We need delete of a znode to work at least.
 */
@Test
public void testCommandLineWorks() throws Exception {
 System.setSecurityManager(new NoExitSecurityManager());
 HBaseZKTestingUtility htu = new HBaseZKTestingUtility();
 // Make it long so for sure succeeds.
 htu.getConfiguration().setInt(HConstants.ZK_SESSION_TIMEOUT, 30000);
 htu.startMiniZKCluster();
 try {
  ZKWatcher zkw = htu.getZooKeeperWatcher();
  String znode = "/testCommandLineWorks";
  ZKUtil.createWithParents(zkw, znode, HConstants.EMPTY_BYTE_ARRAY);
  ZKUtil.checkExists(zkw, znode);
  boolean exception = false;
  try {
   ZKMainServer.main(new String [] {"-server",
    "localhost:" + htu.getZkCluster().getClientPort(), "delete", znode});
  } catch (ExitException ee) {
   // ZKMS calls System.exit which should trigger this exception.
   exception = true;
  }
  assertTrue(exception);
  assertEquals(-1, ZKUtil.checkExists(zkw, znode));
 } finally {
  htu.shutdownMiniZKCluster();
  System.setSecurityManager(null); // or save and restore original
 }
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setUp() throws Exception {
 UTIL.startMiniCluster(3);
 UTIL.getAdmin()
   .createTable(TableDescriptorBuilder.newBuilder(NAME)
     .setCoprocessor(ZooKeeperScanPolicyObserver.class.getName())
     .setValue(ZooKeeperScanPolicyObserver.ZK_ENSEMBLE_KEY,
      "localhost:" + UTIL.getZkCluster().getClientPort())
     .setValue(ZooKeeperScanPolicyObserver.ZK_SESSION_TIMEOUT_KEY, "2000")
     .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).build()).build());
 TABLE = UTIL.getConnection().getTable(NAME);
}

代码示例来源:origin: apache/hbase

final String peerId = "FakePeer";
final ReplicationPeerConfig peerConfig = ReplicationPeerConfig.newBuilder()
 .setClusterKey("localhost:" + utility.getZkCluster().getClientPort() + ":/hbase").build();
try {
 DummyServer server = new DummyServer();

代码示例来源:origin: apache/hbase

assertTrue(currentActivePort >= defaultClientPort);
assertTrue(cluster2.getClientPort() == currentActivePort);
assertTrue(cluster2.getClientPort() == currentActivePort);
assertEquals(2, cluster2.getBackupZooKeeperServerNum());
assertEquals(3, cluster2.getZooKeeperServerNum());
assertTrue(cluster2.getClientPort() == currentActivePort);

代码示例来源:origin: apache/hbase

private void doTest() throws IOException {
 Admin admin = UTIL.getAdmin();
 String peerId = "1";
 ReplicationPeerConfig peerConfig = ReplicationPeerConfig.newBuilder()
   .setClusterKey("localhost:" + UTIL.getZkCluster().getClientPort() + ":/hbase2").build();
 admin.addReplicationPeer(peerId, peerConfig, true);
 assertEquals(peerConfig.getClusterKey(),
  admin.getReplicationPeerConfig(peerId).getClusterKey());
 ReplicationPeerConfig newPeerConfig =
   ReplicationPeerConfig.newBuilder(peerConfig).setBandwidth(123456).build();
 admin.updateReplicationPeerConfig(peerId, newPeerConfig);
 assertEquals(newPeerConfig.getBandwidth(),
  admin.getReplicationPeerConfig(peerId).getBandwidth());
 admin.disableReplicationPeer(peerId);
 assertFalse(admin.listReplicationPeers().get(0).isEnabled());
 admin.enableReplicationPeer(peerId);
 assertTrue(admin.listReplicationPeers().get(0).isEnabled());
 admin.removeReplicationPeer(peerId);
 assertTrue(admin.listReplicationPeers().isEmpty());
 // make sure that we have run into the mocked method
 MockHMaster master = (MockHMaster) UTIL.getHBaseCluster().getMaster();
 assertTrue(master.addPeerCalled);
 assertTrue(master.removePeerCalled);
 assertTrue(master.updatePeerConfigCalled);
 assertTrue(master.enablePeerCalled);
 assertTrue(master.disablePeerCalled);
}

代码示例来源:origin: apache/phoenix

/**
 * Get the connection string for the mini-cluster
 * @return Phoenix connection string
 */
private String getJdbcUrl() {
  return "jdbc:phoenix:localhost:" + testUtil.getZkCluster().getClientPort() + ":/hbase";
}

代码示例来源:origin: apache/hbase

final String peerId = "DummyPeer";
final ReplicationPeerConfig peerConfig = ReplicationPeerConfig.newBuilder()
 .setClusterKey("localhost:" + utility.getZkCluster().getClientPort() + ":/hbase").build();
try {
 MetricsReplicationSourceSource globalSource = getGlobalSource();

代码示例来源:origin: apache/phoenix

@BeforeClass
public static void setUp() throws Exception {
  Configuration conf = HBaseConfiguration.create();
  hbaseTestUtil = new HBaseTestingUtility(conf);
  setUpConfigForMiniCluster(conf);
  //Enforce the limit of the result, so scans will stop between cells.
  conf.setLong(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, 5);
  conf.setLong(HConstants.HBASE_SERVER_SCANNER_MAX_RESULT_SIZE_KEY, 5);
  hbaseTestUtil.startMiniCluster();
  zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort();
  url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
  DriverManager.registerDriver(PhoenixDriver.INSTANCE);
}

代码示例来源:origin: apache/phoenix

@BeforeClass
public static void setUp() throws Exception {
  Configuration conf = HBaseConfiguration.create();
  hbaseTestUtil = new HBaseTestingUtility(conf);
  setUpConfigForMiniCluster(conf);
  conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
  hbaseTestUtil.startMiniCluster();
  // establish url and quorum. Need to use PhoenixDriver and not PhoenixTestDriver
  zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort();
  url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum;
  DriverManager.registerDriver(PhoenixDriver.INSTANCE);
}

代码示例来源:origin: apache/phoenix

@BeforeClass
public static void doSetup() throws Exception {
  setUpTestDriver(ReadOnlyProps.EMPTY_PROPS);
  zkQuorum = TestUtil.LOCALHOST + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + getUtility().getZkCluster().getClientPort();
  conn = DriverManager.getConnection(getUrl());
}

代码示例来源:origin: apache/phoenix

@BeforeClass
public static void doSetup() throws Exception {
  setUpTestDriver(ReadOnlyProps.EMPTY_PROPS);
  zkQuorum = TestUtil.LOCALHOST + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + getUtility().getZkCluster().getClientPort();
  conn = DriverManager.getConnection(getUrl());
}

相关文章