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 2021/06/14 07:51:11 UTC
[GitHub] [zookeeper] li4wang commented on a change in pull request #1691: ZOOKEEPER-4284: Add metrics for observer sync time
li4wang commented on a change in pull request #1691:
URL: https://github.com/apache/zookeeper/pull/1691#discussion_r650644609
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Observer.java
##########
@@ -114,11 +115,17 @@ void observeLeader() throws Exception {
throw new Exception("learned about role change");
}
- self.setLeaderAddressAndId(master.addr, master.getId());
- self.setZabState(QuorumPeer.ZabState.SYNCHRONIZATION);
- syncWithLeader(newLeaderZxid);
- self.setZabState(QuorumPeer.ZabState.BROADCAST);
- completedSync = true;
+ final long startTime = Time.currentElapsedTime();
+ try {
+ self.setLeaderAddressAndId(master.addr, master.getId());
+ self.setZabState(QuorumPeer.ZabState.SYNCHRONIZATION);
+ syncWithLeader(newLeaderZxid);
+ self.setZabState(QuorumPeer.ZabState.BROADCAST);
+ completedSync = true;
+ } finally {
+ final long syncTime = Time.currentElapsedTime() - startTime;
+ ServerMetrics.getMetrics().OBSERVER_SYNC_TIME.add(syncTime);
Review comment:
Agreed. Changed.
I have also opened a JIRA for fix the follower sync time and will submit the fix shortly. https://issues.apache.org/jira/browse/ZOOKEEPER-4318
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Observer.java
##########
@@ -114,11 +115,17 @@ void observeLeader() throws Exception {
throw new Exception("learned about role change");
}
- self.setLeaderAddressAndId(master.addr, master.getId());
- self.setZabState(QuorumPeer.ZabState.SYNCHRONIZATION);
- syncWithLeader(newLeaderZxid);
- self.setZabState(QuorumPeer.ZabState.BROADCAST);
- completedSync = true;
+ final long startTime = Time.currentElapsedTime();
+ try {
+ self.setLeaderAddressAndId(master.addr, master.getId());
+ self.setZabState(QuorumPeer.ZabState.SYNCHRONIZATION);
+ syncWithLeader(newLeaderZxid);
+ self.setZabState(QuorumPeer.ZabState.BROADCAST);
+ completedSync = true;
+ } finally {
+ final long syncTime = Time.currentElapsedTime() - startTime;
+ ServerMetrics.getMetrics().OBSERVER_SYNC_TIME.add(syncTime);
Review comment:
Agreed. Changed.
I have also opened a JIRA for fix the follower sync time and will submit the fix shortly. https://issues.apache.org/jira/browse/ZOOKEEPER-4318
Would you mind taking a quick look at the change?
##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/Observer.java
##########
@@ -114,11 +115,17 @@ void observeLeader() throws Exception {
throw new Exception("learned about role change");
}
- self.setLeaderAddressAndId(master.addr, master.getId());
- self.setZabState(QuorumPeer.ZabState.SYNCHRONIZATION);
- syncWithLeader(newLeaderZxid);
- self.setZabState(QuorumPeer.ZabState.BROADCAST);
- completedSync = true;
+ final long startTime = Time.currentElapsedTime();
+ try {
+ self.setLeaderAddressAndId(master.addr, master.getId());
+ self.setZabState(QuorumPeer.ZabState.SYNCHRONIZATION);
+ syncWithLeader(newLeaderZxid);
+ self.setZabState(QuorumPeer.ZabState.BROADCAST);
+ completedSync = true;
+ } finally {
+ final long syncTime = Time.currentElapsedTime() - startTime;
+ ServerMetrics.getMetrics().OBSERVER_SYNC_TIME.add(syncTime);
Review comment:
Agreed. Changed.
I have also opened a JIRA for fix the follower sync time and will submit the fix shortly. https://issues.apache.org/jira/browse/ZOOKEEPER-4318
@hanm Would you mind taking a quick look at the change?
--
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