use of org.apache.hadoop.hbase.replication.ReplicationPeerConfig in project hbase by apache.
the class TestReplicationAdmin method testNamespacesAndTableCfsConfigConflict.
@Test
public void testNamespacesAndTableCfsConfigConflict() throws Exception {
String ns1 = "ns1";
String ns2 = "ns2";
final TableName tableName1 = TableName.valueOf(ns1 + ":" + name.getMethodName());
final TableName tableName2 = TableName.valueOf(ns2 + ":" + name.getMethodName() + "2");
ReplicationPeerConfig rpc = new ReplicationPeerConfig();
rpc.setClusterKey(KEY_ONE);
hbaseAdmin.addReplicationPeer(ID_ONE, rpc);
rpc = admin.getPeerConfig(ID_ONE);
Set<String> namespaces = new HashSet<String>();
namespaces.add(ns1);
rpc.setNamespaces(namespaces);
admin.updatePeerConfig(ID_ONE, rpc);
rpc = admin.getPeerConfig(ID_ONE);
Map<TableName, List<String>> tableCfs = new HashMap<>();
tableCfs.put(tableName1, new ArrayList<>());
rpc.setTableCFsMap(tableCfs);
try {
admin.updatePeerConfig(ID_ONE, rpc);
fail("Should throw ReplicationException, because table " + tableName1 + " conflict with namespace " + ns1);
} catch (IOException e) {
// OK
}
rpc = admin.getPeerConfig(ID_ONE);
tableCfs.clear();
tableCfs.put(tableName2, new ArrayList<>());
rpc.setTableCFsMap(tableCfs);
admin.updatePeerConfig(ID_ONE, rpc);
rpc = admin.getPeerConfig(ID_ONE);
namespaces.clear();
namespaces.add(ns2);
rpc.setNamespaces(namespaces);
try {
admin.updatePeerConfig(ID_ONE, rpc);
fail("Should throw ReplicationException, because namespace " + ns2 + " conflict with table " + tableName2);
} catch (IOException e) {
// OK
}
admin.removePeer(ID_ONE);
}
use of org.apache.hadoop.hbase.replication.ReplicationPeerConfig in project hbase by apache.
the class TestReplicationAdmin method testSetPeerNamespaces.
@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 = admin.getPeerConfig(ID_ONE);
Set<String> namespaces = new HashSet<>();
namespaces.add(ns1);
namespaces.add(ns2);
rpc.setNamespaces(namespaces);
admin.updatePeerConfig(ID_ONE, rpc);
namespaces = admin.getPeerConfig(ID_ONE).getNamespaces();
assertEquals(2, namespaces.size());
assertTrue(namespaces.contains(ns1));
assertTrue(namespaces.contains(ns2));
rpc = admin.getPeerConfig(ID_ONE);
namespaces.clear();
namespaces.add(ns1);
rpc.setNamespaces(namespaces);
admin.updatePeerConfig(ID_ONE, rpc);
namespaces = admin.getPeerConfig(ID_ONE).getNamespaces();
assertEquals(1, namespaces.size());
assertTrue(namespaces.contains(ns1));
admin.removePeer(ID_ONE);
}
use of org.apache.hadoop.hbase.replication.ReplicationPeerConfig in project hbase by apache.
the class TestReplicationAdminWithClusters method testReplicationPeerConfigUpdateCallback.
@Test(timeout = 300000)
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());
}
use of org.apache.hadoop.hbase.replication.ReplicationPeerConfig in project hbase by apache.
the class TestReplicationAdminWithTwoDifferentZKClusters method setUpBeforeClass.
@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);
}
use of org.apache.hadoop.hbase.replication.ReplicationPeerConfig in project hbase by apache.
the class TestReplicationAdmin method testEnableDisable.
/**
* basic checks that when we add a peer that it is enabled, and that we can disable
* @throws Exception
*/
@Test
public void testEnableDisable() throws Exception {
ReplicationPeerConfig rpc1 = new ReplicationPeerConfig();
rpc1.setClusterKey(KEY_ONE);
admin.addPeer(ID_ONE, rpc1, null);
assertEquals(1, admin.getPeersCount());
assertTrue(admin.getPeerState(ID_ONE));
admin.disablePeer(ID_ONE);
assertFalse(admin.getPeerState(ID_ONE));
try {
admin.getPeerState(ID_SECOND);
} catch (ReplicationPeerNotFoundException e) {
// OK!
}
admin.removePeer(ID_ONE);
}
Aggregations