@Override protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { return attributeValue.equals(new ModelNode(false)); } }, TRACKING)
@Override protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { return attributeValue.equals(new ModelNode(false)); } }, TRACKING)
@Override protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { return !attributeValue.isDefined() || attributeValue.equals(new ModelNode(address.getLastElement().getValue())); } };
static List<String> validateDeprecatedProperites(final ModelNode model) { final List<String> propertiesToReject = new LinkedList<>(); for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ON_OFF_ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName()) && model.get(attribute.getName()).equals(JacORBSubsystemDefinitions.DEFAULT_ENABLED_PROPERTY)) { propertiesToReject.add(attribute.getName()); } } for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName())) { propertiesToReject.add(attribute.getName()); } } return propertiesToReject; }
@Override public DiscardPolicy checkResource(TransformationContext context, PathAddress address) { // If this was an auto-generated channel, discard it @SuppressWarnings("deprecation") ModelNode defaultStack = context.readResourceFromRoot(address.getParent()).getModel().get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName()); return context.readResourceFromRoot(address).getModel().get(ChannelResourceDefinition.Attribute.STACK.getName()).equals(defaultStack) ? DiscardPolicy.SILENT : DiscardPolicy.NEVER; } };
private void populateModelWithCoordinatorEnvConfig(ModelNode operation, ModelNode coordEnvModel) throws OperationFailedException { TransactionSubsystemRootResourceDefinition.STATISTICS_ENABLED.validateAndSet(operation, coordEnvModel); TransactionSubsystemRootResourceDefinition.ENABLE_STATISTICS.validateAndSet(operation, coordEnvModel); TransactionSubsystemRootResourceDefinition.ENABLE_TSM_STATUS.validateAndSet(operation, coordEnvModel); TransactionSubsystemRootResourceDefinition.DEFAULT_TIMEOUT.validateAndSet(operation, coordEnvModel); TransactionSubsystemRootResourceDefinition.MAXIMUM_TIMEOUT.validateAndSet(operation, coordEnvModel); ModelNode mceVal = coordEnvModel.get(TransactionSubsystemRootResourceDefinition.ENABLE_STATISTICS.getName()); if (mceVal.isDefined()) { ModelNode seVal = coordEnvModel.get(TransactionSubsystemRootResourceDefinition.STATISTICS_ENABLED.getName()); if (seVal.isDefined() && !seVal.equals(mceVal)) { throw TransactionLogger.ROOT_LOGGER.inconsistentStatisticsSettings(TransactionSubsystemRootResourceDefinition.STATISTICS_ENABLED.getName(), TransactionSubsystemRootResourceDefinition.ENABLE_STATISTICS.getName()); } seVal.set(mceVal); mceVal.set(new ModelNode()); } }
@Override protected void validateUpdatedModel(final OperationContext context, final Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); if (!context.getProcessType().equals(ProcessType.HOST_CONTROLLER)) { final List<String> propertiesToReject = new LinkedList<String>(); for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ON_OFF_ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName()) && model.get(attribute.getName()).equals(JacORBSubsystemDefinitions.DEFAULT_ENABLED_PROPERTY)) { propertiesToReject.add(attribute.getName()); } } for (final AttributeDefinition attribute : JacORBSubsystemDefinitions.ATTRIBUTES_TO_REJECT) { if (model.hasDefined(attribute.getName())) { propertiesToReject.add(attribute.getName()); } } if (!propertiesToReject.isEmpty()) { throw JacORBLogger.ROOT_LOGGER.cannotEmulateProperties(propertiesToReject); } } }
if (!defClustered.equals(model.get(DEFAULT_SFSB_CACHE))) {
ModelNode newValue = context.readResourceFromRoot(resolvedAddress).getModel().get(PROPERTIES).clone(); if (initialValue.equals(newValue) || (initialValue.isDefined() && initialValue.asPropertyList().isEmpty() && !newValue.isDefined())) { } else { final ModelNode oldPropValue = oldMap.get(key); if (!oldPropValue.equals(value)) {
protected void updateDeliveryGroup(OperationContext context, ModelNode currentValue, ModelNode resolvedValue) throws OperationFailedException { if (currentValue.equals(resolvedValue)) { return; } String groupName = context.getCurrentAddress().getLastElement().getValue(); context.getServiceRegistry(true).getRequiredService(getDeliveryGroupServiceName(groupName)).setMode( resolvedValue.asBoolean() ? ServiceController.Mode.ACTIVE : ServiceController.Mode.NEVER); } });
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<AgroalConnectionPoolConfiguration> handbackHolder) throws OperationFailedException { ModelNode newBlockingTimeout = resolvedValue.remove(AbstractDataSourceDefinition.BLOCKING_TIMEOUT_MILLIS_ATTRIBUTE.getName()); ModelNode newMaxSize = resolvedValue.remove(AbstractDataSourceDefinition.MAX_SIZE_ATTRIBUTE.getName()); ModelNode newMinSize = resolvedValue.remove(AbstractDataSourceDefinition.MIN_SIZE_ATTRIBUTE.getName()); for (String attribute : resolvedValue.keys()) { if (!currentValue.hasDefined(attribute) || !resolvedValue.get(attribute).equals(currentValue.get(attribute))) { // Other attributes changed. Restart required return true; } } if (newBlockingTimeout != null) { getDataSource(context).getConfiguration().connectionPoolConfiguration().setAcquisitionTimeout(Duration.ofMillis(newBlockingTimeout.asInt())); } if (newMaxSize != null) { getDataSource(context).getConfiguration().connectionPoolConfiguration().setMaxSize(newMaxSize.asInt()); // if max-size decreases Agroal will gracefully destroy connections when they are returned to the pool, so there is nothing to do here } if (newMinSize != null) { getDataSource(context).getConfiguration().connectionPoolConfiguration().setMinSize(newMinSize.asInt()); // if min-size increases Agroal will create new connections when looking into the (shared) pool. FlushMode.FILL could be used here to enforce the new min-size } return false; }
@Override protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { return this.value.equals(attributeValue); } }
@Override protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) { return !this.value.equals(attributeValue); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; DescribedOp that = (DescribedOp) o; return description.equals(that.description) && flags.equals(that.flags); }
private boolean isDiscardAllowed(final ModelNode modelNode) { if (modelNode.hasDefined(attributeName)) { return approvedValue.equals(modelNode.get(attributeName)); } return allowUndefined; } }
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandback) throws OperationFailedException { // Some might ask why we are comparing a resolvedValue with the currentValuewhich is not resolved. // Well the issue is that the context that would permit to resolve the currentValue might have changed thus // the resolved value for the currentValue wouldn't be correct. // In fact we just can't resolve the currentValue without any doubt. When in doubt reload, so we will return true in this case. // For example if the currentValue is ${foo} and that for some reason foo has changed in between, then we should reload even if now ${foo} resolves // as resolvedValue. ModelNode resolvedTypedValue = convertToType(attributeName, resolvedValue); return !resolvedTypedValue.equals(currentValue); }
private void emitAttributeValueWrittenNotification(OperationContext context, PathAddress address, String attributeName, ModelNode oldValue, ModelNode newValue) { // only emit a notification if the value has been successfully changed if (oldValue.equals(newValue)) { return; } ModelNode data = new ModelNode(); data.get(NAME.getName()).set(attributeName); data.get(GlobalNotifications.OLD_VALUE).set(oldValue); data.get(GlobalNotifications.NEW_VALUE).set(newValue); Notification notification = new Notification(ATTRIBUTE_VALUE_WRITTEN_NOTIFICATION, address, ControllerLogger.ROOT_LOGGER.attributeValueWritten(attributeName, oldValue, newValue), data); context.emit(notification); }
/** * Gets whether the given {@code resourceModel} has a value for this attribute that should be marshalled to XML. * * @param attribute - attribute for which marshaling is being done * @param resourceModel the model, a non-null node of {@link org.jboss.dmr.ModelType#OBJECT}. * @param marshallDefault {@code true} if the value should be marshalled even if it matches the default value * @return {@code true} if the given {@code resourceModel} has a defined value under this attribute's {@link AttributeDefinition#getName()} () name} * and {@code marshallDefault} is {@code true} or that value differs from this attribute's {@link AttributeDefinition#getDefaultValue() default value}. */ public boolean isMarshallable(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault) { return resourceModel.hasDefined(attribute.getName()) && (marshallDefault || !resourceModel.get(attribute.getName()).equals(attribute.getDefaultValue())); }