Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2010, 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.plan;
 
 import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION;
 import static org.jboss.as.domain.controller.DomainControllerMessages.MESSAGES;
 
 import java.util.Set;
 
Policy used to determine whether a server can be updated, based on the result of updates made to other servers.

Author(s):
Brian Stansberry
 
     private final ConcurrentGroupServerUpdatePolicy parent;
     private final String serverGroupName;
     private final Set<ServerIdentityservers;
     private int successCount;
     private int failureCount;
     private final int maxFailed;

    
Constructor for normal case where the max number of failures before plan is considered failed comes from the plan.

Parameters:
parent parent policy
serverGroupName the name of the server group being updated
servers servers that are being updated
maxFailures maximum number of failed servers before the server group should be rolled back
 
                             final String serverGroupName,
                             final Set<ServerIdentityservers,
                             final int maxFailures) {
         assert parent != null : "parent is null";
         assert serverGroupName != null : "serverGroupName is null";
         assert servers != null : "servers is null";
 
         this. = parent;
         this. = serverGroupName;
         this. = servers;
         this. = maxFailures;
     }

    
Constructor for the rollback case where failure on one server should not prevent execution on the others.

Parameters:
parent parent policy
serverGroupName the name of the server group being updated
servers servers that are being updated
 
                        final String serverGroupName,
                        final Set<ServerIdentityservers) {
         assert parent != null : "parent is null";
         assert serverGroupName != null : "serverGroupName is null";
         assert servers != null : "servers is null";
 
         this. = parent;
         this. = serverGroupName;
         this. = servers;
         this. = servers.size();
     }

    
Gets the name of the server group to which this policy is scoped.

Returns:
the name of the server group. Will not be null
 
     public String getServerGroupName() {
         return ;
     }

    
Gets whether the given server can be updated.

Parameters:
server the id of the server. Cannot be null
Returns:
true if the server can be updated; false if the update should be cancelled
Throws:
java.lang.IllegalStateException if this policy is not expecting a request to update the given server
    public boolean canUpdateServer(ServerIdentity server) {
        if (!.equals(server.getServerGroupName()) || !.contains(server)) {
            throw .unknownServer(server);
        }
        if (!.canChildProceed())
            return false;
        synchronized (this) {
            return  <= ;
        }
    }

    
Records the result of updating a server.

Parameters:
server the id of the server. Cannot be null
response the result of the updates
    public void recordServerResult(ServerIdentity serverModelNode response) {
        if (!.equals(server.getServerGroupName()) || !.contains(server)) {
            throw .unknownServer(server);
        }
        boolean serverFailed = response.has();
        ..tracef("Recording server result for '%s': failed = %s",
                serverserver);
        synchronized (this) {
            int previousFailed = ;
            if (serverFailed) {
                ++;
            }
            else {
                ++;
            }
            if (previousFailed <= ) {
                if (!serverFailed && ( + ) == .size()) {
                    // All results are in; notify parent of success
                    .recordServerGroupResult(false);
                }
                else if (serverFailed &&  > ) {
                    .recordServerGroupResult(true);
                }
            }
        }
    }

    
Gets whether the recordServerResult(org.jboss.as.domain.controller.ServerIdentity,org.jboss.dmr.ModelNode) recorded results} constitute a failed server group update per this policy.

Returns:
true if the server group update is considered to be a failure; false otherwise
    public synchronized boolean isFailed() {
        return  > ;
    }
New to GrepCode? Check out our FAQ X