Esempio n. 1
0
def rolling_update(args):
    if not args.job:
        Log.print_critical(
            "You must specify the job name to do rolling update")

    if not args.skip_confirm:
        deploy_utils.confirm_action(args, "rolling_update")

    get_hbase_service_config(args)
    job_name = args.job[0]

    if job_name != 'regionserver':
        args.vacate_rs = False

    if args.vacate_rs:
        balance_switch(args, False)

    Log.print_info("Rolling updating %s" % job_name)
    hosts = args.hbase_config.jobs[job_name].hosts
    wait_time = 0

    args.task_map = deploy_utils.parse_args_host_and_task(args, hosts)
    for host_id in args.task_map.keys() or hosts.iterkeys():
        for instance_id in args.task_map.get(host_id) or range(
                hosts[host_id].instance_num):
            instance_id = -1 if not deploy_utils.is_multiple_instances(
                host_id, hosts) else instance_id
            if not args.skip_confirm:
                deploy_utils.confirm_rolling_update(host_id, instance_id,
                                                    wait_time)

            port = deploy_utils.get_base_port(
                args.hbase_config.jobs[job_name].base_port, instance_id)
            if args.vacate_rs:
                vacate_region_server(args, hosts[host_id].ip, port)

            stop_job(args, hosts[host_id].ip, job_name, instance_id)
            deploy_utils.wait_for_job_stopping("hbase",
                                               args.hbase_config.cluster.name,
                                               job_name, hosts[host_id].ip,
                                               instance_id)
            start_job(args, hosts[host_id].ip, job_name, host_id, instance_id)
            deploy_utils.wait_for_job_starting("hbase",
                                               args.hbase_config.cluster.name,
                                               job_name, hosts[host_id].ip,
                                               instance_id)

            if args.vacate_rs:
                recover_region_server(args, hosts[host_id].ip, port)
            wait_time = args.time_interval

    if args.vacate_rs:
        balance_switch(args, True)
    Log.print_success("Rolling updating %s success" % job_name)
Esempio n. 2
0
  def update_active_tasks(self):
    # Add all active tasks
    self.metric_sources = []
    for service_name, service in self.collector_config.services.iteritems():
      # Save to database.
      # The active field has the default value True.
      service_record, created = Service.objects.get_or_create(
          name=service_name,
          defaults={"metric_url":service.metric_url})
      if not created:
        # Mark it as active if it exists.
        service_record.active = True
        service_record.save()

      for cluster_name, cluster in service.clusters.iteritems():
        cluster_record, created = Cluster.objects.get_or_create(
            service=service_record, name=cluster_name)
        if not created:
          cluster_record.active = True
          cluster_record.save()

        for job_name in service.jobs:
          job_record, created = Job.objects.get_or_create(
              cluster=cluster_record, name=job_name)
          if not created:
            job_record.active = True
            job_record.save()

          job = cluster.jobs[job_name]
          # We assume http port is always base_port + 1
          port = job.base_port + 1
          # support multiple instances
          hosts = job.hosts
          for host_id, host in hosts.iteritems():
            host_name = job.hostnames[host_id]
            for instance_id in range(host.instance_num):
              task_id = deploy_utils.get_task_id(hosts, host_id, instance_id)
              instance_port = deploy_utils.get_base_port(port,instance_id)
              task_record, created = Task.objects.get_or_create(
                job=job_record, task_id=task_id,
                defaults={"host":host_name, "port":instance_port})
              if not created or task_record.host != host_name or (
                task_record.port != instance_port):
                task_record.active = True
                task_record.host = host_name
                task_record.port = instance_port
                task_record.save()
              self.metric_sources.append(
                MetricSource(self.collector_config, task_record))
Esempio n. 3
0
def rolling_update(args):
    if not args.job:
        Log.print_critical("You must specify the job name to do rolling update")

    if not args.skip_confirm:
        deploy_utils.confirm_action(args, "rolling_update")

    get_hbase_service_config(args)
    job_name = args.job[0]

    if job_name != "regionserver":
        args.vacate_rs = False

    if args.vacate_rs:
        balance_switch(args, False)

    Log.print_info("Rolling updating %s" % job_name)
    hosts = args.hbase_config.jobs[job_name].hosts
    wait_time = 0

    args.task_map = deploy_utils.parse_args_host_and_task(args, hosts)
    for host_id in args.task_map.keys() or hosts.iterkeys():
        for instance_id in args.task_map.get(host_id) or range(hosts[host_id].instance_num):
            instance_id = -1 if not deploy_utils.is_multiple_instances(host_id, hosts) else instance_id
            if not args.skip_confirm:
                deploy_utils.confirm_rolling_update(host_id, instance_id, wait_time)

            port = deploy_utils.get_base_port(args.hbase_config.jobs[job_name].base_port, instance_id)
            if args.vacate_rs:
                vacate_region_server(args, hosts[host_id].ip, port)

            stop_job(args, hosts[host_id].ip, job_name, instance_id)
            deploy_utils.wait_for_job_stopping(
                "hbase", args.hbase_config.cluster.name, job_name, hosts[host_id].ip, instance_id
            )
            start_job(args, hosts[host_id].ip, job_name, host_id, instance_id)
            deploy_utils.wait_for_job_starting(
                "hbase", args.hbase_config.cluster.name, job_name, hosts[host_id].ip, instance_id
            )

            if args.vacate_rs:
                recover_region_server(args, hosts[host_id].ip, port)
            wait_time = args.time_interval

    if args.vacate_rs:
        balance_switch(args, True)
    Log.print_success("Rolling updating %s success" % job_name)