ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Srimanth Gunturi <>
Subject Re: Is there any guide on how to write stackadvisor ?
Date Tue, 26 Jan 2016 18:50:15 GMT
Hi Jeff,

The closest we have to documentation is the python doc comments we have in the base abstract
class of StackAdvisor -

Each stack advisor does 4 things for which there are 4 ?abstract methods

1. recommend component layout - def recommendComponentLayout(self, services, hosts)

2. validate component layout - def validateComponentLayout(self, services, hosts)

3. recommend configurations based on layout - def recommendConfigurations(self, services,

4. validate configurations based on layout - def validateConfigurations(self, services, hosts)

If you notice, all 4 methods are passed 2 important pieces of information:

1. services - Contains any/all information about services being installed and which hosts
they are installed on

2. hosts - Contains any/all information about hosts in cluster

The above 2 data structures will tell you anything about the cluster being created/edited.

So to the question about 'how to get the number of nodemangers' - it should be available by
parsing both these data structures. We have utility method called 'def getHostsWithComponent(self,
serviceName, componentName, services, hosts)' which gets the hosts a particular component
is installed. You can see its usage at -

Hoping this helps.

Best regards,


From: Mithun Mathew <>
Sent: Monday, January 25, 2016 8:50 PM
Subject: Re: Is there any guide on how to write stackadvisor ?

Hi Jeff

Some existing implementation might help you give an idea of how stack_advisor is implemented
to component layout recommendation:

If you can explain what exactly you are trying to achieve, I might be able to help you with


On Mon, Jan 25, 2016 at 4:31 PM, Jeff Zhang <<>>
I try to add stackadvisor for one component. The logic is simple, but don't know how to do
that use ambari api. e.g. how to get the number of nodemangers, how to get the number of hosts
that with my service deployed.  If there's any python api doc, there would be very helpful.

Best Regards

Jeff Zhang

Mithun Mathew (Matt)


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message