protected void subscribe(long index) throws IOException { writeBuffer.clearAll(); writeBuffer.writeLong(ChronicleTcp.ACTION_SUBSCRIBE); writeBuffer.writeLong(index); MappingFunction mapping = withMapping(); if (mapping != null) { // write with mapping and len writeBuffer.writeLong(ChronicleTcp.ACTION_WITH_MAPPING); long pos = writeBuffer.position(); writeBuffer.skip(4); long start = writeBuffer.position(); writeBuffer.writeObject(mapping); writeBuffer.writeInt(pos, (int) (writeBuffer.position() - start)); } writeBuffer.setBufferPositionAndLimit(0, writeBuffer.position()); connection.writeAllOrEOF(writeBuffer); }
protected void query(long index) throws IOException { writeBuffer.clearAll(); writeBuffer.writeLong(ChronicleTcp.ACTION_QUERY); writeBuffer.writeLong(index); writeBuffer.setBufferPositionAndLimit(0, writeBuffer.position()); connection.writeAllOrEOF(writeBuffer); }
withMappedBuffer.clear(); if (withMappedBuffer.capacity() < source.limit()) { withMappedBuffer.resetToSize((int) source.capacity()); if (withMappedBuffer.capacity() == Integer.MAX_VALUE) { throw e; withMappedBuffer.resetToSize( Math.min( Integer.MAX_VALUE, (int) (withMappedBuffer.capacity() * 1.5)) ); return withMappedBuffer.flip();
private SessionHandler(final @NotNull SocketChannel socketChannel) { this.socketChannel = socketChannel; this.connection = new TcpConnection(socketChannel); this.tailer = null; this.appender = null; this.lastHeartbeat = 0; this.lastUnPausedNS = 0; this.readBuffer = new ResizableDirectByteBufferBytes(16); this.readBuffer.clearThreadAssociation(); this.writeBuffer = ChronicleTcp.createBuffer(builder.minBufferSize()); this.writeBuffer.limit(0); this.withMappedBuffer = new ResizableDirectByteBufferBytes(1024); }
protected AbstractStatefulExcerpt(final ExcerptCommon excerpt) { super(excerpt); this.logger = LoggerFactory.getLogger(getClass().getName() + "@" + connection.toString()); this.writeBuffer = new ResizableDirectByteBufferBytes(builder.minBufferSize()); this.readBuffer = ChronicleTcp.createBuffer(builder.minBufferSize()); this.reconnectionIntervalMS = builder.reconnectionIntervalMillis(); this.lastReconnectionAttemptMS = 0; this.lastReconnectionAttempt = 0; }