Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 1098243] Remove redundant request limit configuration options and…
Browse files Browse the repository at this point in the history
… make the warmup periods configurable through the UI
  • Loading branch information
Michael Burman committed Jan 7, 2015
1 parent 6676bc1 commit e8a902e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 72 deletions.
Expand Up @@ -912,14 +912,6 @@ rhq.storage.gossip-port=${default.rhq.storage.gossip-port}
# Defaults 30,000 if undefined.. If specified the value is parsed as a double.
rhq.storage.request.limit.topology-delta=30000

# When a request times out, the request limit as specified by
# rhq.storage.request.limit will be decreased. The change will be persisted to
# this file. The value is parsed as a double and should be expressed as a
# percentage (i.e., a value between 0 and 1). For example, a value of 0.3 means
# that on a request timeout, the the request limit will decrease by 30%.
# Defaults to 0.2 if undefined.
rhq.storage.request.limit.timeout-delta=0.2

# If a request timeout occurs, there is a good possibility that it could be
# followed by successive timeouts due to read/write patterns. This property
# specifies a dampening period such that the request throughput will only be
Expand All @@ -928,10 +920,17 @@ rhq.storage.request.limit.timeout-delta=0.2
# as a long.
rhq.storage.request.limit.timeout-dampening=30000

# Sets the maximum throttling. In other words, the request limit will not
# decrease lower than this value. Defaults to 5,000 if undefined. The value is
# parsed as a double.
rhq.storage.request.limit.min=5000
# The warmup time during which the request limit is allowed to grow from
# 50% of the maximum to 100% of the set request limit value. The value is
# in minutes. Defaults to 3 minutes if undefined.
rhq.storage.request.limit.warmup-period=3

# Sets the maximum throttling value for warmup periods. If a timeout occurs,
# the request rate is halved with increased warmup period (as configured above).
# This setting limits the maximum the warmup is allowed to grow to and can be
# counted as warmup-period * max-warmup-counter, which is by default 30 mins.
# This value defaults to 10 if undefined.
rhq.storage.request.limit.max-warmup-counter=10

##############################################################################
# Metrics aggregation settings
Expand Down
Expand Up @@ -21,10 +21,10 @@

