X Tutup
Skip to content

Commit a725aff

Browse files
committed
added find_active_apache_drill.py
1 parent 64f4865 commit a725aff

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

find_active_apache_drill.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python
2+
# vim:ts=4:sts=4:sw=4:et
3+
#
4+
# Author: Hari Sekhon
5+
# Date: Wed Sep 13 13:58:21 CEST 2017
6+
#
7+
# https://github.com/harisekhon/pytools
8+
#
9+
# License: see accompanying Hari Sekhon LICENSE file
10+
#
11+
# If you're using my code you're welcome to connect with me on LinkedIn
12+
# and optionally send me feedback to help steer this or other code I publish
13+
#
14+
# https://www.linkedin.com/in/harisekhon
15+
#
16+
17+
"""
18+
19+
Tool to return the first responsive Apache Drill node from an argument list of hosts
20+
21+
Can mix and match between a comma separated list of hosts (--host server1,server2 or contents of the $HOST
22+
environment variable if not specified) and general free-form space separated arguments, which is useful if piping
23+
a host list through xargs.
24+
25+
Multi-threaded for speed and exits upon first available host response to minimize delay to ~ 1 second or less.
26+
27+
Useful for simplying scripting or generically extending tools that don't support HBase High Availability directly
28+
29+
By default checks the same --port on all servers. Hosts may have optional :<port> suffixes added to individually
30+
override each one.
31+
32+
Exits with return code 1 and NO_AVAILABLE_SERVER if none of the namenodes are active, --quiet mode will not print
33+
NO_AVAILABLE_SERVER.
34+
35+
Tested on Apache Drill 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11
36+
37+
"""
38+
39+
from __future__ import absolute_import
40+
from __future__ import division
41+
from __future__ import print_function
42+
#from __future__ import unicode_literals
43+
44+
import os
45+
import sys
46+
import traceback
47+
#from random import shuffle
48+
srcdir = os.path.abspath(os.path.dirname(__file__))
49+
libdir = os.path.join(srcdir, 'pylib')
50+
sys.path.append(libdir)
51+
try:
52+
# pylint: disable=wrong-import-position
53+
from find_active_server import FindActiveServer
54+
except ImportError as _:
55+
print(traceback.format_exc(), end='')
56+
sys.exit(4)
57+
58+
__author__ = 'Hari Sekhon'
59+
__version__ = '0.7.1'
60+
61+
62+
class FindActiveApacheDrill(FindActiveServer):
63+
64+
def __init__(self):
65+
# Python 2.x
66+
super(FindActiveApacheDrill, self).__init__()
67+
# Python 3.x
68+
# super().__init__()
69+
self.default_port = 8047
70+
self.protocol = 'http'
71+
self.url_path = '/status'
72+
self.regex = r'Running'
73+
74+
def add_options(self):
75+
self.add_hostoption(name='Apache Drill', default_port=self.default_port)
76+
self.add_ssl_opt()
77+
self.add_common_opts()
78+
79+
def process_options(self):
80+
self.validate_common_opts()
81+
82+
83+
if __name__ == '__main__':
84+
FindActiveApacheDrill().main()

0 commit comments

Comments
 (0)
X Tutup