Exemple #1
0
def run_jar(jar_name, more_args=None, properties=None, hadoop_conf_dir=None):
    """
  Run a jar on Hadoop (``hadoop jar`` command).

  ``more_args`` (after prepending ``jar_name``) and ``properties`` are
  passed to :func:`run_cmd`.

  .. code-block:: python

    >>> import glob, pydoop
    >>> hadoop_home = pydoop.hadoop_home()
    >>> v = pydoop.hadoop_version_info()
    >>> if v.cdh >= (4, 0, 0): hadoop_home += '-0.20-mapreduce'
    >>> jar_name = glob.glob('%s/*examples*.jar' % hadoop_home)[0]
    >>> more_args = ['wordcount']
    >>> try:
    ...     run_jar(jar_name, more_args=more_args)
    ... except RunCmdError as e:
    ...     print e
    ...
    Usage: wordcount <in> <out>
  """
    if hu.is_readable(jar_name):
        args = [jar_name]
        if more_args is not None:
            args.extend(more_args)
        return run_cmd("jar",
                       args,
                       properties,
                       hadoop_conf_dir=hadoop_conf_dir)
    else:
        raise ValueError("Can't read jar file %s" % jar_name)
Exemple #2
0
def run_jar(jar_name, more_args=None, properties=None, hadoop_conf_dir=None):
  """
  Run a jar on Hadoop (``hadoop jar`` command).

  ``more_args`` (after prepending ``jar_name``) and ``properties`` are
  passed to :func:`run_cmd`.

  .. code-block:: python

    >>> import glob, pydoop
    >>> hadoop_home = pydoop.hadoop_home()
    >>> v = pydoop.hadoop_version_info()
    >>> if v.cdh >= (4, 0, 0): hadoop_home += '-0.20-mapreduce'
    >>> jar_name = glob.glob('%s/*examples*.jar' % hadoop_home)[0]
    >>> more_args = ['wordcount']
    >>> try:
    ...     run_jar(jar_name, more_args=more_args)
    ... except RunCmdError as e:
    ...     print e
    ...
    Usage: wordcount <in> <out>
  """
  if hu.is_readable(jar_name):
    args = [jar_name]
    if more_args is not None:
      args.extend(more_args)
    return run_cmd("jar", args, properties, hadoop_conf_dir=hadoop_conf_dir)
  else:
    raise ValueError("Can't read jar file %s" % jar_name)
Exemple #3
0
def run_jar(jar_name, more_args=None, properties=None, hadoop_conf_dir=None, keep_streams=True):
    """
    Run a jar on Hadoop (``hadoop jar`` command).

    All arguments are passed to :func:`run_cmd` (``args = [jar_name] +
    more_args``) .
    """
    if hu.is_readable(jar_name):
        args = [jar_name]
        if more_args is not None:
            args.extend(more_args)
        return run_cmd("jar", args, properties, hadoop_conf_dir=hadoop_conf_dir, keep_streams=keep_streams)
    else:
        raise ValueError("Can't read jar file %s" % jar_name)
Exemple #4
0
def run_jar(jar_name,
            more_args=None,
            properties=None,
            hadoop_conf_dir=None,
            keep_streams=True):
    """
    Run a jar on Hadoop (``hadoop jar`` command).

    All arguments are passed to :func:`run_cmd` (``args = [jar_name] +
    more_args``) .
    """
    if hu.is_readable(jar_name):
        args = [jar_name]
        if more_args is not None:
            args.extend(more_args)
        return run_cmd("jar",
                       args,
                       properties,
                       hadoop_conf_dir=hadoop_conf_dir,
                       keep_streams=keep_streams)
    else:
        raise ValueError("Can't read jar file %s" % jar_name)