Beispiel #1
0
def run(command, parser, known_args, unknown_args):
    """ run command """
    release_file = config.get_heron_release_file()
    with open(release_file) as release_info:
        for line in release_info:
            print line,
    return True
Beispiel #2
0
def run(command, parser, cl_args, unknown_args, action):
    '''
  helper function to take action on topologies
  :param command:
  :param parser:
  :param cl_args:
  :param unknown_args:
  :param action:        description of action taken
  :return:
  '''
    try:
        topology_name = cl_args['topology-name']

        new_args = [
            "--cluster",
            cl_args['cluster'],
            "--role",
            cl_args['role'],
            "--environment",
            cl_args['environ'],
            "--heron_home",
            config.get_heron_dir(),
            "--config_path",
            cl_args['config_path'],
            "--override_config_file",
            cl_args['override_config_file'],
            "--release_file",
            config.get_heron_release_file(),
            "--topology_name",
            topology_name,
            "--command",
            command,
        ]

        if Log.getEffectiveLevel() == logging.DEBUG:
            new_args.append("--verbose")

        lib_jars = config.get_heron_libs(jars.scheduler_jars() +
                                         jars.statemgr_jars())

        # invoke the runtime manager to kill the topology
        execute.heron_class('com.twitter.heron.scheduler.RuntimeManagerMain',
                            lib_jars,
                            extra_jars=[],
                            args=new_args)

    except Exception:
        Log.error('Failed to %s \'%s\'' % (action, topology_name))
        return False

    Log.info('Successfully %s \'%s\'' % (action, topology_name))
    return True
Beispiel #3
0
def launch_a_topology(cl_args, tmp_dir, topology_file, topology_defn_file):
  '''
  Launch a topology given topology jar, its definition file and configurations
  :param cl_args:
  :param tmp_dir:
  :param topology_file:
  :param topology_defn_file:
  :return:
  '''
  # get the normalized path for topology.tar.gz
  topology_pkg_path = config.normalized_class_path(os.path.join(tmp_dir, 'topology.tar.gz'))

  # get the release yaml file
  release_yaml_file = config.get_heron_release_file()

  # create a tar package with the cluster configuration and generated config files
  config_path = cl_args['config_path']
  tar_pkg_files = [topology_file, topology_defn_file]
  generated_config_files = [release_yaml_file, cl_args['override_config_file']]

  config.create_tar(topology_pkg_path, tar_pkg_files, config_path, generated_config_files)

  # pass the args to submitter main
  args = [
      "--cluster", cl_args['cluster'],
      "--role", cl_args['role'],
      "--environment", cl_args['environ'],
      "--heron_home", config.get_heron_dir(),
      "--config_path", config_path,
      "--override_config_file", cl_args['override_config_file'],
      "--release_file", release_yaml_file,
      "--topology_package", topology_pkg_path,
      "--topology_defn", topology_defn_file,
      "--topology_jar", topology_file   # pex file if pex specified
  ]

  if Log.getEffectiveLevel() == logging.DEBUG:
    args.append("--verbose")

  lib_jars = config.get_heron_libs(
      jars.scheduler_jars() + jars.uploader_jars() + jars.statemgr_jars() + jars.packing_jars()
  )

  # invoke the submitter to submit and launch the topology
  execute.heron_class(
      'com.twitter.heron.scheduler.SubmitterMain',
      lib_jars,
      extra_jars=[],
      args=args,
      java_defines=[]
  )
Beispiel #4
0
def run(command, parser, args, unknown_args):
  '''
  :param command:
  :param parser:
  :param args:
  :param unknown_args:
  :return:
  '''
  release_file = config.get_heron_release_file()
  with open(release_file) as release_info:
    for line in release_info:
      print line,

  return True
Beispiel #5
0
def run(command, parser, args, unknown_args):
    '''
  :param command:
  :param parser:
  :param args:
  :param unknown_args:
  :return:
  '''
    release_file = config.get_heron_release_file()
    with open(release_file) as release_info:
        for line in release_info:
            print line,

    return True
Beispiel #6
0
def run(command, parser, cl_args, unknown_args, action):
  '''
  helper function to take action on topologies
  :param command:
  :param parser:
  :param cl_args:
  :param unknown_args:
  :param action:        description of action taken
  :return:
  '''
  try:
    topology_name = cl_args['topology-name']

    new_args = [
        "--cluster", cl_args['cluster'],
        "--role", cl_args['role'],
        "--environment", cl_args['environ'],
        "--heron_home", config.get_heron_dir(),
        "--config_path", cl_args['config_path'],
        "--override_config_file", cl_args['override_config_file'],
        "--release_file", config.get_heron_release_file(),
        "--topology_name", topology_name,
        "--command", command,
    ]

    if Log.getEffectiveLevel() == logging.DEBUG:
      new_args.append("--verbose")

    lib_jars = config.get_heron_libs(jars.scheduler_jars() + jars.statemgr_jars())

    # invoke the runtime manager to kill the topology
    execute.heron_class(
        'com.twitter.heron.scheduler.RuntimeManagerMain',
        lib_jars,
        extra_jars=[],
        args=new_args
    )

  except Exception:
    Log.error('Failed to %s \'%s\'' % (action, topology_name))
    return False

  Log.info('Successfully %s \'%s\'' % (action, topology_name))
  return True
