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:
Andrew Kyle Purtell 2013-12-13 04:23:16 +00:00
parent 05f2b1dfac
commit 4c8631145e
2 changed files with 25 additions and 0 deletions

View File

@ -103,6 +103,7 @@ public class TableAuthManager {
private Configuration conf;
private ZKPermissionWatcher zkperms;
private volatile long mtime;
private TableAuthManager(ZooKeeperWatcher watcher, Configuration conf)
throws IOException {
@ -209,6 +210,7 @@ public class TableAuthManager {
}
}
globalCache = newCache;
mtime++;
} catch (IOException e) {
// Never happens
LOG.error("Error occured while updating the global cache", e);
@ -236,6 +238,7 @@ public class TableAuthManager {
}
tableCache.put(table, newTablePerms);
mtime++;
}
/**
@ -259,6 +262,7 @@ public class TableAuthManager {
}
nsCache.put(namespace, newTablePerms);
mtime++;
}
private PermissionCache<TablePermission> getTablePermissions(TableName table) {
@ -678,6 +682,10 @@ public class TableAuthManager {
serialized);
}
public long getMTime() {
return mtime;
}
static Map<ZooKeeperWatcher,TableAuthManager> managerMap =
new HashMap<ZooKeeperWatcher,TableAuthManager>();

View File

@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.LargeTests;
import org.apache.hadoop.hbase.Waiter.Predicate;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@ -108,7 +109,15 @@ public class TestZKPermissionsWatcher {
List<TablePermission> acl = new ArrayList<TablePermission>();
acl.add(new TablePermission(TEST_TABLE, null, TablePermission.Action.READ,
TablePermission.Action.WRITE));
final long mtimeB = AUTH_B.getMTime();
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);
// check it
@ -132,7 +141,15 @@ public class TestZKPermissionsWatcher {
// update ACL: hubert R
acl = new ArrayList<TablePermission>();
acl.add(new TablePermission(TEST_TABLE, null, TablePermission.Action.READ));
final long mtimeA = AUTH_A.getMTime();
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);
// check it