本文整理了Java中org.apache.hadoop.hbase.client.Admin.getReplicationPeerConfig()
方法的一些代码示例,展示了Admin.getReplicationPeerConfig()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.getReplicationPeerConfig()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:getReplicationPeerConfig
[英]Returns the configured ReplicationPeerConfig for the specified peer.
[中]返回为指定对等方配置的ReplicationPeerConfig。
代码示例来源:origin: apache/hbase
/**
* @deprecated use {@link org.apache.hadoop.hbase.client.Admin#getReplicationPeerConfig(String)}
* instead
*/
@Deprecated
public ReplicationPeerConfig getPeerConfig(String id) throws IOException {
return admin.getReplicationPeerConfig(id);
}
代码示例来源:origin: apache/hbase
/**
* Get the replicable table-cf config of the specified peer.
* @param id a short name that identifies the cluster
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0,
* use {@link #getPeerConfig(String)} instead.
* */
@Deprecated
public String getPeerTableCFs(String id) throws IOException {
ReplicationPeerConfig peerConfig = admin.getReplicationPeerConfig(id);
return ReplicationPeerConfigUtil.convertToString(peerConfig.getTableCFsMap());
}
代码示例来源:origin: apache/hbase
/**
* 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;
}
Admin admin = ConnectionFactory.createConnection(conf).getAdmin();
ReplicationPeerConfig peerConfig = null;
try {
peerConfig = admin.getReplicationPeerConfig(REGION_REPLICA_REPLICATION_PEER);
} catch (ReplicationPeerNotFoundException e) {
LOG.warn("Region replica replication peer id=" + REGION_REPLICA_REPLICATION_PEER
+ " not exist", e);
}
try {
if (peerConfig == null) {
LOG.info("Region replica replication peer id=" + REGION_REPLICA_REPLICATION_PEER
+ " not exist. Creating...");
peerConfig = new ReplicationPeerConfig();
peerConfig.setClusterKey(ZKConfig.getZooKeeperClusterKey(conf));
peerConfig.setReplicationEndpointImpl(RegionReplicaReplicationEndpoint.class.getName());
admin.addReplicationPeer(REGION_REPLICA_REPLICATION_PEER, peerConfig);
}
} finally {
admin.close();
}
}
代码示例来源: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
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
assertTrue(rpc.replicateAllUserTables());
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
Map<TableName, List<String>> result =
hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeTableCFsMap();
assertEquals(1, result.size());
assertEquals(true, result.containsKey(tab1));
rpc.setExcludeTableCFsMap(tableCFs);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
result = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeTableCFsMap();
assertEquals(2, result.size());
assertTrue("Should contain t1", result.containsKey(tab1));
rpc.setExcludeTableCFsMap(tableCFs);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
result = hbaseAdmin.getReplicationPeerConfig(ID_ONE).getExcludeTableCFsMap();
assertEquals(2, result.size());
assertTrue("Should contain t3", result.containsKey(tab3));
代码示例来源:origin: apache/hbase
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
Set<String> namespaces = new HashSet<String>();
namespaces.add(ns1);
rpc.setNamespaces(namespaces);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
try {
Map<TableName, List<String>> tableCfs = new HashMap<>();
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
Map<TableName, List<String>> tableCfs = new HashMap<>();
tableCfs.put(tableName2, new ArrayList<>());
rpc.setTableCFsMap(tableCfs);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
try {
namespaces.clear();
rpc2 = hbaseAdmin.getReplicationPeerConfig(ID_SECOND);
Set<String> excludeNamespaces = new HashSet<String>();
excludeNamespaces.add(ns1);
rpc2.setExcludeNamespaces(excludeNamespaces);
hbaseAdmin.updateReplicationPeerConfig(ID_SECOND, rpc2);
rpc2 = hbaseAdmin.getReplicationPeerConfig(ID_SECOND);
try {
Map<TableName, List<String>> excludeTableCfs = new HashMap<>();
rpc2 = hbaseAdmin.getReplicationPeerConfig(ID_SECOND);
Map<TableName, List<String>> excludeTableCfs = new HashMap<>();
代码示例来源:origin: apache/hbase
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
rpc.setReplicateAllUserTables(false);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, rpc);
代码示例来源:origin: apache/hbase
rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
rpc.setReplicateAllUserTables(false);
hbaseAdmin.updateReplicationPeerConfig(ID_ONE, 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: org.apache.hbase/hbase-client
/**
* @deprecated use {@link org.apache.hadoop.hbase.client.Admin#getReplicationPeerConfig(String)}
* instead
*/
@Deprecated
public ReplicationPeerConfig getPeerConfig(String id) throws IOException {
return admin.getReplicationPeerConfig(id);
}
代码示例来源:origin: apache/hbase
Table htab2B = connection2.getTable(tabBName);
ReplicationPeerConfig rpc = admin1.getReplicationPeerConfig(peerId);
admin1.updateReplicationPeerConfig(peerId,
ReplicationPeerConfig.newBuilder(rpc).setReplicateAllUserTables(false).build());
rpc = admin1.getReplicationPeerConfig(peerId);
Set<String> namespaces = new HashSet<>();
namespaces.add(ns1);
rpc = admin1.getReplicationPeerConfig(peerId);
namespaces = new HashSet<>();
namespaces.add(ns2);
代码示例来源:origin: apache/hbase
ReplicationPeerConfig rpc = admin1.getReplicationPeerConfig(peerId);
rpc.setReplicateAllUserTables(false);
admin1.updateReplicationPeerConfig(peerId, rpc);
admin1.disableTableReplication(TestReplicationBase.tableName);
rpc = admin1.getReplicationPeerConfig(peerId);
rpc.setReplicateAllUserTables(true);
admin1.updateReplicationPeerConfig(peerId, rpc);
代码示例来源:origin: apache/hbase
hbaseAdmin.addReplicationPeer(ID_ONE, builder.build());
ReplicationPeerConfig rpc = hbaseAdmin.getReplicationPeerConfig(ID_ONE);
assertNull(rpc.getRemoteWALDir());
rpc = hbaseAdmin.getReplicationPeerConfig(ID_SECOND);
assertEquals(rootDir, rpc.getRemoteWALDir());
代码示例来源: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 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
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: org.apache.hbase/hbase-client
/**
* Get the replicable table-cf config of the specified peer.
* @param id a short name that identifies the cluster
* @deprecated as release of 2.0.0, and it will be removed in 3.0.0,
* use {@link #getPeerConfig(String)} instead.
* */
@Deprecated
public String getPeerTableCFs(String id) throws IOException {
ReplicationPeerConfig peerConfig = admin.getReplicationPeerConfig(id);
return ReplicationPeerConfigUtil.convertToString(peerConfig.getTableCFsMap());
}
代码示例来源:origin: apache/hbase
.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,
SyncReplicationState.STANDBY);
代码示例来源:origin: apache/hbase
.newBuilder(UTIL1.getAdmin().getReplicationPeerConfig(PEER_ID)).setSerial(true).build());
UTIL2.getAdmin().updateReplicationPeerConfig(PEER_ID, ReplicationPeerConfig
.newBuilder(UTIL2.getAdmin().getReplicationPeerConfig(PEER_ID)).setSerial(true).build());
内容来源于网络,如有侵权,请联系作者删除!