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

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

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

Admin.removeReplicationPeer介绍

[英]Remove a peer and stop the replication.
[中]删除对等方并停止复制。

代码示例

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

/**
 * Removes a peer cluster and stops the replication to it.
 * @param id a short name that identifies the cluster
 * @deprecated use {@link org.apache.hadoop.hbase.client.Admin#removeReplicationPeer(String)} instead
 */
@Deprecated
public void removePeer(String id) throws IOException {
 this.admin.removeReplicationPeer(id);
}

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

@After
public void tearDownBase() throws Exception {
 if (peerExist(PEER_ID2)) {
  hbaseAdmin.removeReplicationPeer(PEER_ID2);
 }
}

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

assertEquals("f2", result.get(tab4).get(1));
hbaseAdmin.removeReplicationPeer(ID_ONE);

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

@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

public void testAddAndRemoveClusters() throws Exception {
 LOG.info("testAddAndRemoveClusters");
 hbaseAdmin.removeReplicationPeer(PEER_ID);
 Thread.sleep(SLEEP_TIME);
 byte[] rowKey = Bytes.toBytes("Won't be replicated");

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

@Test
public void testPeerExcludeNamespaces() throws Exception {
 String ns1 = "ns1";
 String ns2 = "ns2";
 ReplicationPeerConfig rpc = new ReplicationPeerConfig();
 rpc.setClusterKey(KEY_ONE);
 hbaseAdmin.addReplicationPeer(ID_ONE, rpc);
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 assertTrue(rpc.replicateAllUserTables());
 Set<String> namespaces = new HashSet<String>();
 namespaces.add(ns1);
 namespaces.add(ns2);
 rpc.setExcludeNamespaces(namespaces);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 namespaces = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeNamespaces();
 assertEquals(2, namespaces.size());
 assertTrue(namespaces.contains(ns1));
 assertTrue(namespaces.contains(ns2));
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 namespaces = new HashSet<String>();
 namespaces.add(ns1);
 rpc.setExcludeNamespaces(namespaces);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 namespaces = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeNamespaces();
 assertEquals(1, namespaces.size());
 assertTrue(namespaces.contains(ns1));
 hbaseAdmin.removeReplicationPeer(ID_ONE);
}

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

Assert.assertFalse(fs2.exists(getReplayRemoteWALs(REMOTE_WAL_DIR2, PEER_ID)));
UTIL1.getAdmin().removeReplicationPeer(PEER_ID);
verifyRemovedPeer(PEER_ID, REMOTE_WAL_DIR1, UTIL1);
Assert.assertTrue(fs2.exists(getRemoteWALDir(REMOTE_WAL_DIR2, PEER_ID)));
Assert.assertTrue(fs2.exists(getReplayRemoteWALs(REMOTE_WAL_DIR2, PEER_ID)));
UTIL2.getAdmin().removeReplicationPeer(PEER_ID);
verifyRemovedPeer(PEER_ID, REMOTE_WAL_DIR2, UTIL2);

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

@Test
public void testSetPeerNamespaces() throws Exception {
 String ns1 = "ns1";
 String ns2 = "ns2";
 ReplicationPeerConfig rpc = new ReplicationPeerConfig();
 rpc.setClusterKey(KEY_ONE);
 hbaseAdmin.addReplicationPeer(ID_ONE, rpc);
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 rpc.setReplicateAllUserTables(false);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 Set<String> namespaces = new HashSet<>();
 namespaces.add(ns1);
 namespaces.add(ns2);
 rpc.setNamespaces(namespaces);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 namespaces = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getNamespaces();
 assertEquals(2, namespaces.size());
 assertTrue(namespaces.contains(ns1));
 assertTrue(namespaces.contains(ns2));
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 namespaces = new HashSet<>();
 namespaces.add(ns1);
 rpc.setNamespaces(namespaces);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 namespaces = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getNamespaces();
 assertEquals(1, namespaces.size());
 assertTrue(namespaces.contains(ns1));
 hbaseAdmin.removeReplicationPeer(ID_ONE);
}

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

hbaseAdmin.removeReplicationPeer(ID_SECOND);
 fail();
} catch (Exception e) {
hbaseAdmin.removeReplicationPeer(ID_ONE);
assertEquals(1, hbaseAdmin.listReplicationPeers().size());
hbaseAdmin.removeReplicationPeer(ID_SECOND);
assertEquals(0, hbaseAdmin.listReplicationPeers().size());

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

hbaseAdmin.removeReplicationPeer(ID_ONE);
 fail("Can't remove a synchronous replication peer with state=ACTIVE");
} catch (IOException e) {
 hbaseAdmin.removeReplicationPeer(ID_ONE);
 fail("Can't remove a synchronous replication peer with state=STANDBY");
} catch (IOException e) {
 hbaseAdmin.getReplicationPeerSyncReplicationState(ID_ONE));
hbaseAdmin.removeReplicationPeer(ID_ONE);
assertEquals(0, hbaseAdmin.listReplicationPeers().size());

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

@Test
public void testRemovePeer() throws Exception {
 TableName tableName = createTable();
 try (Table table = UTIL.getConnection().getTable(tableName)) {
  for (int i = 0; i < 100; i++) {
   table.put(new Put(Bytes.toBytes(i)).addColumn(CF, CQ, Bytes.toBytes(i)));
  }
 }
 enablePeerAndWaitUntilReplicationDone(100);
 checkOrder(100);
 String encodedRegionName =
  UTIL.getMiniHBaseCluster().getRegions(tableName).get(0).getRegionInfo().getEncodedName();
 ReplicationQueueStorage queueStorage =
  UTIL.getMiniHBaseCluster().getMaster().getReplicationPeerManager().getQueueStorage();
 assertTrue(queueStorage.getLastSequenceId(encodedRegionName, PEER_ID) > 0);
 UTIL.getAdmin().removeReplicationPeer(PEER_ID);
 // confirm that we delete the last pushed sequence id
 assertEquals(HConstants.NO_SEQNUM, queueStorage.getLastSequenceId(encodedRegionName, PEER_ID));
}

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

@Test
public void testRemovePeerNothingReplicated() throws Exception {
 TableName tableName = createTable();
 String encodedRegionName =
  UTIL.getMiniHBaseCluster().getRegions(tableName).get(0).getRegionInfo().getEncodedName();
 ReplicationQueueStorage queueStorage =
  UTIL.getMiniHBaseCluster().getMaster().getReplicationPeerManager().getQueueStorage();
 assertEquals(HConstants.NO_SEQNUM, queueStorage.getLastSequenceId(encodedRegionName, PEER_ID));
 UTIL.getAdmin().removeReplicationPeer(PEER_ID);
 assertEquals(HConstants.NO_SEQNUM, queueStorage.getLastSequenceId(encodedRegionName, PEER_ID));
}

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

ensureRowNotExisted(htab2B, row, f1Name, f2Name);
admin1.removeReplicationPeer(peerId);

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

@Test
public void testSetReplicateAllUserTables() throws Exception {
 ReplicationPeerConfig rpc = new ReplicationPeerConfig();
 rpc.setClusterKey(KEY_ONE);
 hbaseAdmin.addReplicationPeer(ID_ONE, rpc);
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 assertTrue(rpc.replicateAllUserTables());
 rpc.setReplicateAllUserTables(false);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 assertFalse(rpc.replicateAllUserTables());
 rpc.setReplicateAllUserTables(true);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
 assertTrue(rpc.replicateAllUserTables());
 hbaseAdmin.removeReplicationPeer(ID_ONE);
}

代码示例来源: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);
}

相关文章

Admin类方法