Skip to content

Commit e53c0fa

Browse files
committed
AS7-713 Support storing rolling plans in the domain content repo and accessing them via the management API
1 parent cadbb15 commit e53c0fa

File tree

48 files changed

+2004
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2004
-297
lines changed

build/build.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@
678678

679679
<module-def name="org.jboss.as.domain-http-error-context">
680680
<maven-resource group="org.jboss.as" artifact="jboss-as-domain-http-error-context"/>
681-
</module-def>
682-
681+
</module-def>
682+
683683
<module-def name="org.jboss.as.ee">
684684
<maven-resource group="org.jboss.as" artifact="jboss-as-ee"/>
685685
</module-def>
@@ -749,6 +749,10 @@
749749
<maven-resource group="org.jboss.as" artifact="jboss-as-mail"/>
750750
</module-def>
751751

752+
<module-def name="org.jboss.as.management-client-content">
753+
<maven-resource group="org.jboss.as" artifact="jboss-as-management-client-content"/>
754+
</module-def>
755+
752756
<module-def name="org.jboss.as.messaging">
753757
<maven-resource group="org.jboss.as" artifact="jboss-as-messaging"/>
754758
</module-def>

build/src/main/resources/docs/schema/jboss-as-config_1_1.xsd

+27
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<xs:element name="socket-binding-groups" type="socket-binding-groupsType" minOccurs="0" maxOccurs="1"/>
5050
<xs:element name="deployments" type="domain-deploymentsType" minOccurs="0" maxOccurs="1"/>
5151
<xs:element name="server-groups" type="server-groupsType" minOccurs="0" maxOccurs="1"/>
52+
<xs:element name="management-client-content" type="management-client-contentType" minOccurs="0" maxOccurs="1"/>
5253
</xs:sequence>
5354
</xs:complexType>
5455
</xs:element>
@@ -1923,4 +1924,30 @@
19231924
<xs:attribute name="code" type="xs:string" use="optional"/>
19241925
</xs:complexType>
19251926

1927+
<xs:complexType name="management-client-contentType">
1928+
<xs:annotation>
1929+
<xs:documentation>
1930+
<![CDATA[
1931+
Storage information about re-usable chunks of data useful to management clients that are stored
1932+
in the domain content repository.
1933+
]]>
1934+
</xs:documentation>
1935+
</xs:annotation>
1936+
<xs:sequence>
1937+
<xs:element name="rollout-plans" type="contentType" minOccurs="0" maxOccurs="1">
1938+
<xs:annotation>
1939+
<xs:documentation>
1940+
<![CDATA[
1941+
Storage information about a set of named management update rollout plans useful to management
1942+
clients that are stored in the domain content repository. The management API exposed by the domain
1943+
controller provides access to these plans to management clients, allowing clients to use the plans
1944+
by referencing them by name, avoiding the need to recreate them for each use.
1945+
]]>
1946+
</xs:documentation>
1947+
</xs:annotation>
1948+
</xs:element>
1949+
</xs:sequence>
1950+
</xs:complexType>
1951+
1952+
19261953
</xs:schema>

build/src/main/resources/modules/org/jboss/as/host-controller/main/module.xml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<module name="org.jboss.as.controller"/>
3838
<module name="org.jboss.as.deployment-repository"/>
3939
<module name="org.jboss.as.domain-management"/>
40+
<module name="org.jboss.as.management-client-content"/>
4041
<module name="org.jboss.as.network"/>
4142
<module name="org.jboss.as.platform-mbean"/>
4243
<module name="org.jboss.as.process-controller"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
~ JBoss, Home of Professional Open Source.
5+
~ Copyright 2011, Red Hat, Inc., and individual contributors
6+
~ as indicated by the @author tags. See the copyright.txt file in the
7+
~ distribution for a full listing of individual contributors.
8+
~
9+
~ This is free software; you can redistribute it and/or modify it
10+
~ under the terms of the GNU Lesser General Public License as
11+
~ published by the Free Software Foundation; either version 2.1 of
12+
~ the License, or (at your option) any later version.
13+
~
14+
~ This software is distributed in the hope that it will be useful,
15+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
~ Lesser General Public License for more details.
18+
~
19+
~ You should have received a copy of the GNU Lesser General Public
20+
~ License along with this software; if not, write to the Free
21+
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22+
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23+
-->
24+
25+
<module xmlns="urn:jboss:module:1.1" name="org.jboss.as.management-client-content">
26+
27+
<resources>
28+
<!-- Insert resources here -->
29+
</resources>
30+
31+
<dependencies>
32+
<module name="org.jboss.as.controller"/>
33+
<module name="org.jboss.as.deployment-repository"/>
34+
<module name="org.jboss.logging"/>
35+
<module name="org.jboss.vfs"/>
36+
</dependencies>
37+
</module>

