示例#1
0
        public ChannelHistoryInfo GetChannelHistoryInfo(string channel)
        {
            ChannelHistoryInfo channelHistoryInfo;

            if (!channelHistoryDict.TryGetValue(channel, out channelHistoryInfo))
            {
                channelHistoryInfo                     = new ChannelHistoryInfo();
                channelHistoryInfo.channel             = channel;
                channelHistoryInfo.hoursRecorded       = 0;
                channelHistoryInfo.recordingsAttempted = 0;
                channelHistoryInfo.lastAttempt         = DateTime.Now;
                channelHistoryInfo.lastSuccess         = DateTime.Now;
                channelHistoryInfo.activeFlag          = true;
                channelHistoryInfo.serverSpeed         = new ConcurrentDictionary <string, long>();

                channelHistoryDict.TryAdd(channel, channelHistoryInfo);
            }

            return(channelHistoryInfo);
        }
示例#2
0
        public long GetAvgKBytesSec(string server, string channel)
        {
            ChannelHistoryInfo channelHistoryInfo = GetChannelHistoryInfo(channel);

            //Make sure serverSpeed dict exists
            if (channelHistoryInfo.serverSpeed == null)
            {
                return(0);
            }

            //See if there's an entry for this server
            long avgKBytesSec;

            if (channelHistoryInfo.serverSpeed.TryGetValue(server, out avgKBytesSec))
            {
                return(avgKBytesSec);
            }

            //Oh well, just return 0 ifn ot found
            return(0);
        }
示例#3
0
        public void SetServerAvgKBytesSec(string channel, string server, long avgKBytesSec)
        {
            ChannelHistoryInfo channelHistoryInfo = GetChannelHistoryInfo(channel);

            //For backwards compat, make sure serverSpeed is init'd
            if (channelHistoryInfo.serverSpeed == null)
            {
                channelHistoryInfo.serverSpeed = new ConcurrentDictionary <string, long>();
            }

            long origAvgKBytesSec = 0;

            if (channelHistoryInfo.serverSpeed.TryGetValue(server, out origAvgKBytesSec))
            {
                avgKBytesSec = (avgKBytesSec + origAvgKBytesSec) / 2;
                channelHistoryInfo.serverSpeed[server] = avgKBytesSec;
            }
            else
            {
                channelHistoryInfo.serverSpeed.TryAdd(server, avgKBytesSec);
            }
        }