use of org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer in project aeron by real-logic.
the class DriverEventLogger method logFrameOut.
/**
* Log a frame being sent out from the driver to the media.
*
* @param buffer containing the frame.
* @param dstAddress for the frame.
*/
public void logFrameOut(final ByteBuffer buffer, final InetSocketAddress dstAddress) {
final int length = buffer.remaining() + socketAddressLength(dstAddress);
final int captureLength = captureLength(length);
final int encodedLength = encodedLength(captureLength);
final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
final int index = ringBuffer.tryClaim(toEventCodeId(FRAME_OUT), encodedLength);
if (index > 0) {
try {
encode((UnsafeBuffer) ringBuffer.buffer(), index, captureLength, length, buffer, buffer.position(), dstAddress);
} finally {
ringBuffer.commit(index);
}
}
}
use of org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer in project aeron by real-logic.
the class DriverEventLogger method logString.
/**
* Log a generic string associated with an event.
*
* @param code for the event type.
* @param value of the string to be logged.
*/
public void logString(final DriverEventCode code, final String value) {
final int length = value.length() + SIZE_OF_INT;
final int captureLength = captureLength(length);
final int encodedLength = encodedLength(captureLength);
final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
final int index = ringBuffer.tryClaim(toEventCodeId(code), encodedLength);
if (index > 0) {
try {
encode((UnsafeBuffer) ringBuffer.buffer(), index, captureLength, length, value);
} finally {
ringBuffer.commit(index);
}
}
}
use of org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer in project aeron by real-logic.
the class DriverEventLogger method logSubscriptionRemoval.
/**
* Log the removal of a subscription.
*
* @param channel for the channel.
* @param streamId within the channel.
* @param subscriptionId for the subscription.
*/
public void logSubscriptionRemoval(final String channel, final int streamId, final long subscriptionId) {
final int length = SIZE_OF_INT * 2 + SIZE_OF_LONG + channel.length();
final int captureLength = captureLength(length);
final int encodedLength = encodedLength(captureLength);
final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
final int index = ringBuffer.tryClaim(toEventCodeId(REMOVE_SUBSCRIPTION_CLEANUP), encodedLength);
if (index > 0) {
try {
final UnsafeBuffer buffer = (UnsafeBuffer) ringBuffer.buffer();
encodeSubscriptionRemoval(buffer, index, captureLength, length, channel, streamId, subscriptionId);
} finally {
ringBuffer.commit(index);
}
}
}
use of org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer in project aeron by real-logic.
the class DriverEventLogger method log.
/**
* Log an event for the driver.
*
* @param code for the type of event.
* @param buffer containing the encoded event.
* @param offset in the buffer at which the event begins.
* @param length of the encoded event.
*/
public void log(final DriverEventCode code, final DirectBuffer buffer, final int offset, final int length) {
if (DRIVER_EVENT_CODES.contains(code)) {
final int captureLength = captureLength(length);
final int encodedLength = encodedLength(captureLength);
final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
final int index = ringBuffer.tryClaim(toEventCodeId(code), encodedLength);
if (index > 0) {
try {
encode((UnsafeBuffer) ringBuffer.buffer(), index, captureLength, length, buffer, offset);
} finally {
ringBuffer.commit(index);
}
}
}
}
use of org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer in project aeron by real-logic.
the class DriverEventLogger method logResolve.
/**
* Log a resolution for a resolver and the associated result.
*
* @param code representing the event type
* @param resolverName simple class name of the resolver
* @param name host name being resolved
* @param address address that was resolved to, can be null
*/
public void logResolve(final DriverEventCode code, final String resolverName, final String name, final InetAddress address) {
final int length = trailingStringLength(resolverName, MAX_HOST_NAME_LENGTH) + trailingStringLength(name, MAX_HOST_NAME_LENGTH) + inetAddressLength(address);
final int encodedLength = encodedLength(length);
final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
final int index = ringBuffer.tryClaim(toEventCodeId(code), encodedLength);
if (index > 0) {
try {
encodeResolve((UnsafeBuffer) ringBuffer.buffer(), index, length, length, resolverName, name, address);
} finally {
ringBuffer.commit(index);
}
}
}
Aggregations