/// <summary> /// Allocate a counter to represent the heartbeat of a clustered service. /// </summary> /// <param name="aeron"> to allocate the counter. </param> /// <param name="tempBuffer"> to use for building the key and label without allocation. </param> /// <param name="serviceId"> of the service heartbeat. </param> /// <returns> the <seealso cref="Counter"/> for the commit position. </returns> public static Counter Allocate(Aeron.Aeron aeron, IMutableDirectBuffer tempBuffer, int serviceId) { int labelOffset = 0; labelOffset += tempBuffer.PutStringWithoutLengthAscii(KEY_LENGTH + labelOffset, NAME); labelOffset += tempBuffer.PutIntAscii(KEY_LENGTH + labelOffset, serviceId); return(aeron.AddCounter(SERVICE_HEARTBEAT_TYPE_ID, tempBuffer, 0, KEY_LENGTH, tempBuffer, KEY_LENGTH, labelOffset)); }
/// <summary> /// Allocate a counter to represent the heartbeat of a clustered service. /// </summary> /// <param name="aeron"> to allocate the counter. </param> /// <param name="tempBuffer"> to use for building the key and label without allocation. </param> /// <param name="serviceId"> of the service heartbeat. </param> /// <returns> the <seealso cref="Counter"/> for the commit position. </returns> public static Counter Allocate(Aeron.Aeron aeron, IMutableDirectBuffer tempBuffer, int serviceId) { tempBuffer.PutInt(SERVICE_ID_OFFSET, serviceId); int labelOffset = BitUtil.Align(KEY_LENGTH, BitUtil.SIZE_OF_INT); int labelLength = 0; labelLength += tempBuffer.PutStringWithoutLengthAscii(labelOffset + labelLength, NAME); labelLength += tempBuffer.PutIntAscii(labelOffset + labelLength, serviceId); return(aeron.AddCounter(SERVICE_HEARTBEAT_TYPE_ID, tempBuffer, 0, KEY_LENGTH, tempBuffer, labelOffset, labelLength)); }
/// <summary> /// Allocate a counter to represent the commit position on stream for the current leadership term. /// </summary> /// <param name="aeron"> to allocate the counter. </param> /// <param name="tempBuffer"> to use for building the key and label without allocation. </param> /// <param name="recordingId"> for the current term. </param> /// <param name="logPosition"> of the log at the beginning of the leadership term. </param> /// <param name="leadershipTermId"> of the log at the beginning of the leadership term. </param> /// <param name="sessionId"> of the active log for the current leadership term. </param> /// <returns> the <seealso cref="Counter"/> for the consensus position. </returns> public static Counter Allocate(Aeron.Aeron aeron, IMutableDirectBuffer tempBuffer, long recordingId, long logPosition, long leadershipTermId, int sessionId) { tempBuffer.PutLong(RECORDING_ID_OFFSET, recordingId); tempBuffer.PutLong(LOG_POSITION_OFFSET, logPosition); tempBuffer.PutLong(LEADERSHIP_TERM_ID_OFFSET, leadershipTermId); tempBuffer.PutInt(SESSION_ID_OFFSET, sessionId); int labelOffset = 0; labelOffset += tempBuffer.PutStringWithoutLengthAscii(KEY_LENGTH + labelOffset, NAME); labelOffset += tempBuffer.PutLongAscii(KEY_LENGTH + labelOffset, leadershipTermId); labelOffset += tempBuffer.PutStringWithoutLengthAscii(KEY_LENGTH + labelOffset, " logSessionId="); labelOffset += tempBuffer.PutIntAscii(KEY_LENGTH + labelOffset, sessionId); return(aeron.AddCounter(COMMIT_POSITION_TYPE_ID, tempBuffer, 0, KEY_LENGTH, tempBuffer, KEY_LENGTH, labelOffset)); }
/// <summary> /// Allocate a counter to represent the snapshot services should load on start. /// </summary> /// <param name="aeron"> to allocate the counter. </param> /// <param name="tempBuffer"> to use for building the key and label without allocation. </param> /// <param name="leadershipTermId"> at which the snapshot was taken. </param> /// <param name="termPosition"> at which the snapshot was taken. </param> /// <param name="timestamp"> the snapshot was taken. </param> /// <param name="replayTermCount"> for the count of terms to be replayed during recovery after snapshot. </param> /// <returns> the <seealso cref="Counter"/> for the consensus position. </returns> public static Counter Allocate(Aeron.Aeron aeron, IMutableDirectBuffer tempBuffer, long termPosition, long leadershipTermId, long timestamp, int replayTermCount) { tempBuffer.PutLong(LEADERSHIP_TERM_ID_OFFSET, leadershipTermId); tempBuffer.PutLong(TERM_POSITION_OFFSET, termPosition); tempBuffer.PutLong(TIMESTAMP_OFFSET, timestamp); tempBuffer.PutInt(REPLAY_TERM_COUNT_OFFSET, replayTermCount); int labelOffset = 0; labelOffset += tempBuffer.PutStringWithoutLengthAscii(KEY_LENGTH + labelOffset, NAME); labelOffset += tempBuffer.PutLongAscii(KEY_LENGTH + labelOffset, leadershipTermId); labelOffset += tempBuffer.PutStringWithoutLengthAscii(KEY_LENGTH + labelOffset, " termPosition="); labelOffset += tempBuffer.PutLongAscii(KEY_LENGTH + labelOffset, termPosition); labelOffset += tempBuffer.PutStringWithoutLengthAscii(KEY_LENGTH + labelOffset, " replayTermCount="); labelOffset += tempBuffer.PutIntAscii(KEY_LENGTH + labelOffset, replayTermCount); return(aeron.AddCounter(RECOVERY_STATE_TYPE_ID, tempBuffer, 0, KEY_LENGTH, tempBuffer, KEY_LENGTH, labelOffset)); }