PageRenderTime 39ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/jboss-as-7.1.1.Final/controller-client/src/main/java/org/jboss/as/controller/client/helpers/domain/impl/DeploymentActionResultImpl.java

#
Java | 114 lines | 71 code | 17 blank | 26 comment | 7 complexity | 041bda9924ab5479de9d211ad8cd3be7 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2010, 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. package org.jboss.as.controller.client.helpers.domain.impl;
  23. import java.util.Collections;
  24. import java.util.HashMap;
  25. import java.util.Map;
  26. import java.util.UUID;
  27. import org.jboss.as.controller.client.helpers.domain.DeploymentAction;
  28. import org.jboss.as.controller.client.helpers.domain.DeploymentActionResult;
  29. import org.jboss.as.controller.client.helpers.domain.ServerGroupDeploymentActionResult;
  30. import org.jboss.as.controller.client.helpers.domain.ServerIdentity;
  31. import org.jboss.as.controller.client.helpers.domain.ServerUpdateResult;
  32. import org.jboss.as.controller.client.helpers.domain.UpdateFailedException;
  33. /**
  34. * Default implementation of {@link DeploymentActionResult}.
  35. *
  36. * @author Brian Stansberry
  37. */
  38. class DeploymentActionResultImpl implements DeploymentActionResult {
  39. private final DeploymentAction deploymentAction;
  40. private final BasicDomainUpdateResult applierResponse;
  41. private final Map<String, ServerGroupDeploymentActionResult> serverResults = new HashMap<String, ServerGroupDeploymentActionResult>();
  42. private BasicDomainUpdateResult rollbackResponse;
  43. DeploymentActionResultImpl(final DeploymentAction deploymentAction,
  44. final BasicDomainUpdateResult applierResponse) {
  45. assert deploymentAction != null : "deploymentAction is null";
  46. assert applierResponse != null : "applierResponse is null";
  47. this.deploymentAction = deploymentAction;
  48. this.applierResponse = applierResponse;
  49. }
  50. @Override
  51. public DeploymentAction getDeploymentAction() {
  52. return deploymentAction;
  53. }
  54. @Override
  55. public UUID getDeploymentActionId() {
  56. return deploymentAction.getId();
  57. }
  58. @Override
  59. public UpdateFailedException getDomainControllerFailure() {
  60. return applierResponse.getDomainFailure();
  61. }
  62. @Override
  63. public Map<String, ServerGroupDeploymentActionResult> getResultsByServerGroup() {
  64. return Collections.unmodifiableMap(serverResults);
  65. }
  66. @Override
  67. public Map<String, UpdateFailedException> getHostControllerFailures() {
  68. return applierResponse.getHostFailures();
  69. }
  70. @Override
  71. public boolean isCancelledByDomain() {
  72. return applierResponse.isCancelled();
  73. }
  74. @Override
  75. public boolean isRolledBackOnDomain() {
  76. return rollbackResponse != null ? true : applierResponse.isRolledBack();
  77. }
  78. @Override
  79. public UpdateFailedException getDomainControllerRollbackFailure() {
  80. return rollbackResponse == null ? null : rollbackResponse.getDomainFailure();
  81. }
  82. @Override
  83. public Map<String, UpdateFailedException> getHostControllerRollbackFailures() {
  84. return rollbackResponse == null ? Collections.<String, UpdateFailedException>emptyMap(): rollbackResponse.getHostFailures();
  85. }
  86. void markRolledBack(BasicDomainUpdateResult rollbackResponse) {
  87. this.rollbackResponse = rollbackResponse;
  88. }
  89. void storeServerUpdateResult(ServerIdentity server, ServerUpdateResult result) {
  90. ServerGroupDeploymentActionResultImpl sgdar = (ServerGroupDeploymentActionResultImpl) serverResults.get(server.getServerGroupName());
  91. if (sgdar == null) {
  92. sgdar = new ServerGroupDeploymentActionResultImpl(server.getServerGroupName());
  93. serverResults.put(server.getServerGroupName(), sgdar);
  94. }
  95. sgdar.storeServerResult(server.getServerName(), result);
  96. }
  97. }