use of org.apache.hadoop.hbase.zookeeper.ZKWatcher in project hbase by apache.
the class TestZKSecretWatcher method newZK.
private static ZKWatcher newZK(Configuration conf, String name, Abortable abort) throws Exception {
Configuration copy = HBaseConfiguration.create(conf);
ZKWatcher zk = new ZKWatcher(copy, name, abort);
return zk;
}
use of org.apache.hadoop.hbase.zookeeper.ZKWatcher in project hbase by apache.
the class TestVisibilityLabelsReplication method setup.
@Before
public void setup() throws Exception {
// setup configuration
conf = HBaseConfiguration.create();
conf.setInt("hfile.format.version", 3);
conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/1");
conf.setInt("replication.source.size.capacity", 10240);
conf.setLong("replication.source.sleepforretries", 100);
conf.setInt("hbase.regionserver.maxlogs", 10);
conf.setLong("hbase.master.logcleaner.ttl", 10);
conf.setInt("zookeeper.recovery.retry", 1);
conf.setInt("zookeeper.recovery.retry.intervalmill", 10);
conf.setLong(HConstants.THREAD_WAKE_FREQUENCY, 100);
conf.setInt("replication.stats.thread.period.seconds", 5);
conf.setBoolean("hbase.tests.use.shortcircuit.reads", false);
setVisibilityLabelServiceImpl(conf);
conf.setStrings(HConstants.REPLICATION_CODEC_CONF_KEY, KeyValueCodecWithTags.class.getName());
VisibilityTestUtil.enableVisiblityLabels(conf);
conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, VisibilityReplication.class.getName());
conf.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, SimpleCP.class.getName());
// Have to reset conf1 in case zk cluster location different
// than default
conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class, ScanLabelGenerator.class);
conf.set("hbase.superuser", User.getCurrent().getShortName());
SUPERUSER = User.createUserForTesting(conf, User.getCurrent().getShortName(), new String[] { "supergroup" });
// User.createUserForTesting(conf, User.getCurrent().getShortName(), new
// String[] { "supergroup" });
USER1 = User.createUserForTesting(conf, "user1", new String[] {});
TEST_UTIL = new HBaseTestingUtil(conf);
TEST_UTIL.startMiniZKCluster();
MiniZooKeeperCluster miniZK = TEST_UTIL.getZkCluster();
zkw1 = new ZKWatcher(conf, "cluster1", null, true);
// Base conf2 on conf1 so it gets the right zk cluster.
conf1 = HBaseConfiguration.create(conf);
conf1.setInt("hfile.format.version", 3);
conf1.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/2");
conf1.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 6);
conf1.setBoolean("hbase.tests.use.shortcircuit.reads", false);
conf1.setStrings(HConstants.REPLICATION_CODEC_CONF_KEY, KeyValueCodecWithTags.class.getName());
conf1.setStrings(CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, TestCoprocessorForTagsAtSink.class.getName());
// setVisibilityLabelServiceImpl(conf1);
USER1 = User.createUserForTesting(conf1, "user1", new String[] {});
TEST_UTIL1 = new HBaseTestingUtil(conf1);
TEST_UTIL1.setZkCluster(miniZK);
zkw2 = new ZKWatcher(conf1, "cluster2", null, true);
TEST_UTIL.startMiniCluster(1);
// Wait for the labels table to become available
TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
TEST_UTIL1.startMiniCluster(1);
admin = TEST_UTIL.getAdmin();
ReplicationPeerConfig rpc = ReplicationPeerConfig.newBuilder().setClusterKey(TEST_UTIL1.getClusterKey()).build();
admin.addReplicationPeer("2", rpc);
Admin hBaseAdmin = TEST_UTIL.getAdmin();
TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(TABLE_NAME).setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(fam).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build()).build();
try {
hBaseAdmin.createTable(tableDescriptor);
} finally {
if (hBaseAdmin != null) {
hBaseAdmin.close();
}
}
Admin hBaseAdmin1 = TEST_UTIL1.getAdmin();
try {
hBaseAdmin1.createTable(tableDescriptor);
} finally {
if (hBaseAdmin1 != null) {
hBaseAdmin1.close();
}
}
addLabels();
setAuths(conf);
setAuths(conf1);
}
use of org.apache.hadoop.hbase.zookeeper.ZKWatcher in project hbase by apache.
the class TestTablePermissions method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
// setup configuration
Configuration conf = UTIL.getConfiguration();
SecureTestUtil.enableSecurity(conf);
UTIL.startMiniCluster();
// Wait for the ACL table to become available
UTIL.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME);
UTIL.waitTableAvailable(TableName.valueOf("hbase:acl"));
ZKW = new ZKWatcher(UTIL.getConfiguration(), "TestTablePermissions", ABORTABLE);
UTIL.createTable(TEST_TABLE, TEST_FAMILY);
UTIL.createTable(TEST_TABLE2, TEST_FAMILY);
}
use of org.apache.hadoop.hbase.zookeeper.ZKWatcher in project hbase by apache.
the class TestZKPermissionWatcher method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
// setup configuration
Configuration conf = UTIL.getConfiguration();
SecureTestUtil.enableSecurity(conf);
// start minicluster
UTIL.startMiniCluster();
AUTH_A = new AuthManager(conf);
AUTH_B = new AuthManager(conf);
WATCHER_A = new ZKPermissionWatcher(new ZKWatcher(conf, "TestZKPermissionsWatcher_1", ABORTABLE), AUTH_A, conf);
WATCHER_B = new ZKPermissionWatcher(new ZKWatcher(conf, "TestZKPermissionsWatcher_2", ABORTABLE), AUTH_B, conf);
WATCHER_A.start();
WATCHER_B.start();
}
use of org.apache.hadoop.hbase.zookeeper.ZKWatcher in project hbase by apache.
the class TestZKSecretWatcherRefreshKeys method testRefreshKeys.
@Test
public void testRefreshKeys() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
ZKWatcher zk = newZK(conf, "127.0.0.1", new MockAbortable());
AuthenticationTokenSecretManager keyManager = new AuthenticationTokenSecretManager(conf, zk, "127.0.0.1", 60 * 60 * 1000, 60 * 1000);
ZKSecretWatcher watcher = new ZKSecretWatcher(conf, zk, keyManager);
ZKUtil.deleteChildrenRecursively(zk, watcher.getKeysParentZNode());
Integer[] keys = { 1, 2, 3, 4, 5, 6 };
for (Integer key : keys) {
AuthenticationKey ak = new AuthenticationKey(key, EnvironmentEdgeManager.currentTime() + 600 * 1000, null);
ZKUtil.createWithParents(zk, ZNodePaths.joinZNode(watcher.getKeysParentZNode(), key.toString()), Writables.getBytes(ak));
}
Assert.assertNull(keyManager.getCurrentKey());
watcher.refreshKeys();
for (Integer key : keys) {
Assert.assertNotNull(keyManager.getKey(key.intValue()));
}
}
Aggregations