Пример #1
0
        /// <summary>
        /// 分布式缓存客户端开启
        /// </summary>
        public static void Start()
        {
            //_cacheNameList = DistributedCacheManage.GetCacheNameList();//本节点的客户端缓存名列表和服务端缓存列表必须一致

            //客户端订阅分布式缓存
            SubscribeServiceObject ssObject = new SubscribeServiceObject();

            ssObject.publishServiceName = publishServiceName;
            ssObject.ProcessService     = ((ClientLink _clientLink) =>
            {
                List <CacheIdentify> ciList = DistributedCacheClient.GetCacheIdentifyList(); //获取本地缓存索引
                List <CacheObject> coList = _clientLink.GetDistributedCacheData(ciList);     //比对上级中间件缓存,返回差异的缓存对象
                if (coList.Count > 0)
                {
                    //调试
                    //foreach (var i in coList)
                    //{
                    //    if(i.cachename== "mnodeplugin")
                    //    {
                    //        foreach(var n in i.cacheValue)
                    //        {
                    //            CoreFrame.Common.MiddlewareLogHelper.WriterLog(n.key);
                    //            CoreFrame.Common.MiddlewareLogHelper.WriterLog(n.value);
                    //        }
                    //    }
                    //}

                    DistributedCacheClient.SetCacheObjectList(coList);//将差异的缓存对象同步到本节点中间件
                }
            });
            SubscriberManager.Subscribe(ssObject);
        }
Пример #2
0
        /// <summary>
        /// 客户端执行订阅服务
        /// </summary>
        /// <param name="_clientLink"></param>
        public static void ProcessPublishService(string publishServiceName, ClientLink _clientLink)
        {
            switch (publishServiceName)
            {
            case "DistributedCache":    //分布式缓存服务
                List <CacheIdentify> ciList = DistributedCacheClient.GetCacheIdentifyList();
                List <CacheObject>   coList = _clientLink.GetDistributedCacheData(ciList);
                if (coList.Count > 0)
                {
                    DistributedCacheClient.SetCacheObjectList(coList);
                }
                break;

            case "RemotePlugin":    //远程插件服务
                LocalPlugin localPlugin = RemotePluginClient.GetLocalPlugin();
                if (localPlugin.PluginDic.Count > 0)
                {
                    _clientLink.RegisterRemotePlugin(WcfGlobal.Identify, localPlugin.PluginDic.Keys.ToArray());
                }
                break;

            case "UpgradeClient":    //客户端升级
                ClientUpgradeManager.DownLoadUpgrade();
                break;

            case "UpgradeServer":    //中间件升级
                break;

            case "MongodbSync":    //同步Mongodb数据
                break;

            case "MiddlewareMonitor":    //中间件集群监控服务
                break;

            case "MiddlewareCmd":    //中间件命令服务
                break;

            default:
                PublishServiceObject pso = psoList.Find(x => x.publishServiceName == publishServiceName);
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Blue, string.Format("正在执行服务{0}/{1}/{2}/{3}", pso.pluginname, pso.controller, pso.method, pso.argument));
                ServiceResponseData retjson = InvokeWcfService(
                    pso.pluginname
                    , pso.controller
                    , pso.method
                    , (ClientRequestData request) =>
                {
                    request.SetJsonData(pso.argument);
                });
                string txtResult = retjson.GetJsonData();
                MiddlewareLogHelper.WriterLog(LogType.MidLog, true, System.Drawing.Color.Blue, string.Format("服务执行完成,返回结果:{0}", txtResult));
                break;
            }

            ShowHostMsg(Color.Blue, DateTime.Now, "执行“" + publishServiceName + "”订阅服务成功!");
        }