Permalink
Browse files

[AS7-6615] Add missing remote DC attributes

  • Loading branch information...
1 parent 9eadafb commit a0cf0ad01a8251524959190bf502a3bead9b82c5 @kabir kabir committed with bstansberry Apr 3, 2013
@@ -76,6 +76,7 @@
import org.jboss.as.host.controller.operations.HostXmlMarshallingHandler;
import org.jboss.as.host.controller.operations.IsMasterHandler;
import org.jboss.as.host.controller.operations.LocalHostControllerInfoImpl;
+import org.jboss.as.host.controller.operations.RemoteDomainControllerAddHandler;
import org.jboss.as.host.controller.operations.ResolveExpressionOnHostHandler;
import org.jboss.as.host.controller.operations.StartServersHandler;
import org.jboss.as.host.controller.resources.HttpManagementResourceDefinition;
@@ -154,20 +155,15 @@
.setResourceOnly()
.build();
- public static final SimpleAttributeDefinition REMOTE_DC_HOST = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.HOST, ModelType.STRING)
- .setAllowNull(false)
- .setAllowExpression(true)
- .setMinSize(1)
- .build();
- public static final SimpleAttributeDefinition REMOTE_DC_PORT = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.PORT, ModelType.INT)
- .setAllowNull(false)
- .setAllowExpression(true)
- .build();
-
public static final ObjectTypeAttributeDefinition DC_LOCAL = new ObjectTypeAttributeDefinition.Builder(ModelDescriptionConstants.LOCAL)
.build();
- public static final ObjectTypeAttributeDefinition DC_REMOTE = new ObjectTypeAttributeDefinition.Builder(ModelDescriptionConstants.REMOTE, REMOTE_DC_HOST, REMOTE_DC_PORT)
+ public static final ObjectTypeAttributeDefinition DC_REMOTE = new ObjectTypeAttributeDefinition.Builder(
+ ModelDescriptionConstants.REMOTE,
+ RemoteDomainControllerAddHandler.HOST,
+ RemoteDomainControllerAddHandler.PORT,
+ RemoteDomainControllerAddHandler.USERNAME,
+ RemoteDomainControllerAddHandler.SECURITY_REALM)
.build();
public static final ObjectTypeAttributeDefinition DOMAIN_CONTROLLER = new ObjectTypeAttributeDefinition.Builder(ModelDescriptionConstants.DOMAIN_CONTROLLER, DC_LOCAL, DC_REMOTE)
@@ -344,6 +340,5 @@ public void registerChildren(ManagementResourceRegistration hostRegistration) {
//server configurations
hostRegistration.registerSubModel(new ServerConfigResourceDefinition(serverInventory, pathManager));
-
}
-}
+}
@@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.Map;
+
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationDefinition;
import org.jboss.as.controller.OperationFailedException;
@@ -60,14 +61,20 @@
public static final String OPERATION_NAME = "write-remote-domain-controller";
- public static final SimpleAttributeDefinition PORT = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.PORT, ModelType.INT, true)
- .setAllowExpression(true).setValidator(new IntRangeValidator(1, 65535, false, true)).setFlags(AttributeAccess.Flag.RESTART_JVM).build();
+ public static final SimpleAttributeDefinition PORT = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.PORT, ModelType.INT)
+ .setAllowExpression(true)
+ .setValidator(new IntRangeValidator(1, 65535, false, true))
+ .setFlags(AttributeAccess.Flag.RESTART_JVM)
+ .build();
- public static final SimpleAttributeDefinition HOST = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.HOST, ModelType.STRING, true)
- .setAllowExpression(true).setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, false, true)).setFlags(AttributeAccess.Flag.RESTART_JVM).build();
+ public static final SimpleAttributeDefinition HOST = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.HOST, ModelType.STRING)
+ .setAllowExpression(true)
+ .setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, false, true))
+ .setFlags(AttributeAccess.Flag.RESTART_JVM)
+ .build();
- public static final SimpleAttributeDefinition USERNAME = new SimpleAttributeDefinitionBuilder(
- ModelDescriptionConstants.USERNAME, STRING, true).setAllowExpression(true)
+ public static final SimpleAttributeDefinition USERNAME = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.USERNAME, STRING, true)
+ .setAllowExpression(true)
.setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, true, true))
.setFlags(AttributeAccess.Flag.RESTART_JVM).build();
@@ -78,6 +85,7 @@
public static final OperationDefinition DEFINITION = new SimpleOperationDefinitionBuilder(OPERATION_NAME, HostResolver.getResolver("host"))
.setParameters(PORT, HOST, USERNAME, SECURITY_REALM)
.build();
+
private final ManagementResourceRegistration rootRegistration;
private final DomainController domainController;
private final HostControllerConfigurationPersister overallConfigPersister;
@@ -118,6 +126,7 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
PORT.validateAndSet(operation, remoteDC);
HOST.validateAndSet(operation, remoteDC);
USERNAME.validateAndSet(operation, remoteDC);
+
if (operation.has(SECURITY_REALM.getName())) {
SECURITY_REALM.validateAndSet(operation, remoteDC);
hostControllerInfo.setRemoteDomainControllerSecurityRealm(SECURITY_REALM.resolveModelAttribute(context, operation).asString());
@@ -147,8 +156,8 @@ public void handleRollback(OperationContext context, ModelNode operation) {
protected void initializeDomain(OperationContext context, ModelNode remoteDC) throws OperationFailedException {
hostControllerInfo.setMasterDomainController(false);
- ModelNode hostNode = HOST.resolveModelAttribute(context, remoteDC);
- ModelNode portNode = PORT.resolveModelAttribute(context, remoteDC);
+ ModelNode hostNode = RemoteDomainControllerAddHandler.HOST.resolveModelAttribute(context, remoteDC);
+ ModelNode portNode = RemoteDomainControllerAddHandler.PORT.resolveModelAttribute(context, remoteDC);
if (hostNode.isDefined() && portNode.isDefined()) {
// Create a StaticDiscovery option and add it to the host controller info
Map<String, ModelNode> properties = new HashMap<String, ModelNode>();
@@ -167,4 +176,4 @@ protected void initializeDomain(OperationContext context, ModelNode remoteDC) th
domainController.initializeSlaveDomainRegistry(rootRegistration, overallConfigPersister.getDomainPersister(), contentRepository, fileRepository,
hostControllerInfo, extensionRegistry, ignoredDomainResourceRegistry, pathManager);
}
-}
+}
@@ -55,7 +55,6 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.STATIC_DISCOVERY;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SYSTEM_PROPERTY;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.USERNAME;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VAULT;
import static org.jboss.as.controller.parsing.Namespace.DOMAIN_1_0;
import static org.jboss.as.controller.parsing.ParseUtils.isNoNamespaceAttribute;
@@ -69,7 +68,6 @@
import static org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute;
import static org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute;
import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement;
-import static org.jboss.as.host.controller.discovery.Constants.PROPERTY;
import java.util.Collections;
import java.util.EnumSet;
@@ -93,6 +91,7 @@
import org.jboss.as.host.controller.ignored.IgnoredDomainTypeResourceDefinition;
import org.jboss.as.host.controller.model.host.HostResourceDefinition;
import org.jboss.as.host.controller.operations.HostModelRegistrationHandler;
+import org.jboss.as.host.controller.operations.RemoteDomainControllerAddHandler;
import org.jboss.as.host.controller.resources.HttpManagementResourceDefinition;
import org.jboss.as.host.controller.resources.NativeManagementResourceDefinition;
import org.jboss.as.host.controller.resources.ServerConfigResourceDefinition;
@@ -154,7 +153,7 @@ public void writeContent(final XMLExtendedStreamWriter writer, final ModelMarsha
writer.writeStartElement(Element.HOST.getLocalName());
if (modelNode.hasDefined(NAME)) {
- writeAttribute(writer, Attribute.NAME, modelNode.get(NAME).asString());
+ HostResourceDefinition.NAME.marshallAsAttribute(modelNode, writer);
}
writer.writeDefaultNamespace(Namespace.CURRENT.getUriString());
@@ -1673,18 +1672,10 @@ private void writeDomainController(final XMLExtendedStreamWriter writer, final M
} else if (modelNode.hasDefined(REMOTE)) {
writer.writeStartElement(Element.REMOTE.getLocalName());
final ModelNode remote = modelNode.get(REMOTE);
- if (remote.hasDefined(HOST)) {
- writeAttribute(writer, Attribute.HOST, remote.get(HOST).asString());
- }
- if (remote.hasDefined(PORT)) {
- writeAttribute(writer, Attribute.PORT, remote.get(PORT).asString());
- }
- if (remote.hasDefined(SECURITY_REALM)) {
- writeAttribute(writer, Attribute.SECURITY_REALM, remote.require(SECURITY_REALM).asString());
- }
- if (remote.hasDefined(USERNAME)) {
- writeAttribute(writer, Attribute.USERNAME, remote.require(USERNAME).asString());
- }
+ RemoteDomainControllerAddHandler.HOST.marshallAsAttribute(remote, writer);
+ RemoteDomainControllerAddHandler.PORT.marshallAsAttribute(remote, writer);
+ RemoteDomainControllerAddHandler.SECURITY_REALM.marshallAsAttribute(remote, writer);
+ RemoteDomainControllerAddHandler.USERNAME.marshallAsAttribute(remote, writer);
if (ignoredResources != null) {
writeIgnoredResources(writer, ignoredResources);
}

0 comments on commit a0cf0ad

Please sign in to comment.