HBASE-10149. TestZKPermissionsWatcher.testPermissionsWatcher test failure
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1550632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
05f2b1dfac
commit
4c8631145e
|
@ -103,6 +103,7 @@ public class TableAuthManager {
|
||||||
|
|
||||||
private Configuration conf;
|
private Configuration conf;
|
||||||
private ZKPermissionWatcher zkperms;
|
private ZKPermissionWatcher zkperms;
|
||||||
|
private volatile long mtime;
|
||||||
|
|
||||||
private TableAuthManager(ZooKeeperWatcher watcher, Configuration conf)
|
private TableAuthManager(ZooKeeperWatcher watcher, Configuration conf)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
@ -209,6 +210,7 @@ public class TableAuthManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globalCache = newCache;
|
globalCache = newCache;
|
||||||
|
mtime++;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Never happens
|
// Never happens
|
||||||
LOG.error("Error occured while updating the global cache", e);
|
LOG.error("Error occured while updating the global cache", e);
|
||||||
|
@ -236,6 +238,7 @@ public class TableAuthManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
tableCache.put(table, newTablePerms);
|
tableCache.put(table, newTablePerms);
|
||||||
|
mtime++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -259,6 +262,7 @@ public class TableAuthManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCache.put(namespace, newTablePerms);
|
nsCache.put(namespace, newTablePerms);
|
||||||
|
mtime++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PermissionCache<TablePermission> getTablePermissions(TableName table) {
|
private PermissionCache<TablePermission> getTablePermissions(TableName table) {
|
||||||
|
@ -678,6 +682,10 @@ public class TableAuthManager {
|
||||||
serialized);
|
serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getMTime() {
|
||||||
|
return mtime;
|
||||||
|
}
|
||||||
|
|
||||||
static Map<ZooKeeperWatcher,TableAuthManager> managerMap =
|
static Map<ZooKeeperWatcher,TableAuthManager> managerMap =
|
||||||
new HashMap<ZooKeeperWatcher,TableAuthManager>();
|
new HashMap<ZooKeeperWatcher,TableAuthManager>();
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.Abortable;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.LargeTests;
|
import org.apache.hadoop.hbase.LargeTests;
|
||||||
|
import org.apache.hadoop.hbase.Waiter.Predicate;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -108,7 +109,15 @@ public class TestZKPermissionsWatcher {
|
||||||
List<TablePermission> acl = new ArrayList<TablePermission>();
|
List<TablePermission> acl = new ArrayList<TablePermission>();
|
||||||
acl.add(new TablePermission(TEST_TABLE, null, TablePermission.Action.READ,
|
acl.add(new TablePermission(TEST_TABLE, null, TablePermission.Action.READ,
|
||||||
TablePermission.Action.WRITE));
|
TablePermission.Action.WRITE));
|
||||||
|
final long mtimeB = AUTH_B.getMTime();
|
||||||
AUTH_A.setTableUserPermissions("george", TEST_TABLE, acl);
|
AUTH_A.setTableUserPermissions("george", TEST_TABLE, acl);
|
||||||
|
// Wait for the update to propagate
|
||||||
|
UTIL.waitFor(10000, 100, new Predicate<Exception>() {
|
||||||
|
@Override
|
||||||
|
public boolean evaluate() throws Exception {
|
||||||
|
return AUTH_B.getMTime() > mtimeB;
|
||||||
|
}
|
||||||
|
});
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
// check it
|
// check it
|
||||||
|
@ -132,7 +141,15 @@ public class TestZKPermissionsWatcher {
|
||||||
// update ACL: hubert R
|
// update ACL: hubert R
|
||||||
acl = new ArrayList<TablePermission>();
|
acl = new ArrayList<TablePermission>();
|
||||||
acl.add(new TablePermission(TEST_TABLE, null, TablePermission.Action.READ));
|
acl.add(new TablePermission(TEST_TABLE, null, TablePermission.Action.READ));
|
||||||
|
final long mtimeA = AUTH_A.getMTime();
|
||||||
AUTH_B.setTableUserPermissions("hubert", TEST_TABLE, acl);
|
AUTH_B.setTableUserPermissions("hubert", TEST_TABLE, acl);
|
||||||
|
// Wait for the update to propagate
|
||||||
|
UTIL.waitFor(10000, 100, new Predicate<Exception>() {
|
||||||
|
@Override
|
||||||
|
public boolean evaluate() throws Exception {
|
||||||
|
return AUTH_A.getMTime() > mtimeA;
|
||||||
|
}
|
||||||
|
});
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
// check it
|
// check it
|
||||||
|
|
Loading…
Reference in New Issue