Example #1
0
        public static Counter Allocate(Aeron.Aeron aeron, UnsafeBuffer tempBuffer, long recordingId,
                                       int sessionId, int streamId, string strippedChannel, string sourceIdentity)
        {
            tempBuffer.PutLong(RECORDING_ID_OFFSET, recordingId);
            tempBuffer.PutInt(SESSION_ID_OFFSET, sessionId);

            var sourceIdentityLength = Math.Min(sourceIdentity.Length, CountersReader.MAX_KEY_LENGTH - SOURCE_IDENTITY_OFFSET);

            tempBuffer.PutStringAscii(SOURCE_IDENTITY_LENGTH_OFFSET, sourceIdentity);
            var keyLength = SOURCE_IDENTITY_OFFSET + sourceIdentityLength;

            int labelLength = 0;

            labelLength += tempBuffer.PutStringWithoutLengthAscii(keyLength, NAME + ": ");
            labelLength += tempBuffer.PutLongAscii(keyLength + labelLength, recordingId);
            labelLength += tempBuffer.PutStringWithoutLengthAscii(keyLength + labelLength, " ");
            labelLength += tempBuffer.PutIntAscii(keyLength + labelLength, sessionId);
            labelLength += tempBuffer.PutStringWithoutLengthAscii(keyLength + labelLength, " ");
            labelLength += tempBuffer.PutIntAscii(keyLength + labelLength, streamId);
            labelLength += tempBuffer.PutStringWithoutLengthAscii(keyLength + labelLength, " ");
            labelLength += tempBuffer.PutStringWithoutLengthAscii(
                keyLength + labelLength, strippedChannel, 0, CountersReader.MAX_LABEL_LENGTH - labelLength);

            return(aeron.AddCounter(
                       RECORDING_POSITION_TYPE_ID, tempBuffer, 0, keyLength, tempBuffer, keyLength, labelLength));
        }