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


Java ZKConfig类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.zookeeper.ZKConfig的典型用法代码示例。如果您正苦于以下问题:Java ZKConfig类的具体用法?Java ZKConfig怎么用?Java ZKConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ZKConfig类属于org.apache.hadoop.hbase.zookeeper包,在下文中一共展示了ZKConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupRegionReplicaReplication

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
/**
 * Create replication peer for replicating to region replicas if needed.
 * @param conf configuration to use
 * @throws IOException
 */
public static void setupRegionReplicaReplication(Configuration conf) throws IOException {
  if (!isRegionReplicaReplicationEnabled(conf)) {
    return;
  }
  ReplicationAdmin repAdmin = new ReplicationAdmin(conf);
  try {
    if (repAdmin.getPeerConfig(REGION_REPLICA_REPLICATION_PEER) == null) {
      ReplicationPeerConfig peerConfig = new ReplicationPeerConfig();
      peerConfig.setClusterKey(ZKConfig.getZooKeeperClusterKey(conf));
      peerConfig.setReplicationEndpointImpl(RegionReplicaReplicationEndpoint.class.getName());
      repAdmin.addPeer(REGION_REPLICA_REPLICATION_PEER, peerConfig, null);
    }
  } catch (ReplicationException ex) {
    throw new IOException(ex);
  } finally {
    repAdmin.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:ServerRegionReplicaUtil.java

示例2: testWALEntryFilterFromReplicationEndpoint

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
@Test (timeout=120000)
public void testWALEntryFilterFromReplicationEndpoint() throws Exception {
  admin.addPeer("testWALEntryFilterFromReplicationEndpoint",
    new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointWithWALEntryFilter.class.getName()), null);
  // now replicate some data.
  try (Connection connection = ConnectionFactory.createConnection(conf1)) {
    doPut(connection, Bytes.toBytes("row1"));
    doPut(connection, row);
    doPut(connection, Bytes.toBytes("row2"));
  }

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  Assert.assertNull(ReplicationEndpointWithWALEntryFilter.ex.get());
  admin.removePeer("testWALEntryFilterFromReplicationEndpoint");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestReplicationEndpoint.java

示例3: ZookeeperMonitor

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
protected ZookeeperMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,
    StdOutSink sink, ExecutorService executor, boolean treatFailureAsError)  {
  super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError);
  Configuration configuration = connection.getConfiguration();
  znode =
      configuration.get(ZOOKEEPER_ZNODE_PARENT,
          DEFAULT_ZOOKEEPER_ZNODE_PARENT);
  timeout = configuration
      .getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
  ConnectStringParser parser =
      new ConnectStringParser(ZKConfig.getZKQuorumServersString(configuration));
  hosts = Lists.newArrayList();
  for (InetSocketAddress server : parser.getServerAddresses()) {
    hosts.add(server.toString());
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:17,代码来源:Canary.java

示例4: testCustomReplicationEndpoint

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
@Test (timeout=120000)
public void testCustomReplicationEndpoint() throws Exception {
  // test installing a custom replication endpoint other than the default one.
  admin.addPeer("testCustomReplicationEndpoint",
    new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName()), null);

  // check whether the class has been constructed and started
  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.contructedCount.get() >= numRegionServers;
    }
  });

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.startedCount.get() >= numRegionServers;
    }
  });

  Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());

  // now replicate some data.
  doPut(Bytes.toBytes("row42"));

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return ReplicationEndpointForTest.replicateCount.get() >= 1;
    }
  });

  doAssert(Bytes.toBytes("row42"));

  admin.removePeer("testCustomReplicationEndpoint");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:TestReplicationEndpoint.java

示例5: testReplicationEndpointReturnsFalseOnReplicate

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
@Test (timeout=120000)
public void testReplicationEndpointReturnsFalseOnReplicate() throws Exception {
  Assert.assertEquals(0, ReplicationEndpointForTest.replicateCount.get());
  Assert.assertTrue(!ReplicationEndpointReturningFalse.replicated.get());
  int peerCount = admin.getPeersCount();
  final String id = "testReplicationEndpointReturnsFalseOnReplicate";
  admin.addPeer(id,
    new ReplicationPeerConfig().setClusterKey(ZKConfig.getZooKeeperClusterKey(conf1))
      .setReplicationEndpointImpl(ReplicationEndpointReturningFalse.class.getName()), null);
  // This test is flakey and then there is so much stuff flying around in here its, hard to
  // debug.  Peer needs to be up for the edit to make it across. This wait on
  // peer count seems to be a hack that has us not progress till peer is up.
  if (admin.getPeersCount() <= peerCount) {
    LOG.info("Waiting on peercount to go up from " + peerCount);
    Threads.sleep(100);
  }
  // now replicate some data
  doPut(row);

  Waiter.waitFor(conf1, 60000, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      // Looks like replication endpoint returns false unless we put more than 10 edits. We
      // only send over one edit.
      int count = ReplicationEndpointForTest.replicateCount.get();
      LOG.info("count=" + count);
      return ReplicationEndpointReturningFalse.replicated.get();
    }
  });
  if (ReplicationEndpointReturningFalse.ex.get() != null) {
    throw ReplicationEndpointReturningFalse.ex.get();
  }

  admin.removePeer("testReplicationEndpointReturnsFalseOnReplicate");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TestReplicationEndpoint.java

