Skip to content

Commit

Permalink
WFLY-11033 mod_cluster custom load metrics fail to load
Browse files Browse the repository at this point in the history
  • Loading branch information
rhusar committed Sep 19, 2018
1 parent 2f3a169 commit ef367d8
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 9 deletions.
Expand Up @@ -36,6 +36,7 @@
<module name="org.jboss.as.clustering.common"/>
<module name="org.jboss.as.controller"/>
<module name="org.jboss.as.network"/>
<module name="org.jboss.as.server"/>
<module name="org.jboss.common-beans"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.mod_cluster.container.spi"/>
Expand Down
Expand Up @@ -442,6 +442,10 @@ private void parseCustomLoadMetric(XMLExtendedStreamReader reader, List<ModelNod
readAttribute(reader, i, operation, LoadMetricResourceDefinition.SharedAttribute.CAPACITY);
break;
}
case MODULE: {
readAttribute(reader, i, operation, CustomLoadMetricResourceDefinition.Attribute.MODULE);
break;
}
case WEIGHT: {
readAttribute(reader, i, operation, LoadMetricResourceDefinition.SharedAttribute.WEIGHT);
break;
Expand Down
Expand Up @@ -78,6 +78,7 @@ enum XMLAttribute {
// Load metrics
CAPACITY(LoadMetricResourceDefinition.SharedAttribute.CAPACITY),
CLASS(CustomLoadMetricResourceDefinition.Attribute.CLASS),
MODULE(CustomLoadMetricResourceDefinition.Attribute.MODULE),
TYPE(LoadMetricResourceDefinition.Attribute.TYPE),
WEIGHT(LoadMetricResourceDefinition.SharedAttribute.WEIGHT),

Expand Down
Expand Up @@ -59,7 +59,7 @@ modcluster.load-metric.add=Add a load metric to the set of load metrics to calcu
modcluster.load-metric.remove=Remove a load metric from the set of load metrics to calculate the load factor from.
modcluster.load-metric.type=Type of a built-in load metric from the enumerated values.
modcluster.load-metric.class=Class name to use to construct a load metric from.
modcluster.load-metric.module=Module name to load the load metric class from.
modcluster.load-metric.module=Module name from which to load the load metric class.
modcluster.load-metric.weight=Number indicating the significance of a metric with respect to the other metrics. For example, a metric of weight 2 will have twice the impact on the overall load factor than a metric of weight 1.
modcluster.load-metric.capacity=Maximum capacity of the metric used to normalize the load values from a metric which require explicit capacity.
modcluster.load-metric.property=Properties to apply on a loaded metric instance.
Expand Down
Expand Up @@ -173,10 +173,16 @@ private static FailedOperationTransformationConfig createFailedOperationConfig(M

PathAddress subsystemAddress = PathAddress.pathAddress(ModClusterSubsystemResourceDefinition.PATH);
PathAddress configurationAddress = subsystemAddress.append(ProxyConfigurationResourceDefinition.pathElement("default"));
PathAddress dynamicLoadProviderAddress = configurationAddress.append(DynamicLoadProviderResourceDefinition.PATH);

// if (ModClusterModel.VERSION_6_0_0.requiresTransformation(version)) {
if (ModClusterModel.VERSION_6_0_0.requiresTransformation(version)) {
// config.addFailedAttribute(subsystemAddress.append(ProxyConfigurationResourceDefinition.pathElement("other")), FailedOperationTransformationConfig.REJECTED_RESOURCE);
// }

config.addFailedAttribute(dynamicLoadProviderAddress.append(CustomLoadMetricResourceDefinition.pathElement("SomeFakeLoadMetricClass1")),
FailedOperationTransformationConfig.ChainedConfig.createBuilder(CustomLoadMetricResourceDefinition.Attribute.MODULE.getName())
.addConfig(new ModuleAttributeTransformationConfig())
.build());
}

if (ModClusterModel.VERSION_3_0_0.requiresTransformation(version)) {
config.addFailedAttribute(configurationAddress, FailedOperationTransformationConfig.ChainedConfig.createBuilder(ProxyConfigurationResourceDefinition.Attribute.STATUS_INTERVAL.getName(), ProxyConfigurationResourceDefinition.Attribute.PROXIES.getName())
Expand Down Expand Up @@ -229,4 +235,25 @@ protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute)
return new ModelNode(10);
}
}

static class ModuleAttributeTransformationConfig extends FailedOperationTransformationConfig.AttributesPathAddressConfig<ModuleAttributeTransformationConfig> {
ModuleAttributeTransformationConfig() {
super(CustomLoadMetricResourceDefinition.Attribute.MODULE.getName());
}

@Override
protected boolean isAttributeWritable(String attributeName) {
return true;
}

@Override
protected boolean checkValue(String attrName, ModelNode attribute, boolean isWriteAttribute) {
return !attribute.equals(CustomLoadMetricResourceDefinition.Attribute.MODULE.getDefinition().getDefaultValue());
}

@Override
protected ModelNode correctValue(ModelNode toResolve, boolean isWriteAttribute) {
return CustomLoadMetricResourceDefinition.Attribute.MODULE.getDefinition().getDefaultValue();
}
}
}
Expand Up @@ -67,9 +67,11 @@
<property name="name2"
value="${property2:value2}"/>
</load-metric>
<custom-load-metric class="SomeFakeLoadMetricClass1"
<custom-load-metric capacity="${modcluster.custom-load-metric.capacity:1.1}"
class="SomeFakeLoadMetricClass1"
module="com.radoslavhusar.mod_cluster"
weight="${modcluster.custom-load-metric.weight:5}"
capacity="${modcluster.custom-load-metric.capacity:1.1}"/>
/>
<custom-load-metric class="SomeFakeLoadMetricClass2"
capacity="${modcluster.custom-load-metric.capacity:1.1}"/>
<custom-load-metric class="SomeFakeLoadMetricClass3"
Expand Down
Expand Up @@ -67,9 +67,11 @@
<property name="name2"
value="${property2:value2}"/>
</load-metric>
<custom-load-metric class="SomeFakeLoadMetricClass1"
<custom-load-metric capacity="${modcluster.custom-load-metric.capacity:1.1}"
class="SomeFakeLoadMetricClass1"
module="org.wildfly.extension.mod_cluster"
weight="${modcluster.custom-load-metric.weight:5}"
capacity="${modcluster.custom-load-metric.capacity:1.1}"/>
/>
<custom-load-metric class="SomeFakeLoadMetricClass2"
capacity="${modcluster.custom-load-metric.capacity:1.1}"/>
<custom-load-metric class="SomeFakeLoadMetricClass3"
Expand Down
Expand Up @@ -69,9 +69,11 @@
<property name="name2"
value="${property2:value2}"/>
</load-metric>
<custom-load-metric class="SomeFakeLoadMetricClass1"
<custom-load-metric capacity="${modcluster.custom-load-metric.capacity:1.1}"
class="SomeFakeLoadMetricClass1"
module="com.radoslavhusar.mod_cluster"
weight="${modcluster.custom-load-metric.weight:5}"
capacity="${modcluster.custom-load-metric.capacity:1.1}"/>
/>
<custom-load-metric class="SomeFakeLoadMetricClass2"
capacity="${modcluster.custom-load-metric.capacity:1.1}"/>
<custom-load-metric class="SomeFakeLoadMetricClass3"
Expand Down

0 comments on commit ef367d8

Please sign in to comment.