当前位置: 首页>>代码示例>>Java>>正文


Java Header类代码示例

本文整理汇总了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");
  }
}
 
开发者ID:benalexau,项目名称:rpc-bench,代码行数:17,代码来源:BenchServer.java

示例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");
  }
}
 
开发者ID:benalexau,项目名称:rpc-bench,代码行数:17,代码来源:BenchClient.java

示例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());
}
 
开发者ID:real-logic,项目名称:artio,代码行数:18,代码来源:EngineProtocolSubscription.java

示例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());
}
 
开发者ID:real-logic,项目名称:artio,代码行数:23,代码来源:EngineProtocolSubscription.java

示例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());
}
 
开发者ID:real-logic,项目名称:artio,代码行数:20,代码来源:EngineProtocolSubscription.java

示例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);
 
开发者ID:real-logic,项目名称:artio,代码行数:19,代码来源:EngineEndPointHandler.java

示例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);
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:18,代码来源:SubscriptionSplitter.java

示例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);
        }
    }
}
 
开发者ID:real-logic,项目名称:artio,代码行数:25,代码来源:ArchiveScanner.java

示例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);
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:24,代码来源:ControlResponseAdapter.java

示例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();
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:19,代码来源:ArchiveReplayLoadTest.java

示例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;
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:24,代码来源:ControlledMessageTest.java

示例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)));
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:17,代码来源:MultiSubscriberTest.java

示例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);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:21,代码来源:ClusteredServiceAgent.java

示例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();
        }
    }
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:20,代码来源:ImageFragmentAssembler.java

示例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));
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:22,代码来源:SubscriptionTest.java


注:本文中的io.aeron.logbuffer.Header类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。