@NotNull @Override public ExcerptTailer afterLastWritten(@NotNull ChronicleQueue queue) { if (queue == this.queue) throw new IllegalArgumentException("You must pass the queue written to, not the queue read"); @NotNull ExcerptTailer tailer = queue.createTailer() .direction(BACKWARD) .toEnd(); "Unable to move to sourceIndex %s in queue %s", Long.toHexString(sourceIndex), this.queue.fileAbsolutePath()); throw new IORuntimeException(errorMessage + extraInfo(tailer, messageHistory)); "No readable document found at sourceIndex %s in queue %s", Long.toHexString(sourceIndex + 1), this.queue.fileAbsolutePath()); throw new IORuntimeException(errorMessage + extraInfo(tailer, messageHistory));
IOTools.deleteDirWithFiles(new File(output), 2); } catch (IORuntimeException e) { e.printStackTrace();
@NotNull @Override @SuppressWarnings("rawtypes") public BytesRef read(Bytes in, long size, @Nullable BytesRef using) { if (size < 0L || size > (long) Integer.MAX_VALUE) { throw new IORuntimeException("byte[] size should be non-negative int, " + size + " given. Memory corruption?"); } int arrayLength = (int) size; if (using == null) { using = new BytesRef(new byte[arrayLength]); } else if (using.bytes.length < arrayLength) { using.bytes = new byte[arrayLength]; } in.read(using.bytes, 0, arrayLength); using.offset = 0; using.length = arrayLength; return using; }
public static boolean compareUtf8(@org.jetbrains.annotations.NotNull RandomDataInput input, long offset, @org.jetbrains.annotations.Nullable CharSequence other) throws IORuntimeException, BufferUnderflowException, IndexOutOfBoundsException { long utfLen; if ((utfLen = input.readByte(offset++)) < 0) { utfLen &= 0x7FL; long b; int count = 7; while ((b = input.readByte(offset++)) < 0) { utfLen |= (b & 0x7FL) << count; count += 7; } if (b != 0) { if (count > 56) throw new IORuntimeException( "Cannot read more than 9 stop bits of positive value"); utfLen |= (b << count); } else { if (count > 63) throw new IORuntimeException( "Cannot read more than 10 stop bits of negative value"); utfLen = ~utfLen; } } if (utfLen == -1) return other == null; return other != null && compareUtf8(input, offset, utfLen, other); }
public ChronicleMapKeyValueStore(@NotNull RequestContext context, @NotNull Asset asset) { String basePath = context.basePath(); keyType = context.keyType(); @Nullable HostIdentifier hostIdentifier = null; @Nullable EngineReplication engineReplicator1 = null; try { engineReplicator1 = asset.acquireView(EngineReplication.class); @Nullable final EngineReplicationLangBytesConsumer langBytesConsumer = asset.findView (EngineReplicationLangBytesConsumer.class); chronicleMap = builder.create(); } else { @NotNull String pathname = basePath + "/" + context.name(); @NotNull IORuntimeException iore = new IORuntimeException("Could not access " + pathname); iore.initCause(e); throw iore;
@Nullable @Override public Object defaultValue() { throw new IORuntimeException("field " + name() + " required"); } }
public static void appendBytesFromStart(@org.jetbrains.annotations.NotNull Bytes bytes, long startPosition, @org.jetbrains.annotations.NotNull StringBuilder sb) { try { BytesInternal.parse8bit(startPosition, bytes, sb, (int) (bytes.readPosition() - startPosition)); sb.append('\u2016'); sb.append(bytes); } catch (IOException e) { throw new IORuntimeException(e); } }
@Override public long index() throws IORuntimeException { if (this.wire.headerNumber() == Long.MIN_VALUE) { try { wire.headerNumber(queue.rollCycle().toIndex(cycle, store.lastSequenceNumber(StoreAppender.this))); long headerNumber0 = wire.headerNumber(); assert (((AbstractWire) this.wire).isInsideHeader()); return isMetaData() ? headerNumber0 : headerNumber0 + 1; } catch (IOException e) { throw new IORuntimeException(e); } } return isMetaData() ? Long.MIN_VALUE : this.wire.headerNumber() + 1; }
MappedUniqueMicroTimeProvider() { try { file = MappedFile.mappedFile(OS.TMP + "/.time-stamp.dat", OS.pageSize(), 0); bytes = file.acquireBytesForWrite(0); bytes.append8bit("&TSF\nTime stamp file uses for sharing a unique id\n"); BytesUtil.unregister(bytes); } catch (IOException ioe) { throw new IORuntimeException(ioe); } }
@Override public void readMarshallable(BytesIn bytes) throws IORuntimeException { long position = bytes.readPosition(); long capacity = bytes.readLong(); long used = bytes.readLong(); if (capacity < 0 || capacity > bytes.readRemaining() >> 3) throw new IORuntimeException("Corrupt used capacity"); if (used < 0 || used > capacity) throw new IORuntimeException("Corrupt used value"); bytes.readSkip(capacity * 8); long length = bytes.readPosition() - position; bytesStore(((Bytes) bytes).bytesStore(), position, length); }
@NotNull @Override public byte[] read(@NotNull Bytes in, long size, @Nullable byte[] using) { if (size < 0L || size > (long) Integer.MAX_VALUE) { throw new IORuntimeException("byte[] size should be non-negative int, " + size + " given. Memory corruption?"); } int arrayLength = (int) size; if (using == null || arrayLength != using.length) using = new byte[arrayLength]; in.read(using); return using; }
@Nullable @Override public Object defaultValue() { throw new IORuntimeException("field " + name() + " required"); } }
throw new IORuntimeException(e);
@NotNull @Override public byte[] uncompress(@NotNull byte[] bytes) throws IORuntimeException { try { return org.xerial.snappy.Snappy.uncompress(bytes); } catch (IOException e) { throw new IORuntimeException(e); } }
try { ... } catch (IOException ioex) { throw new IORuntimeException(ioex); }
default byte[] uncompress(@NotNull byte[] bytes) throws IORuntimeException { @NotNull ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (InputStream input = decompressingStream(new ByteArrayInputStream(bytes))) { @NotNull byte[] buf = new byte[512]; for (int len; (len = input.read(buf)) > 0; ) baos.write(buf, 0, len); } catch (IOException e) { throw new IORuntimeException(e); } return baos.toByteArray(); }
@Override public InetSocketAddress getLocalAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getLocalAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
@NotNull @Override public InputStream decompressingStream(InputStream input) throws IORuntimeException { try { return new SnappyInputStream(input); } catch (IOException e) { throw new IORuntimeException(e); } }
@Override public InetSocketAddress getLocalAddress() throws IORuntimeException { try { return (InetSocketAddress) socketChannel.getLocalAddress(); } catch (IOException e) { throw new IORuntimeException(e); } }
static long readStopBit0(@org.jetbrains.annotations.NotNull @NotNull StreamingDataInput in, long l) throws IORuntimeException { l &= 0x7FL; long b; int count = 7; while ((b = in.readByte()) < 0) { l |= (b & 0x7FL) << count; count += 7; } if (b != 0) { if (count > 56) throw new IORuntimeException( "Cannot read more than 9 stop bits of positive value"); return l | (b << count); } else { if (count > 63) throw new IORuntimeException( "Cannot read more than 10 stop bits of negative value"); return ~l; } }