gpt4 book ai didi

org.apache.hadoop.hbase.zookeeper.ZKConfig类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 22:50:40 27 4
gpt4 key购买 nike

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

ZKConfig介绍

[英]Utility methods for reading, and building the ZooKeeper configuration. The order and priority for reading the config are as follows: (1). zoo.cfg if ""hbase.config.read.zookeeper.config" is true (2). Property with "hbase.zookeeper.property." prefix from HBase XML (3). other zookeeper related properties in HBASE XML
[中]用于读取和构建ZooKeeper配置的实用方法。读取配置的顺序和优先级如下:(1)。动物园cfg if“”hbase。配置。阅读动物园管理员。config”为true(2)。属性为“hbase”。动物园管理员。所有物“来自HBase XML的前缀(3)。HBase XML中与zookeeper相关的其他属性

代码示例

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

@Test
 public void testGetZKQuorumServersString() {
  Configuration config = new Configuration(TEST_UTIL.getConfiguration());
  config.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, 8888);
  config.set(HConstants.ZOOKEEPER_QUORUM, "foo:1234,bar:5678,baz,qux:9012");

  String s = ZKConfig.getZKQuorumServersString(config);
  assertEquals("foo:1234,bar:5678,baz:8888,qux:9012", s);
 }
}

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

private static String initPeerClusterState(String baseZKNode)
  throws IOException, KeeperException {
 // Add a dummy region server and set up the cluster id
 Configuration testConf = new Configuration(conf);
 testConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, baseZKNode);
 ZKWatcher zkw1 = new ZKWatcher(testConf, "test1", null);
 String fakeRs = ZNodePaths.joinZNode(zkw1.getZNodePaths().rsZNode,
     "hostname1.example.org:1234");
 ZKUtil.createWithParents(zkw1, fakeRs);
 ZKClusterId.setClusterId(zkw1, new ClusterId());
 return ZKConfig.getZooKeeperClusterKey(testConf);
}

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

@Test public void testMakeZKProps() {
 Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
 conf.set(HConstants.ZOOKEEPER_DATA_DIR, this.dataDir.toString());
 Properties properties = ZKConfig.makeZKProps(conf);
 assertEquals(dataDir.toString(), (String)properties.get("dataDir"));
 assertEquals(Integer.valueOf(PORT_NO),
  Integer.valueOf(properties.getProperty("clientPort")));
 assertEquals("localhost:2888:3888", properties.get("server.0"));
 assertEquals(null, properties.get("server.1"));
 String oldValue = conf.get(HConstants.ZOOKEEPER_QUORUM);
 conf.set(HConstants.ZOOKEEPER_QUORUM, "a.foo.bar,b.foo.bar,c.foo.bar");
 properties = ZKConfig.makeZKProps(conf);
 assertEquals(dataDir.toString(), properties.get("dataDir"));
 assertEquals(Integer.valueOf(PORT_NO),
  Integer.valueOf(properties.getProperty("clientPort")));
 assertEquals("a.foo.bar:2888:3888", properties.get("server.0"));
 assertEquals("b.foo.bar:2888:3888", properties.get("server.1"));
 assertEquals("c.foo.bar:2888:3888", properties.get("server.2"));
 assertEquals(null, properties.get("server.3"));
 conf.set(HConstants.ZOOKEEPER_QUORUM, oldValue);
}

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

public ReadOnlyZKClient(Configuration conf) {
 // We might use a different ZK for client access
 String clientZkQuorumServers = ZKConfig.getClientZKQuorumServersString(conf);
 if (clientZkQuorumServers != null) {
  this.connectString = clientZkQuorumServers;
 } else {
  this.connectString = ZKConfig.getZKQuorumServersString(conf);
 }
 this.sessionTimeoutMs = conf.getInt(ZK_SESSION_TIMEOUT, DEFAULT_ZK_SESSION_TIMEOUT);
 this.maxRetries = conf.getInt(RECOVERY_RETRY, DEFAULT_RECOVERY_RETRY);
 this.retryIntervalMs =
   conf.getInt(RECOVERY_RETRY_INTERVAL_MILLIS, DEFAULT_RECOVERY_RETRY_INTERVAL_MILLIS);
 this.keepAliveTimeMs = conf.getInt(KEEPALIVE_MILLIS, DEFAULT_KEEPALIVE_MILLIS);
 LOG.debug(
  "Connect {} to {} with session timeout={}ms, retries {}, " +
   "retry interval {}ms, keepAlive={}ms",
  getId(), connectString, sessionTimeoutMs, maxRetries, retryIntervalMs, keepAliveTimeMs);
 Threads.setDaemonThreadRunning(new Thread(this::run),
  "ReadOnlyZKClient-" + connectString + "@" + getId());
}

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

