Child pages
  • Service Advisor
Skip to end of metadata
Go to start of metadata

Each custom service can provide a service advisor as a Python script named service-advisor.py in their service folder. A Service Advisor allows custom services to integrate into the stack advisor behavior which only applies to the services within the stack.

Service Advisor Inheritance

Unlike the Stack-advisor scripts, the service-advisor scripts do not automatically extend the parent service's service-advisor scripts. The service-advisor script needs to explicitly extend their parent's service service-advisor script.  The following code sample shows how you would refer to a parent's service_advisor.py.  In this case it is extending the root service-advisor.py file in the resources/stacks directory.

Sample service-advisor.py file inheritance
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
STACKS_DIR = os.path.join(SCRIPT_DIR, '../../../stacks/')
PARENT_FILE = os.path.join(STACKS_DIR, 'service_advisor.py')

try:
  with open(PARENT_FILE, 'rb') as fp:
    service_advisor = imp.load_module('service_advisor', fp, PARENT_FILE, ('.py', 'rb', imp.PY_SOURCE))
except Exception as e:
  traceback.print_exc()
  print "Failed to load parent"

class HAWQ200ServiceAdvisor(service_advisor.ServiceAdvisor):

Service Advisor Behavior

Like the stack advisors, service advisors provide information on 4 important aspects for the service:

  1. Recommend layout of the service on cluster
  2. Recommend service configurations
  3. Validate layout of the service on cluster
  4. Validate service configurations

By providing the service-advisor.py file, one can control dynamically each of the above for the service. 

The main interface for the service-advisor scripts contains documentation on how each of the above are called, and what data is provided.

Base service_advisor.py from resources/stacks
class ServiceAdvisor(DefaultStackAdvisor):

  def colocateService(self, hostsComponentsMap, serviceComponents):
    pass

  def getServiceConfigurationRecommendations(self, configurations, clusterSummary, services, hosts):
    pass

  def getServiceComponentLayoutValidations(self, services, hosts):
    return []

  def getServiceConfigurationsValidationItems(self, configurations, recommendedDefaults, services, hosts):
    return []

Examples

  • No labels