HADOOP-14543. ZKFC should use getAversion() while setting the zkacl. Contributed by Brahma Reddy Battula.
This commit is contained in:
parent
c6bd73c6c5
commit
0111711d8b
@ -1080,7 +1080,7 @@ public Void run() throws KeeperException, InterruptedException {
|
|||||||
List<ACL> acl = zkClient.getACL(path, stat);
|
List<ACL> acl = zkClient.getACL(path, stat);
|
||||||
if (acl == null || !acl.containsAll(zkAcl) ||
|
if (acl == null || !acl.containsAll(zkAcl) ||
|
||||||
!zkAcl.containsAll(acl)) {
|
!zkAcl.containsAll(acl)) {
|
||||||
zkClient.setACL(path, zkAcl, stat.getVersion());
|
zkClient.setACL(path, zkAcl, stat.getAversion());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
import org.apache.hadoop.ha.ActiveStandbyElector.State;
|
import org.apache.hadoop.ha.ActiveStandbyElector.State;
|
||||||
import org.apache.hadoop.util.ZKUtil.ZKAuthInfo;
|
import org.apache.hadoop.util.ZKUtil.ZKAuthInfo;
|
||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.zookeeper.CreateMode;
|
||||||
import org.apache.zookeeper.ZooDefs.Ids;
|
import org.apache.zookeeper.ZooDefs.Ids;
|
||||||
|
import org.apache.zookeeper.ZooKeeper;
|
||||||
import org.apache.zookeeper.server.ZooKeeperServer;
|
import org.apache.zookeeper.server.ZooKeeperServer;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.AdditionalMatchers;
|
import org.mockito.AdditionalMatchers;
|
||||||
@ -256,4 +258,30 @@ public void testDontJoinElectionOnDisconnectAndReconnect() throws Exception {
|
|||||||
Mockito.verify(cbs[1], Mockito.never()).becomeActive();
|
Mockito.verify(cbs[1], Mockito.never()).becomeActive();
|
||||||
checkFatalsAndReset();
|
checkFatalsAndReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test to verify that proper ZooKeeper ACLs can be updated on
|
||||||
|
* ActiveStandbyElector's parent znode.
|
||||||
|
*/
|
||||||
|
@Test(timeout = 15000)
|
||||||
|
public void testSetZooKeeperACLsOnParentZnodeName()
|
||||||
|
throws Exception {
|
||||||
|
ActiveStandbyElectorCallback cb =
|
||||||
|
Mockito.mock(ActiveStandbyElectorCallback.class);
|
||||||
|
ActiveStandbyElector elector =
|
||||||
|
new ActiveStandbyElector(hostPort, 5000, PARENT_DIR,
|
||||||
|
Ids.READ_ACL_UNSAFE, Collections.<ZKAuthInfo>emptyList(), cb,
|
||||||
|
CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_DEFAULT);
|
||||||
|
|
||||||
|
// Simulate the case by pre-creating znode 'parentZnodeName'. Then updates
|
||||||
|
// znode's data so that data version will be increased to 1. Here znode's
|
||||||
|
// aversion is 0.
|
||||||
|
ZooKeeper otherClient = createClient();
|
||||||
|
otherClient.create(PARENT_DIR, "sample1".getBytes(), Ids.OPEN_ACL_UNSAFE,
|
||||||
|
CreateMode.PERSISTENT);
|
||||||
|
otherClient.setData(PARENT_DIR, "sample2".getBytes(), -1);
|
||||||
|
otherClient.close();
|
||||||
|
|
||||||
|
elector.ensureParentZNode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user