Procházet zdrojové kódy

Revert "AMBARI-7043. BE: Move stack_advisor.py abstract class one folder up"

This reverts commit 40e3f0fc5d34b4d96a95e0e568e8754b042dc6f5.
Yusaku Sako před 10 roky
rodič
revize
4c5ed4c0cf

+ 1 - 1
ambari-server/src/main/resources/scripts/stack_advisor.py

@@ -33,7 +33,7 @@ ALL_ACTIONS = [ RECOMMEND_COMPONENT_LAYOUT_ACTION, VALIDATE_COMPONENT_LAYOUT_ACT
 USAGE = "Usage: <action> <hosts_file> <services_file>\nPossible actions are: {0}\n".format( str(ALL_ACTIONS) )
 
 SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
-STACK_ADVISOR_PATH_TEMPLATE = os.path.join(SCRIPT_DIRECTORY, '../stacks/stack_advisor.py')
+STACK_ADVISOR_PATH_TEMPLATE = os.path.join(SCRIPT_DIRECTORY, '../stacks/{0}/stack_advisor.py')
 STACK_ADVISOR_IMPL_PATH_TEMPLATE = os.path.join(SCRIPT_DIRECTORY, './../stacks/{0}/{1}/services/stack_advisor.py')
 STACK_ADVISOR_IMPL_CLASS_TEMPLATE = '{0}{1}StackAdvisor'
 

+ 0 - 0
ambari-server/src/main/resources/stacks/stack_advisor.py → ambari-server/src/main/resources/stacks/HDP/stack_advisor.py


+ 1 - 3
ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java

@@ -73,7 +73,6 @@ import com.google.inject.Injector;
 public class AmbariMetaInfoTest {
 
   private static final String STACK_NAME_HDP = "HDP";
-  private static final String STACK_NAME_XYZ = "XYZ";
   private static final String STACK_VERSION_HDP = "0.1";
   private static final String EXT_STACK_NAME = "2.0.6";
   private static final String STACK_VERSION_HDP_02 = "0.2";
@@ -89,7 +88,7 @@ public class AmbariMetaInfoTest {
   private static final String NON_EXT_VALUE = "XXX";
 
   private static final int REPOS_CNT = 3;
-  private static final int STACKS_NAMES_CNT = 2;
+  private static final int STACKS_NAMES_CNT = 1;
   private static final int PROPERTIES_CNT = 62;
   private static final int OS_CNT = 4;
 
@@ -409,7 +408,6 @@ public class AmbariMetaInfoTest {
     Set<Stack> stackNames = metaInfo.getStackNames();
     assertEquals(stackNames.size(), STACKS_NAMES_CNT);
     assertTrue(stackNames.contains(new Stack(STACK_NAME_HDP)));
-    assertTrue(stackNames.contains(new Stack(STACK_NAME_XYZ)));
   }
 
   @Test

+ 1 - 1
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java

@@ -156,7 +156,7 @@ public class AmbariManagementControllerTest {
   private static final String NAGIOS_SERVICE_NAME = "NAGIOS";
   private static final int STACK_VERSIONS_CNT = 12;
   private static final int REPOS_CNT = 3;
-  private static final int STACKS_CNT = 2;
+  private static final int STACKS_CNT = 1;
   private static final int STACK_PROPERTIES_CNT = 99;
   private static final int STACK_COMPONENTS_CNT = 4;
   private static final int OS_CNT = 2;

+ 0 - 93
ambari-server/src/test/python/TestStackAdvisor.py

@@ -1,93 +0,0 @@
-'''
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-'''
-
-from unittest import TestCase
-import os
-
-class TestStackAdvisorInitialization(TestCase):
-
-  def setUp(self):
-    import imp
-
-    self.test_directory = os.path.dirname(os.path.abspath(__file__))
-    stack_advisor_path = os.path.join(self.test_directory, '../../main/resources/scripts/stack_advisor.py')
-    with open(stack_advisor_path, 'rb') as fp:
-        self.stack_advisor = imp.load_module( 'stack_advisor', fp, stack_advisor_path, ('.py', 'rb', imp.PY_SOURCE) )
-
-  def test_stackAdvisorLoadedForNotHDPStack(self):
-    path_template = os.path.join(self.test_directory, '../resources/stacks/{0}/{1}/services/stack_advisor.py')
-    path_template_name = "STACK_ADVISOR_IMPL_PATH_TEMPLATE"
-    setattr(self.stack_advisor, path_template_name, path_template)
-    self.assertEquals(path_template, getattr(self.stack_advisor, path_template_name))
-    instantiate_stack_advisor_method_name = 'instantiateStackAdvisor'
-    instantiate_stack_advisor_method = getattr(self.stack_advisor, instantiate_stack_advisor_method_name)
-    stack_advisor = instantiate_stack_advisor_method("XYZ", "1.0.1", ["1.0.0"])
-    self.assertEquals("XYZ101StackAdvisor", stack_advisor.__class__.__name__)
-    services = {"Versions":
-                  {
-                    "stack_name":"XYZ",
-                    "stack_version":"1.0.1"
-                  },
-                "services":[
-                  {
-                    "StackServices":{
-                      "service_name":"YARN"
-                    },
-                    "components":[
-                      {
-                        "StackServiceComponents": {
-                          "component_name": "RESOURCEMANAGER"
-                        }
-                      },
-                      {
-                        "StackServiceComponents": {
-                          "component_name": "APP_TIMELINE_SERVER"
-                        }
-                      },
-                      {
-                        "StackServiceComponents": {
-                          "component_name":"YARN_CLIENT"
-                        }
-                      },
-                      {
-                        "StackServiceComponents": {
-                          "component_name": "NODEMANAGER"
-                        }
-                      }
-                    ]
-                  }
-                ]
-    }
-    hosts= {
-      "items": [
-        {"Hosts": {"host_name": "host1"}},
-        {"Hosts": {"host_name": "host2"}}
-      ]
-    }
-    config_recommendations = stack_advisor.recommendConfigurations(services, hosts)
-    yarn_configs = config_recommendations["recommendations"]["blueprint"]["configurations"]["yarn-site"]["properties"]
-    '''Check that value is populated from child class, not parent'''
-    self.assertEquals("-Xmx101m", yarn_configs["yarn.nodemanager.resource.memory-mb"])
-
-  def test_stackAdvisorSuperClassIsFoundAndReturnedAsDefaultImpl(self):
-    instantiate_stack_advisor_method_name = 'instantiateStackAdvisor'
-    instantiate_stack_advisor_method = getattr(self.stack_advisor, instantiate_stack_advisor_method_name)
-    '''Not existent stack - to return default implementation'''
-    default_stack_advisor = instantiate_stack_advisor_method("HDP1", "2.0.6", [])
-    self.assertEquals("StackAdvisor", default_stack_advisor.__class__.__name__)
-

+ 1 - 1
ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py

@@ -26,7 +26,7 @@ class TestHDP206StackAdvisor(TestCase):
     import os
 
     testDirectory = os.path.dirname(os.path.abspath(__file__))
-    stackAdvisorPath = os.path.join(testDirectory, '../../../../../main/resources/stacks/stack_advisor.py')
+    stackAdvisorPath = os.path.join(testDirectory, '../../../../../main/resources/stacks/HDP/stack_advisor.py')
     hdp206StackAdvisorPath = os.path.join(testDirectory, '../../../../../main/resources/stacks/HDP/2.0.6/services/stack_advisor.py')
     hdp206StackAdvisorClassName = 'HDP206StackAdvisor'
     with open(stackAdvisorPath, 'rb') as fp:

+ 0 - 67
ambari-server/src/test/resources/stacks/XYZ/1.0.0/services/stack_advisor.py

@@ -1,67 +0,0 @@
-#!/usr/bin/env ambari-python-wrap
-"""
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
-from stack_advisor import StackAdvisor
-
-class XYZ100StackAdvisor(StackAdvisor):
-
-  def recommendConfigurations(self, services, hosts):
-    stackName = services["Versions"]["stack_name"]
-    stackVersion = services["Versions"]["stack_version"]
-    hostsList = [host["Hosts"]["host_name"] for host in hosts["items"]]
-    servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
-
-    recommendations = {
-      "Versions": {"stack_name": stackName, "stack_version": stackVersion},
-      "hosts": hostsList,
-      "services": servicesList,
-      "recommendations": {
-        "blueprint": {
-          "configurations": {},
-          "host_groups": []
-        },
-        "blueprint_cluster_binding": {
-          "host_groups": []
-        }
-      }
-    }
-
-    configurations = recommendations["recommendations"]["blueprint"]["configurations"]
-    for service in servicesList:
-      calculation = self.recommendServiceConfigurations(service)
-      if calculation is not None:
-        calculation(configurations)
-
-    return recommendations
-
-  def recommendServiceConfigurations(self, service):
-    return {
-      "YARN": self.recommendYARNConfigurations,
-    }.get(service, None)
-
-  def putProperty(self, config, configType):
-    config[configType] = {"properties": {}}
-    def appendProperty(key, value):
-      config[configType]["properties"][key] = str(value)
-    return appendProperty
-
-  def recommendYARNConfigurations(self, configurations):
-    putYarnProperty = self.putProperty(configurations, "yarn-site")
-    putYarnProperty('yarn.nodemanager.resource.memory-mb', "-Xmx100m")
-

+ 0 - 30
ambari-server/src/test/resources/stacks/XYZ/1.0.1/services/stack_advisor.py

@@ -1,30 +0,0 @@
-#!/usr/bin/env ambari-python-wrap
-"""
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-"""
-
-import re
-import socket
-import sys
-
-from stack_advisor import StackAdvisor
-
-class XYZ101StackAdvisor(XYZ100StackAdvisor):
-
-  def recommendYARNConfigurations(self, configurations):
-    putYarnProperty = self.putProperty(configurations, "yarn-site")
-    putYarnProperty('yarn.nodemanager.resource.memory-mb', "-Xmx101m")