use of net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder in project Chronicle-Queue by OpenHFT.
the class StageMain method outputQueue.
@NotNull
private static SingleChronicleQueue outputQueue(final Path path, final int index) {
final SingleChronicleQueueBuilder builder = ChronicleQueue.singleBuilder(path);
builder.rollTime(RollTimeCalculator.getNextRollWindow(), ZoneId.of("UTC"));
if (index != UNSET_SOURCE) {
builder.sourceId(index);
}
return builder.rollCycle(RollCycles.HOURLY).build();
}
use of net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder in project Chronicle-Queue by OpenHFT.
the class ChunkCountTest method chunks.
@Test
public void chunks() {
final SingleChronicleQueueBuilder builder = SingleChronicleQueueBuilder.binary(IOTools.createTempFile("chunks")).blockSize(64 << 10).rollCycle(RollCycles.DAILY);
try (SingleChronicleQueue queue = builder.build();
ExcerptAppender appender = queue.acquireAppender()) {
assertEquals(0, queue.chunkCount());
appender.writeText("Hello");
assertEquals(1, queue.chunkCount());
for (int i = 0; i < 100; i++) {
long pos;
try (DocumentContext dc = appender.writingDocument()) {
pos = dc.wire().bytes().writePosition();
dc.wire().bytes().writeSkip(16000);
}
final long expected = builder.useSparseFiles() ? 1 : 1 + (pos >> 18);
assertEquals("i: " + i, expected, queue.chunkCount());
}
}
}
use of net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder in project Chronicle-Queue by OpenHFT.
the class RollCycleDefaultingTest method nonRollCycleDefaultsToDaily.
@Test
public void nonRollCycleDefaultsToDaily() {
expectException("Configured default rollcycle is not a subclass of RollCycle");
String configuredCycle = String.class.getName();
System.setProperty(QueueSystemProperties.DEFAULT_ROLL_CYCLE_PROPERTY, configuredCycle);
SingleChronicleQueueBuilder builder = SingleChronicleQueueBuilder.binary("test");
assertEquals(RollCycles.DEFAULT, builder.rollCycle());
}
use of net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder in project Chronicle-Queue by OpenHFT.
the class RollCycleDefaultingTest method unknownClassDefaultsToDaily.
@Test
public void unknownClassDefaultsToDaily() {
expectException("Default roll cycle class: foobarblah was not found");
String configuredCycle = "foobarblah";
System.setProperty(QueueSystemProperties.DEFAULT_ROLL_CYCLE_PROPERTY, configuredCycle);
SingleChronicleQueueBuilder builder = SingleChronicleQueueBuilder.binary("test");
assertEquals(RollCycles.DEFAULT, builder.rollCycle());
}
use of net.openhft.chronicle.queue.impl.single.SingleChronicleQueueBuilder in project Chronicle-Queue by OpenHFT.
the class ChronicleAppenderCycleTest method useAppender.
private AtomicReference<Throwable> useAppender(Path path, Consumer<ExcerptAppender> tester, CountDownLatch done) {
AtomicReference<Throwable> refThr = new AtomicReference<>();
Thread thread = new Thread(() -> {
try {
SingleChronicleQueueBuilder builder = createBuilder(path);
try (SingleChronicleQueue queue = builder.build()) {
try (ExcerptAppender appender = queue.acquireAppender()) {
tester.accept(appender);
}
}
} catch (Throwable e) {
refThr.set(e);
e.printStackTrace();
} finally {
done.countDown();
}
});
thread.setDaemon(true);
thread.start();
return refThr;
}
Aggregations