如何通过Cascading获取Hadoop以显示调试日志输出?

时间:2012-03-13 19:49:00

标签: debugging logging hadoop stdout cascading

我无法获取Hadoop和Cascading 1.2.6以向我显示应该使用Debug过滤器产生的输出。 Cascading guide says this is how you can view the current tuplescascading user guide。我正在使用它来尝试查看任何调试输出:

Debug debug = new Debug(Debug.Output.STDOUT, true);
debug.setPrintTupleEvery(1);
debug.setPrintFieldsEvery(1);
assembly = new Each( assembly, DebugLevel.VERBOSE, debug );

我对Hadoop和Cascading很新,但是我可能没有找到正确的位置,或者我缺少一些简单的log4j设置(我没有对你得到的默认值进行任何更改)与Cloudera hadoop-0.20.2-cdh3u3

这是我正在使用的WordCount示例类(从jobtracker web ui复制),其中添加了调试语句:

package org.cascading.example;

import cascading.flow.Flow;
import cascading.flow.FlowConnector;
import cascading.operation.Aggregator;
import cascading.operation.Debug;
import cascading.operation.DebugLevel;
import cascading.operation.Function;
import cascading.operation.aggregator.Count;
import cascading.operation.regex.RegexGenerator;
import cascading.pipe.Each;
import cascading.pipe.Every;
import cascading.pipe.GroupBy;
import cascading.pipe.Pipe;
import cascading.scheme.Scheme;
import cascading.scheme.TextLine;
import cascading.tap.Hfs;
import cascading.tap.SinkMode;
import cascading.tap.Tap;
import cascading.tuple.Fields;

import java.util.Properties;

public class WordCount {
    public static void main(String[] args) {
        String inputPath = args[0];
        String outputPath = args[1];

        // define source and sink Taps.
        Scheme sourceScheme = new TextLine( new Fields( "line" ) );
        Tap source = new Hfs( sourceScheme, inputPath );

        Scheme sinkScheme = new TextLine( new Fields( "word", "count" ) );
        Tap sink = new Hfs( sinkScheme, outputPath, SinkMode.REPLACE );

        // the 'head' of the pipe assembly
        Pipe assembly = new Pipe( "wordcount" );

        // For each input Tuple
        // using a regular expression
        // parse out each word into a new Tuple with the field name "word"
        String regex = "(?<!\\pL)(?=\\pL)[^ ]*(?<=\\pL)(?!\\pL)";
        Function function = new RegexGenerator( new Fields( "word" ), regex );

        assembly = new Each( assembly, new Fields( "line" ), function );

        Debug debug = new Debug(Debug.Output.STDOUT, true);
        debug.setPrintTupleEvery(1);
        debug.setPrintFieldsEvery(1);
        assembly = new Each( assembly, DebugLevel.VERBOSE, debug );

        // group the Tuple stream by the "word" value
        assembly = new GroupBy( assembly, new Fields( "word" ) );

        // For every Tuple group
        // count the number of occurrences of "word" and store result in
        // a field named "count"
        Aggregator count = new Count( new Fields( "count" ) );
        assembly = new Every( assembly, count );

        // initialize app properties, tell Hadoop which jar file to use
        Properties properties = new Properties();
        FlowConnector.setApplicationJarClass( properties, WordCount.class );

        // plan a new Flow from the assembly using the source and sink Taps
        FlowConnector flowConnector = new FlowConnector();
        FlowConnector.setDebugLevel( properties, DebugLevel.VERBOSE );
        Flow flow = flowConnector.connect( "word-count", source, sink, assembly );

        // execute the flow, block until complete
        flow.complete();

        // Ask Cascading to create a GraphViz DOT file
        // brew install graphviz # install viewer to look at dot file
        flow.writeDOT("build/flow.dot");
    }
}

它运行正常,我无法在任何地方找到任何调试语句向我显示单词。我通过hadoop dfs -ls以及{{3}}查看了HDFS文件系统。作业跟踪器中映射器的日志输出没有STDOUT的任何输出:

