Esempio n. 1
0
        private PutLog ConvertThreadLocalLogsToPutLogs()
        {
            if (_threadLocalLogs.Value.Count <= 0)
            {
                return(null);
            }

            Int32 count               = _threadLocalLogs.Value.Count;
            var   rawLogs             = new List <ILog>(count);
            var   encodedLogs         = new List <Byte[]>(count);
            Int32 totalEncodedLogByte = 0;

            for (Int32 i = 0; i < count; ++i)
            {
                Log    log        = _threadLocalLogs.Value[i];
                Byte[] encodedLog = LogEncoder.Encode(log);

                CompletePutNoticeResultType completePutNoticeResultType = ValidateEncodedLog(encodedLog);
                if (completePutNoticeResultType != CompletePutNoticeResultType.Success)
                {
                    DropLog(log, completePutNoticeResultType);
                    continue;
                }

                rawLogs.Add(log);
                encodedLogs.Add(encodedLog);
                totalEncodedLogByte += encodedLog.Length;

                UpdateThreadLocalWatcherCounter(log.LogType, encodedLog.Length);
            }

            return(new PutLog(rawLogs.ToArray(), encodedLogs.ToArray(), totalEncodedLogByte));
        }
Esempio n. 2
0
        private void DropLog(Log log, CompletePutNoticeResultType completePutNoticeResultType)
        {
            CompletePutNotifier.Push(new ILog[] { log }, completePutNoticeResultType);

            _threadLocalWatcherCounter.Value.DropLogCount += 1;

            Reporter.Error($"Fail Encode Log. LogType: {log.LogType}, Reason: {completePutNoticeResultType}");
        }
Esempio n. 3
0
        internal Boolean Push(ILog[] logs, CompletePutNoticeResultType completePutNoticeResultType)
        {
            lock (_lock)
            {
                if (_thread == null)
                {
                    return(false);
                }
            }

            return(_completePuts.Push(new CompletePutNotice(logs, completePutNoticeResultType)));
        }
Esempio n. 4
0
 internal CompletePutNotice(ILog[] logs, CompletePutNoticeResultType completePutNoticeResultType)
 {
     Logs = logs;
     CompletePutNoticeResultType = completePutNoticeResultType;
 }