@Override public void send(final DataPacket dataPacket) throws IOException { transaction.send(dataPacket); }
@Override public void send(final byte[] content, final Map<String, String> attributes) throws IOException { transaction.send(content, attributes); }
protected void sendData(final ReportingContext context, final Transaction transaction, Map<String, String> attributes, final JsonArray jsonArray) throws IOException { if(context.getProperty(RECORD_WRITER).isSet()) { transaction.send(getData(context, new ByteArrayInputStream(jsonArray.toString().getBytes(StandardCharsets.UTF_8)), attributes), attributes); } else { transaction.send(jsonArray.toString().getBytes(StandardCharsets.UTF_8), attributes); } }
public TransactionCompletion sendFiles() throws IOException { Transaction transaction = siteToSiteClient.createTransaction(TransferDirection.SEND); try { DataPacketDto.getDataPacketStream(input).forEachOrdered(d -> { try { transaction.send(d); } catch (IOException e) { throw new RuntimeException(e); } }); } catch (RuntimeException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) { throw (IOException) cause; } throw new IOException(e.getMessage(), e); } transaction.confirm(); return transaction.complete(); } }
@Override public void process(final InputStream in) throws IOException { final DataPacket dataPacket = new StandardDataPacket(toWrap.getAttributes(), in, toWrap.getSize()); transaction.send(dataPacket); } });
@Override public void invoke(T value) throws Exception { final NiFiDataPacket niFiDataPacket = builder.createNiFiDataPacket(value, getRuntimeContext()); final Transaction transaction = client.createTransaction(TransferDirection.SEND); if (transaction == null) { throw new IllegalStateException("Unable to create a NiFi Transaction to send data"); } transaction.send(niFiDataPacket.getContent(), niFiDataPacket.getAttributes()); transaction.confirm(); transaction.complete(); }
transaction.send(dataPacket.getContent(), dataPacket.getAttributes());
attributes.put("reporting.task.type", this.getClass().getSimpleName()); transaction.send(data, attributes); transaction.confirm(); transaction.complete();
protected void sendData(final ReportingContext context, final Transaction transaction, Map<String, String> attributes, final JsonArray jsonArray) throws IOException { if(context.getProperty(RECORD_WRITER).isSet()) { transaction.send(getData(context, new ByteArrayInputStream(jsonArray.toString().getBytes(StandardCharsets.UTF_8)), attributes), attributes); } else { transaction.send(jsonArray.toString().getBytes(StandardCharsets.UTF_8), attributes); } }
public TransactionCompletion sendFiles() throws IOException { Transaction transaction = siteToSiteClient.createTransaction(TransferDirection.SEND); try { DataPacketDto.getDataPacketStream(input).forEachOrdered(d -> { try { transaction.send(d); } catch (IOException e) { throw new RuntimeException(e); } }); } catch (RuntimeException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) { throw (IOException) cause; } throw new IOException(e.getMessage(), e); } transaction.confirm(); return transaction.complete(); } }
@Override public void process(final InputStream in) throws IOException { final DataPacket dataPacket = new StandardDataPacket(toWrap.getAttributes(), in, toWrap.getSize()); transaction.send(dataPacket); } });
/** * Send the given batch of tuples to NiFi in a transaction, using the provided builder to * first convert each tuple into a NiFiDataPacket. * * @param tuples a list of tuples to process */ protected void processTuples(List<T> tuples) { if (tuples == null || tuples.size() == 0) { return; } // create a transaction and send the data packets try { final Transaction transaction = client.createTransaction(TransferDirection.SEND); if (transaction == null) { throw new IllegalStateException("Unable to create a NiFi Transaction to send data"); } // convert each tuple to a NiFiDataPacket using the provided builder for (T tuple : tuples) { NiFiDataPacket dp = dataPacketBuilder.createNiFiDataPacket(tuple); transaction.send(dp.getContent(), dp.getAttributes()); } transaction.confirm(); transaction.complete(); } catch (IOException ioe) { DTThrowable.rethrow(ioe); } }
/** * Send the given batch of tuples to NiFi in a transaction, using the provided builder to * first convert each tuple into a NiFiDataPacket. * * @param tuples a list of tuples to process */ protected void processTuples(List<T> tuples) { if (tuples == null || tuples.size() == 0) { return; } // create a transaction and send the data packets try { final Transaction transaction = client.createTransaction(TransferDirection.SEND); if (transaction == null) { throw new IllegalStateException("Unable to create a NiFi Transaction to send data"); } // convert each tuple to a NiFiDataPacket using the provided builder for (T tuple : tuples) { NiFiDataPacket dp = dataPacketBuilder.createNiFiDataPacket(tuple); transaction.send(dp.getContent(), dp.getAttributes()); } transaction.confirm(); transaction.complete(); } catch (IOException ioe) { DTThrowable.rethrow(ioe); } }
attributes.put("reporting.task.type", this.getClass().getSimpleName()); transaction.send(data, attributes); transaction.confirm(); transaction.complete();
transaction.send(data, attributes); transaction.confirm(); transaction.complete();