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()); } }
public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { _messageHeaderDecoder.Wrap(buffer, offset); int templateId = _messageHeaderDecoder.TemplateId(); if (SessionHeaderDecoder.TEMPLATE_ID == templateId) { _sessionHeaderDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); long sessionId = _sessionHeaderDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _sessionMessageListener.OnMessage(_sessionHeaderDecoder.CorrelationId(), sessionId, _sessionHeaderDecoder.Timestamp(), buffer, offset + SessionDecorator.SESSION_HEADER_LENGTH, length - SessionDecorator.SESSION_HEADER_LENGTH, header); } } else if (NewLeaderEventDecoder.TEMPLATE_ID == templateId) { _newLeaderEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); long sessionId = _newLeaderEventDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _cluster.OnNewLeader(sessionId, _newLeaderEventDecoder.LeaderMemberId(), _newLeaderEventDecoder.MemberEndpoints()); } } }
public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); int templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case ScheduleTimerDecoder.TEMPLATE_ID: scheduleTimerDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); serviceControlListener.OnScheduleTimer(scheduleTimerDecoder.CorrelationId(), scheduleTimerDecoder.Deadline()); break; case CancelTimerDecoder.TEMPLATE_ID: cancelTimerDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); serviceControlListener.OnCancelTimer(scheduleTimerDecoder.CorrelationId()); break; case ClusterActionAckDecoder.TEMPLATE_ID: clusterActionAckDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); serviceControlListener.OnServiceAck(clusterActionAckDecoder.LogPosition(), clusterActionAckDecoder.LeadershipTermId(), clusterActionAckDecoder.ServiceId(), clusterActionAckDecoder.Action()); break; case JoinLogDecoder.TEMPLATE_ID: joinLogDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); serviceControlListener.OnJoinLog( joinLogDecoder.LeadershipTermId(), joinLogDecoder.CommitPositionId(), joinLogDecoder.LogSessionId(), joinLogDecoder.LogStreamId(), joinLogDecoder.AckBeforeImage() == BooleanType.TRUE, joinLogDecoder.LogChannel()); break; case CloseSessionDecoder.TEMPLATE_ID: closeSessionDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); serviceControlListener.OnServiceCloseSession(closeSessionDecoder.ClusterSessionId()); break; default: throw new ArgumentException("unknown template id: " + templateId); } }
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 ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } int templateId = _messageHeaderDecoder.TemplateId(); switch (templateId) { case RecordingStartedDecoder.TEMPLATE_ID: _recordingStartedDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.OnStart( _recordingStartedDecoder.RecordingId(), _recordingStartedDecoder.StartPosition(), _recordingStartedDecoder.SessionId(), _recordingStartedDecoder.StreamId(), _recordingStartedDecoder.Channel(), _recordingStartedDecoder.SourceIdentity()); break; case RecordingProgressDecoder.TEMPLATE_ID: _recordingProgressDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.OnProgress( _recordingProgressDecoder.RecordingId(), _recordingProgressDecoder.StartPosition(), _recordingProgressDecoder.Position()); break; case RecordingStoppedDecoder.TEMPLATE_ID: _recordingStoppedDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.OnStop( _recordingStoppedDecoder.RecordingId(), _recordingStoppedDecoder.StartPosition(), _recordingStoppedDecoder.StopPosition()); break; } }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { if (isDone) { return(ABORT); } messageHeaderDecoder.Wrap(buffer, offset); int schemaId = messageHeaderDecoder.SchemaId(); if (schemaId != MessageHeaderDecoder.SCHEMA_ID) { throw new ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } int templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case ControlResponseDecoder.TEMPLATE_ID: controlResponseDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); if (controlResponseDecoder.ControlSessionId() == controlSessionId) { controlEventListener.OnResponse(controlSessionId, controlResponseDecoder.CorrelationId(), controlResponseDecoder.RelevantId(), controlResponseDecoder.Code(), controlResponseDecoder.ErrorMessage()); isDone = true; return(BREAK); } break; case RecordingSignalEventDecoder.TEMPLATE_ID: recordingSignalEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); if (recordingSignalEventDecoder.ControlSessionId() == controlSessionId) { recordingSignalConsumer.OnSignal(recordingSignalEventDecoder.ControlSessionId(), recordingSignalEventDecoder.CorrelationId(), recordingSignalEventDecoder.RecordingId(), recordingSignalEventDecoder.SubscriptionId(), recordingSignalEventDecoder.Position(), recordingSignalEventDecoder.Signal()); isDone = true; return(BREAK); } break; } return(CONTINUE); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { if (isPollComplete) { return(ABORT); } messageHeaderDecoder.Wrap(buffer, offset); int schemaId = messageHeaderDecoder.SchemaId(); if (schemaId != MessageHeaderDecoder.SCHEMA_ID) { throw new ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } if (messageHeaderDecoder.TemplateId() == ControlResponseDecoder.TEMPLATE_ID) { controlResponseDecoder.Wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); controlSessionId = controlResponseDecoder.ControlSessionId(); correlationId = controlResponseDecoder.CorrelationId(); relevantId = controlResponseDecoder.RelevantId(); code = controlResponseDecoder.Code(); version = controlResponseDecoder.Version(); errorMessage = controlResponseDecoder.ErrorMessage(); isPollComplete = true; return(BREAK); } if (messageHeaderDecoder.TemplateId() == ChallengeDecoder.TEMPLATE_ID) { challengeDecoder.Wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); controlSessionId = challengeDecoder.ControlSessionId(); correlationId = challengeDecoder.CorrelationId(); relevantId = Aeron.Aeron.NULL_VALUE; code = ControlResponseCode.NULL_VALUE; version = challengeDecoder.Version(); errorMessage = ""; int encodedChallengeLength = challengeDecoder.EncodedChallengeLength(); encodedChallenge = new byte[encodedChallengeLength]; challengeDecoder.GetEncodedChallenge(encodedChallenge, 0, encodedChallengeLength); isPollComplete = true; return(BREAK); } return(CONTINUE); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case SessionEventDecoder.TEMPLATE_ID: sessionEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); clusterSessionId = sessionEventDecoder.ClusterSessionId(); correlationId = sessionEventDecoder.CorrelationId(); leadershipTermId = sessionEventDecoder.LeadershipTermId(); leaderMemberId = sessionEventDecoder.LeaderMemberId(); eventCode = sessionEventDecoder.Code(); detail = sessionEventDecoder.Detail(); break; case NewLeaderEventDecoder.TEMPLATE_ID: newLeaderEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); clusterSessionId = newLeaderEventDecoder.ClusterSessionId(); leadershipTermId = newLeaderEventDecoder.LeadershipTermId(); leaderMemberId = newLeaderEventDecoder.LeaderMemberId(); detail = newLeaderEventDecoder.MemberEndpoints(); break; case EgressMessageHeaderDecoder.TEMPLATE_ID: egressMessageHeaderDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); leadershipTermId = EgressMessageHeaderDecoder.LeadershipTermIdId(); clusterSessionId = egressMessageHeaderDecoder.ClusterSessionId(); break; case ChallengeDecoder.TEMPLATE_ID: challengeDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); encodedChallenge = new byte[challengeDecoder.EncodedChallengeLength()]; challengeDecoder.GetEncodedChallenge(encodedChallenge, 0, challengeDecoder.EncodedChallengeLength()); clusterSessionId = challengeDecoder.ClusterSessionId(); correlationId = challengeDecoder.CorrelationId(); break; default: throw new ClusterException("unknown templateId: " + templateId); } pollComplete = true; return(ControlledFragmentHandlerAction.BREAK); }
public virtual void OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { _messageHeaderDecoder.Wrap(buffer, offset); int templateId = _messageHeaderDecoder.TemplateId(); switch (templateId) { case RecordingStartedDecoder.TEMPLATE_ID: _recordingStartedDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.OnStart( _recordingStartedDecoder.RecordingId(), _recordingStartedDecoder.StartPosition(), _recordingStartedDecoder.SessionId(), _recordingStartedDecoder.StreamId(), _recordingStartedDecoder.Channel(), _recordingStartedDecoder.SourceIdentity()); break; case RecordingProgressDecoder.TEMPLATE_ID: _recordingProgressDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.OnProgress( _recordingProgressDecoder.RecordingId(), _recordingProgressDecoder.StartPosition(), _recordingProgressDecoder.Position()); break; case RecordingStoppedDecoder.TEMPLATE_ID: _recordingStoppedDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.OnStop( _recordingStoppedDecoder.RecordingId(), _recordingStoppedDecoder.StartPosition(), _recordingStoppedDecoder.StopPosition()); break; default: throw new ArchiveException("unknown templateId: " + templateId); } }
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; } }
public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { _messageHeaderDecoder.Wrap(buffer, offset); int templateId = _messageHeaderDecoder.TemplateId(); switch (templateId) { case SessionEventDecoder.TEMPLATE_ID: _sessionEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.SessionEvent( _sessionEventDecoder.CorrelationId(), _sessionEventDecoder.ClusterSessionId(), _sessionEventDecoder.Code(), _sessionEventDecoder.Detail()); break; case NewLeaderEventDecoder.TEMPLATE_ID: _newLeaderEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.NewLeader(_newLeaderEventDecoder.LastCorrelationId(), _newLeaderEventDecoder.ClusterSessionId(), _newLeaderEventDecoder.LastMessageTimestamp(), _newLeaderEventDecoder.LeadershipTimestamp(), _newLeaderEventDecoder.LeadershipTermId(), _newLeaderEventDecoder.LeaderMemberId(), _newLeaderEventDecoder.MemberEndpoints()); break; case SessionHeaderDecoder.TEMPLATE_ID: _sessionHeaderDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); _listener.OnMessage( _sessionHeaderDecoder.CorrelationId(), _sessionHeaderDecoder.ClusterSessionId(), _sessionHeaderDecoder.Timestamp(), buffer, offset + SESSION_HEADER_LENGTH, length - SESSION_HEADER_LENGTH, header); break; case ChallengeDecoder.TEMPLATE_ID: break; default: throw new InvalidOperationException("unknown templateId: " + templateId); } }
private void HandleControlResponse( IControlResponseListener listener, IDirectBuffer buffer, int offset) { controlResponseDecoder.Wrap( buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); listener.OnResponse( controlResponseDecoder.ControlSessionId(), controlResponseDecoder.CorrelationId(), controlResponseDecoder.RelevantId(), controlResponseDecoder.Code(), controlResponseDecoder.ErrorMessage()); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { if (pollComplete) { return(ABORT); } messageHeaderDecoder.Wrap(buffer, offset); int schemaId = messageHeaderDecoder.SchemaId(); if (schemaId != MessageHeaderDecoder.SCHEMA_ID) { throw new ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } templateId = messageHeaderDecoder.TemplateId(); if (templateId == ControlResponseDecoder.TEMPLATE_ID) { controlResponseDecoder.Wrap( buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); controlSessionId = controlResponseDecoder.ControlSessionId(); correlationId = controlResponseDecoder.CorrelationId(); relevantId = controlResponseDecoder.RelevantId(); code = controlResponseDecoder.Code(); errorMessage = controlResponseDecoder.ErrorMessage(); pollComplete = true; return(BREAK); } return(CONTINUE); }
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()); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { if (isDispatchComplete) { return(ControlledFragmentHandlerAction.ABORT); } messageHeaderDecoder.Wrap(buffer, offset); int schemaId = messageHeaderDecoder.SchemaId(); if (schemaId != MessageHeaderDecoder.SCHEMA_ID) { throw new ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } int templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case ControlResponseDecoder.TEMPLATE_ID: { controlResponseDecoder.Wrap( buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); if (controlResponseDecoder.ControlSessionId() == controlSessionId) { ControlResponseCode code = controlResponseDecoder.Code(); long correlationId = controlResponseDecoder.CorrelationId(); if (ControlResponseCode.RECORDING_UNKNOWN == code && correlationId == this.correlationId) { isDispatchComplete = true; return(ControlledFragmentHandlerAction.BREAK); } if (ControlResponseCode.ERROR == code) { ArchiveException ex = new ArchiveException( "response for correlationId=" + this.correlationId + ", error: " + controlResponseDecoder.ErrorMessage(), (int)controlResponseDecoder.RelevantId(), correlationId); if (correlationId == this.correlationId) { throw ex; } else { errorHandler?.Invoke(ex); } } } break; } case RecordingDescriptorDecoder.TEMPLATE_ID: { recordingDescriptorDecoder.Wrap( buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); long correlationId = recordingDescriptorDecoder.CorrelationId(); if (controlSessionId == recordingDescriptorDecoder.ControlSessionId() && correlationId == this.correlationId) { consumer.OnRecordingDescriptor( controlSessionId, correlationId, recordingDescriptorDecoder.RecordingId(), recordingDescriptorDecoder.StartTimestamp(), recordingDescriptorDecoder.StopTimestamp(), recordingDescriptorDecoder.StartPosition(), recordingDescriptorDecoder.StopPosition(), recordingDescriptorDecoder.InitialTermId(), recordingDescriptorDecoder.SegmentFileLength(), recordingDescriptorDecoder.TermBufferLength(), recordingDescriptorDecoder.MtuLength(), recordingDescriptorDecoder.SessionId(), recordingDescriptorDecoder.StreamId(), recordingDescriptorDecoder.StrippedChannel(), recordingDescriptorDecoder.OriginalChannel(), recordingDescriptorDecoder.SourceIdentity()); if (0 == --remainingRecordCount) { isDispatchComplete = true; return(ControlledFragmentHandlerAction.BREAK); } } break; } } return(ControlledFragmentHandlerAction.CONTINUE); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); int templateId = messageHeaderDecoder.TemplateId(); if (templateId == SessionHeaderDecoder.TEMPLATE_ID) { sessionHeaderDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnSessionMessage( sessionHeaderDecoder.ClusterSessionId(), sessionHeaderDecoder.Timestamp(), buffer, offset + SESSION_HEADER_LENGTH, length - SESSION_HEADER_LENGTH, header); return(ControlledFragmentHandlerAction.CONTINUE); } switch (templateId) { case TimerEventDecoder.TEMPLATE_ID: timerEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnTimerEvent(timerEventDecoder.CorrelationId(), timerEventDecoder.Timestamp()); break; case SessionOpenEventDecoder.TEMPLATE_ID: openEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); string responseChannel = openEventDecoder.ResponseChannel(); byte[] encodedPrincipal = new byte[openEventDecoder.EncodedPrincipalLength()]; openEventDecoder.GetEncodedPrincipal(encodedPrincipal, 0, encodedPrincipal.Length); agent.OnSessionOpen( openEventDecoder.ClusterSessionId(), openEventDecoder.Timestamp(), openEventDecoder.ResponseStreamId(), responseChannel, encodedPrincipal); break; case SessionCloseEventDecoder.TEMPLATE_ID: closeEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnSessionClose( closeEventDecoder.ClusterSessionId(), closeEventDecoder.Timestamp(), closeEventDecoder.CloseReason()); break; case ClusterActionRequestDecoder.TEMPLATE_ID: actionRequestDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnServiceAction( actionRequestDecoder.LogPosition(), actionRequestDecoder.LeadershipTermId(), actionRequestDecoder.Timestamp(), actionRequestDecoder.Action()); break; case NewLeadershipTermEventDecoder.TEMPLATE_ID: newLeadershipTermEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnNewLeadershipTermEvent( newLeadershipTermEventDecoder.LeadershipTermId(), newLeadershipTermEventDecoder.LogPosition(), newLeadershipTermEventDecoder.Timestamp(), newLeadershipTermEventDecoder.LeaderMemberId(), newLeadershipTermEventDecoder.LogSessionId()); break; case ClusterChangeEventDecoder.TEMPLATE_ID: clusterChangeEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version() ); agent.OnClusterChange( clusterChangeEventDecoder.LeadershipTermId(), clusterChangeEventDecoder.LogPosition(), clusterChangeEventDecoder.Timestamp(), clusterChangeEventDecoder.LeaderMemberId(), clusterChangeEventDecoder.ClusterSize(), clusterChangeEventDecoder.EventType(), clusterChangeEventDecoder.MemberId(), clusterChangeEventDecoder.ClusterMembers()); break; } return(ControlledFragmentHandlerAction.CONTINUE); }
public virtual ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case ControlResponseDecoder.TEMPLATE_ID: controlResponseDecoder.Wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); controlSessionId = controlResponseDecoder.ControlSessionId(); correlationId = controlResponseDecoder.CorrelationId(); relevantId = controlResponseDecoder.RelevantId(); code = controlResponseDecoder.Code(); if (ControlResponseCode.ERROR == code) { errorMessage = controlResponseDecoder.ErrorMessage(); } else { errorMessage = ""; } break; case RecordingDescriptorDecoder.TEMPLATE_ID: break; default: throw new System.InvalidOperationException("unknown templateId: " + templateId); } pollComplete = true; return(ControlledFragmentHandlerAction.BREAK); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); int templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case SnapshotMarkerDecoder.TEMPLATE_ID: snapshotMarkerDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); long typeId = snapshotMarkerDecoder.TypeId(); if (typeId != ClusteredServiceContainer.SNAPSHOT_TYPE_ID) { throw new InvalidOperationException("unexpected snapshot type: " + typeId); } switch (snapshotMarkerDecoder.Mark()) { case SnapshotMark.BEGIN: if (inSnapshot) { throw new InvalidOperationException("already in snapshot"); } inSnapshot = true; return(ControlledFragmentHandlerAction.CONTINUE); case SnapshotMark.END: if (!inSnapshot) { throw new InvalidOperationException("missing begin snapshot"); } isDone = true; return(ControlledFragmentHandlerAction.BREAK); } break; case ClientSessionDecoder.TEMPLATE_ID: clientSessionDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); string responseChannel = clientSessionDecoder.ResponseChannel(); byte[] encodedPrincipal = new byte[clientSessionDecoder.EncodedPrincipalLength()]; clientSessionDecoder.GetEncodedPrincipal(encodedPrincipal, 0, encodedPrincipal.Length); agent.AddSession( clientSessionDecoder.ClusterSessionId(), clientSessionDecoder.ResponseStreamId(), responseChannel, encodedPrincipal); break; default: throw new InvalidOperationException("unknown template id: " + templateId); } return(ControlledFragmentHandlerAction.CONTINUE); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { if (pollComplete) { return(ABORT); } messageHeaderDecoder.Wrap(buffer, offset); int schemaId = messageHeaderDecoder.SchemaId(); if (schemaId != MessageHeaderDecoder.SCHEMA_ID) { throw new ClusterException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case SessionMessageHeaderDecoder.TEMPLATE_ID: sessionMessageHeaderDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); leadershipTermId = sessionMessageHeaderDecoder.LeadershipTermId(); clusterSessionId = sessionMessageHeaderDecoder.ClusterSessionId(); pollComplete = true; return(BREAK); case SessionEventDecoder.TEMPLATE_ID: sessionEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); clusterSessionId = sessionEventDecoder.ClusterSessionId(); correlationId = sessionEventDecoder.CorrelationId(); leadershipTermId = sessionEventDecoder.LeadershipTermId(); leaderMemberId = sessionEventDecoder.LeaderMemberId(); eventCode = sessionEventDecoder.Code(); detail = sessionEventDecoder.Detail(); pollComplete = true; return(BREAK); case NewLeaderEventDecoder.TEMPLATE_ID: newLeaderEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); clusterSessionId = newLeaderEventDecoder.ClusterSessionId(); leadershipTermId = newLeaderEventDecoder.LeadershipTermId(); leaderMemberId = newLeaderEventDecoder.LeaderMemberId(); detail = newLeaderEventDecoder.MemberEndpoints(); pollComplete = true; return(BREAK); case ChallengeDecoder.TEMPLATE_ID: challengeDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); encodedChallenge = new byte[challengeDecoder.EncodedChallengeLength()]; challengeDecoder.GetEncodedChallenge(encodedChallenge, 0, challengeDecoder.EncodedChallengeLength()); clusterSessionId = challengeDecoder.ClusterSessionId(); correlationId = challengeDecoder.CorrelationId(); pollComplete = true; return(BREAK); } return(CONTINUE); }
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(); if (SessionMessageHeaderDecoder.TEMPLATE_ID == templateId) { _sessionMessageHeaderDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); var sessionId = _sessionMessageHeaderDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _listener.OnMessage( sessionId, _sessionMessageHeaderDecoder.Timestamp(), buffer, offset + AeronCluster.SESSION_HEADER_LENGTH, length - AeronCluster.SESSION_HEADER_LENGTH, header); } return; } switch (templateId) { case SessionEventDecoder.TEMPLATE_ID: { _sessionEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); var sessionId = _sessionEventDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _listener.OnSessionEvent( _sessionEventDecoder.CorrelationId(), sessionId, _sessionEventDecoder.LeadershipTermId(), _sessionEventDecoder.LeaderMemberId(), _sessionEventDecoder.Code(), _sessionEventDecoder.Detail()); } break; } case NewLeaderEventDecoder.TEMPLATE_ID: { _newLeaderEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); var sessionId = _newLeaderEventDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _listener.OnNewLeader( sessionId, _sessionEventDecoder.LeadershipTermId(), _newLeaderEventDecoder.LeaderMemberId(), _newLeaderEventDecoder.IngressEndpoints()); } break; } } }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); int templateId = messageHeaderDecoder.TemplateId(); int schemaId = messageHeaderDecoder.SchemaId(); if (schemaId != MessageHeaderDecoder.SCHEMA_ID) { throw new ClusterException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } if (templateId == SessionMessageHeaderEncoder.TEMPLATE_ID) { sessionHeaderDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnSessionMessage( header.Position, sessionHeaderDecoder.ClusterSessionId(), sessionHeaderDecoder.Timestamp(), buffer, offset + SESSION_HEADER_LENGTH, length - SESSION_HEADER_LENGTH, header); return(ControlledFragmentHandlerAction.CONTINUE); } switch (templateId) { case TimerEventDecoder.TEMPLATE_ID: timerEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnTimerEvent( header.Position, timerEventDecoder.CorrelationId(), timerEventDecoder.Timestamp() ); break; case SessionOpenEventDecoder.TEMPLATE_ID: openEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); string responseChannel = openEventDecoder.ResponseChannel(); byte[] encodedPrincipal = new byte[openEventDecoder.EncodedPrincipalLength()]; openEventDecoder.GetEncodedPrincipal(encodedPrincipal, 0, encodedPrincipal.Length); agent.OnSessionOpen( openEventDecoder.LeadershipTermId(), header.Position, openEventDecoder.ClusterSessionId(), openEventDecoder.Timestamp(), openEventDecoder.ResponseStreamId(), responseChannel, encodedPrincipal); break; case SessionCloseEventDecoder.TEMPLATE_ID: closeEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnSessionClose( closeEventDecoder.LeadershipTermId(), header.Position, closeEventDecoder.ClusterSessionId(), closeEventDecoder.Timestamp(), closeEventDecoder.CloseReason()); break; case ClusterActionRequestDecoder.TEMPLATE_ID: actionRequestDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnServiceAction( actionRequestDecoder.LeadershipTermId(), actionRequestDecoder.LogPosition(), actionRequestDecoder.Timestamp(), actionRequestDecoder.Action()); break; case NewLeadershipTermEventDecoder.TEMPLATE_ID: newLeadershipTermEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); var clusterTimeUnit = newLeadershipTermEventDecoder.TimeUnit() == ClusterTimeUnit.NULL_VALUE ? ClusterTimeUnit.MILLIS : newLeadershipTermEventDecoder.TimeUnit(); agent.OnNewLeadershipTermEvent( newLeadershipTermEventDecoder.LeadershipTermId(), newLeadershipTermEventDecoder.LogPosition(), newLeadershipTermEventDecoder.Timestamp(), newLeadershipTermEventDecoder.TermBaseLogPosition(), newLeadershipTermEventDecoder.LeaderMemberId(), newLeadershipTermEventDecoder.LogSessionId(), clusterTimeUnit, newLeadershipTermEventDecoder.AppVersion() ); break; case MembershipChangeEventDecoder.TEMPLATE_ID: membershipChangeEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version() ); agent.OnMembershipChange( membershipChangeEventDecoder.LeadershipTermId(), membershipChangeEventDecoder.LogPosition(), membershipChangeEventDecoder.Timestamp(), membershipChangeEventDecoder.LeaderMemberId(), membershipChangeEventDecoder.ClusterSize(), membershipChangeEventDecoder.ChangeType(), membershipChangeEventDecoder.MemberId(), membershipChangeEventDecoder.ClusterMembers()); break; } return(ControlledFragmentHandlerAction.CONTINUE); }
public ControlledFragmentHandlerAction 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 SnapshotMarkerDecoder.TEMPLATE_ID: snapshotMarkerDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); long typeId = snapshotMarkerDecoder.TypeId(); if (typeId != ClusteredServiceContainer.Configuration.SNAPSHOT_TYPE_ID) { throw new ClusterException("unexpected snapshot type: " + typeId); } switch (snapshotMarkerDecoder.Mark()) { case SnapshotMark.BEGIN: if (inSnapshot) { throw new ClusterException("already in snapshot"); } inSnapshot = true; appVersion = snapshotMarkerDecoder.AppVersion(); timeUnit = snapshotMarkerDecoder.TimeUnit() == ClusterTimeUnit.NULL_VALUE ? ClusterTimeUnit.MILLIS : snapshotMarkerDecoder.TimeUnit(); return(ControlledFragmentHandlerAction.CONTINUE); case SnapshotMark.END: if (!inSnapshot) { throw new ClusterException("missing begin snapshot"); } isDone = true; return(ControlledFragmentHandlerAction.BREAK); } break; case ClientSessionDecoder.TEMPLATE_ID: clientSessionDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); string responseChannel = clientSessionDecoder.ResponseChannel(); byte[] encodedPrincipal = new byte[clientSessionDecoder.EncodedPrincipalLength()]; clientSessionDecoder.GetEncodedPrincipal(encodedPrincipal, 0, encodedPrincipal.Length); agent.AddSession( clientSessionDecoder.ClusterSessionId(), clientSessionDecoder.ResponseStreamId(), responseChannel, encodedPrincipal); break; } return(ControlledFragmentHandlerAction.CONTINUE); }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case SessionEventDecoder.TEMPLATE_ID: sessionEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); clusterSessionId = sessionEventDecoder.ClusterSessionId(); correlationId = sessionEventDecoder.CorrelationId(); eventCode = sessionEventDecoder.Code(); detail = sessionEventDecoder.Detail(); break; case NewLeaderEventDecoder.TEMPLATE_ID: newLeaderEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); clusterSessionId = newLeaderEventDecoder.ClusterSessionId(); break; case SessionHeaderDecoder.TEMPLATE_ID: sessionHeaderDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); clusterSessionId = sessionHeaderDecoder.ClusterSessionId(); correlationId = sessionHeaderDecoder.CorrelationId(); break; case ChallengeDecoder.TEMPLATE_ID: challengeDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); challengeData = new byte[challengeDecoder.ChallengeDataLength()]; challengeDecoder.GetChallengeData(challengeData, 0, challengeDecoder.ChallengeDataLength()); clusterSessionId = challengeDecoder.ClusterSessionId(); correlationId = challengeDecoder.CorrelationId(); break; case AdminResponseDecoder.TEMPLATE_ID: adminResponseDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); adminResponseData = new byte[adminResponseDecoder.ResponseDataLength()]; adminResponseDecoder.GetResponseData(adminResponseData, 0, adminResponseDecoder.ResponseDataLength()); clusterSessionId = adminResponseDecoder.ClusterSessionId(); correlationId = adminResponseDecoder.CorrelationId(); break; default: throw new InvalidOperationException("Unknown templateId: " + templateId); } pollComplete = true; return(ControlledFragmentHandlerAction.BREAK); }
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 ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case RecordingStartedDecoder.TEMPLATE_ID: recordingStartedDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); recordingId = recordingStartedDecoder.RecordingId(); recordingStartPosition = recordingStartedDecoder.StartPosition(); recordingPosition = recordingStartPosition; recordingStopPosition = Aeron.Aeron.NULL_VALUE; pollComplete = true; break; case RecordingProgressDecoder.TEMPLATE_ID: recordingProgressDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); recordingId = recordingProgressDecoder.RecordingId(); recordingStartPosition = recordingProgressDecoder.StartPosition(); recordingPosition = recordingProgressDecoder.Position(); recordingStopPosition = Aeron.Aeron.NULL_VALUE; pollComplete = true; break; case RecordingStoppedDecoder.TEMPLATE_ID: recordingStoppedDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); recordingId = recordingStoppedDecoder.RecordingId(); recordingStartPosition = recordingStoppedDecoder.StartPosition(); recordingStopPosition = recordingStoppedDecoder.StopPosition(); recordingPosition = recordingStopPosition; pollComplete = true; break; } }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); switch (messageHeaderDecoder.TemplateId()) { case SessionHeaderDecoder.TEMPLATE_ID: { sessionHeaderDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnSessionMessage(sessionHeaderDecoder.ClusterSessionId(), sessionHeaderDecoder.CorrelationId(), sessionHeaderDecoder.Timestamp(), buffer, offset + ClientSession.SESSION_HEADER_LENGTH, length - ClientSession.SESSION_HEADER_LENGTH, header); break; } case TimerEventDecoder.TEMPLATE_ID: { timerEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnTimerEvent(timerEventDecoder.CorrelationId(), timerEventDecoder.Timestamp()); break; } case SessionOpenEventDecoder.TEMPLATE_ID: { openEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); string responseChannel = openEventDecoder.ResponseChannel(); byte[] encodedPrincipal = new byte[openEventDecoder.EncodedPrincipalLength()]; openEventDecoder.GetEncodedPrincipal(encodedPrincipal, 0, encodedPrincipal.Length); agent.OnSessionOpen(openEventDecoder.ClusterSessionId(), openEventDecoder.Timestamp(), openEventDecoder.ResponseStreamId(), responseChannel, encodedPrincipal); break; } case SessionCloseEventDecoder.TEMPLATE_ID: { closeEventDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnSessionClose(closeEventDecoder.ClusterSessionId(), closeEventDecoder.Timestamp(), closeEventDecoder.CloseReason()); break; } case ClusterActionRequestDecoder.TEMPLATE_ID: { actionRequestDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); agent.OnServiceAction(header.Position(), actionRequestDecoder.Timestamp(), actionRequestDecoder.Action()); break; } } return(ControlledFragmentHandlerAction.CONTINUE); }
public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { _messageHeaderDecoder.Wrap(buffer, offset); int templateId = _messageHeaderDecoder.TemplateId(); if (EgressMessageHeaderDecoder.TEMPLATE_ID == templateId) { _egressMessageHeaderDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); var sessionId = _egressMessageHeaderDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _listener.OnMessage( sessionId, _egressMessageHeaderDecoder.Timestamp(), buffer, offset + SESSION_HEADER_LENGTH, length - SESSION_HEADER_LENGTH, header); } return; } switch (templateId) { case SessionEventDecoder.TEMPLATE_ID: { _sessionEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); var sessionId = _sessionEventDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _listener.SessionEvent( _sessionEventDecoder.CorrelationId(), sessionId, _sessionEventDecoder.LeadershipTermId(), _sessionEventDecoder.LeaderMemberId(), _sessionEventDecoder.Code(), _sessionEventDecoder.Detail()); } break; } case NewLeaderEventDecoder.TEMPLATE_ID: { _newLeaderEventDecoder.Wrap( buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, _messageHeaderDecoder.BlockLength(), _messageHeaderDecoder.Version()); var sessionId = _newLeaderEventDecoder.ClusterSessionId(); if (sessionId == _clusterSessionId) { _listener.NewLeader( sessionId, _sessionEventDecoder.LeadershipTermId(), _newLeaderEventDecoder.LeaderMemberId(), _newLeaderEventDecoder.MemberEndpoints()); } break; } case ChallengeDecoder.TEMPLATE_ID: break; default: throw new ClusterException("unknown templateId: " + templateId); } }
public ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { if (isDispatchComplete) { return(ABORT); } messageHeaderDecoder.Wrap(buffer, offset); int schemaId = messageHeaderDecoder.SchemaId(); if (schemaId != MessageHeaderDecoder.SCHEMA_ID) { throw new ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" + schemaId); } int templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case ControlResponseDecoder.TEMPLATE_ID: { controlResponseDecoder .Wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); if (controlResponseDecoder.ControlSessionId() == controlSessionId) { ControlResponseCode code = controlResponseDecoder.Code(); long correlationId = controlResponseDecoder.CorrelationId(); if (ControlResponseCode.SUBSCRIPTION_UNKNOWN == code && correlationId == this.correlationId) { isDispatchComplete = true; return(BREAK); } if (ControlResponseCode.ERROR == code) { ArchiveException ex = new ArchiveException( "response for correlationId=" + this.correlationId + ", error: " + controlResponseDecoder.ErrorMessage(), (int)controlResponseDecoder.RelevantId(), correlationId); if (correlationId == this.correlationId) { throw ex; } else { errorHandler?.Invoke(ex); } } } } break; case RecordingSubscriptionDescriptorDecoder.TEMPLATE_ID: { recordingSubscriptionDescriptorDecoder.Wrap( buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); long correlationId = recordingSubscriptionDescriptorDecoder.CorrelationId(); if (recordingSubscriptionDescriptorDecoder.ControlSessionId() == controlSessionId && correlationId == this.correlationId) { consumer.OnSubscriptionDescriptor( controlSessionId, correlationId, recordingSubscriptionDescriptorDecoder.SubscriptionId(), recordingSubscriptionDescriptorDecoder.StreamId(), recordingSubscriptionDescriptorDecoder.StrippedChannel()); if (0 == --remainingSubscriptionCount) { isDispatchComplete = true; return(BREAK); } } } break; } return(CONTINUE); }
public virtual void OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case RecordingStartedDecoder.TEMPLATE_ID: recordingStartedDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); recordingId = recordingStartedDecoder.RecordingId(); recordingStartPosition = recordingStartedDecoder.StartPosition(); recordingPosition = recordingStartPosition; recordingStopPosition = -1; break; case RecordingProgressDecoder.TEMPLATE_ID: recordingProgressDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); recordingId = recordingProgressDecoder.RecordingId(); recordingStartPosition = recordingProgressDecoder.StartPosition(); recordingPosition = recordingProgressDecoder.Position(); recordingStopPosition = -1; break; case RecordingStoppedDecoder.TEMPLATE_ID: recordingStoppedDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); recordingId = recordingStoppedDecoder.RecordingId(); recordingStartPosition = recordingStoppedDecoder.StartPosition(); recordingStopPosition = recordingStoppedDecoder.StopPosition(); recordingPosition = recordingStopPosition; break; default: throw new System.InvalidOperationException("Unknown templateId: " + templateId); } pollComplete = true; }
public virtual ControlledFragmentHandlerAction OnFragment(IDirectBuffer buffer, int offset, int length, Header header) { messageHeaderDecoder.Wrap(buffer, offset); int templateId = messageHeaderDecoder.TemplateId(); switch (templateId) { case ControlResponseDecoder.TEMPLATE_ID: controlResponseDecoder.Wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); if (controlResponseDecoder.ControlSessionId() != controlSessionId) { break; } ControlResponseCode code = controlResponseDecoder.Code(); if (ControlResponseCode.RECORDING_UNKNOWN == code) { isDispatchComplete = true; return(ControlledFragmentHandlerAction.BREAK); } if (ControlResponseCode.ERROR == code) { throw new System.InvalidOperationException("response for expectedCorrelationId=" + expectedCorrelationId + ", error: " + controlResponseDecoder.ErrorMessage()); } break; case RecordingDescriptorDecoder.TEMPLATE_ID: recordingDescriptorDecoder.Wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version()); long correlationId = recordingDescriptorDecoder.CorrelationId(); if (controlSessionId != recordingDescriptorDecoder.ControlSessionId() || correlationId != expectedCorrelationId) { break; } consumer.OnRecordingDescriptor(controlSessionId, correlationId, recordingDescriptorDecoder.RecordingId(), recordingDescriptorDecoder.StartTimestamp(), recordingDescriptorDecoder.StopTimestamp(), recordingDescriptorDecoder.StartPosition(), recordingDescriptorDecoder.StopPosition(), recordingDescriptorDecoder.InitialTermId(), recordingDescriptorDecoder.SegmentFileLength(), recordingDescriptorDecoder.TermBufferLength(), recordingDescriptorDecoder.MtuLength(), recordingDescriptorDecoder.SessionId(), recordingDescriptorDecoder.StreamId(), recordingDescriptorDecoder.StrippedChannel(), recordingDescriptorDecoder.OriginalChannel(), recordingDescriptorDecoder.SourceIdentity()); if (0 == --remainingRecordCount) { isDispatchComplete = true; return(ControlledFragmentHandlerAction.BREAK); } break; default: throw new System.InvalidOperationException("Unknown templateId: " + templateId); } return(ControlledFragmentHandlerAction.CONTINUE); }