Search in sources :

Example 6 with ValueOut

use of net.openhft.chronicle.wire.ValueOut in project Chronicle-Queue by OpenHFT.

the class QueueInspectorTest method shouldDetermineWritingProcessIdWhenDocumentIsNotComplete.

@Test
public void shouldDetermineWritingProcessIdWhenDocumentIsNotComplete() throws IOException {
    try (final SingleChronicleQueue queue = SingleChronicleQueueBuilder.binary(tmpDir.newFolder()).testBlockSize().build()) {
        final QueueInspector inspector = new QueueInspector(queue);
        final ExcerptAppender appender = queue.acquireAppender();
        appender.writeDocument(37L, ValueOut::int64);
        try (final DocumentContext ctx = appender.writingDocument()) {
            ctx.wire().write("foo").int32(17L);
            final int writingThreadId = inspector.getWritingThreadId();
            assertThat(writingThreadId, is(Affinity.getThreadId()));
            assertThat(QueueInspector.isValidThreadId(writingThreadId), is(true));
        }
    }
}
Also used : ValueOut(net.openhft.chronicle.wire.ValueOut) ExcerptAppender(net.openhft.chronicle.queue.ExcerptAppender) DocumentContext(net.openhft.chronicle.wire.DocumentContext) Test(org.junit.Test)

Aggregations

ValueOut (net.openhft.chronicle.wire.ValueOut)6 ExcerptAppender (net.openhft.chronicle.queue.ExcerptAppender)5 DocumentContext (net.openhft.chronicle.wire.DocumentContext)5 Test (org.junit.Test)4 ExcerptTailer (net.openhft.chronicle.queue.ExcerptTailer)2 Wire (net.openhft.chronicle.wire.Wire)1 NotNull (org.jetbrains.annotations.NotNull)1