@Override protected void applyUpdate(final DomainModel element) throws UpdateFailedException { final ServerGroupElement serverGroup = element.getServerGroup(serverGroupName); if (serverGroup == null) { throw new UpdateFailedException("Server group " + serverGroupName + " does not exist"); } serverGroupUpdate.applyUpdate(serverGroup); }
/** {@inheritDoc} */ @Override protected void applyUpdate(DomainModel element) throws UpdateFailedException { StringBuilder illegal = null; for (String groupName : element.getServerGroupNames()) { ServerGroupElement sge = element.getServerGroup(groupName); if (bindingGroupName.equals(sge.getSocketBindingGroupName())) { if (illegal == null) { illegal = new StringBuilder(groupName); } else { illegal.append(", "); illegal.append(groupName); } } } if (illegal != null) { throw new UpdateFailedException(String.format("Socket binding group %s cannot " + "be removed as it is referenced by server groups %s", this.bindingGroupName, illegal.toString())); } if(! element.removeBindingGroup(bindingGroupName)) { throw new UpdateFailedException(String.format("binding-group (%s) does not exist", bindingGroupName)); } }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { // Finds groups with our deployment Set<String> groupNames = new HashSet<String>(domainModel.getServerGroupNames()); for (Iterator<String> it = groupNames.iterator(); it.hasNext();) { String groupName = it.next(); ServerGroupElement group = domainModel.getServerGroup(groupName); ServerGroupDeploymentElement sgde = group.getDeployment(uniqueName); if (sgde == null) { it.remove(); } } // Find servers in those groups List<String> result = new ArrayList<String>(); for (String serverName : hostModel.getActiveServerNames()) { ServerElement server = hostModel.getServer(serverName); if (groupNames.contains(server.getServerGroup())) { result.add(serverName); } } return result; } }
@Override public DomainServerGroupUpdate<?> getCompensatingUpdate(final DomainModel original) { final ServerGroupElement serverGroup = original.getServerGroup(serverGroupName); if (serverGroup == null) return null; return create(serverGroupName, serverGroupUpdate.getCompensatingUpdate(serverGroup)); }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { // Finds groups with our deployment Set<String> groupNames = new HashSet<String>(domainModel.getServerGroupNames()); for (Iterator<String> it = groupNames.iterator(); it.hasNext();) { String groupName = it.next(); ServerGroupElement group = domainModel.getServerGroup(groupName); ServerGroupDeploymentElement sgde = group.getDeployment(uniqueName); if (sgde == null) { it.remove(); } } // Find servers in those groups List<String> result = new ArrayList<String>(); for (String serverName : hostModel.getActiveServerNames()) { ServerElement server = hostModel.getServer(serverName); if (groupNames.contains(server.getServerGroup())) { result.add(serverName); } } return result; } }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { List<String> result = new ArrayList<String>(); for (String serverName : hostModel.getActiveServerNames()) { ServerElement server = hostModel.getServer(serverName); if (socketGroupName.equals(server.getSocketBindingGroupName()) || socketGroupName.equals(domainModel.getServerGroup(server.getServerGroup()).getSocketBindingGroupName())) { result.add(serverName); } } return result; }
@Override protected void applyUpdate(final DomainModel element) throws UpdateFailedException { // Validate empty ProfileElement pe = element.getProfile(profileName); if (pe != null && (pe.getIncludedProfiles().size() > 0 || pe.getSubsystems().size() > 0)) { throw new UpdateFailedException("Profile '" + profileName + "' is not empty and cannot be removed"); } // Validate unused StringBuilder illegal = null; for (String serverGroupName : element.getServerGroupNames()) { ServerGroupElement sge = element.getServerGroup(serverGroupName); if (profileName.equals(sge.getName())) { if (illegal == null) { illegal = new StringBuilder(sge.getName()); } else { illegal.append(", "); illegal.append(sge.getName()); } } } if (illegal != null) { throw new UpdateFailedException(String.format("Profile %s cannot be removed as it is still used by server groups %s", profileName, illegal.toString())); } element.removeProfile(profileName); }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { if (getServerModelUpdate() == null) { return Collections.emptyList(); } else { List<String> result = new ArrayList<String>(); // Relevant profiles keyed by the name of those that include them Map<String, Set<String>> includedProfilesByRoot = new HashMap<String, Set<String>>(); for (String server : hostModel.getActiveServerNames()) { String serverGroupName = hostModel.getServer(server).getServerGroup(); String sgProfileName = domainModel.getServerGroup(serverGroupName).getProfileName(); if (!includedProfilesByRoot.containsKey(sgProfileName)) { // Find all the profiles related to this server group's profile includedProfilesByRoot.put(sgProfileName, domainModel.getProfiles(sgProfileName).keySet()); } if (includedProfilesByRoot.get(sgProfileName).contains(profileName)) { result.add(server); } } return result; } } }
@Override protected void applyUpdate(final DomainModel element) throws UpdateFailedException { if (!element.removeDeployment(uniqueName)) { throw new UpdateFailedException("Deployment '" + uniqueName + "' did not exist; cannot replace it"); } DeploymentUnitElement due = new DeploymentUnitElement(uniqueName, runtimeName, hash, start); element.addDeployment(due); for (String groupName : element.getServerGroupNames()) { ServerGroupElement group = element.getServerGroup(groupName); ServerGroupDeploymentElement sgde = group.getDeployment(uniqueName); if (group.removeDeployment(groupName)) { group.addDeployment(uniqueName, runtimeName, hash, sgde.isStart()); } } }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { if (getServerModelUpdate() == null) { return Collections.emptyList(); } else { List<String> result = new ArrayList<String>(); for (String server : hostModel.getActiveServerNames()) { String serverGroupName = hostModel.getServer(server).getServerGroup(); if (profileName.equals(domainModel.getServerGroup(serverGroupName).getProfileName())) { result.add(server); } } return result; } } }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { if (getServerModelUpdate() == null) { return Collections.emptyList(); } else { List<String> result = new ArrayList<String>(); for (String server : hostModel.getActiveServerNames()) { String serverGroupName = hostModel.getServer(server).getServerGroup(); if (profileName.equals(domainModel.getServerGroup(serverGroupName).getProfileName())) { result.add(server); } } return result; } } }
/** {@inheritDoc} */ @Override public AbstractDomainModelUpdate<?> getCompensatingUpdate(DomainModel original) { final ServerGroupElement group = original.getServerGroup(serverGroupName); return new DomainServerGroupAdd(group.getName(), group.getProfileName()); }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { String propertyName = propertyUpdate.getPropertyName(); if (hostModel.getSystemProperties().getPropertyNames().contains(propertyName)) { // This property is overridden on host and thus on all servers, // so no servers are affected by this change return Collections.emptyList(); } List<String> activeServers = hostModel.getActiveServerNames(); // Remove any server that directly overrides the property or whose // server group overrides the property for (Iterator<String> it = activeServers.iterator(); it.hasNext();) { ServerElement server = hostModel.getServer(it.next()); if (server.getSystemProperties().getPropertyNames().contains(propertyName)) { it.remove(); } else { ServerGroupElement sge = domainModel.getServerGroup(server.getServerGroup()); if (sge.getSystemProperties().getPropertyNames().contains(propertyName)) { it.remove(); } } } return activeServers; } }
final ServerGroupElement serverGroup = domainModel.getServerGroup(serverGroupName); if (serverGroup == null) { throw new IllegalArgumentException("Domain model does not contain a server group named '" + serverGroupName + "'");