Source:
<code>public void write(EtlKey key, Object val) throws IOException, InterruptedException { if (val instanceof CamusWrapper<?>) { if (key.getTime() < beginTimeStamp) { try { Method getCounterMethod = context.getClass().getMethod("getCounter", String.class, String.class); ((Counter) getCounterMethod.invoke(context, "total", "skip-old")).increment(1); } catch (NoSuchMethodException e) { ((Mapper.Context)context).getCounter("total", "skip-old").increment(1); <START> } catch (Exception e) { <END> log.error("error incrementing counter 'total:skip-old': " + e.getMessage()); } committer.addOffset(key); } else { if (!key.getTopic().equals(currentTopic)) { for (RecordWriter<IEtlKey, CamusWrapper> writer : dataWriters.values()) { writer.close(context); } dataWriters.clear(); currentTopic = key.getTopic(); } committer.addCounts(key); CamusWrapper value = (CamusWrapper) val; String workingFileName = EtlMultiOutputFormat.getWorkingFileName(context, key); if (!dataWriters.containsKey(workingFileName)) { dataWriters.put(workingFileName, getDataRecordWriter(context, workingFileName, value)); log.info("Writing to data file: " + workingFileName); } dataWriters.get(workingFileName).write(key, value); } } else if (val instanceof ExceptionWritable) { committer.addOffset(key); log.warn("ExceptionWritable key: " + key + " value: " + val); errorWriter.append(key, (ExceptionWritable) val); } else { log.warn("Unknow type of record: " + val); } }</code><technical_language>instanceOfInterface mechanism work? do need catch Exception here? If catch Exception for hadoop2, need do for hadoop1. code capture exception, good in sense this error lost in map log. If capture exception, need record times error fail job end</technical_language>

Target:
public void write(EtlKey key, Object val) throws IOException, InterruptedException { if (val instanceof CamusWrapper<?>) { if (key.getTime() < beginTimeStamp) { try { Method getCounterMethod = context.getClass().getMethod("getCounter", String.class, String.class); ((Counter) getCounterMethod.invoke(context, "total", "skip-old")).increment(1); } catch (NoSuchMethodException e) { ((Mapper.Context)context).getCounter("total", "skip-old").increment(1); } catch (IllegalArgumentException e) { log.error("IllegalArgumentException while incrementing counter 'total:skip-old': " + e.getMessage()); throw new RuntimeException(e); } catch (IllegalAccessException e) { log.error("IllegalAccessException while incrementing counter 'total:skip-old': " + e.getMessage()); throw new RuntimeException(e); } catch (InvocationTargetException e) { log.error("InvocationTargetException while incrementing counter 'total:skip-old': " + e.getMessage()); throw new RuntimeException(e); } committer.addOffset(key); } else { if (!key.getTopic().equals(currentTopic)) { for (RecordWriter<IEtlKey, CamusWrapper> writer : dataWriters.values()) { writer.close(context); } dataWriters.clear(); currentTopic = key.getTopic(); } committer.addCounts(key); CamusWrapper value = (CamusWrapper) val; String workingFileName = EtlMultiOutputFormat.getWorkingFileName(context, key); if (!dataWriters.containsKey(workingFileName)) { dataWriters.put(workingFileName, getDataRecordWriter(context, workingFileName, value)); log.info("Writing to data file: " + workingFileName); } dataWriters.get(workingFileName).write(key, value); } } else if (val instanceof ExceptionWritable) { committer.addOffset(key); log.warn("ExceptionWritable key: " + key + " value: " + val); errorWriter.append(key, (ExceptionWritable) val); } else { log.warn("Unknow type of record: " + val); } }