Beispiel #7
0
def run(command, parser, cl_args, unknown_args):
  '''
  :param command:
  :param parser:
  :param cl_args:
  :param unknown_args:
  :return:
  '''
  try:
    topology_name = cl_args['topology-name']
    container_id = cl_args['container-id']

    new_args = [
        "--cluster", cl_args['cluster'],
        "--role", cl_args['role'],
        "--environment", cl_args['environ'],
        "--heron_home", config.get_heron_dir(),
        "--config_path", cl_args['config_path'],
        "--override_config_file", cl_args['override_config_file'],
        "--release_file", config.get_heron_release_file(),
        "--topology_name", topology_name,
        "--command", command,
        "--container_id", str(container_id)
    ]

    lib_jars = config.get_heron_libs(jars.scheduler_jars() + jars.statemgr_jars())

    # invoke the runtime manager to kill the topology
    execute.heron_class(
        'com.twitter.heron.scheduler.RuntimeManagerMain',
        lib_jars,
        extra_jars=[],
        args=new_args
    )

  except Exception as ex:
    Log.debug(traceback.format_exc(ex))
    Log.error('Failed to restart topology \'%s\'' % topology_name)
    return False

  Log.info('Successfully restarted topology \'%s\'' % topology_name)
  return True
Beispiel #8
0
def run(command, parser, cl_args, unknown_args):
    '''
  :param command:
  :param parser:
  :param cl_args:
  :param unknown_args:
  :return:
  '''
    try:
        topology_name = cl_args['topology-name']
        container_id = cl_args['container-id']

        new_args = [
            "--cluster", cl_args['cluster'], "--role", cl_args['role'],
            "--environment", cl_args['environ'], "--heron_home",
            config.get_heron_dir(), "--config_path", cl_args['config_path'],
            "--override_config_file", cl_args['override_config_file'],
            "--release_file",
            config.get_heron_release_file(), "--topology_name", topology_name,
            "--command", command, "--container_id",
            str(container_id)
        ]

        lib_jars = config.get_heron_libs(jars.scheduler_jars() +
                                         jars.statemgr_jars())

        # invoke the runtime manager to kill the topology
        execute.heron_class('com.twitter.heron.scheduler.RuntimeManagerMain',
                            lib_jars,
                            extra_jars=[],
                            args=new_args)

    except Exception as ex:
        Log.debug(traceback.format_exc(ex))
        Log.error('Failed to restart topology \'%s\'' % topology_name)
        return False

    Log.info('Successfully restarted topology \'%s\'' % topology_name)
    return True
Beispiel #9
0
def launch_a_topology(cl_args, tmp_dir, topology_file, topology_defn_file):
    '''
  Launch a topology given topology jar, its definition file and configurations
  :param cl_args:
  :param tmp_dir:
  :param topology_file:
  :param topology_defn_file:
  :return:
  '''
    # get the normalized path for topology.tar.gz
    topology_pkg_path = config.normalized_class_path(
        os.path.join(tmp_dir, 'topology.tar.gz'))

    # get the release yaml file
    release_yaml_file = config.get_heron_release_file()

    # create a tar package with the cluster configuration and generated config files
    config_path = cl_args['config_path']
    tar_pkg_files = [topology_file, topology_defn_file]
    generated_config_files = [
        release_yaml_file, cl_args['override_config_file']
    ]

    config.create_tar(topology_pkg_path, tar_pkg_files, config_path,
                      generated_config_files)

    # pass the args to submitter main
    args = [
        "--cluster",
        cl_args['cluster'],
        "--role",
        cl_args['role'],
        "--environment",
        cl_args['environ'],
        "--heron_home",
        config.get_heron_dir(),
        "--config_path",
        config_path,
        "--override_config_file",
        cl_args['override_config_file'],
        "--release_file",
        release_yaml_file,
        "--topology_package",
        topology_pkg_path,
        "--topology_defn",
        topology_defn_file,
        "--topology_jar",
        topology_file  # pex file if pex specified
    ]

    if Log.getEffectiveLevel() == logging.DEBUG:
        args.append("--verbose")

    lib_jars = config.get_heron_libs(jars.scheduler_jars() +
                                     jars.uploader_jars() +
                                     jars.statemgr_jars() +
                                     jars.packing_jars())

    # invoke the submitter to submit and launch the topology
    execute.heron_class('com.twitter.heron.scheduler.SubmitterMain',
                        lib_jars,
                        extra_jars=[],
                        args=args,
                        java_defines=[])