private void addPeer(String id, int masterClusterNumber, int slaveClusterNumber) throws Exception { try (Admin admin = ConnectionFactory.createConnection(configurations[masterClusterNumber]) .getAdmin()) { admin.addReplicationPeer(id, new ReplicationPeerConfig().setClusterKey(utilities[slaveClusterNumber].getClusterKey())); } }
rpc.setClusterKey(utility2.getClusterKey()); replicationAdmin.addPeer("2", rpc, null);
@BeforeClass public static void setUpBeforeClass() throws Exception { utility1 = new HBaseTestingUtility(conf1); utility1.startMiniCluster(); admin = new ReplicationAdmin(conf1); conf2 = HBaseConfiguration.create(conf1); conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2"); conf2.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, 2182); utility2 = new HBaseTestingUtility(conf2); utility2.startMiniCluster(); ReplicationPeerConfig config = new ReplicationPeerConfig(); config.setClusterKey(utility2.getClusterKey()); admin.addPeer(peerId, config, null); HTableDescriptor table = new HTableDescriptor(tableName); HColumnDescriptor fam = new HColumnDescriptor(famName); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); table.addFamily(fam); utility1.getAdmin().createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE); utility1.waitUntilAllRegionsAssigned(tableName); }
@BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_RPC_TIMEOUT_KEY, 60000); TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, 120000); TEST_UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2); TEST_UTIL.getConfiguration().setInt(START_LOG_ERRORS_AFTER_COUNT_KEY, 0); TEST_UTIL.startMiniCluster(); ASYNC_CONN = ConnectionFactory.createAsyncConnection(TEST_UTIL.getConfiguration()).get(); conf2 = HBaseConfiguration.create(TEST_UTIL.getConfiguration()); conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2"); TEST_UTIL2 = new HBaseTestingUtility(conf2); TEST_UTIL2.startMiniCluster(); admin2 = ConnectionFactory.createAsyncConnection(TEST_UTIL2.getConfiguration()).get().getAdmin(); ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(TEST_UTIL2.getClusterKey()); ASYNC_CONN.getAdmin().addReplicationPeer(ID_SECOND, rpc).join(); }
@Test public void testReplicationPeerConfigUpdateCallback() throws Exception { String peerId = "1"; ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(utility2.getClusterKey()); rpc.setReplicationEndpointImpl(TestUpdatableReplicationEndpoint.class.getName()); rpc.getConfiguration().put("key1", "value1"); admin1.addReplicationPeer(peerId, rpc); rpc.getConfiguration().put("key1", "value2"); admin.updatePeerConfig(peerId, rpc); if (!TestUpdatableReplicationEndpoint.hasCalledBack()) { synchronized (TestUpdatableReplicationEndpoint.class) { TestUpdatableReplicationEndpoint.class.wait(2000L); } } assertEquals(true, TestUpdatableReplicationEndpoint.hasCalledBack()); admin.removePeer(peerId); }
ReplicationPeerConfig.newBuilder().setClusterKey(utility2.getClusterKey()).build(); hbaseAdmin.addReplicationPeer(PEER_ID, rpc); Thread.sleep(SLEEP_TIME);
@BeforeClass public static void setUpBeforeClass() throws Exception { conf1 = HBaseConfiguration.create(); conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1"); conf1.setLong("replication.source.sleepforretries", 100); // Each WAL is about 120 bytes conf1.setInt(HConstants.REPLICATION_SOURCE_TOTAL_BUFFER_KEY, REPLICATION_SOURCE_QUOTA); conf1.setLong("replication.source.per.peer.node.bandwidth", 100L); utility1 = new HBaseTestingUtility(conf1); utility1.startMiniZKCluster(); MiniZooKeeperCluster miniZK = utility1.getZkCluster(); new ZKWatcher(conf1, "cluster1", null, true); conf2 = new Configuration(conf1); conf2.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2"); utility2 = new HBaseTestingUtility(conf2); utility2.setZkCluster(miniZK); new ZKWatcher(conf2, "cluster2", null, true); ReplicationAdmin admin1 = new ReplicationAdmin(conf1); ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(utility2.getClusterKey()); utility1.startMiniCluster(); utility2.startMiniCluster(); admin1.addPeer("peer1", rpc, null); admin1.addPeer("peer2", rpc, null); admin1.addPeer("peer3", rpc, null); numOfPeer = admin1.getPeersCount(); }
@Before public void setUpBase() throws Exception { if (!peerExist(PEER_ID2)) { ReplicationPeerConfigBuilder builder = ReplicationPeerConfig.newBuilder() .setClusterKey(utility2.getClusterKey()).setSerial(isSerialPeer()); if (isSyncPeer()) { FileSystem fs2 = utility2.getTestFileSystem(); // The remote wal dir is not important as we do not use it in DA state, here we only need to // confirm that a sync peer in DA state can still replicate data to remote cluster // asynchronously. builder.setReplicateAllUserTables(false) .setTableCFsMap(ImmutableMap.of(tableName, ImmutableList.of())) .setRemoteWALDir(new Path("/RemoteWAL") .makeQualified(fs2.getUri(), fs2.getWorkingDirectory()).toUri().toString()); } hbaseAdmin.addReplicationPeer(PEER_ID2, builder.build()); } }
int initialInvocations = RandomTimeoutBlockingRpcChannel.invokations.get(); RandomTimeoutRpcClient rpcClient = (RandomTimeoutRpcClient) RpcClientFactory .createClient(TEST_UTIL.getConfiguration(), TEST_UTIL.getClusterKey()); if (admin.getConnection().isClosed()) { rpcClient = (RandomTimeoutRpcClient) RpcClientFactory .createClient(TEST_UTIL.getConfiguration(), TEST_UTIL.getClusterKey());
private void addPeer(String id, int masterClusterNumber, int slaveClusterNumber, String tableCfs) throws Exception { try (Admin admin = ConnectionFactory.createConnection(configurations[masterClusterNumber]).getAdmin()) { admin.addReplicationPeer( id, new ReplicationPeerConfig().setClusterKey(utilities[slaveClusterNumber].getClusterKey()) .setReplicateAllUserTables(false) .setTableCFsMap(ReplicationPeerConfigUtil.parseTableCFsFromConfig(tableCfs))); } }
@Before public void setup() throws ReplicationException, IOException { root = TEST_UTIL.getDataTestDirOnTestFS(); rp.getPeerStorage().addPeer(peerId, ReplicationPeerConfig.newBuilder().setClusterKey(TEST_UTIL.getClusterKey()).build(), true, SyncReplicationState.NONE); rq.addPeerToHFileRefs(peerId); }
public static void createPeer() throws IOException { ReplicationPeerConfig rpc = ReplicationPeerConfig.newBuilder() .setClusterKey(UTIL.getClusterKey()).setSerial(true).build(); UTIL.getAdmin().addReplicationPeer(PEER_1, rpc); UTIL.getAdmin().addReplicationPeer(PEER_2, rpc); }
@Test public void testPeerNameControl() throws Exception { int exists = 0; rp.getPeerStorage().addPeer("6", ReplicationPeerConfig.newBuilder().setClusterKey(utility.getClusterKey()).build(), true, SyncReplicationState.NONE); try { rp.getPeerStorage().addPeer("6", ReplicationPeerConfig.newBuilder().setClusterKey(utility.getClusterKey()).build(), true, SyncReplicationState.NONE); } catch (ReplicationException e) { if (e.getCause() instanceof KeeperException.NodeExistsException) { exists++; } } assertEquals(1, exists); // clean up rp.getPeerStorage().removePeer("6"); }
new ReplicationPeerConfig().setClusterKey(utility2.getClusterKey()) .setReplicationEndpointImpl(FailureInjectingReplicationEndpointForTest.class.getName()), null);
"remoteWALs").makeQualified(fs2.getUri(), fs2.getWorkingDirectory()); UTIL1.getAdmin().addReplicationPeer(PEER_ID, ReplicationPeerConfig.newBuilder().setClusterKey(UTIL2.getClusterKey()) .setReplicateAllUserTables(false) .setTableCFsMap(ImmutableMap.of(TABLE_NAME, new ArrayList<>())) .setRemoteWALDir(REMOTE_WAL_DIR2.toUri().toString()).build()); UTIL2.getAdmin().addReplicationPeer(PEER_ID, ReplicationPeerConfig.newBuilder().setClusterKey(UTIL1.getClusterKey()) .setReplicateAllUserTables(false) .setTableCFsMap(ImmutableMap.of(TABLE_NAME, new ArrayList<>()))
new ReplicationPeerConfig().setClusterKey(utility2.getClusterKey()) .setReplicationEndpointImpl(ReplicationEndpointForTest.class.getName()), null);
rpc.setClusterKey(HTU2.getClusterKey()); admin.addPeer("2", rpc, null); admin.close();
ReplicationPeerConfig.newBuilder().setClusterKey(TEST_UTIL_PEER.getClusterKey()).build());
rpc.setClusterKey(utility2.getClusterKey()); admin1.addPeer("1", rpc, null); rpc.setClusterKey(utility3.getClusterKey()); admin1.addPeer("2", rpc, null);
protected void setupReplication() throws Exception { ReplicationAdmin admin1 = new ReplicationAdmin(conf1); ReplicationAdmin admin2 = new ReplicationAdmin(conf2); Admin ha = utility1.getAdmin(); ha.createTable(t1_syncupSource); ha.createTable(t2_syncupSource); ha.close(); ha = utility2.getAdmin(); ha.createTable(t1_syncupTarget); ha.createTable(t2_syncupTarget); ha.close(); Connection connection1 = ConnectionFactory.createConnection(utility1.getConfiguration()); Connection connection2 = ConnectionFactory.createConnection(utility2.getConfiguration()); // Get HTable from Master ht1Source = connection1.getTable(t1_su); ht2Source = connection1.getTable(t2_su); // Get HTable from Peer1 ht1TargetAtPeer1 = connection2.getTable(t1_su); ht2TargetAtPeer1 = connection2.getTable(t2_su); /** * set M-S : Master: utility1 Slave1: utility2 */ ReplicationPeerConfig rpc = new ReplicationPeerConfig(); rpc.setClusterKey(utility2.getClusterKey()); admin1.addPeer("1", rpc, null); admin1.close(); admin2.close(); }