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 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 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) { 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 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: HandleControlResponse(listener, buffer, offset); break; case RecordingDescriptorDecoder.TEMPLATE_ID: HandleRecordingDescriptor(listener, buffer, offset); break; } }
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 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) { 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); }