Example usage for org.apache.commons.lang.exception ExceptionUtils printRootCauseStackTrace

List of usage examples for org.apache.commons.lang.exception ExceptionUtils printRootCauseStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.lang.exception ExceptionUtils printRootCauseStackTrace.

Prototype

public static void printRootCauseStackTrace(Throwable throwable) 

Source Link

Document

Prints a compact stack trace for the root cause of a throwable to System.err.

The compact stack trace starts with the root cause and prints stack frames up to the place where it was caught and wrapped.

Usage

From source file:com.xiaomi.linden.hadoop.indexing.map.LindenMapper.java

@Override
public void map(Object key, Object value, Context context) throws IOException, InterruptedException {
    LindenIndexRequest indexRequest;/*from  w  w w  .j a v a  2 s .  co  m*/
    try {
        indexRequest = LindenIndexRequestParser.parse(lindenConfig.getSchema(), value.toString());
    } catch (Exception e) {
        ExceptionUtils.printRootCauseStackTrace(e);
        throw new IllegalStateException("LindenIndexRequestParser parsing error", e);
    }

    if (indexRequest.getType() != IndexRequestType.INDEX) {
        throw new IllegalStateException("Index request type error");
    }

    Document doc = LindenDocParser.parse(indexRequest.getDoc(), lindenConfig);
    // now we have uid and lucene Doc;
    IntermediateForm form = new IntermediateForm();
    form.process(new Term(lindenConfig.getSchema().getId(), indexRequest.getDoc().getId()), doc,
            lindenConfig.getIndexAnalyzerInstance(), facetsConfig);
    form.closeWriter();

    int chosenShard = DefaultShardingStrategy.calculateShard(shards.length, indexRequest);
    if (chosenShard >= 0) {
        // insert into one shard
        context.write(shards[chosenShard], form);
    } else {
        logger.error("calculateShard failed for " + value.toString());
        return;
    }
}