controller/src/main/java/org/jboss/as/controller/descriptions/ModelDescriptionConstants.java

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public class ModelDescriptionConstants {
116116
public static final String LOCALE = "locale";
117117
public static final String MANAGEMENT_SUBSYSTEM_ENDPOINT = "management-subsystem-endpoint";
118118
public static final String MANAGEMENT = "management";
119+
public static final String MANAGEMENT_CLIENT_CONTENT = "management-client-content";
119120
public static final String MANAGEMENT_INTERFACE = "management-interface";
120121
public static final String MASK = "mask";
121122
public static final String MASTER = "master";
@@ -200,6 +201,7 @@ public class ModelDescriptionConstants {
200201
public static final String ROLLED_BACK = "rolled-back";
201202
public static final String ROLLING_TO_SERVERS = "rolling-to-servers";
202203
public static final String ROLLOUT_PLAN = "rollout-plan";
204+
public static final String ROLLOUT_PLANS = "rollout-plans";
203205
public static final String RUNNING_SERVER = "server";
204206
public static final String RUNTIME_NAME = "runtime-name";
205207
public static final String RUNTIME_UPDATE_SKIPPED = "runtime-update-skipped";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* JBoss, Home of Professional Open Source.
3+
* Copyright 2011, Red Hat, Inc., and individual contributors
4+
* as indicated by the @author tags. See the copyright.txt file in the
5+
* distribution for a full listing of individual contributors.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
*/
22+
23+
package org.jboss.as.controller.operations.validation;
24+
25+
import static org.jboss.as.controller.ControllerMessages.MESSAGES;
26+
27+
import org.jboss.as.controller.OperationFailedException;
28+
import org.jboss.dmr.ModelNode;
29+
import org.jboss.dmr.ModelType;
30+
31+
/**
32+
* Validates that a parameter is a byte[] of an acceptable length.
33+
*
34+
* @author Brian Stansberry (c) 2011 Red Hat Inc.
35+
*/
36+
public class BytesValidator extends ModelTypeValidator implements MinMaxValidator{
37+
38+
public static final BytesValidator createSha1(final boolean nullable) {
39+
return new BytesValidator(20, 20, nullable);
40+
}
41+
42+
private final int min;
43+
private final int max;
44+
45+
public BytesValidator(final int min, final int max, final boolean nullable) {
46+
super(ModelType.BYTES, nullable);
47+
this.min = min;
48+
this.max = max;
49+
}
50+
51+
@Override
52+
public Long getMin() {
53+
return Long.valueOf(min);
54+
}
55+
56+
@Override
57+
public Long getMax() {
58+
return Long.valueOf(max);
59+
}
60+
61+
/**
62+
* {@inheritDoc}
63+
*/
64+
@Override
65+
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
66+
super.validateParameter(parameterName, value);
67+
if (value.isDefined() && value.getType() != ModelType.EXPRESSION) {
68+
byte[] val = value.asBytes();
69+
if (val.length < min) {
70+
throw new OperationFailedException(new ModelNode().set(MESSAGES.invalidMinSize(val.length, parameterName, min)));
71+
}
72+
else if (val.length > max) {
73+
throw new OperationFailedException(new ModelNode().set(MESSAGES.invalidMaxSize(val.length, parameterName, max)));
74+
}
75+
}
76+
}
77+
}

controller/src/main/java/org/jboss/as/controller/parsing/Element.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public enum Element {
8585
LOOPBACK_ADDRESS("loopback-address"),
8686

8787
MANAGEMENT("management"),
88+
MANAGEMENT_CLIENT_CONTENT("management-client-content"),
8889
MANAGEMENT_INTERFACES("management-interfaces"),
8990
MULTICAST("multicast"),
9091

@@ -114,8 +115,8 @@ public enum Element {
114115

115116
REMOTE("remote"),
116117
REMOTE_DESTINATION("remote-destination"),
118+
ROLLOUT_PLANS("rollout-plans"),
117119

118-
SCANNING("scanning"),
119120
SECRET("secret"),
120121
SECURITY_REALM("security-realm"),
121122
SECURITY_REALMS("security-realms"),

host-controller/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
<scope>provided</scope>
9393
<optional>true</optional>
9494
</dependency>
95+
<dependency>
96+
<groupId>org.jboss.as</groupId>
97+
<artifactId>jboss-as-management-client-content</artifactId>
98+
</dependency>
9599
<dependency>
96100
<groupId>org.jboss.as</groupId>
97101
<artifactId>jboss-as-threads</artifactId>

host-controller/src/main/java/org/jboss/as/domain/controller/DomainModelUtil.java

+31-11
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.EXTENSION;
3030
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.INTERFACE;
3131
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.JVM;
32+
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.MANAGEMENT_CLIENT_CONTENT;
3233
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PATH;
3334
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROCESS_TYPE;
3435
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROFILE;
3536
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELEASE_CODENAME;
3637
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELEASE_VERSION;
3738
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
39+
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLOUT_PLAN;
40+
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLOUT_PLANS;
3841
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_GROUP;
3942
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SOCKET_BINDING_GROUP;
4043
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SOCKET_BINDING_PORT_OFFSET;
@@ -74,12 +77,16 @@
7477
import org.jboss.as.controller.operations.global.WriteAttributeHandlers;
7578
import org.jboss.as.controller.operations.global.WriteAttributeHandlers.IntRangeValidatingHandler;
7679
import org.jboss.as.controller.operations.global.WriteAttributeHandlers.ModelTypeValidatingHandler;
80+
import org.jboss.as.controller.operations.validation.ModelTypeValidator;
81+
import org.jboss.as.controller.operations.validation.ParameterValidator;
7782
import org.jboss.as.controller.persistence.ExtensibleConfigurationPersister;
7883
import org.jboss.as.controller.registry.AttributeAccess.Storage;
7984
import org.jboss.as.controller.registry.ManagementResourceRegistration;
8085
import org.jboss.as.controller.registry.OperationEntry;
86+
import org.jboss.as.controller.registry.Resource;
8187
import org.jboss.as.controller.resource.SocketBindingGroupResourceDefinition;
8288
import org.jboss.as.domain.controller.descriptions.DomainDescriptionProviders;
89+
import org.jboss.as.domain.controller.descriptions.DomainRootDescription;
8390
import org.jboss.as.domain.controller.operations.ApplyRemoteMasterDomainModelHandler;
8491
import org.jboss.as.domain.controller.operations.DomainServerLifecycleHandlers;
8592
import org.jboss.as.domain.controller.operations.ProcessTypeHandler;
@@ -104,6 +111,8 @@
104111
import org.jboss.as.domain.controller.operations.deployment.ServerGroupDeploymentReplaceHandler;
105112
import org.jboss.as.domain.controller.operations.deployment.ServerGroupDeploymentUndeployHandler;
106113
import org.jboss.as.domain.controller.resource.SocketBindingResourceDefinition;
114+
import org.jboss.as.management.client.content.ManagedDMRContentResourceDefinition;
115+
import org.jboss.as.management.client.content.ManagedDMRContentTypeResourceDefinition;
107116
import org.jboss.as.server.ServerEnvironment;
108117
import org.jboss.as.server.controller.descriptions.ServerDescriptionConstants;
109118
import org.jboss.as.server.deployment.repository.api.ContentRepository;
@@ -125,10 +134,10 @@ public class DomainModelUtil {
125134
/**
126135
* Update the model to hold domain level configuration.
127136
*
128-
* @param rootModel - the model to be updated.
137+
* @param rootResource the root resource to be updated.
129138
*/
130-
public static void updateCoreModel(final ModelNode rootModel) {
131-
139+
public static void updateCoreModel(final Resource rootResource) {
140+
final ModelNode rootModel = rootResource.getModel();
132141
rootModel.get(RELEASE_VERSION).set(Version.AS_VERSION);
133142
rootModel.get(RELEASE_CODENAME).set(Version.AS_RELEASE_CODENAME);
134143
}
@@ -140,8 +149,8 @@ public static ExtensionContext initializeMasterDomainRegistry(final ManagementRe
140149
}
141150

142151
public static ExtensionContext initializeSlaveDomainRegistry(final ManagementResourceRegistration root, final ExtensibleConfigurationPersister configurationPersister,
143-
final FileRepository fileRepository, final LocalHostControllerInfo hostControllerInfo) {
144-
return initializeDomainRegistry(root, configurationPersister, null, fileRepository, false, null, null, hostControllerInfo);
152+
final ContentRepository contentRepository, final FileRepository fileRepository, final LocalHostControllerInfo hostControllerInfo) {
153+
return initializeDomainRegistry(root, configurationPersister, contentRepository, fileRepository, false, null, null, hostControllerInfo);
145154
}
146155

147156
private static ExtensionContext initializeDomainRegistry(final ManagementResourceRegistration root, final ExtensibleConfigurationPersister configurationPersister,
@@ -154,18 +163,21 @@ private static ExtensionContext initializeDomainRegistry(final ManagementResourc
154163
// Other root resource operations
155164
XmlMarshallingHandler xmh = new XmlMarshallingHandler(configurationPersister);
156165
root.registerOperationHandler(XmlMarshallingHandler.OPERATION_NAME, xmh, xmh, false, OperationEntry.EntryType.PUBLIC, readOnly);
166+
157167
root.registerOperationHandler(NamespaceAddHandler.OPERATION_NAME, NamespaceAddHandler.INSTANCE, NamespaceAddHandler.INSTANCE, false);
158168
root.registerOperationHandler(NamespaceRemoveHandler.OPERATION_NAME, NamespaceRemoveHandler.INSTANCE, NamespaceRemoveHandler.INSTANCE, false);
159169
root.registerOperationHandler(SchemaLocationAddHandler.OPERATION_NAME, SchemaLocationAddHandler.INSTANCE, SchemaLocationAddHandler.INSTANCE, false);
160170
root.registerOperationHandler(SchemaLocationRemoveHandler.OPERATION_NAME, SchemaLocationRemoveHandler.INSTANCE, SchemaLocationRemoveHandler.INSTANCE, false);
161-
DeploymentUploadBytesHandler dubh = new DeploymentUploadBytesHandler(contentRepo);
171+
172+
DeploymentUploadBytesHandler dubh = isMaster ? new DeploymentUploadBytesHandler(contentRepo) : new DeploymentUploadBytesHandler();
162173
root.registerOperationHandler(DeploymentUploadBytesHandler.OPERATION_NAME, dubh, dubh, false, OperationEntry.EntryType.PUBLIC, deploymentUpload);
163-
DeploymentUploadURLHandler duuh = new DeploymentUploadURLHandler(contentRepo);
174+
DeploymentUploadURLHandler duuh = isMaster ? new DeploymentUploadURLHandler(contentRepo) : new DeploymentUploadURLHandler();
164175
root.registerOperationHandler(DeploymentUploadURLHandler.OPERATION_NAME, duuh, duuh, false, OperationEntry.EntryType.PUBLIC, deploymentUpload);
165-
DeploymentUploadStreamAttachmentHandler dush = new DeploymentUploadStreamAttachmentHandler(contentRepo);
176+
DeploymentUploadStreamAttachmentHandler dush = isMaster ? new DeploymentUploadStreamAttachmentHandler(contentRepo) : new DeploymentUploadStreamAttachmentHandler();
166177
root.registerOperationHandler(DeploymentUploadStreamAttachmentHandler.OPERATION_NAME, dush, dush, false, OperationEntry.EntryType.PUBLIC, deploymentUpload);
167178
DeploymentFullReplaceHandler dfrh = isMaster ? new DeploymentFullReplaceHandler(contentRepo) : new DeploymentFullReplaceHandler(fileRepository);
168179
root.registerOperationHandler(DeploymentFullReplaceHandler.OPERATION_NAME, dfrh, dfrh);
180+
169181
SnapshotDeleteHandler snapshotDelete = new SnapshotDeleteHandler(configurationPersister);
170182
root.registerOperationHandler(SnapshotDeleteHandler.OPERATION_NAME, snapshotDelete, snapshotDelete, false);
171183
SnapshotListHandler snapshotList = new SnapshotListHandler(configurationPersister);
@@ -242,11 +254,19 @@ private static ExtensionContext initializeDomainRegistry(final ManagementResourc
242254

243255
// Root Deployments
244256
final ManagementResourceRegistration deployments = root.registerSubModel(PathElement.pathElement(DEPLOYMENT), DomainDescriptionProviders.DEPLOYMENT_PROVIDER);
245-
DeploymentAddHandler dah = new DeploymentAddHandler(contentRepo);
257+
DeploymentAddHandler dah = isMaster ? new DeploymentAddHandler(contentRepo) : new DeploymentAddHandler();
246258
deployments.registerOperationHandler(DeploymentAddHandler.OPERATION_NAME, dah, dah);
247-
DeploymentRemoveHandler drh = new DeploymentRemoveHandler(contentRepo);
259+
DeploymentRemoveHandler drh = isMaster ? new DeploymentRemoveHandler(contentRepo) : new DeploymentRemoveHandler();
248260
deployments.registerOperationHandler(DeploymentRemoveHandler.OPERATION_NAME, drh, drh);
249261

262+
// Management client content
263+
ManagedDMRContentTypeResourceDefinition plansDef = new ManagedDMRContentTypeResourceDefinition(contentRepo, ROLLOUT_PLAN,
264+
PathElement.pathElement(MANAGEMENT_CLIENT_CONTENT, ROLLOUT_PLANS), DomainRootDescription.getResourceDescriptionResolver(ROLLOUT_PLANS));
265+
ManagementResourceRegistration mgmtContent = root.registerSubModel(plansDef);
266+
ParameterValidator contentValidator = new ModelTypeValidator(ModelType.OBJECT); // TODO create a structural validator
267+
ManagedDMRContentResourceDefinition planDef = ManagedDMRContentResourceDefinition.create(ROLLOUT_PLAN, contentValidator, DomainRootDescription.getResourceDescriptionResolver(ROLLOUT_PLAN));
268+
mgmtContent.registerSubModel(planDef);
269+
250270
// Extensions
251271
final ManagementResourceRegistration extensions = root.registerSubModel(PathElement.pathElement(EXTENSION), CommonProviders.EXTENSION_PROVIDER);
252272
final ExtensionContext extensionContext = new ExtensionContextImpl(profile, deployments, configurationPersister, ProcessType.HOST_CONTROLLER);
@@ -256,7 +276,7 @@ private static ExtensionContext initializeDomainRegistry(final ManagementResourc
256276
extensions.registerOperationHandler(ExtensionRemoveHandler.OPERATION_NAME, removeExtensionHandler, removeExtensionHandler, false);
257277

258278
if(!isMaster) {
259-
ApplyRemoteMasterDomainModelHandler armdmh = new ApplyRemoteMasterDomainModelHandler(extensionContext, fileRepository, hostControllerInfo);
279+
ApplyRemoteMasterDomainModelHandler armdmh = new ApplyRemoteMasterDomainModelHandler(extensionContext, fileRepository, contentRepo, hostControllerInfo);
260280
root.registerOperationHandler(ApplyRemoteMasterDomainModelHandler.OPERATION_NAME, armdmh, armdmh, false, OperationEntry.EntryType.PRIVATE);
261281
} else {
262282
ReadMasterDomainModelHandler rmdmh = new ReadMasterDomainModelHandler(domainController, registry);

0 commit comments

Comments
 (0)