public FlowFileTransaction() { this(null, null, new StopWatch(true), 0, null, null); }
final StopWatch stopWatch = new StopWatch(true); final List<FileInfo> listing = transfer.getListing(); final long millis = stopWatch.getElapsed(TimeUnit.MILLISECONDS);
final StopWatch stopWatch = new StopWatch(true);
@OnScheduled public void onScheduled(final ProcessContext context) throws IOException { final String dbFileString = context.getProperty(GEO_DATABASE_FILE).getValue(); final File dbFile = new File(dbFileString); final StopWatch stopWatch = new StopWatch(true); final DatabaseReader reader = new DatabaseReader.Builder(dbFile).build(); stopWatch.stop(); getLogger().info("Completed loading of Maxmind Database. Elapsed time was {} milliseconds.", new Object[]{stopWatch.getDuration(TimeUnit.MILLISECONDS)}); databaseReaderRef.set(reader); }
private void loadDatabase(final File dbFile, final String dbFileChecksum) throws IOException { final StopWatch stopWatch = new StopWatch(true); final DatabaseReader reader = new DatabaseReader.Builder(dbFile).build(); stopWatch.stop(); getLogger().info("Completed loading of Maxmind Database. Elapsed time was {} milliseconds.", new Object[]{stopWatch.getDuration(TimeUnit.MILLISECONDS)}); databaseReader = reader; databaseChecksum = dbFileChecksum; }
final StopWatch stopWatch = new StopWatch(true); flowFile = session.write(flowFile, new StreamCallback() { @Override
@Override public void data(final InputStream data) throws RejectException, TooMuchDataException, IOException { final ProcessSession processSession = sessionFactory.createSession(); final StopWatch watch = new StopWatch(); watch.start(); try { FlowFile flowFile = processSession.create(); final AtomicBoolean limitExceeded = new AtomicBoolean(false); flowFile = processSession.write(flowFile, (OutputStream out) -> { final LimitingInputStream lis = new LimitingInputStream(data, maxMessageSize); IOUtils.copy(lis, out); if (lis.hasReachedLimit()) { limitExceeded.set(true); } }); if (limitExceeded.get()) { throw new TooMuchDataException("Maximum message size limit reached - client must send smaller messages"); } flowFile = processSession.putAllAttributes(flowFile, extractMessageAttributes()); watch.stop(); processSession.getProvenanceReporter().receive(flowFile, "smtp://" + host + ":" + port + "/", watch.getDuration(TimeUnit.MILLISECONDS)); processSession.transfer(flowFile, ListenSMTP.REL_SUCCESS); processSession.commit(); } catch (FlowFileAccessException | IllegalStateException | RejectException | IOException ex) { log.error("Unable to fully process input due to " + ex.getMessage(), ex); throw ex; } finally { processSession.rollback(); //make sure this happens no matter what - is safe } }
private int receiveFlowFiles(final Transaction transaction, final ProcessContext context, final ProcessSession session) throws IOException, ProtocolException { final String userDn = transaction.getCommunicant().getDistinguishedName(); final StopWatch stopWatch = new StopWatch(true); final Set<FlowFile> flowFilesReceived = new HashSet<>(); long bytesReceived = 0L;
final StopWatch stopWatch = new StopWatch(true); try {
@Override public void onEvents(PartitionContext context, Iterable<EventData> messages) throws Exception { final ProcessSession session = processSessionFactory.createSession(); try { final StopWatch stopWatch = new StopWatch(true); if (readerFactory != null && writerFactory != null) { writeRecords(context, messages, session, stopWatch); } else { writeFlowFiles(context, messages, session, stopWatch); } // Commit NiFi first. session.commit(); // If creating an Event Hub checkpoint failed, then the same message can be retrieved again. context.checkpoint(); } catch (Exception e) { getLogger().error("Unable to fully process received message due to " + e, e); // FlowFiles those are already committed will not get rollback. session.rollback(); } }
final StopWatch stopWatch = new StopWatch(true); flowFile = session.write(flowFile, encoder);
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { updateMapping(context); final List<FlowFile> flowFiles = session.get(5); if (flowFiles.isEmpty()) { return; } final ComponentLog logger = getLogger(); final int maxBufferSize = context.getProperty(MAX_BUFFER_SIZE).asDataSize(DataUnit.B).intValue(); for (FlowFile flowFile : flowFiles) { if (flowFile.getSize() > maxBufferSize) { session.transfer(flowFile, REL_FAILURE); continue; } final StopWatch stopWatch = new StopWatch(true); flowFile = session.write(flowFile, new ReplaceTextCallback(context, flowFile, maxBufferSize)); logger.info("Transferred {} to 'success'", new Object[]{flowFile}); session.getProvenanceReporter().modifyContent(flowFile, stopWatch.getElapsed(TimeUnit.MILLISECONDS)); session.transfer(flowFile, REL_SUCCESS); } }
final StopWatch stopWatch = new StopWatch(true);
final StopWatch stopWatch = new StopWatch(true);
final long newFileSize = removeAll ? 0L : ff.getSize() - startOffset - endOffset; final StopWatch stopWatch = new StopWatch(true); if (newFileSize <= 0) { ff = session.write(ff, new OutputStreamCallback() {
final StopWatch stopWatch = new StopWatch(true); if (encode) { flowFile = session.write(flowFile, new StreamCallback() {
@OnScheduled public void onScheduled(final ProcessContext context) throws IOException { getLogger().debug("Loading packages"); final StopWatch stopWatch = new StopWatch(true); // Load required MDHT packages System.setProperty( "org.eclipse.emf.ecore.EPackage.Registry.INSTANCE", "org.eclipse.emf.ecore.impl.EPackageRegistryImpl" ); CDAPackage.eINSTANCE.eClass(); HITSPPackage.eINSTANCE.eClass(); CCDPackage.eINSTANCE.eClass(); ConsolPackage.eINSTANCE.eClass(); IHEPackage.eINSTANCE.eClass(); stopWatch.stop(); getLogger().debug("Loaded packages in {}", new Object[] {stopWatch.getDuration(TimeUnit.MILLISECONDS)}); // Initialize JEXL jexl = new JexlBuilder().cache(1024).debug(false).silent(true).strict(false).create(); jexlCtx = new MapContext(); getLogger().debug("Loading mappings"); loadMappings(); // Load CDA mappings for parser }
@Override public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { FlowFile flowFile = session.get(); if (flowFile == null) { return; } final StopWatch stopWatch = new StopWatch(true); final byte[] buffer = new byte[(int) flowFile.getSize()]; session.read(flowFile, in -> StreamUtils.fillBuffer(in, buffer)); try { sendMessage(buffer); } catch (final ProcessException processException) { getLogger().error("Failed to send {} to EventHub due to {}; routing to failure", new Object[]{flowFile, processException}, processException); session.transfer(session.penalize(flowFile), REL_FAILURE); return; } final String namespace = context.getProperty(NAMESPACE).getValue(); final String eventHubName = context.getProperty(EVENT_HUB_NAME).getValue(); session.getProvenanceReporter().send(flowFile, "amqps://" + namespace + ".servicebus.windows.net" + "/" + eventHubName, stopWatch.getElapsed(TimeUnit.MILLISECONDS)); session.transfer(flowFile, REL_SUCCESS); }
StopWatch stopWatch = new StopWatch(true); sender.send(content); session.getProvenanceReporter().send(flowFile, transitUri, stopWatch.getElapsed(TimeUnit.MILLISECONDS));
final StopWatch stopWatch = new StopWatch(true);