@Override public void encode(final DataPacket dataPacket, final OutputStream encodedOut) throws IOException { final DataOutputStream out = new DataOutputStream(encodedOut); final Map<String, String> attributes = dataPacket.getAttributes(); out.writeInt(attributes.size()); for (final Map.Entry<String, String> entry : attributes.entrySet()) { writeString(entry.getKey(), out); writeString(entry.getValue(), out); } out.writeLong(dataPacket.getSize()); final InputStream in = dataPacket.getData(); StreamUtils.copy(in, encodedOut); encodedOut.flush(); }
final byte[] data = new byte[(int) dataPacket.getSize()]; StreamUtils.fillBuffer(inStream, data);
contentBytes += dataPacket.getSize(); this.state = TransactionState.DATA_EXCHANGED; } catch (final IOException ioe) {
} else { transfers++; contentBytes += packet.getSize();
bytesReceived += dataPacket.getSize();
final byte[] data = new byte[(int) dataPacket.getSize()]; StreamUtils.fillBuffer(inStream, data);
final byte[] data = new byte[(int) dataPacket.getSize()]; StreamUtils.fillBuffer(inStream, data);
@Override protected NiFiDataPacket createTuple(final DataPacket dataPacket) throws IOException { // read the data into a byte array and wrap it with the attributes into a NiFiDataPacket final InputStream inStream = dataPacket.getData(); final byte[] data = new byte[(int)dataPacket.getSize()]; StreamUtils.fillBuffer(inStream, data); final Map<String, String> attributes = dataPacket.getAttributes(); return new StandardNiFiDataPacket(data, attributes); }
@Override protected NiFiDataPacket createTuple(final DataPacket dataPacket) throws IOException { // read the data into a byte array and wrap it with the attributes into a NiFiDataPacket final InputStream inStream = dataPacket.getData(); final byte[] data = new byte[(int)dataPacket.getSize()]; StreamUtils.fillBuffer(inStream, data); final Map<String, String> attributes = dataPacket.getAttributes(); return new StandardNiFiDataPacket(data, attributes); }
bytesReceived += dataPacket.getSize();