本文整理汇总了Java中org.kitesdk.morphline.base.Notifications.notifyStartSession方法的典型用法代码示例。如果您正苦于以下问题:Java Notifications.notifyStartSession方法的具体用法?Java Notifications.notifyStartSession怎么用?Java Notifications.notifyStartSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kitesdk.morphline.base.Notifications
的用法示例。
在下文中一共展示了Notifications.notifyStartSession方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.kitesdk.morphline.base.Notifications; //导入方法依赖的package包/类
@Override
public void process(Event event) {
numRecords.mark();
Timer.Context timerContext = mappingTimer.time();
try {
Record record = new Record();
for (Entry<String, String> entry : event.getHeaders().entrySet()) {
record.put(entry.getKey(), entry.getValue());
}
byte[] bytes = event.getBody();
if (bytes != null && bytes.length > 0) {
record.put(Fields.ATTACHMENT_BODY, bytes);
}
try {
Notifications.notifyStartSession(morphline);
if (!morphline.process(record)) {
numFailedRecords.mark();
LOG.warn("Morphline {} failed to process record: {}", morphlineFileAndId, record);
}
} catch (RuntimeException t) {
numExceptionRecords.mark();
morphlineContext.getExceptionHandler().handleException(t, record);
}
} finally {
timerContext.stop();
}
}
示例2: executePipeline
import org.kitesdk.morphline.base.Notifications; //导入方法依赖的package包/类
public static List<Record> executePipeline(Pipeline pipeline, Record inputRecord) {
Command morphline = pipeline.getMorphline();
try {
LOG.trace("Input Record: {}", inputRecord);
// Process the Record
Notifications.notifyStartSession(morphline);
boolean success = morphline.process(inputRecord);
Notifications.notifyCommitTransaction(morphline);
if (!success) {
throw new MorphlineRuntimeException("Morphline failed to process incoming Record: " + inputRecord);
}
// Collect the output
List<Record> outputRecords = pipeline.getCollector().getRecords();
if (!outputRecords.iterator().hasNext()) {
throw new MorphlineRuntimeException("Morphline did not produce output Record(s)");
}
LOG.trace("Output Record(s): {}", outputRecords);
return outputRecords;
} catch (RuntimeException e) {
Notifications.notifyRollbackTransaction(morphline);
// TODO : Review exception handling
LOG.warn("Morphline failed to execute properly on incoming Record: " + inputRecord, e);
throw e;
}
}
示例3: map
import org.kitesdk.morphline.base.Notifications; //导入方法依赖的package包/类
@Override
public void map(Result result, SolrUpdateWriter solrUpdateWriter) {
numRecords.mark();
Timer.Context timerContext = mappingTimer.time();
try {
Record record = new Record();
record.put(Fields.ATTACHMENT_BODY, result);
record.put(Fields.ATTACHMENT_MIME_TYPE, MorphlineResultToSolrMapper.OUTPUT_MIME_TYPE);
for (Map.Entry<String, String> entry : forcedRecordFields.entrySet()) {
record.replaceValues(entry.getKey(), entry.getValue());
}
collector.reset(solrUpdateWriter);
try {
Notifications.notifyStartSession(morphline);
if (!morphline.process(record)) {
numFailedRecords.mark();
LOG.warn("Morphline {} failed to process record: {}", morphlineFileAndId, record);
}
} catch (RuntimeException t) {
numExceptionRecords.mark();
morphlineContext.getExceptionHandler().handleException(t, record);
}
} finally {
collector.reset(null);
timerContext.stop();
}
}
示例4: execute
import org.kitesdk.morphline.base.Notifications; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple) {
try {
finalChild.reset();
Record record = new Record();
record.put(org.kitesdk.morphline.base.Fields.ATTACHMENT_BODY, tupleMapper.map(tuple));
Notifications.notifyStartSession(morphline);
boolean exceptionRaised = false;
try {
boolean processed = morphline.process(record);
if (!processed) {
//TODO handle Morphline returned false
LOG.error("Morphline processing returned false. inputTuple = {}", tuple);
collector.fail(tuple);
return;
}
} catch (RuntimeException rt) {
exceptionRaised = true;
morphlineContext.getExceptionHandler().handleException(rt, record);
}
if (terminalBolt) {
collector.ack(tuple);
return;
}
if (exceptionRaised) {
//Decide if you need extra handling apart from FaultTolerance handler provided by Morphline
}
List<Record> morphlineResults = finalChild.getRecords();
if (morphlineResults.size() == 0) {
//TODO handle zero result
LOG.warn("Zero result by morphline processing. inputTuple: {}", tuple);
collector.ack(tuple);
return;
}
if (morphlineResults.size() > 1) {
//TODO Emit to error stream, ignore or fail tuple
LOG.error("Morphline must not generate more than one output record per input record. returnedSize="
+ morphlineResults.size());
collector.fail(tuple);
}
Object finalResults = recordMapper.map(morphlineResults.get(0));
// Useful when expected more than one output from Morphline execution
/*Object[] finalResults = new Object[recordMappers.size()];
for (int i = 0; i < morphlineResults.size(); i++) {
finalResults[i] = recordMappers.get(i).map(morphlineResults.get(i));
}*/
if (anchorTuple) {
collector.emit(tuple, new Values(finalResults));
} else {
collector.emit(new Values(finalResults));
}
collector.ack(tuple);
} catch (Exception e) {
this.collector.reportError(e);
collector.fail(tuple);
}
}
示例5: startSession
import org.kitesdk.morphline.base.Notifications; //导入方法依赖的package包/类
protected void startSession() {
Notifications.notifyStartSession(morphline);
}
示例6: load
import org.kitesdk.morphline.base.Notifications; //导入方法依赖的package包/类
private boolean load(Record record) {
Notifications.notifyStartSession(morphline);
return morphline.process(record);
}
示例7: map
import org.kitesdk.morphline.base.Notifications; //导入方法依赖的package包/类
/**
* Extract content from the path specified in the value. Key is useless.
*/
public void map(String value, Configuration configuration, Context context) throws IOException {
LOG.info("Processing file {}", value);
InputStream in = null;
Record record = null;
Timer.Context timerContext = elapsedTime.time();
try {
PathParts parts = new PathParts(value.toString(), configuration);
record = getRecord(parts);
if (record == null) {
return; // ignore
}
for (Map.Entry<String, String> entry : commandLineMorphlineHeaders.entrySet()) {
record.replaceValues(entry.getKey(), entry.getValue());
}
long fileLength = parts.getFileStatus().getLen();
if (disableFileOpen) {
in = new ByteArrayInputStream(new byte[0]);
} else {
in = new BufferedInputStream(parts.getFileSystem().open(parts.getUploadPath()));
}
record.put(Fields.ATTACHMENT_BODY, in);
Notifications.notifyStartSession(morphline);
if (!morphline.process(record)) {
LOG.warn("Morphline {} failed to process record: {}", morphlineFileAndId, record);
}
if (context != null) {
context.getCounter(MorphlineCounters.class.getName(), MorphlineCounters.FILES_READ.toString()).increment(1);
context.getCounter(MorphlineCounters.class.getName(), MorphlineCounters.FILE_BYTES_READ.toString()).increment(fileLength);
}
} catch (Exception e) {
LOG.error("Unable to process file " + value, e);
if (context != null) {
context.getCounter(getClass().getName() + ".errors", e.getClass().getName()).increment(1);
}
morphlineContext.getExceptionHandler().handleException(e, record);
} finally {
timerContext.stop();
if (in != null) {
in.close();
}
}
}