org.apache.hadoop.hbase.client.Admin.listReplicationPeers()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(112)

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

Admin.listReplicationPeers介绍

[英]Return a list of replication peers.
[中]返回复制对等点的列表。

代码示例

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

/**
 * Get the number of slave clusters the local cluster has.
 * @return number of slave clusters
 * @throws IOException
 * @deprecated
 */
@Deprecated
public int getPeersCount() throws IOException {
 return this.admin.listReplicationPeers().size();
}

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

/**
  * @deprecated use {@link org.apache.hadoop.hbase.client.Admin#listReplicationPeers()} instead
  */
 @VisibleForTesting
 @Deprecated
 List<ReplicationPeerDescription> listReplicationPeers() throws IOException {
  return admin.listReplicationPeers();
 }
}

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

/**
 * @deprecated use {@link org.apache.hadoop.hbase.client.Admin#listReplicationPeers()} instead
 */
@Deprecated
public Map<String, ReplicationPeerConfig> listPeerConfigs() throws IOException {
 List<ReplicationPeerDescription> peers = this.admin.listReplicationPeers();
 Map<String, ReplicationPeerConfig> result = new TreeMap<>();
 for (ReplicationPeerDescription peer : peers) {
  result.put(peer.getPeerId(), peer.getPeerConfig());
 }
 return result;
}

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

/**
 * Get the current cluster state in a synchronous replication peer.
 * @param peerId a short name that identifies the peer
 * @return the current cluster state
 * @throws IOException if a remote or network exception occurs
 */
default SyncReplicationState getReplicationPeerSyncReplicationState(String peerId)
  throws IOException {
 List<ReplicationPeerDescription> peers = listReplicationPeers(Pattern.compile(peerId));
 if (peers.isEmpty() || !peers.get(0).getPeerId().equals(peerId)) {
  throw new IOException("Replication peer " + peerId + " does not exist");
 }
 return peers.get(0).getSyncReplicationState();
}

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

/**
 * Get the state of the specified peer cluster
 * @param id String format of the Short name that identifies the peer,
 * an IllegalArgumentException is thrown if it doesn't exist
 * @return true if replication is enabled to that peer, false if it isn't
 */
@Deprecated
public boolean getPeerState(String id) throws ReplicationException, IOException {
 List<ReplicationPeerDescription> peers = admin.listReplicationPeers(Pattern.compile(id));
 if (peers.isEmpty() || !id.equals(peers.get(0).getPeerId())) {
  throw new ReplicationPeerNotFoundException(id);
 }
 return peers.get(0).isEnabled();
}

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

private boolean peerExist(String peerId) throws IOException {
 return hbaseAdmin.listReplicationPeers().stream().anyMatch(p -> peerId.equals(p.getPeerId()));
}

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

List<ReplicationPeerDescription> peers = admin.listReplicationPeers();

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

public void upgrade() throws Exception {
 try (Connection conn = ConnectionFactory.createConnection(conf)) {
  Admin admin = conn.getAdmin();
  admin.listReplicationPeers().forEach((peerDesc) -> {
   String peerId = peerDesc.getPeerId();
   ReplicationPeerConfig peerConfig = peerDesc.getPeerConfig();
   if ((peerConfig.getNamespaces() != null && !peerConfig.getNamespaces().isEmpty())
     || (peerConfig.getTableCFsMap() != null && !peerConfig.getTableCFsMap().isEmpty())) {
    peerConfig.setReplicateAllUserTables(false);
    try {
     admin.updateReplicationPeerConfig(peerId, peerConfig);
    } catch (Exception e) {
     LOG.error("Failed to upgrade replication peer config for peerId=" + peerId, e);
    }
   }
  });
 }
}

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

