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

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

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

Admin.updateReplicationPeerConfig介绍

[英]Update the peerConfig for the specified peer.
[中]更新指定对等方的peerConfig。

代码示例

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

/**
 * @deprecated use
 *             {@link org.apache.hadoop.hbase.client.Admin#updateReplicationPeerConfig(String, ReplicationPeerConfig)}
 *             instead
 */
@Deprecated
public void updatePeerConfig(String id, ReplicationPeerConfig peerConfig) throws IOException {
 this.admin.updateReplicationPeerConfig(id, peerConfig);
}

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

tableCFs.put(tab1, null);
rpc.setExcludeTableCFsMap(tableCFs);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
Map<TableName, List<String>> result =
  hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeTableCFsMap();
tableCFs.get(tab2).add("f1");
rpc.setExcludeTableCFsMap(tableCFs);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
result = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeTableCFsMap();
assertEquals(2, result.size());
tableCFs.get(tab4).add("f2");
rpc.setExcludeTableCFsMap(tableCFs);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
result = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeTableCFsMap();
assertEquals(2, result.size());

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

namespaces.add(ns1);
rpc.setNamespaces(namespaces);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
try {
 tableCfs.put(tableName1, new ArrayList<>());
 rpc.setTableCFsMap(tableCfs);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 fail("Should throw ReplicationException" + " Because table " + tableName1
   + " conflict with namespace " + ns1);
tableCfs.put(tableName2, new ArrayList<>());
rpc.setTableCFsMap(tableCfs);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
try {
 namespaces.add(ns2);
 rpc.setNamespaces(namespaces);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
 fail("Should throw ReplicationException" + " Because namespace " + ns2
   + " conflict with table " + tableName2);
excludeNamespaces.add(ns1);
rpc2.setExcludeNamespaces(excludeNamespaces);
hbaseAdmin.updateReplicationPeerConfig(ID_SECOND, rpc2);
rpc2 = hbaseAdmin.getReplicationPeerConfig(ID_SECOND);
try {

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

@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

hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);

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

hbaseAdmin.updateReplicationPeerConfig(ID_ONE, builder.build());
 fail("Change replication endpoint implementation class on an existing peer is not allowed");
} catch (Exception e) {
 builder = ReplicationPeerConfig.newBuilder();
 builder.setClusterKey(KEY_ONE);
 hbaseAdmin.updateReplicationPeerConfig(ID_ONE, builder.build());
 fail("Change replication endpoint implementation class on an existing peer is not allowed");
} catch (Exception e) {
 hbaseAdmin.updateReplicationPeerConfig(ID_SECOND, builder.build());
 fail("Change replication endpoint implementation class on an existing peer is not allowed");
} catch (Exception e) {

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

@Test
public void testPeerClusterKey() throws Exception {
 ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder();
 builder.setClusterKey(KEY_ONE);
 hbaseAdmin.addReplicationPeer(ID_ONE, builder.build());
 try {
  builder.setClusterKey(KEY_SECOND);
  hbaseAdmin.updateReplicationPeerConfig(ID_ONE, builder.build());
  fail("Change cluster key on an existing peer is not allowed");
 } catch (Exception e) {
  // OK
 }
}

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

admin1.updateReplicationPeerConfig(peerId,
 ReplicationPeerConfig.newBuilder(rpc).setReplicateAllUserTables(false).build());
Set<String> namespaces = new HashSet<>();
namespaces.add(ns1);
admin1.updateReplicationPeerConfig(peerId,
 ReplicationPeerConfig.newBuilder(rpc).setNamespaces(namespaces).build());
LOG.info("update peer config");
tableCfs.put(tabAName, new ArrayList<>());
tableCfs.get(tabAName).add("f1");
admin1.updateReplicationPeerConfig(peerId, ReplicationPeerConfig.newBuilder(rpc)
  .setNamespaces(namespaces).setTableCFsMap(tableCfs).build());
LOG.info("update peer config");

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

admin1.updateReplicationPeerConfig(peerId, rpc);
 admin1.updateReplicationPeerConfig(peerId, rpc);

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

@Test
public void testRemoveTable() throws Exception {
 TableName tableName = createTable();
 ReplicationPeerConfig peerConfig = ReplicationPeerConfig.newBuilder()
  .setClusterKey("127.0.0.1:2181:/hbase")
  .setReplicationEndpointImpl(LocalReplicationEndpoint.class.getName())
  .setReplicateAllUserTables(false)
  .setTableCFsMap(ImmutableMap.of(tableName, Collections.emptyList())).setSerial(true).build();
 UTIL.getAdmin().addReplicationPeer(PEER_ID, peerConfig, true);
 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)));
  }
 }
 RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(tableName).get(0).getRegionInfo();
 waitUntilHasLastPushedSequenceId(region);
 UTIL.getAdmin().updateReplicationPeerConfig(PEER_ID,
  ReplicationPeerConfig.newBuilder(peerConfig).setTableCFsMap(Collections.emptyMap()).build());
 ReplicationQueueStorage queueStorage =
  UTIL.getMiniHBaseCluster().getMaster().getReplicationPeerManager().getQueueStorage();
 assertEquals(HConstants.NO_SEQNUM,
  queueStorage.getLastSequenceId(region.getEncodedName(), PEER_ID));
}

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

