@Override
@SuppressWarnings("IllegalCatch")
void executeStrategy(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta, ObjectName on,
ServiceRegistryWrapper services) throws ConfigHandlingException {
for (Entry<String, AttributeConfigElement> configAttributeEntry : configuration.entrySet()) {
try {
AttributeConfigElement ace = configAttributeEntry.getValue();
if (!ace.getResolvedValue().isPresent()) {
LOG.debug("Skipping attribute {} for {}", configAttributeEntry.getKey(), on);
continue;
}
Object toBeMergedIn = ace.getResolvedValue().get();
// Get the existing values so we can merge the new values with them.
Attribute currentAttribute = ta.getAttribute(on, ace.getJmxName());
Object oldValue = currentAttribute != null ? currentAttribute.getValue() : null;
// Merge value with currentValue
toBeMergedIn = merge(oldValue, toBeMergedIn);
ta.setAttribute(on, ace.getJmxName(), new Attribute(ace.getJmxName(), toBeMergedIn));
LOG.debug("Attribute {} set to {} for {}", configAttributeEntry.getKey(), toBeMergedIn, on);
} catch (RuntimeException e) {
LOG.error("Error while merging object names of {}", on, e);
throw new ConfigHandlingException(String.format("Unable to set attributes for %s, "
+ "Error with attribute %s : %s ",
on,
configAttributeEntry.getKey(),
configAttributeEntry.getValue()),
DocumentedException.ErrorType.APPLICATION,
DocumentedException.ErrorTag.OPERATION_FAILED,
DocumentedException.ErrorSeverity.ERROR);
}
}
}
MergeEditConfigStrategy.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:hashsdn-controller
作者:
评论列表
文章目录