Skip to content

Commit

Permalink
ZOOKEEPER-3177: Revert globalOutstandingLimit refactoring changes
Browse files Browse the repository at this point in the history
Hopefully this will fix the findBugs issue on master in the right way.
lvfangmin hanm Please validate.

Author: Andor Molnar <andor@apache.org>

Reviewers: Michael Han <hanm@apache.org>, Enrico Olivelli <eolivelli@gmail.com>

Closes apache#711 from anmolnar/ZOOKEEPER-3177
  • Loading branch information
anmolnar authored and hanm committed Nov 21, 2018
1 parent 9146054 commit 1507f67
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,11 @@ public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
protected static final Logger LOG;

public static final String GLOBAL_OUTSTANDING_LIMIT = "zookeeper.globalOutstandingLimit";
protected static int globalOutstandingLimit = 1000;

static {
LOG = LoggerFactory.getLogger(ZooKeeperServer.class);

Environment.logEnv("Server environment:", LOG);

globalOutstandingLimit = Integer.getInteger(GLOBAL_OUTSTANDING_LIMIT, 1000);
LOG.info("{} = {}", GLOBAL_OUTSTANDING_LIMIT, globalOutstandingLimit);
}

protected ZooKeeperServerBean jmxServerBean;
Expand Down Expand Up @@ -864,6 +860,17 @@ public static int getSnapCount() {
}
}

public int getGlobalOutstandingLimit() {
String sc = System.getProperty(GLOBAL_OUTSTANDING_LIMIT);
int limit;
try {
limit = Integer.parseInt(sc);
} catch (Exception e) {
limit = 1000;
}
return limit;
}

public void setServerCnxnFactory(ServerCnxnFactory factory) {
serverCnxnFactory = factory;
}
Expand Down Expand Up @@ -1090,7 +1097,7 @@ public void processConnectRequest(ServerCnxn cnxn, ByteBuffer incomingBuffer) th
}

public boolean shouldThrottle(long outStandingCount) {
if (globalOutstandingLimit < getInProcess()) {
if (getGlobalOutstandingLimit() < getInProcess()) {
return outStandingCount > 0;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ public class FollowerZooKeeperServer extends LearnerZooKeeperServer {
super(logFactory, self.tickTime, self.minSessionTimeout,
self.maxSessionTimeout, zkDb, self);
this.pendingSyncs = new ConcurrentLinkedQueue<Request>();

int divisor = self.getQuorumSize() > 2 ? self.getQuorumSize() - 1 : 1;
globalOutstandingLimit = Integer.getInteger(GLOBAL_OUTSTANDING_LIMIT, 1000) / divisor;
LOG.info("Override {} to {}", GLOBAL_OUTSTANDING_LIMIT, globalOutstandingLimit);
}

public Follower getFollower(){
Expand Down Expand Up @@ -126,6 +122,14 @@ synchronized public void sync(){
commitProcessor.commit(r);
}

@Override
public int getGlobalOutstandingLimit() {
int divisor = self.getQuorumSize() > 2 ? self.getQuorumSize() - 1 : 1;
int globalOutstandingLimit = super.getGlobalOutstandingLimit() / divisor;
LOG.info("Override {} to {}", GLOBAL_OUTSTANDING_LIMIT, globalOutstandingLimit);
return globalOutstandingLimit;
}

@Override
public String getState() {
return "follower";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public class LeaderZooKeeperServer extends QuorumZooKeeperServer {
*/
LeaderZooKeeperServer(FileTxnSnapLog logFactory, QuorumPeer self, ZKDatabase zkDb) throws IOException {
super(logFactory, self.tickTime, self.minSessionTimeout, self.maxSessionTimeout, zkDb, self);

int divisor = self.getQuorumSize() > 2 ? self.getQuorumSize() - 1 : 1;
globalOutstandingLimit = Integer.getInteger(GLOBAL_OUTSTANDING_LIMIT, 1000) / divisor;
LOG.info("Override {} to {}", GLOBAL_OUTSTANDING_LIMIT, globalOutstandingLimit);
}

public Leader getLeader(){
Expand Down Expand Up @@ -106,6 +102,14 @@ public synchronized void shutdown() {
super.shutdown();
}

@Override
public int getGlobalOutstandingLimit() {
int divisor = self.getQuorumSize() > 2 ? self.getQuorumSize() - 1 : 1;
int globalOutstandingLimit = super.getGlobalOutstandingLimit() / divisor;
LOG.info("Override {} to {}", GLOBAL_OUTSTANDING_LIMIT, globalOutstandingLimit);
return globalOutstandingLimit;
}

@Override
public void createSessionTracker() {
sessionTracker = new LeaderSessionTracker(
Expand Down

0 comments on commit 1507f67

Please sign in to comment.