Beispiel #1
0
 public void Command(string command)
 {
     if (!_cmdlock.TryEnter())
     {
         _logger.Info("当前命令正在执行!");
         return;
     }
     try
     {
         _logger.InfoFormat("开始执行{0}命令", command);
         switch (command)
         {
         case "platform":
             PlatFormInfoCache.Instance.DatabaseInit();
             AuthenticationCache.Instance.DatabaseInit();
             PlatFormCache.Instance.DatabaseInit();
             VideoNodeKeyArray.Instance.ForbiddenInit();
             break;
         }
         _logger.InfoFormat("执行{0}命令结束", command);
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
     finally
     {
         _cmdlock.Exit();
     }
 }
Beispiel #2
0
        public void Refresh()
        {
            if (DateTime.Now.Subtract(_lasttime).TotalMinutes < int.Parse(AppSettingCache.Instance["RefreshInterval"]) || !_lock.TryEnter())
            {
                _logger.Info(string.Format("由于时间未到或刷新正在执行,请求刷新未执行,上次请求时间为{0}", _lasttime.ToString("yyyy-MM-dd HH:mm:ss")));
                return;
            }
            try
            {
                ThreadPool.QueueUserWorkItem(state => {
                    _logger.Info("刷新开始!");
                    var job = new ListCacheJob();
                    job.Execute(null);
                    _lasttime = DateTime.Now;
                    _logger.Info("刷新执行成功!");
                });

                //timer = new Timer(TimerCallback, null, int.Parse(AppSettingCache.Instance["RefreshExtensionInterval"]) * 60 * 1000, 0);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            finally
            {
                _lock.Exit();
            }
        }
Beispiel #3
0
 public void Execute(JobExecutionContext context)
 {
     if (!_lock.TryEnter())
     {
         return;
     }
     try
     {
         LiveChannelCache.Instance.Init();
         var source  = LiveListCache.Instance.Dictionary.Values.Where(l => l.HiddenFlag == 0).Select(l => l.Main.ChannelID).ToPerfectList();
         var compare = LiveChannelCache.Instance.Items.Select(l => l.ChannelID).ToPerfectList();
         var hiddens = source.Except(compare).ToPerfectList();
         var shows   = compare.Except(source).ToPerfectList();
         if (hiddens.Count > 0)
         {
             if (hiddens.Count < AppSettingCache.LiveHiddenMaxCount)
             {
                 foreach (var hidden in hiddens)
                 {
                     if (LiveListCache.Instance.Dictionary.ContainsKey(hidden))
                     {
                         var video = LiveListCache.Instance.Dictionary[hidden];
                         video.HiddenFlag = 1;
                         LiveEpgIndex.DeleteVideo(video, LiveEpgLuceneNet.Instance.IndexDic);
                         _logger.Info(string.Format("频道{0}已下线", hidden));
                     }
                 }
             }
             else
             {
                 _logger.Info(string.Format("下线个数超过最大阀值,当前下线个数为{0}", hiddens.Count));
             }
         }
         if (shows.Count > 0)
         {
             foreach (var show in shows)
             {
                 if (LiveListCache.Instance.Dictionary.ContainsKey(show))
                 {
                     var video = LiveListCache.Instance.Dictionary[show];
                     video.HiddenFlag = 0;
                     LiveEpgIndex.InsertVideo(video, LiveEpgLuceneNet.Instance.IndexDic);
                     _logger.Info(string.Format("频道{0}已上线", show));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
     finally
     {
         _lock.Exit();
     }
 }
Beispiel #4
0
 public bool AddNode(string key, int hitCount, string pIdex, params object[] objs)
 {
     if (!_isLock && !_lock.TryEnter())
     {
         return(false);
     }
     try
     {
         var count = 1;
         if (objs != null && objs.Length > 0)
         {
             count = int.Parse(objs[0].ToString());
         }
         if (!_dic.ContainsKey(key))
         {
             if (_dic.Count < SettingCache.LuceneDictCount)
             {
                 InstrumentNode node = new InstrumentNode();
                 node.Key          = key;
                 node.LastHitCount = hitCount;
                 node.SearchCount  = count;
                 node.PIndex       = pIdex;
                 _dic[node.Key]    = node;
             }
         }
         else
         {
             _dic[key].LastHitCount = hitCount;
             _dic[key].SearchCount += count;
         }
         return(true);
     }
     finally
     {
         _lock.Exit();
     }
 }
Beispiel #5
0
 public void Init()
 {
     if (!_lock.TryEnter())
     {
         return;
     }
     try
     {
         _cache = RefreshCache();
     }
     finally
     {
         _lock.Exit();
     }
 }
 public void Execute(JobExecutionContext context)
 {
     if (!_lock.TryEnter())
     {
         return;
     }
     try
     {
         _log.Info("HotSearchWordJob开始更新");
         LuceneDictionary.Instance.Refresh();
     }
     catch (Exception ex)
     {
         _log.Error(ex);
     }
     finally
     {
         _log.Info("HotSearchWordJob结束更新");
         _lock.Exit();
     }
 }
Beispiel #7
0
 public void Execute(JobExecutionContext context)
 {
     if (!_lock.TryEnter())
     {
         return;
     }
     try
     {
         _log.Info("CoverJob开始更新");
         CoverImageCache.Instance.DatabaseInit();
         CoverNavCache.Instance.DatabaseInit();
         //ConverImageCache.Instance.DatabaseInit();
         SplashScreenCache.Instance.DatabaseInit();
     }
     catch (Exception ex)
     {
         _log.Error(ex);
     }
     finally
     {
         _log.Info("CoverJob结束更新");
         _lock.Exit();
     }
 }
Beispiel #8
0
        public void Execute(JobExecutionContext context)
        {
            if (!_lock.TryEnter())
            {
                return;
            }
            try
            {
                _logger.Info("ListCacheJob开始更新");

                PlatFormInfoCache.Instance.DatabaseInit();
                AuthenticationCache.Instance.DatabaseInit();
                //CustomerCache.Instance.DatabaseInit();
                PlatFormCache.Instance.DatabaseInit();
                VideoNodeKeyArray.Instance.Reset();

                _logger.Info("BKInfo开始同步");
                BKInfoCache.Instance.Init();
                BKTypeCache.Instance.Init();
                _logger.Info("BKInfo结束同步");

                ForbiddenAreaCache.Instance.DatabaseInit();

                if (bool.Parse(AppSettingCache.Instance["VodAct"]))   //是否启动点播
                {
                    BoxTagCache.Instance.Init();

                    _logger.Info("Channels开始同步");
                    ChannelCache.Instance.Init();
                    ViceChnanelCache.Instance.Init();
                    _logger.Info("Channels结束同步");

                    ChannelTagRelCache.Instance.Init();

                    ChannelRecomRelCache.Instance.Init();

                    BoxTypeInfoCache.Instance.Init();
                    TagTypeCache.Instance.Init();
                    BoxTypeCache.Instance.DatabaseInit();

                    _logger.Info("ListCache开始计算整合");
                    ListCache.Instance.DatabaseInit();
                    _logger.Info("ListCache结束整合");

                    _logger.Info("TagCache开始计算整合");
                    TagCache.Instance.DatabaseInit();
                    _logger.Info("TagCache结束整合");

                    _logger.Info("RecommandCache开始计算整合");
                    RecommandCache.Instance.DatabaseInit();
                    _logger.Info("RecommandCache结束整合");

                    _logger.Info("TreeNodeCache开始计算整合");
                    TreeNodeInfoCache.Instance.Init();
                    TreeNodeChannelRelCache.Instance.Init();
                    TreeNodeCache.Instance.DatabaseInit();
                    _logger.Info("TreeNodeCache结束整合");
                }

                if (bool.Parse(AppSettingCache.Instance["LiveAct"]))   //是否启动直播
                {
                    _logger.Info("LiveCache开始计算整合");
                    LiveChannelCache.Instance.Init();
                    ChannelLiveItemsCache.Instance.DatabaseInit();
                    ChannelLiveRelCache.Instance.Init();
                    ChannelLiveRecomRelCache.Instance.Init();
                    ChannelLiveCustomerRelCache.Instance.Init();
                    LiveTypeCache.Instance.DatabaseInit();
                    LiveListCache.Instance.DatabaseInit();
                    LiveTypeDicCache.Instance.DatabaseInit();
                    LiveRecommandCache.Instance.DatabaseInit();
                    _logger.Info("LiveCache结束整合");
                }

                CoverImageCache.Instance.DatabaseInit();
                CoverNavCache.Instance.DatabaseInit();
                //ConverImageCache.Instance.DatabaseInit();
                SplashScreenCache.Instance.DatabaseInit();

                //if (NetNodeService.Instance.HasChildren)     //有孩子节点启动分布式
                //{
                //    Thread thread = new Thread(state => {
                //        if (!_synclock.TryEnter())
                //            return;
                //        try
                //        {
                //            NetNodeService.Instance.SyncChildrenData();
                //        }
                //        catch (Exception ex)
                //        {
                //            _logger.Error(ex);
                //        }
                //        finally
                //        {
                //            _synclock.Exit();
                //        }
                //    });
                //    thread.Start();
                //}
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            finally
            {
                _logger.Info("ListCacheJob结束更新");
                _lock.Exit();
            }
        }
Beispiel #9
0
        public void Execute(JobExecutionContext context)
        {
            if (!_lock.TryEnter() && !NetNodeService.Instance.HasChildren)
            {
                return;
            }
            try
            {
                _logger.Info("ListExtensionJob开始更新");

                //CustomerCache.Instance.RefreshExtension();
                PlatFormInfoCache.Instance.RefreshExtension();
                AuthenticationCache.Instance.RefreshExtension();
                PlatFormCache.Instance.RefreshExtension();

                if (bool.Parse(AppSettingCache.Instance["VodAct"]))   //是否启动点播
                {
                    BoxTypeCache.Instance.RefreshExtension();
                    ListCache.Instance.RefreshExtension();
                    TagCache.Instance.RefreshExtension();
                    RecommandCache.Instance.RefreshExtension();
                }
                if (bool.Parse(AppSettingCache.Instance["LiveAct"]))   //是否启动直播
                {
                    ChannelLiveItemsCache.Instance.RefreshExtension();
                    LiveTypeCache.Instance.RefreshExtension();
                    LiveListCache.Instance.RefreshExtension();
                    LiveTypeDicCache.Instance.RefreshExtension();
                    LiveRecommandCache.Instance.RefreshExtension();
                }

                if (NetNodeService.Instance.HasChildren)     //有孩子节点启动分布式
                {
                    ThreadPool.QueueUserWorkItem(state =>
                    {
                        if (!_synclock.TryEnter())
                        {
                            return;
                        }
                        try
                        {
                            NetNodeService.Instance.SyncChildrenData();
                        }
                        catch (Exception ex)
                        {
                            _logger.Error(ex);
                        }
                        finally
                        {
                            _synclock.Exit();
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            finally
            {
                _lock.Exit();
                _logger.Info("ListExtensionJob结束更新");
            }
        }