private void AnswerPingRequest()
        {
            try
            {
                PingRequest pingRequest = PingRequestLogic.GetMostRecent();

                if (pingRequest == null)
                {
                    return;
                }

                ApplicationServer appServer = GetApplicationServerForThisMachine(Environment.MachineName);

                // Can't do anything if we don't have an app server
                if (appServer == null)
                {
                    return;
                }

                // See if we have already responded to the most recent ping request.

                PingResponse pingResponse = PingResponseLogic.GetByPingRequestAndServer(pingRequest, appServer);

                if (pingResponse != null)
                {
                    return;
                }                                      // Already responded.

                string comment = "PTR file version " + ReflectionUtility.GetFileVersion(Assembly.GetExecutingAssembly()) + " -- " + this.CommentFromServiceHost;

                pingResponse = new PingResponse(pingRequest.Id, DateTime.Now, appServer, comment);

                PingResponseLogic.Save(pingResponse);

                Logger.LogInformation(string.Format(CultureInfo.CurrentCulture,
                                                    "{0} responded to ping request", appServer.Name), PrestoTaskRunnerName);
            }
            catch (Exception ex)
            {
                // Just eat it. We don't want ping response failures to stop processing.
                CommonUtility.ProcessExceptionWithLimits(ex, PrestoTaskRunnerName);
            }
        }
示例#2
0
 public IEnumerable <PingResponse> GetAllForPingRequest(PingRequest pingRequest)
 {
     return(Invoke(() => PingResponseLogic.GetAllForPingRequest(pingRequest)));
 }