本文整理汇总了Java中io.aeron.logbuffer.Header类的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Header类属于io.aeron.logbuffer包,在下文中一共展示了Header类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMessage
import io.aeron.logbuffer.Header; //导入依赖的package包/类
@SuppressWarnings("PMD.UnusedFormalParameter")
private void onMessage(final DirectBuffer buffer, final int offset,
final int length, final Header header) {
final int msgOffset = ENCODED_LENGTH + offset;
HDR_D.wrap(buffer, offset);
switch (HDR_D.templateId()) {
case PingDecoder.TEMPLATE_ID:
onPing(buffer, msgOffset, HDR_D.blockLength(), HDR_D.version());
break;
case SizeDecoder.TEMPLATE_ID:
onSize(buffer, msgOffset, HDR_D.blockLength(), HDR_D.version());
break;
default:
throw new IllegalStateException("Unknown message template");
}
}
示例2: onMessage
import io.aeron.logbuffer.Header; //导入依赖的package包/类
@SuppressWarnings("PMD.UnusedFormalParameter")
private void onMessage(final DirectBuffer buffer, final int offset,
final int length, final Header header) {
final int msgOffset = MessageHeaderDecoder.ENCODED_LENGTH + offset;
HDR_D.wrap(buffer, offset);
switch (HDR_D.templateId()) {
case PongDecoder.TEMPLATE_ID:
onPong(buffer, msgOffset, HDR_D.blockLength(), HDR_D.version());
break;
case PriceDecoder.TEMPLATE_ID:
onPrice(buffer, msgOffset, HDR_D.blockLength(), HDR_D.version());
break;
default:
throw new IllegalStateException("Unknown message template");
}
}
示例3: onLibraryConnect
import io.aeron.logbuffer.Header; //导入依赖的package包/类
private Action onLibraryConnect(
final DirectBuffer buffer,
final int offset,
final int blockLength,
final int version,
final Header header)
{
libraryConnect.wrap(buffer, offset, blockLength, version);
final int libraryId = libraryConnect.libraryId();
final String libraryName = libraryConnect.libraryName();
return handler.onLibraryConnect(
libraryId,
libraryName,
libraryConnect.correlationId(),
header.sessionId());
}
示例4: onRequestSession
import io.aeron.logbuffer.Header; //导入依赖的package包/类
private Action onRequestSession(
final DirectBuffer buffer,
final int offset,
final int blockLength,
final int version,
final Header header)
{
requestSession.wrap(buffer, offset, blockLength, version);
final int libraryId = requestSession.libraryId();
final Action action = handler.onApplicationHeartbeat(libraryId, header.sessionId());
if (action != null)
{
return action; // Continue processing messages but not this message.
}
return handler.onRequestSession(
libraryId,
requestSession.sessionId(),
requestSession.correlationId(),
requestSession.lastReceivedSequenceNumber(),
requestSession.sequenceIndex());
}
示例5: onRequestDisconnect
import io.aeron.logbuffer.Header; //导入依赖的package包/类
private Action onRequestDisconnect(
final DirectBuffer buffer,
final int offset,
final int blockLength,
final int version,
final Header header)
{
requestDisconnect.wrap(buffer, offset, blockLength, version);
final int libraryId = requestDisconnect.libraryId();
final Action action = handler.onApplicationHeartbeat(libraryId, header.sessionId());
if (action != null)
{
return action; // Continue processing messages, but not this message.
}
return handler.onRequestDisconnect(
libraryId,
requestDisconnect.connection(),
requestDisconnect.reason());
}
示例6: onInitiateConnection
import io.aeron.logbuffer.Header; //导入依赖的package包/类
Action onInitiateConnection(
int libraryId,
int port,
String host,
String senderCompId,
String senderSubId,
String senderLocationId,
String targetCompId,
String targetSubId,
String targetLocationId,
SequenceNumberType sequenceNumberType,
int requestedInitialSequenceNumber,
boolean resetSequenceNumber,
String username,
String password,
int heartbeatIntervalInS,
long correlationId,
Header header);
示例7: onReplicatedMessage
import io.aeron.logbuffer.Header; //导入依赖的package包/类
private Action onReplicatedMessage(
final DirectBuffer buffer,
final int offset,
final int length,
final Header header,
final long connectionId,
final int libraryId)
{
if (replicatedConnectionIds.contains(connectionId))
{
return replicateMessage(buffer, offset, length, header, libraryId);
}
else
{
return handleMessage(buffer, offset, length, header);
}
}
示例8: forEachFragment
import io.aeron.logbuffer.Header; //导入依赖的package包/类
public void forEachFragment(
final StreamIdentifier streamId,
final FragmentHandler handler,
final ErrorHandler errorHandler)
{
final UnsafeBuffer termBuffer = new UnsafeBuffer(0, 0);
for (final File logFile : directoryDescriptor.listLogFiles(streamId))
{
final ByteBuffer byteBuffer = LoggerUtil.mapExistingFile(logFile);
if (byteBuffer.capacity() > 0)
{
termBuffer.wrap(byteBuffer);
final int initialTermId = LogBufferDescriptor.initialTermId(termBuffer);
final Header header = new Header(initialTermId, termBuffer.capacity());
TermReader.read(
termBuffer,
0,
handler,
Integer.MAX_VALUE,
header,
errorHandler);
}
}
}
示例9: onFragment
import io.aeron.logbuffer.Header; //导入依赖的package包/类
public void onFragment(
final DirectBuffer buffer,
final int offset,
@SuppressWarnings("unused") final int length,
@SuppressWarnings("unused") final Header header)
{
messageHeaderDecoder.wrap(buffer, offset);
final int templateId = messageHeaderDecoder.templateId();
switch (templateId)
{
case ControlResponseDecoder.TEMPLATE_ID:
handleControlResponse(listener, buffer, offset);
break;
case RecordingDescriptorDecoder.TEMPLATE_ID:
handleRecordingDescriptor(listener, buffer, offset);
break;
default:
throw new IllegalStateException("Unknown templateId: " + templateId);
}
}
示例10: validateFragment
import io.aeron.logbuffer.Header; //导入依赖的package包/类
private void validateFragment(final DirectBuffer buffer, final int offset, final int length, final Header header)
{
int actual = buffer.getInt(offset, LITTLE_ENDIAN);
if (fragmentCount != actual)
{
throw new IllegalStateException("expected=" + fragmentCount + " actual=" + actual);
}
actual = buffer.getInt(offset + (length - 4), LITTLE_ENDIAN);
if (fragmentCount != actual)
{
throw new IllegalStateException("expected=" + fragmentCount + " actual=" + actual);
}
remaining -= length;
fragmentCount++;
receivedPosition = header.position();
}
示例11: onFragment
import io.aeron.logbuffer.Header; //导入依赖的package包/类
public Action onFragment(final DirectBuffer buffer, final int offset, final int length, final Header header)
{
++fragmentCount;
Action action = Action.CONTINUE;
if (fragmentCount == 3)
{
action = Action.ABORT;
}
else if (fragmentCount == 5)
{
action = Action.BREAK;
}
if (Action.ABORT != action)
{
collectedBuffer.putBytes(limit, buffer, offset, length);
limit += length;
}
return action;
}
示例12: verifyData
import io.aeron.logbuffer.Header; //导入依赖的package包/类
private void verifyData(final UnsafeBuffer srcBuffer, final FragmentHandler mockFragmentHandler)
{
final ArgumentCaptor<DirectBuffer> bufferArg = ArgumentCaptor.forClass(DirectBuffer.class);
final ArgumentCaptor<Integer> offsetArg = ArgumentCaptor.forClass(Integer.class);
verify(mockFragmentHandler, times(1)).onFragment(
bufferArg.capture(), offsetArg.capture(), eq(srcBuffer.capacity()), any(Header.class));
final DirectBuffer capturedBuffer = bufferArg.getValue();
final int offset = offsetArg.getValue();
for (int i = 0; i < srcBuffer.capacity(); i++)
{
final int index = offset + i;
assertThat("same at " + index, capturedBuffer.getByte(index), is(srcBuffer.getByte(i)));
}
}
示例13: onSessionMessage
import io.aeron.logbuffer.Header; //导入依赖的package包/类
void onSessionMessage(
final long clusterSessionId,
final long correlationId,
final long timestampMs,
final DirectBuffer buffer,
final int offset,
final int length,
final Header header)
{
this.timestampMs = timestampMs;
service.onSessionMessage(
clusterSessionId,
correlationId,
timestampMs,
buffer,
offset,
length,
header);
}
示例14: handleFragment
import io.aeron.logbuffer.Header; //导入依赖的package包/类
private void handleFragment(
final DirectBuffer buffer, final int offset, final int length, final Header header, final byte flags)
{
if ((flags & BEGIN_FRAG_FLAG) == BEGIN_FRAG_FLAG)
{
builder.reset().append(buffer, offset, length);
}
else
{
builder.append(buffer, offset, length);
if ((flags & END_FRAG_FLAG) == END_FRAG_FLAG)
{
final int msgLength = builder.limit();
delegate.onFragment(builder.buffer(), 0, msgLength, header);
builder.reset();
}
}
}
示例15: shouldReadData
import io.aeron.logbuffer.Header; //导入依赖的package包/类
@Test
public void shouldReadData()
{
subscription.addImage(imageOneMock);
when(imageOneMock.poll(any(FragmentHandler.class), anyInt())).then(
(invocation) ->
{
final FragmentHandler handler = (FragmentHandler)invocation.getArguments()[0];
handler.onFragment(atomicReadBuffer, HEADER_LENGTH, READ_BUFFER_CAPACITY - HEADER_LENGTH, header);
return 1;
});
assertThat(subscription.poll(fragmentHandler, FRAGMENT_COUNT_LIMIT), is(1));
verify(fragmentHandler).onFragment(
eq(atomicReadBuffer),
eq(HEADER_LENGTH),
eq(READ_BUFFER_CAPACITY - HEADER_LENGTH),
any(Header.class));
}