waitUntilReplicatedToTheCurrentWALFile(rs);
UTIL.getAdmin().disableReplicationPeer(PEER_ID);
UTIL.getAdmin().updateReplicationPeerConfig(PEER_ID,
 ReplicationPeerConfig.newBuilder(peerConfig)
  .setTableCFsMap(ImmutableMap.of(tableName, Collections.emptyList())).build());

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

@Test
public void testChangeToSerial() throws Exception {
 ReplicationPeerConfig peerConfig =
  ReplicationPeerConfig.newBuilder().setClusterKey("127.0.0.1:2181:/hbase")
   .setReplicationEndpointImpl(LocalReplicationEndpoint.class.getName()).build();
 UTIL.getAdmin().addReplicationPeer(PEER_ID, peerConfig, true);
 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)));
  }
 }
 RegionInfo region = UTIL.getAdmin().getRegions(tableName).get(0);
 HRegionServer srcRs = UTIL.getRSForFirstRegionInTable(tableName);
 HRegionServer rs = UTIL.getOtherRegionServer(srcRs);
 moveRegionAndArchiveOldWals(region, rs);
 waitUntilReplicationDone(100);
 waitUntilReplicatedToTheCurrentWALFile(srcRs);
 UTIL.getAdmin().disableReplicationPeer(PEER_ID);
 UTIL.getAdmin().updateReplicationPeerConfig(PEER_ID,
  ReplicationPeerConfig.newBuilder(peerConfig).setSerial(true).build());
 UTIL.getAdmin().enableReplicationPeer(PEER_ID);
 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)));
  }
 }
 waitUntilReplicationDone(200);
 checkOrder(200);
}

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

@Test
 public void testRemoveSerialFlag() throws Exception {
  TableName tableName = createTable();
  addPeer(true);
  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)));
   }
  }
  RegionInfo region = UTIL.getMiniHBaseCluster().getRegions(tableName).get(0).getRegionInfo();
  waitUntilHasLastPushedSequenceId(region);
  UTIL.getAdmin().updateReplicationPeerConfig(PEER_ID, ReplicationPeerConfig
   .newBuilder(UTIL.getAdmin().getReplicationPeerConfig(PEER_ID)).setSerial(false).build());
  waitUntilReplicationDone(100);

  ReplicationQueueStorage queueStorage =
   UTIL.getMiniHBaseCluster().getMaster().getReplicationPeerManager().getQueueStorage();
  assertEquals(HConstants.NO_SEQNUM,
   queueStorage.getLastSequenceId(region.getEncodedName(), PEER_ID));
 }
}

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

@Test
 public void testRemoveSerialFlag() 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);
  ReplicationPeerConfig peerConfig = UTIL.getAdmin().getReplicationPeerConfig(PEER_ID);
  UTIL.getAdmin().updateReplicationPeerConfig(PEER_ID,
   ReplicationPeerConfig.newBuilder(peerConfig).setSerial(false).build());
  // confirm that we delete the last pushed sequence id
  assertEquals(HConstants.NO_SEQNUM, queueStorage.getLastSequenceId(encodedRegionName, PEER_ID));
 }
}

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

@Test
public void testShipperQuitWhenDA() throws Exception {
 UTIL1.getAdmin().updateReplicationPeerConfig(PEER_ID, ReplicationPeerConfig
  .newBuilder(UTIL1.getAdmin().getReplicationPeerConfig(PEER_ID)).setSerial(true).build());
 UTIL2.getAdmin().updateReplicationPeerConfig(PEER_ID, ReplicationPeerConfig
  .newBuilder(UTIL2.getAdmin().getReplicationPeerConfig(PEER_ID)).setSerial(true).build());
 UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID,

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

@Test
public void test() throws Exception {
 UTIL1.getAdmin().updateReplicationPeerConfig(PEER_ID, ReplicationPeerConfig
  .newBuilder(UTIL1.getAdmin().getReplicationPeerConfig(PEER_ID)).setSerial(true).build());
 UTIL2.getAdmin().updateReplicationPeerConfig(PEER_ID, ReplicationPeerConfig
  .newBuilder(UTIL2.getAdmin().getReplicationPeerConfig(PEER_ID)).setSerial(true).build());

相关文章

Admin类方法