List<ReplicationPeerDescription> peerDescriptions = admin.listReplicationPeers();
if (peerDescriptions != null && peerDescriptions.size() > 0) {
 List<String> peers = peerDescriptions.stream()

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

@Test
public void testAddPeerWithState() throws Exception {
 ReplicationPeerConfig rpc1 = new ReplicationPeerConfig();
 rpc1.setClusterKey(KEY_ONE);
 hbaseAdmin.addReplicationPeer(ID_ONE, rpc1, true);
 assertTrue(hbaseAdmin.listReplicationPeers(Pattern.compile(ID_ONE)).get(0).isEnabled());
 hbaseAdmin.removeReplicationPeer(ID_ONE);
 ReplicationPeerConfig rpc2 = new ReplicationPeerConfig();
 rpc2.setClusterKey(KEY_SECOND);
 hbaseAdmin.addReplicationPeer(ID_SECOND, rpc2, false);
 assertFalse(hbaseAdmin.listReplicationPeers(Pattern.compile(ID_SECOND)).get(0).isEnabled());
 hbaseAdmin.removeReplicationPeer(ID_SECOND);
}

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

private static void shutdown(HBaseTestingUtility util) throws Exception {
 if (util.getHBaseCluster() == null) {
  return;
 }
 Admin admin = util.getAdmin();
 if (!admin.listReplicationPeers(Pattern.compile(PEER_ID)).isEmpty()) {
  if (admin
   .getReplicationPeerSyncReplicationState(PEER_ID) != SyncReplicationState.DOWNGRADE_ACTIVE) {
   admin.transitReplicationPeerSyncReplicationState(PEER_ID,
    SyncReplicationState.DOWNGRADE_ACTIVE);
  }
  admin.removeReplicationPeer(PEER_ID);
 }
 util.shutdownMiniCluster();
}

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

@After
public void tearDownAfterTest() throws IOException {
 for (ReplicationPeerDescription desc : UTIL.getAdmin().listReplicationPeers()) {
  UTIL.getAdmin().removeReplicationPeer(desc.getPeerId());
 }
}

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

/**
 * Tests that the peer configuration used by ReplicationAdmin contains all
 * the peer's properties.
 */
@Test
public void testPeerConfig() throws Exception {
 ReplicationPeerConfig config = new ReplicationPeerConfig();
 config.setClusterKey(KEY_ONE);
 config.getConfiguration().put("key1", "value1");
 config.getConfiguration().put("key2", "value2");
 hbaseAdmin.addReplicationPeer(ID_ONE, config);
 List<ReplicationPeerDescription> peers = hbaseAdmin.listReplicationPeers();
 assertEquals(1, peers.size());
 ReplicationPeerDescription peerOne = peers.get(0);
 assertNotNull(peerOne);
 assertEquals("value1", peerOne.getPeerConfig().getConfiguration().get("key1"));
 assertEquals("value2", peerOne.getPeerConfig().getConfiguration().get("key2"));
 hbaseAdmin.removeReplicationPeer(ID_ONE);
}

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

assertEquals(1, hbaseAdmin.listReplicationPeers().size());
assertEquals(1, hbaseAdmin.listReplicationPeers().size());
 fail();
assertEquals(2, hbaseAdmin.listReplicationPeers().size());
assertEquals(1, hbaseAdmin.listReplicationPeers().size());
hbaseAdmin.removeReplicationPeer(ID_SECOND);
assertEquals(0, hbaseAdmin.listReplicationPeers().size());

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

@After
public void tearDown() throws Exception {
 Admin admin = UTIL.getAdmin();
 for (ReplicationPeerDescription pd : admin.listReplicationPeers()) {
  admin.removeReplicationPeer(pd.getPeerId());
 }
 rollAllWALs();
 if (WRITER != null) {
  WRITER.close();
  WRITER = null;
 }
}

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

@After
public void tearDown() throws Exception {
 for (ReplicationPeerDescription desc : hbaseAdmin.listReplicationPeers()) {
  hbaseAdmin.removeReplicationPeer(desc.getPeerId());
 }
 ReplicationQueueStorage queueStorage = ReplicationStorageFactory
   .getReplicationQueueStorage(TEST_UTIL.getZooKeeperWatcher(), TEST_UTIL.getConfiguration());
 for (ServerName serverName : queueStorage.getListOfReplicators()) {
  for (String queue : queueStorage.getAllQueues(serverName)) {
   queueStorage.removeQueue(serverName, queue);
  }
  queueStorage.removeReplicatorIfQueueIsEmpty(serverName);
 }
}

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

assertEquals(0, hbaseAdmin.listReplicationPeers().size());

代码示例来源: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/hbase

hbaseAdmin.removeReplicationPeer(ID_ONE);
hbaseAdmin.removeReplicationPeer(ID_SECOND);
assertEquals(0, hbaseAdmin.listReplicationPeers().size());

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

try (final Admin admin = source.getConnection().getAdmin()) {
 for (ReplicationPeerDescription peer : admin.listReplicationPeers()) {
  admin.removeReplicationPeer(peer.getPeerId());

相关文章

Admin类方法