public Stat setACL(String path, List<ACL> acl, int version) throws KeeperException.NoNodeException { Stat stat = new Stat(); DataNode n = nodes.get(path); if (n == null) { throw new KeeperException.NoNodeException(); } synchronized (n) { aclCache.removeUsage(n.acl); n.stat.setAversion(version); n.acl = aclCache.convertAcls(acl); n.copyStat(stat); return stat; } }
public Stat setACL(String path, List<ACL> acl, int version) throws KeeperException.NoNodeException { Stat stat = new Stat(); DataNode n = nodes.get(path); if (n == null) { throw new KeeperException.NoNodeException(); } synchronized (n) { aclCache.removeUsage(n.acl); n.stat.setAversion(version); n.acl = aclCache.convertAcls(acl); n.copyStat(stat); return stat; } }
aclCache.removeUsage(node.acl); nodeDataSize.addAndGet(-getNodeSize(path, node.data));
aclCache.removeUsage(node.acl);
@Test public void testAddUsage() { List<ACL> testACL = createACL("myid"); ReferenceCountedACLCache cache = new ReferenceCountedACLCache(); Long aclId = cache.convertAcls(testACL); assertEquals(1, cache.size()); cache.addUsage(aclId); assertEquals(1, cache.size()); cache.removeUsage(aclId); assertEquals(1, cache.size()); cache.removeUsage(aclId); assertEquals(0, cache.size()); }
@Test public void testAddThenRemove() { List<ACL> testACL = createACL("myid"); ReferenceCountedACLCache cache = new ReferenceCountedACLCache(); Long aclId = cache.convertAcls(testACL); assertEquals(1, cache.size()); cache.removeUsage(aclId); assertEquals(0, cache.size()); }
@Test public void testMultipleAddsAndRemove() { List<ACL> testACL = createACL("myid"); ReferenceCountedACLCache cache = new ReferenceCountedACLCache(); Long aclId = cache.convertAcls(testACL); assertEquals(1, cache.size()); cache.convertAcls(testACL); assertEquals(1, cache.size()); List<ACL> testACL2 = createACL("anotherId"); cache.convertAcls(testACL2); cache.removeUsage(aclId); assertEquals(2, cache.size()); cache.removeUsage(aclId); assertEquals(1, cache.size()); Long newId = cache.convertAcls(testACL); assertFalse(aclId.equals(newId)); }