示例6: testRegionReplicaReplicationPeerIsCreated

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
@Test
public void testRegionReplicaReplicationPeerIsCreated() throws IOException, ReplicationException {
  // create a table with region replicas. Check whether the replication peer is created
  // and replication started.
  ReplicationAdmin admin = new ReplicationAdmin(HTU.getConfiguration());
  String peerId = "region_replica_replication";

  if (admin.getPeerConfig(peerId) != null) {
    admin.removePeer(peerId);
  }

  HTableDescriptor htd = HTU.createTableDescriptor(
    "testReplicationPeerIsCreated_no_region_replicas");
  HTU.getHBaseAdmin().createTable(htd);
  ReplicationPeerConfig peerConfig = admin.getPeerConfig(peerId);
  assertNull(peerConfig);

  htd = HTU.createTableDescriptor("testReplicationPeerIsCreated");
  htd.setRegionReplication(2);
  HTU.getHBaseAdmin().createTable(htd);

  // assert peer configuration is correct
  peerConfig = admin.getPeerConfig(peerId);
  assertNotNull(peerConfig);
  assertEquals(peerConfig.getClusterKey(), ZKConfig.getZooKeeperClusterKey(
      HTU.getConfiguration()));
  assertEquals(peerConfig.getReplicationEndpointImpl(),
    RegionReplicaReplicationEndpoint.class.getName());
  admin.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:TestRegionReplicaReplicationEndpoint.java

示例7: testRegionReplicaReplicationPeerIsCreatedForModifyTable

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
@Test (timeout=240000)
public void testRegionReplicaReplicationPeerIsCreatedForModifyTable() throws Exception {
  // modify a table by adding region replicas. Check whether the replication peer is created
  // and replication started.
  ReplicationAdmin admin = new ReplicationAdmin(HTU.getConfiguration());
  String peerId = "region_replica_replication";

  if (admin.getPeerConfig(peerId) != null) {
    admin.removePeer(peerId);
  }

  HTableDescriptor htd
    = HTU.createTableDescriptor("testRegionReplicaReplicationPeerIsCreatedForModifyTable");
  HTU.getHBaseAdmin().createTable(htd);

  // assert that replication peer is not created yet
  ReplicationPeerConfig peerConfig = admin.getPeerConfig(peerId);
  assertNull(peerConfig);

  HTU.getHBaseAdmin().disableTable(htd.getTableName());
  htd.setRegionReplication(2);
  HTU.getHBaseAdmin().modifyTable(htd.getTableName(), htd);
  HTU.getHBaseAdmin().enableTable(htd.getTableName());

  // assert peer configuration is correct
  peerConfig = admin.getPeerConfig(peerId);
  assertNotNull(peerConfig);
  assertEquals(peerConfig.getClusterKey(), ZKConfig.getZooKeeperClusterKey(
      HTU.getConfiguration()));
  assertEquals(peerConfig.getReplicationEndpointImpl(),
    RegionReplicaReplicationEndpoint.class.getName());
  admin.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:TestRegionReplicaReplicationEndpoint.java

示例8: initPeerClusterState

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
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);
  ZooKeeperWatcher zkw1 = new ZooKeeperWatcher(testConf, "test1", null);
  String fakeRs = ZKUtil.joinZNode(zkw1.rsZNode, "hostname1.example.org:1234");
  ZKUtil.createWithParents(zkw1, fakeRs);
  ZKClusterId.setClusterId(zkw1, new ClusterId());
  return ZKConfig.getZooKeeperClusterKey(testConf);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestReplicationStateZKImpl.java

示例9: setUp

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
@Before
@Override
public void setUp() {
  super.setUp();
  DummyServer ds1 = new DummyServer(server1);
  DummyServer ds2 = new DummyServer(server2);
  DummyServer ds3 = new DummyServer(server3);
  rq1 = ReplicationFactory.getReplicationQueues(zkw, conf, ds1);
  rq2 = ReplicationFactory.getReplicationQueues(zkw, conf, ds2);
  rq3 = ReplicationFactory.getReplicationQueues(zkw, conf, ds3);
  rqc = ReplicationFactory.getReplicationQueuesClient(zkw, conf, ds1);
  rp = ReplicationFactory.getReplicationPeers(zkw, conf, zkw);
  OUR_KEY = ZKConfig.getZooKeeperClusterKey(conf);
  rqZK = new ReplicationQueuesZKImpl(zkw, conf, ds1);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:TestReplicationStateZKImpl.java

示例10: ReplicationStateZKBase

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
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);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:ReplicationStateZKBase.java

示例11: applyClusterKeyToConf

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:HBaseConfiguration.java

示例12: addPeer

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
/**
*
* @param configuration
* @param peerName
* @param tableCFs
* @throws ReplicationException
* @throws IOException
*/
  protected void addPeer(final Configuration configuration,String peerName, Map<TableName, List<String>> tableCFs)
     throws ReplicationException, IOException {
      try (ReplicationAdmin replicationAdmin = new ReplicationAdmin(configuration)) {
          ReplicationPeerConfig peerConfig = new ReplicationPeerConfig()
              .setClusterKey(ZKConfig.getZooKeeperClusterKey(configuration))
              .setReplicationEndpointImpl(HbaseEndpoint.class.getName());

          replicationAdmin.addPeer(peerName, peerConfig, tableCFs);
      }
  }
 
开发者ID:mravi,项目名称:hbase-connect-kafka,代码行数:19,代码来源:BaseTest.java

示例13: expireSession

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
/**
  * Expire a ZooKeeper session as recommended in ZooKeeper documentation
  * http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A4
  * There are issues when doing this:
  * [1] http://www.mail-archive.com/[email protected]/msg01942.html
  * [2] https://issues.apache.org/jira/browse/ZOOKEEPER-1105
  *
  * @param nodeZK - the ZK to make expiry
  * @param checkStatus - true to check if the we can create a HTable with the
  *                    current configuration.
  */
public void expireSession(ZooKeeperWatcher nodeZK, boolean checkStatus)
  throws Exception {
  Configuration c = new Configuration(this.conf);
  String quorumServers = ZKConfig.getZKQuorumServersString(c);
  int sessionTimeout = 500;
  ZooKeeper zk = nodeZK.getRecoverableZooKeeper().getZooKeeper();
  byte[] password = zk.getSessionPasswd();
  long sessionID = zk.getSessionId();

  // Expiry seems to be asynchronous (see comment from P. Hunt in [1]),
  //  so we create a first watcher to be sure that the
  //  event was sent. We expect that if our watcher receives the event
  //  other watchers on the same machine will get is as well.
  // When we ask to close the connection, ZK does not close it before
  //  we receive all the events, so don't have to capture the event, just
  //  closing the connection should be enough.
  ZooKeeper monitor = new ZooKeeper(quorumServers,
    1000, new org.apache.zookeeper.Watcher(){
    @Override
    public void process(WatchedEvent watchedEvent) {
      LOG.info("Monitor ZKW received event="+watchedEvent);
    }
  } , sessionID, password);

  // Making it expire
  ZooKeeper newZK = new ZooKeeper(quorumServers,
      sessionTimeout, EmptyWatcher.instance, sessionID, password);
  newZK.close();
  LOG.info("ZK Closed Session 0x" + Long.toHexString(sessionID));

   // Now closing & waiting to be sure that the clients get it.
   monitor.close();

  if (checkStatus) {
    new HTable(new Configuration(conf), HConstants.META_TABLE_NAME).close();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:49,代码来源:HBaseTestingUtility.java

示例14: initPeerClusterState

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
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.znodePaths.rsZNode, "hostname1.example.org:1234");
  ZKUtil.createWithParents(zkw1, fakeRs);
  ZKClusterId.setClusterId(zkw1, new ClusterId());
  return ZKConfig.getZooKeeperClusterKey(testConf);
}
 
开发者ID:apache,项目名称:hbase,代码行数:12,代码来源:TestReplicationStateZKImpl.java

示例15: setUp

import org.apache.hadoop.hbase.zookeeper.ZKConfig; //导入依赖的package包/类
@Before
public void setUp() {
  zkTimeoutCount = 0;
  rqs = ReplicationStorageFactory.getReplicationQueueStorage(zkw, conf);
  rp = ReplicationFactory.getReplicationPeers(zkw, conf);
  OUR_KEY = ZKConfig.getZooKeeperClusterKey(conf);
}
 
开发者ID:apache,项目名称:hbase,代码行数:8,代码来源:TestReplicationStateZKImpl.java


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