Beispiel #1
0
        public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header)
        {
            messageHeaderDecoder.Wrap(buffer, offset);

            int templateId = messageHeaderDecoder.TemplateId();

            if (JoinLogDecoder.TEMPLATE_ID == templateId)
            {
                joinLogDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    messageHeaderDecoder.BlockLength(),
                    messageHeaderDecoder.Version());

                clusteredServiceAgent.OnJoinLog(
                    joinLogDecoder.LeadershipTermId(),
                    joinLogDecoder.LogPosition(),
                    joinLogDecoder.MaxLogPosition(),
                    joinLogDecoder.MemberId(),
                    joinLogDecoder.LogSessionId(),
                    joinLogDecoder.LogStreamId(),
                    joinLogDecoder.LogChannel());
            }
            else if (ServiceTerminationPositionDecoder.TEMPLATE_ID == templateId)
            {
                serviceTerminationPositionDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    messageHeaderDecoder.BlockLength(),
                    messageHeaderDecoder.Version());

                clusteredServiceAgent.OnServiceTerminationPosition(serviceTerminationPositionDecoder.LogPosition());
            }
        }
Beispiel #2
0
        public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header)
        {
            messageHeaderDecoder.Wrap(buffer, offset);

            int schemaId = messageHeaderDecoder.SchemaId();

            if (schemaId != MessageHeaderDecoder.SCHEMA_ID)
            {
                throw new ClusterException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId);
            }

            int templateId = messageHeaderDecoder.TemplateId();

            switch (templateId)
            {
            case JoinLogDecoder.TEMPLATE_ID:
                joinLogDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    messageHeaderDecoder.BlockLength(),
                    messageHeaderDecoder.Version());

                clusteredServiceAgent.OnJoinLog(
                    joinLogDecoder.LeadershipTermId(),
                    joinLogDecoder.LogPosition(),
                    joinLogDecoder.MaxLogPosition(),
                    joinLogDecoder.MemberId(),
                    joinLogDecoder.LogSessionId(),
                    joinLogDecoder.LogStreamId(),
                    joinLogDecoder.LogChannel());
                break;

            case ServiceTerminationPositionDecoder.TEMPLATE_ID:
                serviceTerminationPositionDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    messageHeaderDecoder.BlockLength(),
                    messageHeaderDecoder.Version());

                clusteredServiceAgent.OnServiceTerminationPosition(serviceTerminationPositionDecoder.LogPosition());
                break;

            case ElectionStartEventDecoder.TEMPLATE_ID:
                electionStartEventDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    messageHeaderDecoder.BlockLength(),
                    messageHeaderDecoder.Version());

                clusteredServiceAgent.OnElectionStartEvent(electionStartEventDecoder.LogPosition());
                break;
            }
        }
Beispiel #3
0
        public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header)
        {
            messageHeaderDecoder.Wrap(buffer, offset);

            int templateId = messageHeaderDecoder.TemplateId();

            if (JoinLogDecoder.TEMPLATE_ID != templateId)
            {
                throw new ClusterException("unknown template id: " + templateId);
            }

            joinLogDecoder.Wrap(
                buffer,
                offset + MessageHeaderDecoder.ENCODED_LENGTH,
                messageHeaderDecoder.BlockLength(),
                messageHeaderDecoder.Version());

            clusteredServiceAgent.OnJoinLog(
                joinLogDecoder.LeadershipTermId(),
                joinLogDecoder.CommitPositionId(),
                joinLogDecoder.LogSessionId(),
                joinLogDecoder.LogStreamId(),
                joinLogDecoder.LogChannel());
        }