import static org.rhq.server.metrics.StorageClientConstants.DATA_CENTER;
import static org.rhq.server.metrics.StorageClientConstants.LOAD_BALANCING;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_LIMIT_MIN;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_TIMEOUT_DAMPENING;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_TIMEOUT_DELTA;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_TOPOLOGY_CHANGE_DELTA;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_WARMUP_PERIOD;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_WARMUP_PERIOD_MAX_COUNTER;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -386,41 +386,47 @@ public double getRequestLimit() {

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public double getMinRequestLimit() {
return session.getMinRequestLimit();
public double getRequestLimitTopologyDelta() {
return session.getTopologyDelta();
}

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setMinRequestLimit(double minRequestLimit) {
session.setMinRequestLimit(minRequestLimit);
persistStorageProperty(REQUEST_LIMIT_MIN, Double.toString(minRequestLimit));
public void setRequestWarmupPeriod(int requestWarmupPeriod) {
session.setWarmupTimePeriod(requestWarmupPeriod);
persistStorageProperty(REQUEST_WARMUP_PERIOD, Integer.toString(requestWarmupPeriod));
}

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public double getRequestLimitTopologyDelta() {
return session.getTopologyDelta();
public int getRequestWarmupPeriod() {
return session.getWarmupTimePeriod();
}

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setRequestLimitTopologyDelta(double delta) {
session.setTopologyDelta(delta);
persistStorageProperty(REQUEST_TOPOLOGY_CHANGE_DELTA, Double.toString(delta));
public void setRequestWarmupCounterMaximum(int requestWarmupCounterMaximum) {
session.setWarmupTimePeriod(requestWarmupCounterMaximum);
persistStorageProperty(REQUEST_WARMUP_PERIOD_MAX_COUNTER, Integer.toString(requestWarmupCounterMaximum));
}

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public double getRequestTimeoutDelta() {
return session.getTimeoutDelta();
public int getRequestWarmupCounterMaximum() {
return session.getMaxWarmupCounter();
}

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setRequestTimeoutDelta(double requestTimeoutDelta) {
session.setTimeoutDelta(requestTimeoutDelta);
persistStorageProperty(REQUEST_TIMEOUT_DELTA, Double.toString(requestTimeoutDelta));
public int getCurrentWarmupTime() {
return session.getPreviousWarmupTime();
}

@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setRequestLimitTopologyDelta(double delta) {
session.setTopologyDelta(delta);
persistStorageProperty(REQUEST_TOPOLOGY_CHANGE_DELTA, Double.toString(delta));
}

@Override
Expand Down
Expand Up @@ -26,17 +26,19 @@ public interface StorageClientManagerMBean {

double getRequestLimit();

double getMinRequestLimit();
double getRequestLimitTopologyDelta();

void setMinRequestLimit(double minRequestLimit);
void setRequestWarmupPeriod(int requestWarmupPeriod);

double getRequestLimitTopologyDelta();
int getRequestWarmupPeriod();

void setRequestLimitTopologyDelta(double delta);
void setRequestWarmupCounterMaximum(int requestWarmupCounterMaximum);

double getRequestTimeoutDelta();
int getRequestWarmupCounterMaximum();

void setRequestTimeoutDelta(double requestTimeoutDelta);
int getCurrentWarmupTime();

void setRequestLimitTopologyDelta(double delta);

long getRequestTimeoutDampening();

Expand Down
Expand Up @@ -24,9 +24,9 @@
*/
public class StorageClientConstants {

public static final String REQUEST_LIMIT_MIN = "rhq.storage.request.limit.min";
public static final String REQUEST_WARMUP_PERIOD = "rhq.storage.request.limit.warmup-period";

public static final String REQUEST_TIMEOUT_DELTA = "rhq.storage.request.limit.timeout-delta";
public static final String REQUEST_WARMUP_PERIOD_MAX_COUNTER = "rhq.storage.request.limit.max-warmup-counter";

public static final String REQUEST_TIMEOUT_DAMPENING = "rhq.storage.request.timeout-dampening";

Expand Down
Expand Up @@ -19,9 +19,9 @@

package org.rhq.server.metrics;

import static org.rhq.server.metrics.StorageClientConstants.REQUEST_LIMIT_MIN;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_WARMUP_PERIOD;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_WARMUP_PERIOD_MAX_COUNTER;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_TIMEOUT_DAMPENING;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_TIMEOUT_DELTA;
import static org.rhq.server.metrics.StorageClientConstants.REQUEST_TOPOLOGY_CHANGE_DELTA;

import java.math.BigDecimal;
Expand Down Expand Up @@ -51,9 +51,9 @@
*/
public class StorageSession implements Host.StateListener {

private static final int DEFAULT_WARMUP_TIME_IN_MINUTES = 3;
private static final int MAX_WARMUP_COUNTER = 10;
private int previousWarmupTime = DEFAULT_WARMUP_TIME_IN_MINUTES;
private int warmupTimePeriod = Integer.parseInt(System.getProperty(REQUEST_WARMUP_PERIOD, "3"));
private int maxWarmupCounter = Integer.parseInt(System.getProperty(REQUEST_WARMUP_PERIOD_MAX_COUNTER, "10"));
private int previousWarmupTime = warmupTimePeriod;

private final Log log = LogFactory.getLog(StorageSession.class);

Expand All @@ -63,12 +63,8 @@ public class StorageSession implements Host.StateListener {

private boolean isClusterAvailable = false;

private double minRequestLimit = Double.parseDouble(System.getProperty(REQUEST_LIMIT_MIN, "5000"));

private RateLimiter permits = null;

private double timeoutDelta = Double.parseDouble(System.getProperty(REQUEST_TIMEOUT_DELTA, "0.2"));

private long permitsLastChanged = System.currentTimeMillis();

private long timeoutDampening = Long.parseLong(System.getProperty(REQUEST_TIMEOUT_DAMPENING, "30000"));
Expand All @@ -78,7 +74,7 @@ public class StorageSession implements Host.StateListener {
public StorageSession(Session wrappedSession) {
this.wrappedSession = wrappedSession;
this.wrappedSession.getCluster().register(this);
permits = getRateLimiter(DEFAULT_WARMUP_TIME_IN_MINUTES);
permits = getRateLimiter(warmupTimePeriod);
}

private RateLimiter getRateLimiter(int warmupTime) {
Expand Down Expand Up @@ -121,30 +117,14 @@ public double getRequestLimit() {
return new BigDecimal(permits.getRate(), new MathContext(2, RoundingMode.HALF_UP)).doubleValue();
}

public double getTimeoutDelta() {
return timeoutDelta;
}

public void setTimeoutDelta(double timeoutDelta) {
this.timeoutDelta = timeoutDelta;
}

public double getMinRequestLimit() {
return minRequestLimit;
}

public void setMinRequestLimit(double minRequestLimit) {
this.minRequestLimit = minRequestLimit;
}

public double getTopologyDelta() {
return topologyDelta;
}

public synchronized void setTopologyDelta(double delta) {
topologyDelta = delta;
// On delta change, reset warmup period
previousWarmupTime = DEFAULT_WARMUP_TIME_IN_MINUTES;
previousWarmupTime = warmupTimePeriod;
setRequestLimit();
}

Expand Down Expand Up @@ -272,8 +252,8 @@ void handleNoHostAvailable(NoHostAvailableException e) {
synchronized void handleTimeout() {
if (System.currentTimeMillis() - permitsLastChanged > timeoutDampening) {
int warmupTime = previousWarmupTime;
if(previousWarmupTime < (MAX_WARMUP_COUNTER * DEFAULT_WARMUP_TIME_IN_MINUTES)) {
warmupTime += DEFAULT_WARMUP_TIME_IN_MINUTES;
if(previousWarmupTime < (maxWarmupCounter * warmupTimePeriod)) {
warmupTime += warmupTimePeriod;
previousWarmupTime = warmupTime;
}
permits = getRateLimiter(warmupTime);
Expand Down Expand Up @@ -307,4 +287,24 @@ private void fireClusterDownEvent(NoHostAvailableException e) {
listener.onStorageClusterDown(e);
}
}

public int getWarmupTimePeriod() {
return warmupTimePeriod;
}

public void setWarmupTimePeriod(int warmupTimePeriod) {
this.warmupTimePeriod = warmupTimePeriod;
}

public int getMaxWarmupCounter() {
return maxWarmupCounter;
}

public void setMaxWarmupCounter(int maxWarmupCounter) {
this.maxWarmupCounter = maxWarmupCounter;
}

public int getPreviousWarmupTime() {
return previousWarmupTime;
}
}
Expand Up @@ -441,20 +441,22 @@

<metric property="ConnectionErrors" measurementType="trendsup" displayType="summary" description="Number of times the connection failed to the storage node." />

<metric property="CurrentWarmupTime" measurementType="dynamic" displayType="summary" description="Current throttling warmup period time in minutes." />

<resource-configuration>
<c:simple-property name="RequestLimit" type="double" required="false" description="Sets throttling in terms of
requests per second. Defaults to 30,000 if undefined. Note that this setting is automatically
changed when various events such as request timeouts occur." readOnly="true"/>
<c:simple-property name="MinRequestLimit" type="double" displayName="Minimum Request Limit" required="false"
description="This sets a minimum threshold for the request limit. If the request limit is
automatically decreased, it will never drop below this value."/>
<c:simple-property name="RequestLimitTopologyDelta" displayName="Request Limit Topology Change Delta"
required="false" description="The request limit will automatically change by this amount when
there is a topology change event. Topology change events include nodes being added/removed and
nodes going up/down. Defaults to 30,000 if undefined."/>
<c:simple-property name="RequestTimeoutDelta" type="double" required="false" description="When a request times
out, the limit is decreased by this amount. The value is interpreted as a percentage. Defaults
to 0.2 (i.e., 20%) if undefined."/>
<c:simple-property name="RequestWarmupPeriod" type="integer" required="false" description="The warmup period time during which the request limit is grown
from 50% to 100% of the calculated value. The value is in minutes. Defaults to 3 minutes if undefined." displayName="Warmup Period" />
<c:simple-property name="RequestWarmupCounterMaximum" type="integer" required="false" description="Sets the maximum throttling value for warmup periods. If a timeout occurs
the request rate is halved with increased warmup period. This settings limits the maximum value of added warmup periods. The maximum warmup
period is calculated: Warmup Period * Warmup Counter Maximum. Defaults to 10 if undefined (30 minutes maximum warmup with default values)."
displayName="Warmup Counter Maximum" />
</resource-configuration>
</service>

Expand Down

0 comments on commit e8a902e

Please sign in to comment.