this.conf = conf;
if (clientZK) {
 String clientZkQuorumServers = ZKConfig.getClientZKQuorumServersString(conf);
 String serverZkQuorumServers = ZKConfig.getZKQuorumServersString(conf);
 if (clientZkQuorumServers != null) {
  if (clientZkQuorumServers.equals(serverZkQuorumServers)) {
 this.quorum = ZKConfig.getZKQuorumServersString(conf);

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

private void testKey(String ensemble, int port, String znode, Boolean multiplePortSupport)
  throws IOException {
 Configuration conf = new Configuration();
 String key = ensemble+":"+port+":"+znode;
 String ensemble2 = null;
 ZKConfig.ZKClusterKey zkClusterKey = ZKConfig.transformClusterKey(key);
 if (multiplePortSupport) {
  ensemble2 = ZKConfig.standardizeZKQuorumServerString(ensemble,
    Integer.toString(port));
  assertEquals(ensemble2, zkClusterKey.getQuorumString());
 assertEquals(zkClusterKey.getQuorumString(), conf.get(HConstants.ZOOKEEPER_QUORUM));
 assertEquals(zkClusterKey.getClientPort(), conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, -1));
 assertEquals(zkClusterKey.getZnodeParent(), conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT));
 String reconstructedKey = ZKConfig.getZooKeeperClusterKey(conf);
 if (multiplePortSupport) {
  String key2 = ensemble2 + ":" + port + ":" + znode;

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

job.setOutputFormatClass(TableOutputFormat.class);
if (reducer != null) job.setReducerClass(reducer);
conf.set(TableOutputFormat.OUTPUT_TABLE, table);
conf.setStrings("io.serializations", conf.get("io.serializations"),
  MutationSerialization.class.getName(), ResultSerialization.class.getName());
 ZKConfig.validateClusterKey(quorumAddress);
 conf.set(TableOutputFormat.QUORUM_ADDRESS,quorumAddress);

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

/**
 * Apply the settings in the given key to the given configuration, this is
 * used to communicate with distant clusters
 * @param conf configuration object to configure
 * @param key string that contains the 3 required configuratins
 * @throws IOException
 */
private static void applyClusterKeyToConf(Configuration conf, String key)
  throws IOException{
 ZKConfig.ZKClusterKey zkClusterKey = ZKConfig.transformClusterKey(key);
 conf.set(HConstants.ZOOKEEPER_QUORUM, zkClusterKey.getQuorumString());
 conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkClusterKey.getClientPort());
 conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zkClusterKey.getZnodeParent());
}

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

String parentZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
  HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
ZooKeeper zk = new ZooKeeper(ZKConfig.getZKQuorumServersString(conf),
  conf.getInt(HConstants.ZK_SESSION_TIMEOUT,
  HConstants.DEFAULT_ZK_SESSION_TIMEOUT), EmptyWatcher.instance);

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

/**
  * Get the client ZK Quorum servers string
  * @param conf the configuration to read
  * @return Client quorum servers, or null if not specified
  */
 public static String getClientZKQuorumServersString(Configuration conf) {
  String clientQuromServers = conf.get(HConstants.CLIENT_ZOOKEEPER_QUORUM);
  if (clientQuromServers == null) {
   return null;
  }
  int defaultClientPort =
    conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, HConstants.DEFAULT_ZOOKEEPER_CLIENT_PORT);
  String clientZkClientPort =
    Integer.toString(conf.getInt(HConstants.CLIENT_ZOOKEEPER_CLIENT_PORT, defaultClientPort));
  // Build the ZK quorum server string with "server:clientport" list, separated by ','
  final String[] serverHosts = StringUtils.getStrings(clientQuromServers);
  return buildZKQuorumServerString(serverHosts, clientZkClientPort);
 }
}

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

@Test
public void testGetZooKeeperClusterKey() {
 Configuration conf = HBaseConfiguration.create();
 conf.set(HConstants.ZOOKEEPER_QUORUM, "\tlocalhost\n");
 conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, "3333");
 conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "hbase");
 String clusterKey = ZKConfig.getZooKeeperClusterKey(conf, "test");
 assertTrue(!clusterKey.contains("\t") && !clusterKey.contains("\n"));
 assertEquals("localhost:3333:hbase,test", clusterKey);
}

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

