|
@@ -19,6 +19,7 @@
|
|
|
package org.apache.ambari.server.controller;
|
|
|
|
|
|
import org.apache.ambari.server.state.AutoDeployInfo;
|
|
|
+import org.apache.ambari.server.state.BulkCommandDefinition;
|
|
|
import org.apache.ambari.server.state.ComponentInfo;
|
|
|
import org.apache.ambari.server.state.CustomCommandDefinition;
|
|
|
|
|
@@ -95,6 +96,9 @@ public class StackServiceComponentResponse {
|
|
|
*/
|
|
|
private boolean recoveryEnabled;
|
|
|
|
|
|
+ private String bulkCommandsDisplayName;
|
|
|
+ private String bulkCommandMasterComponentName;
|
|
|
+ private boolean hasBulkCommands;
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -112,6 +116,9 @@ public class StackServiceComponentResponse {
|
|
|
versionAdvertised = component.isVersionAdvertised();
|
|
|
autoDeploy = component.getAutoDeploy();
|
|
|
recoveryEnabled = component.isRecoveryEnabled();
|
|
|
+ hasBulkCommands = componentHasBulkCommands(component);
|
|
|
+ bulkCommandsDisplayName = getBulkCommandsDisplayName(component);
|
|
|
+ bulkCommandMasterComponentName = getBulkCommandsMasterComponentName(component);
|
|
|
|
|
|
// the custom command names defined for this component
|
|
|
List<CustomCommandDefinition> definitions = component.getCustomCommands();
|
|
@@ -125,6 +132,54 @@ public class StackServiceComponentResponse {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get bulk command master component name
|
|
|
+ *
|
|
|
+ * @param component
|
|
|
+ * the component to generate the response from (not {@code null}).
|
|
|
+ * @return master component name
|
|
|
+ */
|
|
|
+ private String getBulkCommandsMasterComponentName(ComponentInfo component) {
|
|
|
+ BulkCommandDefinition o = component.getBulkCommandDefinition();
|
|
|
+ if (o == null) {
|
|
|
+ return "";
|
|
|
+ } else {
|
|
|
+ return o.getMasterComponent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the display name shown on the user interface which bulk commands are grouped under
|
|
|
+ *
|
|
|
+ * @param component
|
|
|
+ * the component to generate the response from (not {@code null}).
|
|
|
+ * @return display name of the bulk command group
|
|
|
+ */
|
|
|
+ private String getBulkCommandsDisplayName(ComponentInfo component) {
|
|
|
+ BulkCommandDefinition o = component.getBulkCommandDefinition();
|
|
|
+ if (o == null) {
|
|
|
+ return "";
|
|
|
+ } else {
|
|
|
+ return o.getDisplayName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Determine if the component has bulk commands
|
|
|
+ *
|
|
|
+ * @param component
|
|
|
+ * the component to generate the response from (not {@code null}).
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
+ private boolean componentHasBulkCommands(ComponentInfo component) {
|
|
|
+ BulkCommandDefinition o = component.getBulkCommandDefinition();
|
|
|
+ if (o == null) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return o.getDisplayName() != null && !o.getDisplayName().trim().isEmpty();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Get stack name.
|
|
|
*
|
|
@@ -352,4 +407,16 @@ public class StackServiceComponentResponse {
|
|
|
public List<String> getCustomCommands() {
|
|
|
return customCommands;
|
|
|
}
|
|
|
+
|
|
|
+ public boolean hasBulkCommands(){
|
|
|
+ return hasBulkCommands;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getBulkCommandsDisplayName(){
|
|
|
+ return bulkCommandsDisplayName == null ? "":bulkCommandsDisplayName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getBulkCommandsMasterComponentName(){
|
|
|
+ return bulkCommandMasterComponentName == null ? "":bulkCommandMasterComponentName;
|
|
|
+ }
|
|
|
}
|