You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/05/20 18:41:38 UTC
[GitHub] [zookeeper] lvfangmin commented on a change in pull request #1191: [ZOOKEEPER-3657] Implementing snapshot schedule to avoid high latency issue due to disk contention
lvfangmin commented on a change in pull request #1191:
URL: https://github.com/apache/zookeeper/pull/1191#discussion_r428231210
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Follower.java
##########
@@ -150,13 +157,95 @@ void followLeader() throws InterruptedException {
}
}
+ // Visible for testing
+ protected void snapPing(QuorumPacket qp) throws IOException {
+ int peerSnapPingVersion = -1;
+ long snapPingId = -1;
+ int snapCode = -1;
+ try {
+ ByteArrayInputStream bis = new ByteArrayInputStream(qp.getData());
+ DataInputStream dis = new DataInputStream(bis);
+ peerSnapPingVersion = dis.readInt();
+ snapPingId = dis.readLong();
+ snapCode = dis.readInt();
+ } catch (IOException e) {
+ LOG.error("Error while parsing SnapPing packet", e);
+ return;
+ }
+
+ if (peerSnapPingVersion != SnapPingManager.SNAP_PING_VERSION) {
+ LOG.warn("The SnapPing version on leader is {} which is not "
+ + "compatible with ours {}, will skip", peerSnapPingVersion,
+ SnapPingManager.SNAP_PING_VERSION);
+ if (fzk.syncProcessor.isOnlySnapWhenSafetyIsThreatened()) {
+ LOG.info("SnapPing version incompatible, start self snapshot");
+ fzk.syncProcessor.setOnlySnapWhenSafetyIsThreatened(false);
+ }
+ return;
+ }
+
+ if (snapCode == SnapPingCode.CANCEL.ordinal()) {
Review comment:
That's a good point, it seems more natural to use enum for these code, I'll add a comment to the enum to WARN ordering changes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org