public class QoSHandler extends Object implements org.swisspush.gateleen.core.logging.LoggableResource
{
"config":{
"percentile":75,
"quorum":40,
"period":5,
"minSampleCount" : 1000,
"minSentinelCount" : 5
},
"sentinels":{
"sentinelA":{
"percentile":50
},
"sentinelB":{},
"sentinelC":{},
"sentinelD":{}
},
"rules":{
"/test/myapi1/v1/.*":{
"reject":1.2,
"warn":0.5
},
"/test/myapi2/v1/.*":{
"reject":0.3
}
}
}
The config section defines the global settings of the QoS.
percentile: Indicates which percentile value from the metrics will be used (eg. 50, 75, 95, 98, 999 or 99)
quorum: Percentage of the the sentinels which have to be over the calculated threshold to trigger the given rule.
period: The period (in seconds) after which a new calculation is triggered. If a rule is set to reject requests,
it will reject requests until the next period.
minSampleCount: The min. count of the samples a sentinel has to provide to be regarded for the QoS calculation.
minSentinelCount:The min count of sentinels which have to be available to perform a QoS calculation. A sentinel is only available
if it corresponds to the minSampleCount rule.
The sentinels section defines which metrics (defined in the routing rules) will be used as sentinels. To determine
the load, the lowest measured percentile value will be preserved for each sentinel and put in relation to the current percentile value.
This calculated ratio is later used to check if a rule needs some actions or not. You can override
the taken percentile value for a specific sentinel by setting the attribute percentile.
The rules section defines the rules for the QoS. Each rule is based on a pattern like the routing rules.
The possible attributes are:
reject: The ratio (eg. 1.3 means that *quorum* % of all sentinels must have an even or greater current ratio)
which defines when a rule rejects the given request.
warn: The ratio which defines when a rule writes a warning in the log without rejecting the given request.
You can combine warn and reject
| Modifier and Type | Field and Description |
|---|---|
protected static String |
REJECT_ACTION |
protected static String |
WARN_ACTION |
| Constructor and Description |
|---|
QoSHandler(io.vertx.core.Vertx vertx,
org.swisspush.gateleen.core.storage.ResourceStorage storage,
String qosSettingsPath,
Map<String,Object> properties,
String prefix)
Creates a new instance of the QoSHandler.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
actionNecessary(Double ratio,
double thresholdSentinelRatio)
Takes the ratio of the rule and compares if
the calculated sentinel ratio from the desc.
|
protected void |
cancelTimer()
Cancels the timer.
|
protected QoSConfig |
createQoSConfig(io.vertx.core.json.JsonObject qosSettings)
Creates the QoS config object from the given JsonObject
and returns it.
|
protected List<QoSSentinel> |
createQoSSentinels(io.vertx.core.json.JsonObject qosSettings)
Creates the QoS sentinel objects from the given JsonObject
and returns them in a list.
|
void |
enableResourceLogging(boolean resourceLoggingEnabled) |
protected void |
evaluateQoSActions()
Calculates the threshold and determines if any action
for each rule has to be applied.
|
QoSSentinel |
getOldSentinel(String sentinelName)
We try to retrive the old sentinel (if available).
|
protected List<QoSRule> |
getQosRules()
Returns a list of the QoS rules.
|
protected List<QoSSentinel> |
getQosSentinels()
Gets a list of all sentinels.
|
boolean |
handle(io.vertx.core.http.HttpServerRequest request)
Processes the request if it’s a request concerning
the updates of the QoS settings or if it’s a request
affected by the QoS rules.
|
protected io.vertx.core.json.JsonObject |
parseQoSSettings(io.vertx.core.buffer.Buffer buffer)
Tries to parse the QoS settings.
|
protected void |
setGlobalQoSConfig(QoSConfig globalQoSConfig)
Sets the global configuration for the QoS.
|
protected void |
setMBeanServer(MBeanServer mbeanServer)
Sets the mbean server.
|
protected void |
setQosRules(List<QoSRule> qosRules)
Sets the QoS rules.
|
protected void |
setQosSentinels(List<QoSSentinel> qosSentinels)
Sets a list of all sentinels.
|
protected static final String REJECT_ACTION
protected static final String WARN_ACTION
public QoSHandler(io.vertx.core.Vertx vertx,
org.swisspush.gateleen.core.storage.ResourceStorage storage,
String qosSettingsPath,
Map<String,Object> properties,
String prefix)
vertx - vertx referencestorage - storage referenceqosSettingsPath - the url path to the QoS rulesproperties - the propertiesprefix - the prefix for the serverpublic void enableResourceLogging(boolean resourceLoggingEnabled)
enableResourceLogging in interface org.swisspush.gateleen.core.logging.LoggableResourceprotected void setMBeanServer(MBeanServer mbeanServer)
mbeanServer - a mbean serverpublic boolean handle(io.vertx.core.http.HttpServerRequest request)
true otherwise false.request - protected QoSConfig createQoSConfig(io.vertx.core.json.JsonObject qosSettings)
qosSettings - json objectprotected List<QoSSentinel> createQoSSentinels(io.vertx.core.json.JsonObject qosSettings)
qosSettings - json objectpublic QoSSentinel getOldSentinel(String sentinelName)
sentinelName - the name of the sentinel.protected io.vertx.core.json.JsonObject parseQoSSettings(io.vertx.core.buffer.Buffer buffer)
buffer - buffer from the requestprotected void cancelTimer()
protected void evaluateQoSActions()
protected boolean actionNecessary(Double ratio, double thresholdSentinelRatio)
ratio - thresholdSentinelRatio - protected void setGlobalQoSConfig(QoSConfig globalQoSConfig)
globalQoSConfig - the config object for QoS.protected List<QoSRule> getQosRules()
protected void setQosRules(List<QoSRule> qosRules)
qosRules - a list of the QoS rule objectsprotected void setQosSentinels(List<QoSSentinel> qosSentinels)
qosSentinels - list with sentinel objectsprotected List<QoSSentinel> getQosSentinels()
Copyright © 2016–2021. All rights reserved.