Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we reading the system property and parsing the value at every call of shouldThrottle ?
can't we cache the value ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the case. This is just a dumb revert, please see #712 as another approach for the same issue.

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