@Override public boolean hasNext() { return indexTrailer.nextIndex(); }
@Override public T get(Long id) { if (!exTrailer.index(id)) { return null; } return read(exTrailer); }
/** * @see com.ottogroup.bi.spqr.pipeline.queue.StreamingMessageQueueConsumer#next() */ public StreamingDataMessage next() { // check if a new message is available and read it from chronicle if possible if(queueReader.nextIndex()) { long timestamp = queueReader.readLong(); int bytes = queueReader.readInt(); byte[] body = new byte[bytes]; queueReader.read(body); queueReader.finish(); if(this.messageRetrievalCounter != null) this.messageRetrievalCounter.inc(); return new StreamingDataMessage(body, timestamp); } // otherwise return null; return null; }
@Override protected boolean publishData() throws IOException { if(nextIndex) { if (!tailer.nextIndex()) { pause(); if (!closed && !tailer.nextIndex()) { return false; if(!tailer.index(this.index)) { return false; } else { final long size = tailer.capacity(); long remaining = size + ChronicleTcp.HEADER_SIZE; buffer.putLong(tailer.index()); int size2 = (int) Math.min(remaining, buffer.capacity()); buffer.limit(size2); tailer.read(buffer); buffer.flip(); remaining -= buffer.remaining(); tailer.read(buffer); int count = 1; while (count++ < maxMessages) { if (tailer.nextIndex()) { if (tailer.wasPadding()) { throw new AssertionError("Entry should not be padding - remove");
@SuppressWarnings("unchecked") static LoggingEventRecord read(ExcerptTailer ex) { int vers = ex.readInt(); if (vers == 1) { LoggingEventRecord rec = new LoggingEventRecord(); rec.timestamp = ex.readLong(); rec.level = ex.readInt(); int argLen = ex.readInt(); int propsLen = ex.readInt(); int callerDataLen = ex.readInt(); rec.threadName = ex.readUTF(); rec.loggerName = ex.readUTF(); rec.message = ex.readUTF(); args[i] = ex.readUTF(); : Collections.<String, String>emptyMap()); for (int i = 0; i < propsLen; i++) { String key = ex.readUTF(); String val = ex.readUTF(); mdcProps.put(key, val); callerData[i] = ex.readObject(StackTraceElement.class); if (ex.readBoolean()) { rec.cause = ex.readObject(Throwable.class);
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; }
public boolean readOne() { if (!excerpt.nextIndex()) { // System.out.println("r- " + excerpt.index()); return false; } long pos = excerpt.position(); // System.out.println("Reading " + excerpt.index()); MessageType mt = excerpt.readEnum(MessageType.class); if (mt == null) { // rewind and read again. excerpt.position(pos); System.err.println("Unknown message type " + excerpt.readUTFΔ()); return true; } switch (mt) { case report: { metaData.readFromEngine(excerpt, sourceId); report.readMarshallable(excerpt); gwEvents.report(metaData, report); break; } default: System.err.println("Unknown message type " + mt); break; } 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; }
while (vtail.nextIndex()) { MessageKey key = (MessageKey) vtail.readObject(); System.out.println("key " + key);
@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); count--; tailer.finish();
@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; }
while (!excerpt.index(index)) Thread.sleep(50); System.out.print(index + ": "); int nullCount = 0; while (excerpt.remaining() > 0) { char ch = (char) excerpt.readUnsignedByte(); if (ch == 0) { nullCount++;
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 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 public void close() throws IOException { if(this.tailer != null) { this.tailer.close(); this.tailer = null; } if(this.socket.isOpen()) { this.socket.close(); } }
@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; final long size = tailer.capacity(); long remaining = size + ChronicleTcp.HEADER_SIZE; buffer.putLong(tailer.index()); int size2 = (int) Math.min(remaining, buffer.capacity()); buffer.limit(size2); tailer.read(buffer); buffer.flip(); remaining -= buffer.remaining(); 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())) { break; int size2 = (int) tailer.capacity(); buffer.limit(buffer.position() + size2 + ChronicleTcp.HEADER_SIZE);
@SuppressWarnings("unchecked") static LoggingEventRecord read(ExcerptTailer ex) { int vers = ex.readInt(); if (vers == 1) { LoggingEventRecord rec = new LoggingEventRecord(); rec.timestamp = ex.readLong(); rec.level = ex.readInt(); int argLen = ex.readInt(); int propsLen = ex.readInt(); int callerDataLen = ex.readInt(); rec.threadName = ex.readUTF(); rec.loggerName = ex.readUTF(); rec.message = ex.readUTF(); args[i] = ex.readUTF(); : Collections.<String, String>emptyMap()); for (int i = 0; i < propsLen; i++) { String key = ex.readUTF(); String val = ex.readUTF(); mdcProps.put(key, val); callerData[i] = ex.readObject(StackTraceElement.class); if (ex.readBoolean()) { rec.cause = ex.readObject(Throwable.class);