This is an automated email from the ASF dual-hosted git repository.
oleewere pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new d1744d4 AMBARI-23945. Add upgrade & restart/stop hidden service
component commands.
d1744d4 is described below
commit d1744d40f40d393d21fb85ceb084c65bff5733c0
Author: Oliver Szabo <[email protected]>
AuthorDate: Wed May 30 17:06:21 2018 +0200
AMBARI-23945. Add upgrade & restart/stop hidden service component commands.
---
.../src/main/python/migrationHelper.py | 178 ++++++++++++++++++++-
.../AMBARI_INFRA_SOLR/0.1.0/metainfo.xml | 20 +++
.../0.1.0/package/scripts/infra_solr.py | 13 ++
.../0.1.0/package/scripts/infra_solr_client.py | 13 +-
.../common-services/LOGSEARCH/0.5.0/metainfo.xml | 23 +++
.../LOGSEARCH/0.5.0/package/scripts/logfeeder.py | 13 +-
.../LOGSEARCH/0.5.0/package/scripts/logsearch.py | 13 ++
7 files changed, 266 insertions(+), 7 deletions(-)
diff --git
a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
index d340cb9..3c811d4 100755
--- a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
+++ b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
@@ -25,6 +25,7 @@ import urllib2
import json
import base64
import optparse
+import socket
import time
import traceback
import ConfigParser
@@ -41,6 +42,12 @@ SOLR_SERVICE_NAME = 'AMBARI_INFRA_SOLR'
SOLR_COMPONENT_NAME ='INFRA_SOLR'
+LOGSEARCH_SERVICE_NAME = 'LOGSEARCH'
+
+LOGSEARCH_SERVER_COMPONENT_NAME ='LOGSEARCH_SERVER'
+LOGSEARCH_LOGFEEDER_COMPONENT_NAME ='LOGSEARCH_LOGFEEDER'
+
+
CLUSTERS_URL = '/api/v1/clusters/{0}'
GET_HOSTS_COMPONENTS_URL =
'/services/{0}/components/{1}?fields=host_components'
@@ -285,7 +292,8 @@ def create_batch_command(command, hosts, cluster,
service_name, component_name,
return request_schedules
-def create_command_request(command, parameters, hosts, cluster, context):
+
+def create_command_request(command, parameters, hosts, cluster, context,
service=SOLR_SERVICE_NAME, component=SOLR_COMPONENT_NAME):
request = {}
request_info = {}
request_info["context"] = context
@@ -300,8 +308,8 @@ def create_command_request(command, parameters, hosts,
cluster, context):
request["RequestInfo"] = request_info
resource_filter = {}
- resource_filter["service_name"] = SOLR_SERVICE_NAME
- resource_filter["component_name"] = SOLR_COMPONENT_NAME
+ resource_filter["service_name"] = service
+ resource_filter["component_name"] = component
resource_filter["hosts"] = ','.join(hosts)
resource_filters = []
@@ -357,9 +365,13 @@ def validte_common_options(options, parser, config):
print 'collection option is required'
sys.exit(1)
-def get_solr_hosts(options, accessor, cluster):
- host_components_json = get_json(accessor, CLUSTERS_URL.format(cluster) +
GET_HOSTS_COMPONENTS_URL.format(SOLR_SERVICE_NAME, SOLR_COMPONENT_NAME))
+def get_service_components(options, accessor, cluster, service, component):
+ host_components_json = get_json(accessor, CLUSTERS_URL.format(cluster) +
GET_HOSTS_COMPONENTS_URL.format(service, component))
component_hosts = get_component_hosts(host_components_json)
+ return component_hosts
+
+def get_solr_hosts(options, accessor, cluster):
+ component_hosts = get_service_components(options, accessor, cluster,
SOLR_SERVICE_NAME, SOLR_COMPONENT_NAME)
if options.include_solr_hosts:
new_component_hosts = []
@@ -411,6 +423,148 @@ def backup(options, accessor, parser, config, collection,
index_location):
cmd_request = create_command_request("BACKUP", parameters, component_hosts,
cluster, 'Backup Solr Collection: ' + collection)
return post_json(accessor, CLUSTERS_URL.format(cluster) + REQUESTS_API_URL,
cmd_request)
+
+def upgrade_solr_instances(options, accessor, parser, config):
+ """
+ Upgrade (remove & re-install) infra solr instances
+ """
+ cluster = config.get('ambari_server', 'cluster')
+ solr_instance_hosts = get_service_components(options, accessor, cluster,
"AMBARI_INFRA_SOLR", "INFRA_SOLR")
+
+ context = "Upgrade Solr Instances"
+ sys.stdout.write("Sending upgrade request: [{0}] ".format(context))
+ sys.stdout.flush()
+
+ cmd_request = create_command_request("UPGRADE_SOLR_INSTANCE", {},
solr_instance_hosts, cluster, context)
+ response = post_json(accessor, CLUSTERS_URL.format(cluster) +
REQUESTS_API_URL, cmd_request)
+ request_id = get_request_id(response)
+ sys.stdout.write(colors.OKGREEN + 'DONE\n' + colors.ENDC)
+ sys.stdout.flush()
+ print 'Upgrade command request id: {0}'.format(request_id)
+ if options.async:
+ print "Upgrade request sent to Ambari server. Check Ambari UI about the
results."
+ sys.exit(0)
+ else:
+ sys.stdout.write("Start monitoring Ambari request with id {0}
...".format(request_id))
+ sys.stdout.flush()
+ cluster = config.get('ambari_server', 'cluster')
+ monitor_request(options, accessor, cluster, request_id, context)
+ print "{0}... {1} DONE{2}".format(context, colors.OKGREEN, colors.ENDC)
+
+def upgrade_solr_clients(options, accessor, parser, config):
+ """
+ Upgrade (remove & re-install) infra solr clients
+ """
+ cluster = config.get('ambari_server', 'cluster')
+ solr_client_hosts = get_service_components(options, accessor, cluster,
"AMBARI_INFRA_SOLR", "INFRA_SOLR_CLIENT")
+
+ fqdn = socket.getfqdn()
+ if fqdn in solr_client_hosts:
+ solr_client_hosts.remove(fqdn)
+ host = socket.gethostname()
+ if host in solr_client_hosts:
+ solr_client_hosts.remove(host)
+ context = "Upgrade Solr Clients"
+ sys.stdout.write("Sending upgrade request: [{0}] ".format(context))
+ sys.stdout.flush()
+
+ cmd_request = create_command_request("UPGRADE_SOLR_CLIENT", {},
solr_client_hosts, cluster, context, component="INFRA_SOLR_CLIENT")
+ response = post_json(accessor, CLUSTERS_URL.format(cluster) +
REQUESTS_API_URL, cmd_request)
+ request_id = get_request_id(response)
+ sys.stdout.write(colors.OKGREEN + 'DONE\n' + colors.ENDC)
+ sys.stdout.flush()
+ print 'Upgrade command request id: {0}'.format(request_id)
+ if options.async:
+ print "Upgrade request sent to Ambari server. Check Ambari UI about the
results."
+ sys.exit(0)
+ else:
+ sys.stdout.write("Start monitoring Ambari request with id {0}
...".format(request_id))
+ sys.stdout.flush()
+ cluster = config.get('ambari_server', 'cluster')
+ monitor_request(options, accessor, cluster, request_id, context)
+ print "{0}... {1}DONE{2}".format(context, colors.OKGREEN, colors.ENDC)
+
+def upgrade_logfeeders(options, accessor, parser, config):
+ """
+ Upgrade (remove & re-install) logfeeders
+ """
+ cluster = config.get('ambari_server', 'cluster')
+ logfeeder_hosts = get_service_components(options, accessor, cluster,
"LOGSEARCH", "LOGSEARCH_SERVER")
+
+ context = "Upgrade Log Feeders"
+ sys.stdout.write("Sending upgrade request: [{0}] ".format(context))
+ sys.stdout.flush()
+
+ cmd_request = create_command_request("UPGRADE_LOGFEEDER", {},
logfeeder_hosts, cluster, context, service="LOGSEARCH",
component="LOGSEARCH_LOGFEEDER")
+ response = post_json(accessor, CLUSTERS_URL.format(cluster) +
REQUESTS_API_URL, cmd_request)
+ request_id = get_request_id(response)
+ sys.stdout.write(colors.OKGREEN + 'DONE\n' + colors.ENDC)
+ sys.stdout.flush()
+ print 'Upgrade command request id: {0}'.format(request_id)
+ if options.async:
+ print "Upgrade request sent to Ambari server. Check Ambari UI about the
results."
+ sys.exit(0)
+ else:
+ sys.stdout.write("Start monitoring Ambari request with id {0}
...".format(request_id))
+ sys.stdout.flush()
+ cluster = config.get('ambari_server', 'cluster')
+ monitor_request(options, accessor, cluster, request_id, context)
+ print "{0}... {1} DONE{2}".format(context, colors.OKGREEN, colors.ENDC)
+
+def upgrade_logsearch_portal(options, accessor, parser, config):
+ """
+ Upgrade (remove & re-install) logsearch server instances
+ """
+ cluster = config.get('ambari_server', 'cluster')
+ logsearch_portal_hosts = get_service_components(options, accessor, cluster,
"LOGSEARCH", "LOGSEARCH_SERVER")
+
+ context = "Upgrade Log Search Portal"
+ sys.stdout.write("Sending upgrade request: [{0}] ".format(context))
+ sys.stdout.flush()
+
+ cmd_request = create_command_request("UPGRADE_LOGSEARCH_PORTAL", {},
logsearch_portal_hosts, cluster, context, service="LOGSEARCH",
component="LOGSEARCH_SERVER")
+ response = post_json(accessor, CLUSTERS_URL.format(cluster) +
REQUESTS_API_URL, cmd_request)
+ request_id = get_request_id(response)
+ sys.stdout.write(colors.OKGREEN + 'DONE\n' + colors.ENDC)
+ sys.stdout.flush()
+ print 'Upgrade command request id: {0}'.format(request_id)
+ if options.async:
+ print "Upgrade request sent to Ambari server. Check Ambari UI about the
results."
+ sys.exit(0)
+ else:
+ sys.stdout.write("Start monitoring Ambari request with id {0}
...".format(request_id))
+ sys.stdout.flush()
+ cluster = config.get('ambari_server', 'cluster')
+ monitor_request(options, accessor, cluster, request_id, context)
+ print "{0}... {1} DONE{2}".format(context, colors.OKGREEN, colors.ENDC)
+
+def service_components_command(options, accessor, parser, config, service,
component, command, command_str):
+ """
+ Run command on service components
+ """
+ cluster = config.get('ambari_server', 'cluster')
+ service_components = get_service_components(options, accessor, cluster,
service, component)
+
+ context = "{0} {1}".format(command_str, component)
+ sys.stdout.write("Sending '{0}' request: [{1}] ".format(command, context))
+ sys.stdout.flush()
+
+ cmd_request = create_command_request(command, {}, service_components,
cluster, context, service=service, component=component)
+ response = post_json(accessor, CLUSTERS_URL.format(cluster) +
REQUESTS_API_URL, cmd_request)
+ request_id = get_request_id(response)
+ sys.stdout.write(colors.OKGREEN + 'DONE\n' + colors.ENDC)
+ sys.stdout.flush()
+ print '{0} command request id: {1}'.format(command_str, request_id)
+ if options.async:
+ print "{0} request sent to Ambari server. Check Ambari UI about the
results.".format(command_str)
+ sys.exit(0)
+ else:
+ sys.stdout.write("Start monitoring Ambari request with id {0}
...".format(request_id))
+ sys.stdout.flush()
+ cluster = config.get('ambari_server', 'cluster')
+ monitor_request(options, accessor, cluster, request_id, context)
+ print "{0}... {1} DONE{2}".format(context, colors.OKGREEN, colors.ENDC)
+
def monitor_request(options, accessor, cluster, request_id, context):
while True:
request_response=get_json(accessor,
"/api/v1/clusters/{0}{1}/{2}".format(cluster, REQUESTS_API_URL, request_id))
@@ -1029,6 +1183,20 @@ if __name__=="__main__":
reload_collections(options, accessor, parser, config, service_filter)
elif options.action.lower() == 'migrate':
migrate_snapshots(options, accessor, parser, config, service_filter)
+ elif options.action.lower() == 'upgrade-solr-clients':
+ upgrade_solr_clients(options, accessor, parser, config)
+ elif options.action.lower() == 'upgrade-solr-instances':
+ upgrade_solr_instances(options, accessor, parser, config)
+ elif options.action.lower() == 'upgrade-logsearch-portal':
+ upgrade_logsearch_portal(options, accessor, parser, config)
+ elif options.action.lower() == 'upgrade-logfeeders':
+ upgrade_logfeeders(options, accessor, parser, config)
+ elif options.action.lower() == 'stop-logsearch':
+ service_components_command(options, accessor, parser, config,
LOGSEARCH_SERVICE_NAME, LOGSEARCH_SERVER_COMPONENT_NAME, "STOP", "Stop")
+ service_components_command(options, accessor, parser, config,
LOGSEARCH_SERVICE_NAME, LOGSEARCH_LOGFEEDER_COMPONENT_NAME, "STOP", "Stop")
+ elif options.action.lower() == 'restart-logsearch':
+ service_components_command(options, accessor, parser, config,
LOGSEARCH_SERVICE_NAME, LOGSEARCH_SERVER_COMPONENT_NAME, "RESTART", "Restart")
+ service_components_command(options, accessor, parser, config,
LOGSEARCH_SERVICE_NAME, LOGSEARCH_LOGFEEDER_COMPONENT_NAME, "RESTART",
"Restart")
elif options.action.lower() == 'rolling-restart-solr':
rolling_restart_solr(options, accessor, parser, config)
else:
diff --git
a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml
b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml
index de75d05..cd22ecc 100644
---
a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml
+++
b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml
@@ -72,6 +72,15 @@
<background>true</background>
</commandScript>
</customCommand>
+ <customCommand>
+ <name>UPGRADE_SOLR_INSTANCE</name>
+ <hidden>true</hidden>
+ <commandScript>
+ <script>scripts/infra_solr.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>1200</timeout>
+ </commandScript>
+ </customCommand>
</customCommands>
<dependencies>
<dependency>
@@ -109,6 +118,17 @@
<script>scripts/infra_solr_client.py</script>
<scriptType>PYTHON</scriptType>
</commandScript>
+ <customCommands>
+ <customCommand>
+ <name>UPGRADE_SOLR_CLIENT</name>
+ <hidden>true</hidden>
+ <commandScript>
+ <script>scripts/infra_solr_client.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>3600</timeout>
+ </commandScript>
+ </customCommand>
+ </customCommands>
<configFiles>
<configFile>
<type>env</type>
diff --git
a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr.py
b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr.py
index da1eaa8..502943e 100644
---
a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr.py
+++
b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr.py
@@ -18,6 +18,9 @@ limitations under the License.
"""
import sys
+from ambari_commons.repo_manager import ManagerFactory
+from ambari_commons.shell import RepoCallContext
+from ambari_commons.os_utils import get_ambari_repo_file_full_name
from resource_management.core.logger import Logger
from resource_management.core.source import Template
from resource_management.core.resources.system import Execute, File
@@ -143,5 +146,15 @@ class InfraSolr(Script):
def migrate(self, env):
migrate_index(env)
+ def upgrade_solr_instance(self, env):
+ pkg_provider = ManagerFactory.get()
+ context = RepoCallContext()
+ context.is_upgrade=True
+ context.log_output = True
+ context.use_repos = {}
+ context.use_repos['ambari']=get_ambari_repo_file_full_name()
+ pkg_provider.remove_package('ambari-infra-solr', context,
ignore_dependencies=True)
+ pkg_provider.upgrade_package('ambari-infra-solr', context)
+
if __name__ == "__main__":
InfraSolr().execute()
\ No newline at end of file
diff --git
a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr_client.py
b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr_client.py
index 3b72d8c..5fd412b 100644
---
a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr_client.py
+++
b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/infra_solr_client.py
@@ -17,12 +17,14 @@ limitations under the License.
"""
+from ambari_commons.repo_manager import ManagerFactory
+from ambari_commons.shell import RepoCallContext
+from ambari_commons.os_utils import get_ambari_repo_file_full_name
from resource_management.core.exceptions import ClientComponentHasNoStatus
from resource_management.libraries.script.script import Script
from setup_infra_solr import setup_infra_solr
-
class InfraSolrClient(Script):
def install(self, env):
@@ -48,6 +50,15 @@ class InfraSolrClient(Script):
def status(self, env):
raise ClientComponentHasNoStatus()
+ def upgrade_solr_client(self, env):
+ pkg_provider = ManagerFactory.get()
+ context = RepoCallContext()
+ context.is_upgrade=True
+ context.log_output = True
+ context.use_repos = {}
+ context.use_repos['ambari']=get_ambari_repo_file_full_name()
+ pkg_provider.remove_package('ambari-infra-solr-client', context,
ignore_dependencies=True)
+ pkg_provider.upgrade_package('ambari-infra-solr-client', context)
if __name__ == "__main__":
InfraSolrClient().execute()
\ No newline at end of file
diff --git
a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/metainfo.xml
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/metainfo.xml
index 4c99830..54a4ab8 100644
---
a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/metainfo.xml
+++
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/metainfo.xml
@@ -54,6 +54,17 @@
<logId>logsearch_perf</logId>
</log>
</logs>
+ <customCommands>
+ <customCommand>
+ <name>UPGRADE_LOGSEARCH_PORTAL</name>
+ <hidden>true</hidden>
+ <commandScript>
+ <script>scripts/logsearch.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>1200</timeout>
+ </commandScript>
+ </customCommand>
+ </customCommands>
<dependencies>
<dependency>
<name>AMBARI_INFRA_SOLR/INFRA_SOLR_CLIENT</name>
@@ -93,6 +104,18 @@
</log>
</logs>
+ <customCommands>
+ <customCommand>
+ <name>UPGRADE_LOGFEEDER</name>
+ <hidden>true</hidden>
+ <commandScript>
+ <script>scripts/logfeeder.py</script>
+ <scriptType>PYTHON</scriptType>
+ <timeout>1200</timeout>
+ </commandScript>
+ </customCommand>
+ </customCommands>
+
<configuration-dependencies>
<config-type>infra-solr-env</config-type>
<config-type>logsearch-common-env</config-type>
diff --git
a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logfeeder.py
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logfeeder.py
index 2aa8b66..375cf55 100644
---
a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logfeeder.py
+++
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logfeeder.py
@@ -17,7 +17,9 @@ limitations under the License.
"""
-import getpass
+from ambari_commons.repo_manager import ManagerFactory
+from ambari_commons.shell import RepoCallContext
+from ambari_commons.os_utils import get_ambari_repo_file_full_name
from resource_management.core.resources.system import Execute
from resource_management.libraries.functions.format import format
from resource_management.libraries.functions.check_process_status import
check_process_status
@@ -58,6 +60,15 @@ class LogFeeder(Script):
check_process_status(status_params.logfeeder_pid_file)
+ def upgrade_logfeeder(self, env):
+ pkg_provider = ManagerFactory.get()
+ context = RepoCallContext()
+ context.is_upgrade=True
+ context.log_output = True
+ context.use_repos = {}
+ context.use_repos['ambari']=get_ambari_repo_file_full_name()
+ pkg_provider.remove_package('ambari-logsearch-logfeeder', context,
ignore_dependencies=True)
+ pkg_provider.upgrade_package('ambari-logsearch-logfeeder', context)
if __name__ == "__main__":
LogFeeder().execute()
diff --git
a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logsearch.py
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logsearch.py
index a276357..1dd5d8d 100644
---
a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logsearch.py
+++
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/logsearch.py
@@ -17,6 +17,9 @@ limitations under the License.
"""
+from ambari_commons.repo_manager import ManagerFactory
+from ambari_commons.shell import RepoCallContext
+from ambari_commons.os_utils import get_ambari_repo_file_full_name
from resource_management.core.resources.system import Execute, File
from resource_management.libraries.functions.check_process_status import
check_process_status
from resource_management.libraries.functions.format import format
@@ -58,5 +61,15 @@ class LogSearch(Script):
check_process_status(status_params.logsearch_pid_file)
+ def upgrade_logsearch_portal(self, env):
+ pkg_provider = ManagerFactory.get()
+ context = RepoCallContext()
+ context.is_upgrade=True
+ context.log_output = True
+ context.use_repos = {}
+ context.use_repos['ambari']=get_ambari_repo_file_full_name()
+ pkg_provider.remove_package('ambari-logsearch-portal', context,
ignore_dependencies=True)
+ pkg_provider.upgrade_package('ambari-logsearch-portal', context)
+
if __name__ == "__main__":
LogSearch().execute()
--
To stop receiving notification emails like this one, please contact
[email protected].