@Override public T get(Long id) { if (!exTrailer.index(id)) { return null; } return read(exTrailer); }
@Override public boolean index(long index) throws IndexOutOfBoundsException { return wrappedTailer.index(index); }
@Override public long index() { return wrappedTailer.index(); }
@Override public boolean index(long index) throws IndexOutOfBoundsException { return wrappedExcerpt == null ? wrappedTailer.index(index) : wrappedExcerpt.index(index); }
@Override public boolean index(long index) throws IndexOutOfBoundsException { return excerpt == null ? tailer.index(index) : excerpt.index(index); }
public long getTimestamp() { if (timestamp == -1) { tailer.index(localIndex); this.timestamp = tailer.readLong(); } return timestamp; }
@Override protected boolean onSubscribe(final SelectionKey key, long data) throws IOException { this.index = data; if (this.index == ChronicleTcp.IDX_TO_START) { this.index = -1; } else if (this.index == ChronicleTcp.IDX_TO_END) { this.index = tailer.toEnd().index(); } sendSizeAndIndex(ChronicleTcp.SYNC_IDX_LEN, this.index); key.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE); return true; }
@Override protected boolean handleSubscribe(final SelectionKey key) throws IOException { this.index = command.data(); if (this.index == -1) { this.index = -1; } else if (this.index == -2) { this.index = tailer.toEnd().index(); } sendSizeAndIndex(ChronicleTcp.SYNC_IDX_LEN, this.index); key.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE); return false; }
while (!excerpt.index(index)) Thread.sleep(50); System.out.print(index + ": ");
public byte[] getContent() { if (content == null) { tailer.index(localIndex); int contentSize = tailer.readInt(16); tailer.position(20); content = new byte[contentSize]; tailer.read(content); } return content; }
while (!excerpt.index(index)) Thread.sleep(50); System.out.print(index + ": ");
public Log getLog(long index) { initalize(); if (!indexRange.contains(index)) { logger.debug("indexRange {} notContains {}", indexRange, index); return null; } long localIndex = index - indexOffset; if (!tailer.index(localIndex)) { if (tailer.wasPadding()) { logger.debug("padded ", index); return Log.paddedEntry(localIndex, index); } logger.debug("chronicle {} notContain {} {}", basePath, index, localIndex); return null; } return new Log(localIndex, index, tailer); }
@Override protected boolean publishData() throws IOException { if (!tailer.index(index)) { if (tailer.wasPadding()) { if (index >= 0) { sendSizeAndIndex(ChronicleTcp.PADDED_LEN, tailer.index()); if(!closed && !tailer.index(index)) { return false; buffer.putLong(tailer.index()); tailer.read(buffer); int count = 1; while (tailer.index(index + 1) && count++ < maxMessages) { if(!tailer.wasPadding()) { if (tailer.capacity() + ChronicleTcp.HEADER_SIZE >= (buffer.capacity() - buffer.position())) { buffer.limit(buffer.position() + size2 + ChronicleTcp.HEADER_SIZE); buffer.putInt(size2); buffer.putLong(tailer.index()); tailer.read(buffer); index++;
protected boolean onQuery(final SelectionKey key, long data) throws IOException { if (tailer.index(data)) { final long now = System.currentTimeMillis(); setLastHeartbeat(now); while (true) { if (tailer.nextIndex()) { sendSizeAndIndex(ChronicleTcp.SYNC_IDX_LEN, tailer.index()); tailer.finish(); break; } else { if (lastHeartbeat <= now) { sendSizeAndIndex(ChronicleTcp.IN_SYNC_LEN, ChronicleTcp.IDX_NONE); break; } } } } else { sendSizeAndIndex(ChronicleTcp.IN_SYNC_LEN, 0L); } return true; }
protected boolean handleQuery(final SelectionKey key) throws IOException { if(tailer.index(command.data())) { final long now = System.currentTimeMillis(); setLastHeartbeat(now); while (true) { if (tailer.nextIndex()) { sendSizeAndIndex(ChronicleTcp.SYNC_IDX_LEN, tailer.index()); break; } else { if (lastHeartbeat <= now) { sendSizeAndIndex(ChronicleTcp.IN_SYNC_LEN, 0L); break; } } } } else { sendSizeAndIndex(ChronicleTcp.IN_SYNC_LEN, 0L); } return true; }
public <T extends Encodable> T getVal(Function<DirectBuffer, T> parseFrom) { tailer.index(localIndex); int contentSize = tailer.readInt(16); tailer.position(20); DirectBuffer buffer = new DirectBuffer(tailer.address() + tailer.position(), contentSize); return parseFrom.apply(buffer); }
@Override protected boolean handleSubscribe(final SelectionKey key) throws IOException { this.index = command.data(); if (this.index == -1) { this.nextIndex = true; this.tailer = tailer.toStart(); this.index = -1; } else if (this.index == -2) { this.nextIndex = false; this.tailer = tailer.toEnd(); this.index = tailer.index(); } else { this.nextIndex = false; } sendSizeAndIndex(ChronicleTcp.SYNC_IDX_LEN, this.index); key.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE); return false; }
@Override protected boolean write(Object attached) throws IOException { if (!tailer.index(index)) { if (tailer.wasPadding()) { if (index >= 0) { sendSizeAndIndex(ChronicleTcp.PADDED_LEN, tailer.index()); if (running.get() && !tailer.index(index)) { return false; writeBuffer.putLong(tailer.index()); for (int count = builder.maxExcerptsPerMessage(); (count > 0) && tailer.index(index + 1); ) { if (!tailer.wasPadding()) { bytes = applyMapping(tailer, attached); size = (int) bytes.limit(); writeBuffer.putInt(size); writeBuffer.putLong(tailer.index()); bytes.read(writeBuffer, size);
if (!tailer.index(this.index)) { return false; writeBuffer.putLong(tailer.index()); bytes.read(writeBuffer, size); long previousIndex = tailer.index(); long currentIndex = previousIndex; for (int count = builder.maxExcerptsPerMessage(); (count > 0) && tailer.nextIndex(); ) { currentIndex = tailer.index(); bytes = applyMapping(tailer, attached); tailer.finish(); tailer.index(previousIndex); break; throw new EOFException("Failed to send index=" + tailer.index());
@Override protected boolean onSubscribe(final SelectionKey key, long data) throws IOException { this.index = data; if (this.index == ChronicleTcp.IDX_TO_START) { this.nextIndex = true; this.tailer = tailer.toStart(); this.index = -1; } else if (this.index == ChronicleTcp.IDX_TO_END) { this.nextIndex = false; this.tailer = tailer.toEnd(); this.index = tailer.index(); if (this.index == -1) { this.nextIndex = true; this.tailer = tailer.toStart(); this.index = -1; } } else { this.nextIndex = false; } sendSizeAndIndex(ChronicleTcp.SYNC_IDX_LEN, this.index); key.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE); return false; }