use of org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider in project wildfly by wildfly.
the class ModClusterSubsystemAdd method getModClusterLoadProvider.
private LoadBalanceFactorProvider getModClusterLoadProvider(final Set<LoadMetric> metrics, final OperationContext context, ModelNode model) throws OperationFailedException {
LoadBalanceFactorProvider load = null;
if (model.hasDefined(CommonAttributes.SIMPLE_LOAD_PROVIDER_FACTOR)) {
// TODO it seems we don't support that stuff.
int value = ModClusterConfigResourceDefinition.SIMPLE_LOAD_PROVIDER.resolveModelAttribute(context, model).asInt(1);
SimpleLoadBalanceFactorProvider myload = new SimpleLoadBalanceFactorProvider();
myload.setLoadBalanceFactor(value);
load = myload;
}
if (model.get(DynamicLoadProviderDefinition.PATH.getKeyValuePair()).isDefined()) {
final ModelNode node = model.get(DynamicLoadProviderDefinition.PATH.getKeyValuePair());
int decayFactor = DynamicLoadProviderDefinition.DECAY.resolveModelAttribute(context, node).asInt();
int history = DynamicLoadProviderDefinition.HISTORY.resolveModelAttribute(context, node).asInt();
if (node.hasDefined(CommonAttributes.LOAD_METRIC)) {
addLoadMetrics(metrics, node.get(CommonAttributes.LOAD_METRIC), context);
}
if (node.hasDefined(CommonAttributes.CUSTOM_LOAD_METRIC)) {
addLoadMetrics(metrics, node.get(CommonAttributes.CUSTOM_LOAD_METRIC), context);
}
if (!metrics.isEmpty()) {
DynamicLoadBalanceFactorProvider loader = new DynamicLoadBalanceFactorProvider(metrics);
loader.setDecayFactor(decayFactor);
loader.setHistory(history);
load = loader;
}
}
if (load == null) {
// Use a default one...
ROOT_LOGGER.useDefaultLoadBalancer();
SimpleLoadBalanceFactorProvider myload = new SimpleLoadBalanceFactorProvider();
myload.setLoadBalanceFactor(1);
load = myload;
}
return load;
}
use of org.jboss.modcluster.load.impl.SimpleLoadBalanceFactorProvider in project wildfly by wildfly.
the class ModClusterSubsystemServiceHandler method getLoadProvider.
private LoadBalanceFactorProvider getLoadProvider(String proxyName, final Set<LoadMetric> metrics, final OperationContext context, ModelNode model) throws OperationFailedException {
LoadBalanceFactorProvider load = null;
if (model.get(SimpleLoadProviderResourceDefinition.PATH.getKeyValuePair()).isDefined()) {
ModelNode simpleProviderModel = model.get(SimpleLoadProviderResourceDefinition.PATH.getKeyValuePair());
int value = SimpleLoadProviderResourceDefinition.Attribute.FACTOR.resolveModelAttribute(context, simpleProviderModel).asInt();
SimpleLoadBalanceFactorProvider simpleLoadProvider = new SimpleLoadBalanceFactorProvider();
simpleLoadProvider.setLoadBalanceFactor(value);
load = simpleLoadProvider;
}
if (model.get(DynamicLoadProviderResourceDefinition.PATH.getKeyValuePair()).isDefined()) {
ModelNode node = model.get(DynamicLoadProviderResourceDefinition.PATH.getKeyValuePair());
float decayFactor = (float) DynamicLoadProviderResourceDefinition.Attribute.DECAY.resolveModelAttribute(context, node).asDouble();
int history = DynamicLoadProviderResourceDefinition.Attribute.HISTORY.resolveModelAttribute(context, node).asInt();
int initialLoad = DynamicLoadProviderResourceDefinition.Attribute.INITIAL_LOAD.resolveModelAttribute(context, node).asInt();
if (node.hasDefined(LoadMetricResourceDefinition.WILDCARD_PATH.getKey())) {
this.addLoadMetrics(metrics, node.get(LoadMetricResourceDefinition.WILDCARD_PATH.getKey()), context);
}
if (node.hasDefined(CustomLoadMetricResourceDefinition.WILDCARD_PATH.getKey())) {
this.addLoadMetrics(metrics, node.get(CustomLoadMetricResourceDefinition.WILDCARD_PATH.getKey()), context);
}
if (!metrics.isEmpty()) {
DynamicLoadBalanceFactorProvider loadBalanceFactorProvider = new DynamicLoadBalanceFactorProvider(metrics, initialLoad);
loadBalanceFactorProvider.setDecayFactor(decayFactor);
loadBalanceFactorProvider.setHistory(history);
load = loadBalanceFactorProvider;
}
}
if (load == null) {
ROOT_LOGGER.usingSimpleLoadProvider(proxyName);
load = new SimpleLoadBalanceFactorProvider();
}
return load;
}
Aggregations