Task Logs: 'attempt_201203131143_0022_m_000000_0'



stdout logs


stderr logs
2012-03-13 14:32:24.642 java[74752:1903] Unable to load realm info from SCDynamicStore


syslog logs
2012-03-13 14:32:24,786 INFO org.apache.hadoop.security.UserGroupInformation: JAAS Configuration already set up for Hadoop, not re-installing.
2012-03-13 14:32:25,278 WARN org.apache.hadoop.util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2012-03-13 14:32:25,617 INFO org.apache.hadoop.metrics.jvm.JvmMetrics: Initializing JVM Metrics with processName=MAP, sessionId=
2012-03-13 14:32:25,903 INFO org.apache.hadoop.mapred.Task:  Using ResourceCalculatorPlugin : null
2012-03-13 14:32:25,945 INFO cascading.tap.hadoop.MultiInputSplit: current split input path: hdfs://localhost/usr/tnaleid/shakespeare/input/comedies/cymbeline
2012-03-13 14:32:25,980 WARN org.apache.hadoop.io.compress.snappy.LoadSnappy: Snappy native library not loaded
2012-03-13 14:32:25,988 INFO org.apache.hadoop.mapred.MapTask: numReduceTasks: 1
2012-03-13 14:32:26,002 INFO org.apache.hadoop.mapred.MapTask: io.sort.mb = 100
2012-03-13 14:32:26,246 INFO org.apache.hadoop.mapred.MapTask: data buffer = 79691776/99614720
2012-03-13 14:32:26,247 INFO org.apache.hadoop.mapred.MapTask: record buffer = 262144/327680
2012-03-13 14:32:27,623 INFO org.apache.hadoop.mapred.MapTask: Starting flush of map output
2012-03-13 14:32:28,274 INFO org.apache.hadoop.mapred.MapTask: Finished spill 0
2012-03-13 14:32:28,310 INFO org.apache.hadoop.mapred.Task: Task:attempt_201203131143_0022_m_000000_0 is done. And is in the process of commiting
2012-03-13 14:32:28,337 INFO org.apache.hadoop.mapred.Task: Task 'attempt_201203131143_0022_m_000000_0' done.
2012-03-13 14:32:28,361 INFO org.apache.hadoop.mapred.TaskLogsTruncater: Initializing logs' truncater with mapRetainSize=-1 and reduceRetainSize=-1

最后,我还写出了DOT文件,其中没有我期望的Debug语句(虽然可能会被删除):

word count flow diagram

是否有一些我遗漏的日志文件,或者是我需要设置的配置设置?

1 个答案:

答案 0 :(得分:2)

我从mailing list得到了答案。

将其改为此作品:

assembly = new Each( assembly, new Fields( "line" ), function );

// simpler debug statement
assembly = new Each( assembly, new Debug("hello", true) );

assembly = new GroupBy( assembly, new Fields( "word" ) );

在stderr下的jobdetails UI中输出:

Task Logs: 'attempt_201203131143_0028_m_000000_0'



stdout logs


stderr logs
2012-03-13 16:21:41.304 java[78617:1903] Unable to load realm info from SCDynamicStore
hello: ['word']
hello: ['CYMBELINE']
<SNIP>

我直接从文档中尝试过这个,这对我不起作用(即使我还将FlowConnector debugLevel设置为VERBOSE):

assembly = new Each( assembly, DebugLevel.VERBOSE, new Debug() );

似乎它与文档中的DebugLevel.VERBOSE有关,因为当我尝试这个时,我仍然没有输出:

assembly = new Each( assembly, DebugLevel.VERBOSE, new Debug("hello", true) );

更改它以删除DebugLevel也为我提供输出

assembly = new Each( assembly, new Debug() );

我也可以通过这样做来切换到stdout:

assembly = new Each( assembly, new Debug(Debug.Output.STDOUT) );

我打赌仍然有一些我用VERBOSE日志级别的东西配置错误,或者1.2.6与文档不再匹配,但至少现在我可以在日志中看到输出