private long OnTakeSnapshot(long logPosition, long leadershipTermId) { long recordingId; using (AeronArchive archive = AeronArchive.Connect(archiveCtx)) using (Publication publication = aeron.AddExclusivePublication(ctx.SnapshotChannel(), ctx.SnapshotStreamId())) { var channel = ChannelUri.AddSessionId(ctx.SnapshotChannel(), publication.SessionId); long subscriptionId = archive.StartRecording(channel, ctx.SnapshotStreamId(), SourceLocation.LOCAL); try { CountersReader counters = aeron.CountersReader(); int counterId = AwaitRecordingCounter(publication.SessionId, counters); recordingId = RecordingPos.GetRecordingId(counters, counterId); SnapshotState(publication, logPosition, leadershipTermId); service.OnTakeSnapshot(publication); AwaitRecordingComplete(recordingId, publication.Position, counters, counterId, archive); } finally { archive.StopRecording(subscriptionId); } } return(recordingId); }
internal void Connect(Aeron.Aeron aeron) { if (null == _responsePublication) { _responsePublication = aeron.AddExclusivePublication(ResponseChannel, ResponseStreamId); } }
internal void Connect(Aeron.Aeron aeron) { if (null == _responsePublication) { try { _responsePublication = aeron.AddExclusivePublication(ResponseChannel, ResponseStreamId); } catch (RegistrationException) { // ignore } } }