Configuration c = new Configuration(this.conf);
String quorumServers = ZKConfig.getZKQuorumServersString(c);
ZooKeeper zk = nodeZK.getRecoverableZooKeeper().getZooKeeper();
byte[] password = zk.getSessionPasswd();

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

/**
 * Return the ZK Quorum servers string given the specified configuration
 *
 * @param conf
 * @return Quorum servers String
 */
private static String getZKQuorumServersStringFromHbaseConfig(Configuration conf) {
 String defaultClientPort = Integer.toString(
   conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, HConstants.DEFAULT_ZOOKEEPER_CLIENT_PORT));
 // Build the ZK quorum server string with "server:clientport" list, separated by ','
 final String[] serverHosts =
   conf.getStrings(HConstants.ZOOKEEPER_QUORUM, HConstants.LOCALHOST);
 return buildZKQuorumServerString(serverHosts, defaultClientPort);
}

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

conf = HBaseConfiguration.create();
zkQuorum = ZKConfig.getZKQuorumServersString(conf);
zkBaseDir = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
  HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);

代码示例来源:origin: harbby/presto-connectors

public ReplicationStateZKBase(ZooKeeperWatcher zookeeper, Configuration conf,
  Abortable abortable) {
 this.zookeeper = zookeeper;
 this.conf = conf;
 this.abortable = abortable;
 String replicationZNodeName = conf.get("zookeeper.znode.replication", "replication");
 String peersZNodeName = conf.get("zookeeper.znode.replication.peers", "peers");
 String queuesZNodeName = conf.get("zookeeper.znode.replication.rs", "rs");
 this.peerStateNodeName = conf.get("zookeeper.znode.replication.peers.state", "peer-state");
 this.ourClusterKey = ZKConfig.getZooKeeperClusterKey(this.conf);
 this.replicationZNode = ZKUtil.joinZNode(this.zookeeper.baseZNode, replicationZNodeName);
 this.peersZNode = ZKUtil.joinZNode(replicationZNode, peersZNodeName);
 this.queuesZNode = ZKUtil.joinZNode(replicationZNode, queuesZNodeName);
}

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

@Test
public void testSetDataVersionMismatchInLoop() throws Exception {
 String znode = "/hbase/splitWAL/9af7cfc9b15910a0b3d714bf40a3248f";
 Configuration conf = TEST_UTIL.getConfiguration();
 ZKWatcher zkw = new ZKWatcher(conf, "testSetDataVersionMismatchInLoop",
   abortable, true);
 String ensemble = ZKConfig.getZKQuorumServersString(conf);
 RecoverableZooKeeper rzk = ZKUtil.connect(conf, ensemble, zkw);
 rzk.create(znode, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
 rzk.setData(znode, "OPENING".getBytes(), 0);
 Field zkField = RecoverableZooKeeper.class.getDeclaredField("zk");
 zkField.setAccessible(true);
 int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
 ZookeeperStub zkStub = new ZookeeperStub(ensemble, timeout, zkw);
 zkStub.setThrowExceptionInNumOperations(1);
 zkField.set(rzk, zkStub);
 byte[] opened = "OPENED".getBytes();
 rzk.setData(znode, opened, 1);
 byte[] data = rzk.getData(znode, false, new Stat());
 assertTrue(Bytes.equals(opened, data));
}

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

@Test
public void testZKConfigLoading() throws Exception {
 Configuration conf = HBaseConfiguration.create();
 // Test that we read only from the config instance
 // (i.e. via hbase-default.xml and hbase-site.xml)
 conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, 2181);
 Properties props = ZKConfig.makeZKProps(conf);
 assertEquals("Property client port should have been default from the HBase config",
           "2181",
           props.getProperty("clientPort"));
}

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

@Test public void testShouldAssignDefaultZookeeperClientPort() {
 Configuration config = HBaseConfiguration.create();
 config.clear();
 Properties p = ZKConfig.makeZKProps(config);
 assertNotNull(p);
 assertEquals(2181, p.get("clientPort"));
}

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

public String parse(final Configuration c) {
 return ZKConfig.getZKQuorumServersString(c);
}

代码示例来源:origin: co.cask.hbase/hbase

/**
  * Return the ZK Quorum servers string given the specified configuration.
  * @param conf
  * @return Quorum servers
  */
 public static String getZKQuorumServersString(Configuration conf) {
  return getZKQuorumServersString(makeZKProps(conf));
 }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com