本文整理汇总了Java中org.apache.nifi.util.StopWatch类的典型用法代码示例。如果您正苦于以下问题:Java StopWatch类的具体用法?Java StopWatch怎么用?Java StopWatch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StopWatch类属于org.apache.nifi.util包,在下文中一共展示了StopWatch类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: enrich
import org.apache.nifi.util.StopWatch; //导入依赖的package包/类
@Override
public FlowFile enrich(ProcessSession session, FlowFile ff, Map<String, String> content) {
StopWatch stopWatch = new StopWatch(true);
ff = session.write(ff, new StreamingJSONAppender(this.field, makeJsonFromMapOfJsons(content)));
session.getProvenanceReporter().modifyContent(ff, stopWatch.getElapsed(TimeUnit.MILLISECONDS));
return ff;
}
开发者ID:qntfy,项目名称:nifi-redis,代码行数:8,代码来源:JSONFlowFileEnricherImpl.java
示例2: CheckedStopWatch
import org.apache.nifi.util.StopWatch; //导入依赖的package包/类
CheckedStopWatch(long timeframeMilliseconds) {
this.stopWatch = new StopWatch(false);
this.timeFrameMilliseconds = timeframeMilliseconds;
}
开发者ID:Asymmetrik,项目名称:nifi-nars,代码行数:5,代码来源:AttributeTumblingWindow.java
示例3: onTrigger
import org.apache.nifi.util.StopWatch; //导入依赖的package包/类
@Override
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get();
if ( flowFile == null ) {
return;
}
final String outboundAddress = context.getProperty(OUTBOUND_ADDRESS).evaluateAttributeExpressions(flowFile).getValue();
try {
final StopWatch stopWatch = new StopWatch(true);
final byte[] buffer = new byte[(int) flowFile.getSize()];
session.read(flowFile, new InputStreamCallback() {
@Override
public void process(final InputStream in) throws IOException {
StreamUtils.fillBuffer(in, buffer, false);
}
});
// TODO detect flowFile MIME_TYPE and convert buffer into JSON, String or buffer
JsonObject message = new JsonObject(new String(buffer, StandardCharsets.UTF_8));
if(attributePattern != null) {
DeliveryOptions options = new DeliveryOptions();
for(String attributeName : flowFile.getAttributes().keySet()) {
if (attributePattern != null && attributePattern.matcher(attributeName).matches()) {
options.addHeader(attributeName, flowFile.getAttribute(attributeName));
}
}
put(outboundAddress, message, options);
} else {
put(outboundAddress, message);
}
final Map<String, String> attributes = new HashMap<>();
attributes.put("eventbus.address", outboundAddress);
flowFile = session.putAllAttributes(flowFile, attributes);
session.getProvenanceReporter().receive(flowFile, outboundAddress, "sent message to eventBus", stopWatch.getElapsed(TimeUnit.MILLISECONDS));
getLogger().info("Successfully sent {} ({}) to EventBuss in {} millis", new Object[]{flowFile, flowFile.getSize(), stopWatch.getElapsed(TimeUnit.MILLISECONDS)});
session.transfer(flowFile, REL_SUCCESS);
} catch (ProcessException pe) {
getLogger().error("Failed to send {} to EventBuss due to {}; routing to failure", new Object[] {flowFile, pe.toString()}, pe);
session.transfer(flowFile, REL_FAILURE);
}
}
开发者ID:xmlking,项目名称:nifi-websocket,代码行数:48,代码来源:PublishEventBus.java
示例4: onTrigger
import org.apache.nifi.util.StopWatch; //导入依赖的package包/类
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
final ProcessorLog logger = getLogger();
final Message<JsonObject> message = messageQueue.poll();
if (message == null) {
context.yield();
return;
}
FlowFile flowFile = session.create();
try {
final StopWatch stopWatch = new StopWatch(true);
flowFile = session.write(flowFile, new OutputStreamCallback() {
@Override
public void process(final OutputStream out) throws IOException {
out.write(message.body().encode().getBytes(StandardCharsets.UTF_8));
}
});
if (flowFile.getSize() == 0L) {
session.remove(flowFile);
} else {
final Map<String, String> attributes = new HashMap<>();
if (headerPattern != null) {
MultiMap headers = message.headers();
headers.names()
.stream()
.filter(headerName -> headerPattern.matcher(headerName).matches())
.forEach(headerName -> attributes.put(headerName, headers.get(headerName)));
// attributes.putAll(
// headers.entries()
// .stream()
// .filter(entry -> headerPattern.matcher(entry.getKey()).matches())
// .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))
// );
}
attributes.put(CoreAttributes.MIME_TYPE.key(), "application/json");
attributes.put(CoreAttributes.FILENAME.key(), flowFile.getAttribute(CoreAttributes.FILENAME.key()) + ".json");
attributes.put("eventbus.address", message.address());
flowFile = session.putAllAttributes(flowFile, attributes);
session.getProvenanceReporter().receive(flowFile, message.address(), "received eventBus message", stopWatch.getElapsed(TimeUnit.MILLISECONDS));
getLogger().info("Successfully received {} ({}) from EventBus in {} millis", new Object[]{flowFile, flowFile.getSize(), stopWatch.getElapsed(TimeUnit.MILLISECONDS)});
session.transfer(flowFile, REL_SUCCESS);
}
} catch (Exception e) {
session.remove(flowFile);
throw e;
}
}
开发者ID:xmlking,项目名称:nifi-websocket,代码行数:54,代码来源:GetEventBus.java
注:本文中的org.apache.nifi.util.StopWatch类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论