Пример #1
0
 public GossipServiceClient(GrpcBaseHelper h, string logRootPath, string logName)
 {
     this.gossipClient = new GossipTask.GossipTaskClient(h.NewChannel());
     this.helper       = h;
     this.logPath      = logRootPath;
     if (String.IsNullOrEmpty(logName))
     {
         this.logPathName = logRootPath + System.IO.Path.DirectorySeparatorChar + "gossip.log";
     }
     else
     {
         this.logPathName = logRootPath + System.IO.Path.DirectorySeparatorChar + logName;
     }
 }
Пример #2
0
        public string RestartGossip()
        {
            string  res     = "重启成功";
            Channel channel = helper.NewChannel();

            try
            {
                GossipTask.GossipTaskClient gClient = new GossipTask.GossipTaskClient(channel);
                DateTime      opTime  = DateTime.Now;
                string        name    = LocalInfoUtil.GetLocalUsername();
                StringBuilder sb      = new StringBuilder();
                string        content = "-----{0}-----{1} at {2} gossip restarting ... ";
                WriteLog(String.Format(content,
                                       opTime.ToLongTimeString(),
                                       name,
                                       opTime.ToString("yyyy-MM-dd HH:mm:ss")),
                         "restart Gossip");
                gClient.stopService(new StopRequest {
                });

                Thread.Sleep(500);
                gClient.startServiceAsync(new StartRequest {
                });
            }
            catch (Exception e)
            {
                WriteLog(String.Format("重启Gossip发生错误,请重试!\r\n 可能原因:{0}", e.Message), "");
                return(String.Format("重启Gossip发生错误,请重试!\r\n 可能原因:{0}", e.Message));
            }
            finally
            {
                channel.ShutdownAsync().Wait();
            }
            WriteLog(String.Format("############ {0} ############\r\n", res), "");
            return(res);
        }