use of org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer in project Aeron by real-logic.
the class DriverEventLogger method logUntetheredSubscriptionStateChange.
/**
* Log an untethered subscription state change.
*
* @param oldState before the change.
* @param newState after the change.
* @param subscriptionId to which the change applies.
* @param streamId of the image.
* @param sessionId of the image.
* @param <E> type of the event.
*/
public <E extends Enum<E>> void logUntetheredSubscriptionStateChange(final E oldState, final E newState, final long subscriptionId, final int streamId, final int sessionId) {
final int length = untetheredSubscriptionStateChangeLength(oldState, newState);
final int captureLength = captureLength(length);
final int encodedLength = encodedLength(captureLength);
final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
final int index = ringBuffer.tryClaim(toEventCodeId(UNTETHERED_SUBSCRIPTION_STATE_CHANGE), encodedLength);
if (index > 0) {
try {
encodeUntetheredSubscriptionStateChange((UnsafeBuffer) ringBuffer.buffer(), index, captureLength, length, oldState, newState, subscriptionId, streamId, sessionId);
} finally {
ringBuffer.commit(index);
}
}
}
use of org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer in project Aeron by real-logic.
the class DriverEventLogger method logAddress.
/**
* Log an address with associated event.
*
* @param code representing the event type.
* @param address to be logged.
*/
public void logAddress(final DriverEventCode code, final InetSocketAddress address) {
final int length = socketAddressLength(address);
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, address);
} 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 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 ClusterEventLogger method logRequestVote.
/**
* Log a request to vote from a cluster candidate for leadership.
*
* @param logLeadershipTermId leadershipTermId processes from the log by the candidate.
* @param logPosition position reached in the log for the latest leadership term.
* @param candidateTermId the term id as the candidate sees it for the election.
* @param candidateId id of the candidate node.
*/
public void logRequestVote(final long logLeadershipTermId, final long logPosition, final long candidateTermId, final int candidateId) {
final int length = requestVoteLength();
final int captureLength = captureLength(length);
final int encodedLength = encodedLength(captureLength);
final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
final int index = ringBuffer.tryClaim(REQUEST_VOTE.toEventCodeId(), encodedLength);
if (index > 0) {
try {
encodeRequestVote((UnsafeBuffer) ringBuffer.buffer(), index, captureLength, length, logLeadershipTermId, logPosition, candidateTermId, candidateId);
} finally {
ringBuffer.commit(index);
}
}
}
Aggregations