Java Code Examples for net.openhft.chronicle.bytes.Bytes#readLong()

The following examples show how to use net.openhft.chronicle.bytes.Bytes#readLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BytesForTesting.java    From Chronicle-Salt with Apache License 2.0 5 votes vote down vote up
void checkZeros(Bytes b) {
    for (int i = 8; i <= 32; i += 8) {
        if (b.readLong(b.realCapacity() - i) != 0) {
            fail(b.toHexString());
        }
    }
}
 
Example 2
Source File: NonClusteredSslIntegrationTest.java    From Chronicle-Network with Apache License 2.0 5 votes vote down vote up
@Override
public void process(@NotNull final Bytes in, @NotNull final Bytes out, final StubNetworkContext nc) {
    latch.countDown();
    try {
        if (nc.isAcceptor() && in.readRemaining() != 0) {
            final int magic = in.readInt();
            if (magic != 0xFEDCBA98)
                throw new IllegalStateException("Invalid magic number " + Integer.toHexString(magic));
            final long received = in.readLong();
            final int len = in.readInt();
            final byte[] tmp = new byte[len];
            in.read(tmp);
            if (DEBUG) {
                if (len > 10) {
                    System.out.printf("%s received payload of length %d%n", label, len);
                    System.out.println(in);
                } else {
                    System.out.printf("%s received [%d] %d/%s%n", label, tmp.length, received, new String(tmp, StandardCharsets.US_ASCII));
                }
            }
            operationCount++;
        } else if (!nc.isAcceptor()) {
            if (System.currentTimeMillis() > lastSent + 100L) {
                out.writeInt(0xFEDCBA98);
                out.writeLong((counter++));
                final String payload = "ping-" + (counter - 1);
                out.writeInt(payload.length());
                out.write(payload.getBytes(StandardCharsets.US_ASCII));
                if (DEBUG) {
                    System.out.printf("%s sent [%d] %d/%s%n", label, payload.length(), counter - 1, payload);
                }
                operationCount++;
                lastSent = System.currentTimeMillis();
            }
        }
    } catch (RuntimeException e) {
        System.err.printf("Exception in %s: %s/%s%n", label, e.getClass().getSimpleName(), e.getMessage());
        e.printStackTrace();
    }
}
 
Example 3
Source File: BenchmarkMain.java    From Chronicle-Queue with Apache License 2.0 5 votes vote down vote up
private static long readMessage(Bytes<?> bytes) {
    Jvm.safepoint();
    long start = bytes.readLong();
    long rp = bytes.readPosition();
    long rl = bytes.readLimit();
    long addr = bytes.addressForRead(rp);
    long addrEnd = bytes.addressForRead(rl);
    Memory memory = OS.memory();
    for (addr += 8; addr + 7 < addrEnd; addr += 8)
        memory.readLong(addr);
    Jvm.safepoint();
    return start;
}
 
Example 4
Source File: LongMarshaller.java    From Chronicle-Map with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Long read(@NotNull Bytes in, long size, @Nullable Long using) {
    return in.readLong();
}
 
Example 5
Source File: LongMarshaller.java    From Chronicle-Map with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Long read(Bytes in, @Nullable Long using) {
    return in.readLong();
}
 
Example 6
Source File: Issue58.java    From Chronicle-Map with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public UUID read(Bytes bytes, @Nullable UUID using) {
    return new UUID(bytes.readLong(), bytes.readLong());
}