use of org.apache.nifi.remote.io.socket.BufferStateManager in project nifi by apache.
the class SSLSocketChannel method write.
public void write(final byte[] data, final int offset, final int len) throws IOException {
logger.debug("{} Writing {} bytes of data", this, len);
if (!connected) {
connect();
}
int iterations = len / MAX_WRITE_SIZE;
if (len % MAX_WRITE_SIZE > 0) {
iterations++;
}
for (int i = 0; i < iterations; i++) {
streamOutManager.clear();
final int itrOffset = offset + i * MAX_WRITE_SIZE;
final int itrLen = Math.min(len - itrOffset, MAX_WRITE_SIZE);
final ByteBuffer byteBuffer = ByteBuffer.wrap(data, itrOffset, itrLen);
final BufferStateManager buffMan = new BufferStateManager(byteBuffer, Direction.READ);
final Status status = encryptAndWriteFully(buffMan);
switch(status) {
case BUFFER_OVERFLOW:
streamOutManager.ensureSize(engine.getSession().getPacketBufferSize());
appDataManager.ensureSize(engine.getSession().getApplicationBufferSize());
continue;
case OK:
continue;
case CLOSED:
throw new IOException("Channel is closed");
case BUFFER_UNDERFLOW:
throw new AssertionError("Got Buffer Underflow but should not have...");
}
}
}
Aggregations