use of io.aeron.agent.DriverEventCode in project aeron by real-logic.
the class DriverEventLoggerTest method logString.
@Test
void logString() {
final int recordOffset = align(100, ALIGNMENT);
logBuffer.putLong(CAPACITY + TAIL_POSITION_OFFSET, recordOffset);
final DriverEventCode eventCode = CMD_IN_ADD_PUBLICATION;
final String value = "abc";
final int captureLength = value.length() + SIZE_OF_INT;
logger.logString(eventCode, value);
verifyLogHeader(logBuffer, recordOffset, toEventCodeId(eventCode), captureLength, captureLength);
assertEquals(value, logBuffer.getStringAscii(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH), LITTLE_ENDIAN));
}
use of io.aeron.agent.DriverEventCode in project Aeron by real-logic.
the class DriverEventLoggerTest method logAddress.
@Test
void logAddress() {
final int recordOffset = 64;
logBuffer.putLong(CAPACITY + TAIL_POSITION_OFFSET, recordOffset);
final DriverEventCode eventCode = NAME_RESOLUTION_NEIGHBOR_REMOVED;
final int captureLength = 12;
logger.logAddress(eventCode, new InetSocketAddress("localhost", 5656));
verifyLogHeader(logBuffer, recordOffset, toEventCodeId(eventCode), captureLength, captureLength);
assertEquals(5656, logBuffer.getInt(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH), LITTLE_ENDIAN));
assertEquals(4, logBuffer.getInt(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH + SIZE_OF_INT), LITTLE_ENDIAN));
}
use of io.aeron.agent.DriverEventCode in project Aeron by real-logic.
the class DriverLoggingAgentTest method testLogMediaDriverEvents.
private void testLogMediaDriverEvents(final String channel, final String enabledEvents, final EnumSet<DriverEventCode> expectedEvents) {
before(enabledEvents, expectedEvents);
final MediaDriver.Context driverCtx = new MediaDriver.Context().errorHandler(Tests::onError).publicationLingerTimeoutNs(0).timerIntervalNs(TimeUnit.MILLISECONDS.toNanos(1));
try (MediaDriver mediaDriver = MediaDriver.launch(driverCtx)) {
try (Aeron aeron = Aeron.connect(new Aeron.Context().aeronDirectoryName(mediaDriver.aeronDirectoryName()));
Subscription subscription = aeron.addSubscription(channel, STREAM_ID);
Publication publication = aeron.addPublication(channel, STREAM_ID)) {
final UnsafeBuffer offerBuffer = new UnsafeBuffer(new byte[32]);
while (publication.offer(offerBuffer) < 0) {
Tests.yield();
}
final MutableInteger counter = new MutableInteger();
final FragmentHandler handler = (buffer, offset, length, header) -> counter.value++;
while (0 == subscription.poll(handler, 1)) {
Tests.yield();
}
assertEquals(counter.get(), 1);
}
final Supplier<String> errorMessage = () -> "Pending events: " + WAIT_LIST;
while (!WAIT_LIST.isEmpty()) {
Tests.yieldingIdle(errorMessage);
}
}
}
use of io.aeron.agent.DriverEventCode in project aeron by real-logic.
the class DriverEventLoggerTest method log.
@Test
void log() {
final DriverEventCode eventCode = CMD_IN_TERMINATE_DRIVER;
DRIVER_EVENT_CODES.add(eventCode);
final int recordOffset = align(13, ALIGNMENT);
logBuffer.putLong(CAPACITY + TAIL_POSITION_OFFSET, recordOffset);
final int length = 100;
final int srcOffset = 20;
buffer.setMemory(srcOffset, length, (byte) 5);
logger.log(eventCode, buffer, srcOffset, length);
verifyLogHeader(logBuffer, recordOffset, toEventCodeId(eventCode), length, length);
for (int i = 0; i < length; i++) {
assertEquals(5, logBuffer.getByte(encodedMsgOffset(recordOffset + LOG_HEADER_LENGTH + i)));
}
}
use of io.aeron.agent.DriverEventCode in project aeron by real-logic.
the class DriverEventDissectorTest method dissectCommandUnknown.
@Test
void dissectCommandUnknown() {
final DriverEventCode eventCode = SEND_CHANNEL_CREATION;
internalEncodeLogHeader(buffer, 0, 5, 5, () -> 1_000_000_000L);
dissectCommand(eventCode, buffer, 0, builder);
assertEquals("[1.0] " + CONTEXT + ": " + eventCode.name() + " [5/5]: COMMAND_UNKNOWN: " + eventCode, builder.toString());
}
Aggregations