[07/50] [abbrv] ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/12a3cd87 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/12a3cd87 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/12a3cd87 Branch: refs/heads/branch-dev-patch-upgrade Commit: 12a3cd87184167cadf3cd12eb9b3c9d67dd3907a Parents: 5ec73bc Author: Jonathan HurleyAuthored: Sat Dec 3 08:35:12 2016 -0500 Committer: Jonathan Hurley Committed: Sat Dec 3 14:09:44 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../ambari/server/topology/TopologyManager.java | 19 ++- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 6 files changed, 121 insertions(+), 29 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/12a3cd87/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING : counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED :
[02/14] ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/12a3cd87 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/12a3cd87 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/12a3cd87 Branch: refs/heads/branch-feature-AMBARI-18456 Commit: 12a3cd87184167cadf3cd12eb9b3c9d67dd3907a Parents: 5ec73bc Author: Jonathan HurleyAuthored: Sat Dec 3 08:35:12 2016 -0500 Committer: Jonathan Hurley Committed: Sat Dec 3 14:09:44 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../ambari/server/topology/TopologyManager.java | 19 ++- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 6 files changed, 121 insertions(+), 29 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/12a3cd87/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING : counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED :
ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
Repository: ambari Updated Branches: refs/heads/branch-2.5 5e8a30210 -> 2fdd80873 AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2fdd8087 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2fdd8087 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2fdd8087 Branch: refs/heads/branch-2.5 Commit: 2fdd80873a4a31b53d39a101846cabc6a7bbd7e5 Parents: 5e8a302 Author: Jonathan HurleyAuthored: Sat Dec 3 08:35:12 2016 -0500 Committer: Jonathan Hurley Committed: Sat Dec 3 17:01:27 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../ambari/server/topology/TopologyManager.java | 19 ++- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 6 files changed, 121 insertions(+), 29 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/2fdd8087/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING :
ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
Repository: ambari Updated Branches: refs/heads/trunk 5ec73bce0 -> 12a3cd871 AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/12a3cd87 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/12a3cd87 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/12a3cd87 Branch: refs/heads/trunk Commit: 12a3cd87184167cadf3cd12eb9b3c9d67dd3907a Parents: 5ec73bc Author: Jonathan HurleyAuthored: Sat Dec 3 08:35:12 2016 -0500 Committer: Jonathan Hurley Committed: Sat Dec 3 14:09:44 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../ambari/server/topology/TopologyManager.java | 19 ++- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 6 files changed, 121 insertions(+), 29 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/12a3cd87/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING : counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ?
ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
Repository: ambari Updated Branches: refs/heads/branch-2.5 aec30d56a -> 19ca036c6 AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/19ca036c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/19ca036c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/19ca036c Branch: refs/heads/branch-2.5 Commit: 19ca036c683e6d1741f1b6d73a2f3326f3fc20fd Parents: aec30d5 Author: Jonathan HurleyAuthored: Thu Dec 1 15:49:06 2016 -0500 Committer: Jonathan Hurley Committed: Fri Dec 2 16:30:09 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 5 files changed, 103 insertions(+), 28 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/19ca036c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING : counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED :
[15/24] ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/32840c1e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/32840c1e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/32840c1e Branch: refs/heads/branch-feature-AMBARI-18456 Commit: 32840c1ed434ae4cc99e3ab6f7d3f2604fb69d06 Parents: f4ea309 Author: Jonathan HurleyAuthored: Thu Dec 1 15:49:06 2016 -0500 Committer: Jonathan Hurley Committed: Fri Dec 2 10:19:41 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 5 files changed, 103 insertions(+), 28 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/32840c1e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING : counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED : HostRoleStatus.HOLDING_TIMEDOUT; } + // Because tasks are not skippable,
[42/50] [abbrv] ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/32840c1e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/32840c1e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/32840c1e Branch: refs/heads/branch-dev-patch-upgrade Commit: 32840c1ed434ae4cc99e3ab6f7d3f2604fb69d06 Parents: f4ea309 Author: Jonathan HurleyAuthored: Thu Dec 1 15:49:06 2016 -0500 Committer: Jonathan Hurley Committed: Fri Dec 2 10:19:41 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 5 files changed, 103 insertions(+), 28 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/32840c1e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING : counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED : HostRoleStatus.HOLDING_TIMEDOUT; } + // Because tasks are not skippable,
ambari git commit: AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley)
Repository: ambari Updated Branches: refs/heads/trunk f4ea30919 -> 32840c1ed AMBARI-19055 - Removing Tasks From host_role_command Causes Upgrades To Show As PENDING (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/32840c1e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/32840c1e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/32840c1e Branch: refs/heads/trunk Commit: 32840c1ed434ae4cc99e3ab6f7d3f2604fb69d06 Parents: f4ea309 Author: Jonathan HurleyAuthored: Thu Dec 1 15:49:06 2016 -0500 Committer: Jonathan Hurley Committed: Fri Dec 2 10:19:41 2016 -0500 -- .../controller/internal/CalculatedStatus.java | 52 +++- .../internal/RequestResourceProvider.java | 34 - .../internal/StageResourceProvider.java | 2 +- .../internal/CalculatedStatusTest.java | 31 .../internal/RequestResourceProviderTest.java | 12 +++-- 5 files changed, 103 insertions(+), 28 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/32840c1e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java index 3a86aef..3c415df 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java @@ -53,6 +53,17 @@ public class CalculatedStatus { */ private final double percent; + /** + * A status which represents a COMPLETED state at 0% + */ + public static final CalculatedStatus COMPLETED = new CalculatedStatus(HostRoleStatus.COMPLETED, + HostRoleStatus.COMPLETED, 100.0); + + /** + * A status which represents a PENDING state at 0% + */ + public static final CalculatedStatus PENDING = new CalculatedStatus(HostRoleStatus.PENDING, + HostRoleStatus.PENDING, 0.0); // - Constructors -- @@ -79,12 +90,6 @@ public class CalculatedStatus { this.percent = percent; } - /** - * Static factory method to get Status that represents a Completed state - */ - public static CalculatedStatus getCompletedStatus() { -return new CalculatedStatus(HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, 100.0); - } // - CalculatedStatus -- @@ -291,14 +296,25 @@ public class CalculatedStatus { } /** - * Calculates the overall status of an upgrade. - * @param stageDto the map of stage-to-summary value objects - * @param stageIds the stage ids to consider from the value objects + * Calculates the overall status of an upgrade. If there are no tasks, then a + * status of {@link HostRoleStatus#COMPLETED} is returned. + * + * @param stageDto + * the map of stage-to-summary value objects + * @param stageIds + * the stage ids to consider from the value objects * @return the calculated status */ public static CalculatedStatus statusFromStageSummary(Map stageDto, Set stageIds) { +// if either are empty, then we have no tasks and therefore no status - we +// should return COMPLETED. This can happen if someone removes all tasks but +// leaves the stages and request +if (stageDto.isEmpty() || stageIds.isEmpty()) { + return COMPLETED; +} + Collection stageStatuses = new HashSet<>(); Collection stageDisplayStatuses = new HashSet<>(); Collection taskStatuses = new ArrayList<>(); @@ -378,19 +394,28 @@ public class CalculatedStatus { */ public static HostRoleStatus calculateSummaryStatusOfStage(Map counters, int total, boolean skippable) { + +// when there are 0 tasks, return COMPLETED +if (total == 0) { + return HostRoleStatus.COMPLETED; +} + if (counters.get(HostRoleStatus.PENDING) == total) { return HostRoleStatus.PENDING; } + // By definition, any tasks in a future stage must be held in a PENDING status. if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) { return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING : counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED :