epermana / tungsten-replicator

Automatically exported from code.google.com/p/tungsten-replicator
1 stars 0 forks source link

trepctl should be able to identify services by role #306

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. To which tool/application/daemon will this feature apply?

trepctl 

2. Describe the feature in general

We need to know which service in a multi-master node is the master and which 
ones are the slaves. Currently, we do that by parsing the output of "trepctl 
services".
We also need to know, given a service name, which host is the master for such 
service.

3. Describe the feature interface

we should be able to query trepctl for the following:

 * give me the master service for node $hostname 
 * give me the list of slave services for node $hostname
 * tell me the master host for service S in host $hostname
 * give me a qualified list of slave services with their corresponding master

4. Give an idea (if applicable) of a possible implementation

(syntax still to be finalized)
All the commands below (except "info all" return one string.

trepctl [-host H] info master num 
returns the number of master services (0 or 1)

trepctl [-host H] info services num 
returns the number of services 

trepctl [-host H] info slaves num
returns the number of slave services 

trepctl [-host H] info services
returns a space separated list of service names

trepctl [-host H] info master 
returns the name of the master (or relay) service for the given node
returns an empty string if there is no master on such node

trepctl [-host H] info slaves
returns a simple space separated list of service names
returns an empty string if there are no slaves

trepctl [-host H] info masterof service_name
returns the hostname where the master service for the given service name should 
be

trepctl info all
returns all the above information in one go.
master num:1
slaves num :3
master: service1
slaves: service2,service3,service4
services: service1,service2,service3,service4
masterof:service1 hostnameW
masterof:service2 hostnameX
masterof:service3 hostnameY
masteroof:service4 hostnameZ

5. Describe pros and cons of this feature.

5a. Why the world will be a better place with this feature.

These commands would help the creation of advanced scripting.
In shell scripting, the commands returning a single string would be used. In 
more advanced languages, "info all" may be called and used for further usage.

5b. What hardship will the human race have to endure if this feature is
implemented.

There is some overlapping with the information returned by other trepctl 
commands. But this command will avoid calling too many commands to get a single 
piece of information.

Original issue reported on code.google.com by g.maxia on 2 Mar 2012 at 7:19

GoogleCodeExporter commented 9 years ago
Some of these features are now available using the filter "simple_services" 
(http://code.google.com/p/tungsten-toolbox/downloads/list).

for example 
trepctl services | simple_services --role=master --action=list
alpha

trepctl services | simple_services --role=master --action=list
bravo,charlie

trepctl services | simple_services --service=alpha --action=role
master

trepctl services | simple_services --service=bravo --action=role
slave

Original comment by g.maxia on 4 Mar 2012 at 5:24