Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *
   *  * JBoss, Home of Professional Open Source.
   *  * Copyright 2013, Red Hat, Inc., and individual contributors
   *  * as indicated by the @author tags. See the copyright.txt file in the
   *  * distribution for a full listing of individual contributors.
   *  *
   *  * This is free software; you can redistribute it and/or modify it
   *  * under the terms of the GNU Lesser General Public License as
  *  * published by the Free Software Foundation; either version 2.1 of
  *  * the License, or (at your option) any later version.
  *  *
  *  * This software is distributed in the hope that it will be useful,
  *  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  *  * Lesser General Public License for more details.
  *  *
  *  * You should have received a copy of the GNU Lesser General Public
  *  * License along with this software; if not, write to the Free
  *  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  *  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  *
  */
 package org.jboss.as.domain.controller.operations;
 
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROFILE;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SERVER_GROUP;
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SOCKET_BINDING_GROUP;
 
 import java.util.Set;
 
Executed on the DC when a slave's server-config has its server-group or socket-binding-group override changed

Author(s):
Kabir Khan
 
 
     public static String OPERATION_NAME = "slave-server-config-change";
 
     protected final String host;
     protected final Transformers transformers;
 
     public PullDownDataForServerConfigOnSlaveHandler(final String hostfinal Transformers transformersDomainControllerRuntimeIgnoreTransformationRegistry runtimeIgnoreTransformationRegistry) {
         this. = host;
         this. = transformers;
         this. = runtimeIgnoreTransformationRegistry;
     }
 
     @Override
     public void execute(final OperationContext contextfinal ModelNode operationthrows OperationFailedException {
         context.acquireControllerLock();
 
         final ServerConfigInfo serverInfo = IgnoredNonAffectedServerGroupsUtil.createServerConfigInfo(operation.require());
 
         final Resource root = context.readResource(.);
 
         final Set<PathElementunknownElements = new HashSet<>();
 
         //Check the server group exists and if it is unknown
         final String serverGroupName = serverInfo.getServerGroup();
         final PathElement serverGroupElement = PathElement.pathElement(serverGroupName);
         final Resource serverGroupResource = root.getChild(serverGroupElement);
         if (serverGroupResource == null) {
             throw ..noResourceFor(PathAddress.pathAddress(serverGroupElement));
         }
 
         String serverGroupSocketBindingGroup = null;
         if (!.isServerGroupKnown(rootserverGroupName)) {
             unknownElements.add(serverGroupElement);
 
             //Look at the things brought in by the server group and see if they also need adding
             final ModelNode serverGroupModel = serverGroupResource.getModel();
 
             //server-group's profile
             final String profileName = serverGroupModel.get().asString();
             final PathElement profileElement = PathElement.pathElement(profileName);
             final Resource profileResource = root.getChild(profileElement);
             if (profileResource == null) {
                 throw ..noResourceFor(PathAddress.pathAddress(profileElement));
             }
 
            if (!.isProfileKnown(rootprofileName)) {
                unknownElements.add(profileElement);
                Set<PathElementunknownExtensions = .getUnknownExtensionsForProfile(rootprofileName);
                unknownElements.addAll(unknownExtensions);
            }
            //server-group's socket-binding group
            if (serverGroupModel.hasDefined()) {
                serverGroupSocketBindingGroup = serverGroupModel.get().asString();
                addSocketBindingGroup(unknownElementsrootserverGroupSocketBindingGroup);
            }
        }
        if (serverInfo.getSocketBindingGroup() != null && !serverInfo.getSocketBindingGroup().equals(serverGroupSocketBindingGroup)) {
            addSocketBindingGroup(unknownElementsrootserverInfo.getSocketBindingGroup());
        }
        final ReadMasterDomainModelUtil readUtil = ReadMasterDomainModelUtil.readMasterDomainResourcesForSlaveRequest(contextunknownElementsroot);
        context.getResult().set(readUtil.getDescribedResources());
        context.completeStep(new OperationContext.ResultHandler() {
            @Override
            public void handleResult(ResultAction resultActionOperationContext contextModelNode operation) {
                if (resultAction == .) {
                    //Since this method gets invoked as part of a transaction on the slave, gather the known resources and record them once the tx completes
                    .addKnownDataForSlave(readUtil.getNewKnownRootResources());
                    .updateSlaveServerConfig(serverInfo);
                }
            }
        });
    }
    private void addSocketBindingGroup(Set<PathElementunknownElementsResource rootString socketBindingGroupthrows OperationFailedException {
        final PathElement socketBindingGroupElement = PathElement.pathElement(socketBindingGroup);
        final Resource socketBindingGroupResource = root.getChild(socketBindingGroupElement);
        if (socketBindingGroupResource == null) {
            throw ..noResourceFor(PathAddress.pathAddress(socketBindingGroupElement));
        }
        if (!.isSocketBindingGroupKnown(rootsocketBindingGroup)) {
            unknownElements.add(socketBindingGroupElement);
        }
    }
New to GrepCode? Check out our FAQ X