@Override public RecordWriter<DocumentURI, VALUEOUT> getRecordWriter( TaskAttemptContext context) throws IOException, InterruptedException { Configuration conf = context.getConfiguration(); // TODO: if MAPREDUCE-3377 still exists, need to re-run initialize fastLoad = Boolean.valueOf(conf.get(OUTPUT_FAST_LOAD)); Map<String, ContentSource> sourceMap = getSourceMap(fastLoad, context); // construct the ContentWriter return new ContentWriter<VALUEOUT>(conf, sourceMap, fastLoad, am); }
protected Session getSession(int fId, boolean nextReplica) { TransactionMode mode = TransactionMode.AUTO; if (needCommit) { mode = TransactionMode.UPDATE; } return getSession(fId, nextReplica, mode); }
protected void commit(int id) throws IOException { try { sessions[id].commit(); succeeded += commitUris[id].size(); commitUris[id].clear(); } catch (Exception e) { LOG.error("Error commiting transaction " + e.getMessage()); rollback(id); sessions[id].close(); sessions[id] = null; } }
Content content = createContent(key,value); if (content == null) { failed++; if (counts[fId] == batchSize) { if (sessions[sid] == null) { sessions[sid] = getSession(sid, false); insertBatch(forestContents[fId], sid); stmtCounts[sid]++; commit(sid); stmtCounts[sid] = 0; committed = true;
counts[i]); if (sessions[sid] == null) { sessions[sid] = getSession(sid, false); insertBatch(remainder, sid); } catch (Throwable e) { LOG.error("Error caught inserting documents: ", e); if (stmtCounts[i] > 0 && needCommit) { try { commit(i); sessions[i].close(); } catch (Throwable e) {
rollback(id); sessions[id] = getSession(id, true); continue; } else if (retryable) {
protected void rollback(int id) throws IOException { try { sessions[id].rollback(); } catch (Exception e) { LOG.error("Error rolling back transaction " + e.getMessage()); if (LOG.isDebugEnabled()) { LOG.debug(e); } } finally { if (countBased) { rollbackCount(id); } failed += commitUris[id].size(); for (DocumentURI failedUri : commitUris[id]) { LOG.warn("Failed document: " + failedUri); } commitUris[id].clear(); } }
needCommit = needCommit(); if (needCommit) { commitUris = new ArrayList[arraySize];