Skip to content

Commit

Permalink
recover zookeeper master same with apache:master
Browse files Browse the repository at this point in the history
  • Loading branch information
brettKK committed Apr 22, 2018
1 parent 700dfb7 commit c4db5e2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ public synchronized void deserialize(InputArchive ia) throws IOException {
}
List<ACL> aclList = new ArrayList<ACL>();
Index j = ia.startVector("acls");
if (j == null) {
LOG.error("ERROR: incorrent format of InputArchive" + ia);
throw new RuntimeException("ERROR: incorrent format of InputArchive" + ia);
}
while (!j.done()) {
ACL acl = new ACL();
acl.deserialize(ia, "acl");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ void followLeader() throws InterruptedException {
fzk.registerJMX(new FollowerBean(this, zk), self.jmxLocalPeerBean);
try {
QuorumServer leaderServer = findLeader();
if (leaderServer == null) {
LOG.error("found no leader");
throw new Exception("found no leader");
}
try {
connectToLeader(leaderServer.addr, leaderServer.hostname);
long newEpochZxid = registerWithLeader(Leader.FOLLOWERINFO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import org.apache.jute.BinaryInputArchive;
import org.apache.jute.BinaryOutputArchive;
import org.apache.jute.InputArchive;
import org.apache.jute.OutputArchive;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
Expand Down Expand Up @@ -193,32 +191,6 @@ public void testSerializeDeserialize() throws IOException {
assertCachesEqual(cache, deserializedCache);
}

@Test
public void testNPEInDeserialize() throws IOException {
ReferenceCountedACLCache serializeCache = new ReferenceCountedACLCache(){
@Override
public synchronized void serialize(OutputArchive oa) throws IOException {
oa.writeInt(1, "map");
oa.writeLong(1, "long");
oa.startVector(null, "acls");
oa.endVector(null, "acls");
}
};
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive archive = BinaryOutputArchive.getArchive(baos);
serializeCache.serialize(archive);

BinaryInputArchive inArchive = BinaryInputArchive.getArchive(new ByteArrayInputStream(baos.toByteArray()));
ReferenceCountedACLCache deserializedCache = new ReferenceCountedACLCache();
try{
deserializedCache.deserialize(inArchive);
}catch (NullPointerException e){
fail("should not throw NPE while do deserialized");
}catch (RuntimeException e) {
// do nothing.
}
}

private void assertCachesEqual(ReferenceCountedACLCache expected, ReferenceCountedACLCache actual){
assertEquals(expected.aclIndex, actual.aclIndex);
assertEquals(expected.aclKeyMap, actual.aclKeyMap);
Expand Down

0 comments on commit c4db5e2

Please sign in to comment.