GetInstanceJavaProcess() public méthode

public GetInstanceJavaProcess ( ) : Process
Résultat System.Diagnostics.Process
Exemple #1
0
        private static void ControlKillInstance(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }

            Process process = instance.GetInstanceJavaProcess();

            if (process != null)
            {
                KillProcessAndChildrens(process.Id, instance);
            }
        }
Exemple #2
0
        public static BundleStatus GetCombinedBundleStatus(AemInstance pInstance)
        {
            if (pInstance == null)
            {
                return(BundleStatus.NO_ACTIVE_INSTANCE);
            }

            // check if process is running
            if (!pInstance.RemoteProcess)
            {
                Process process = pInstance.GetInstanceJavaProcess();
                if (process == null || process.HasExited)
                {
                    return(BundleStatus.DISABLED);
                }
            }

            // get bundle status
            BundleStatus bundleStatus          = BundleStatus.UNKNOWN;
            string       bundleListUrl         = pInstance.UrlWithContextPath + "/system/console/bundles/.json";
            Stopwatch    responseTimeStopwatch = new Stopwatch();

            try {
                mLog.Debug("Get bundle list from URL: " + bundleListUrl);

                HttpWebRequest request = pInstance.WebRequestCreate(bundleListUrl);
                request.Method           = "GET";
                request.Timeout          = AEMManager.Properties.Settings.Default.BundleListTimeout;
                request.ReadWriteTimeout = AEMManager.Properties.Settings.Default.BundleListTimeout;

                responseTimeStopwatch.Start();
                using (WebResponse response = request.GetResponse()) {
                    responseTimeStopwatch.Stop();

                    String responseText;
                    using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) {
                        responseText = streamReader.ReadToEnd();
                    }

                    // parse JSON
                    bool   success = false;
                    object value   = JSON.JsonDecode(responseText, ref success);
                    if (success)
                    {
                        bundleStatus = GetCombinedBundleStatus(value, responseTimeStopwatch.ElapsedMilliseconds);
                    }
                    else
                    {
                        mLog.Warn("Parsing JSON response failed: " + responseText);
                    }
                }
            }
            catch (WebException ex) {
                if (ex.Status == WebExceptionStatus.Timeout)
                {
                    mLog.Debug("Unable to connect to " + bundleListUrl + " due to timeout. "
                               + "Configured timeout: " + AEMManager.Properties.Settings.Default.BundleListTimeout + "ms, "
                               + "measured response time: " + responseTimeStopwatch.ElapsedMilliseconds + "ms");
                }
                else
                {
                    mLog.Debug("Unable to connect to " + bundleListUrl + ": " + ex.Message);
                    bundleStatus = BundleStatus.UNKNOWN;
                }
            }
            catch (Exception ex) {
                mLog.Error("Error getting bundle list from URL: " + bundleListUrl, ex);
                bundleStatus = BundleStatus.UNKNOWN;
            }

            return(bundleStatus);
        }
        public static BundleStatus GetCombinedBundleStatus(AemInstance pInstance)
        {
            if (pInstance == null) {
            return BundleStatus.NO_ACTIVE_INSTANCE;
              }

              // check if process is running
              if (!pInstance.RemoteProcess) {
            Process process = pInstance.GetInstanceJavaProcess();
            if (process == null || process.HasExited) {
              return BundleStatus.DISABLED;
            }
              }

              // get bundle status
              BundleStatus bundleStatus = BundleStatus.UNKNOWN;
              string bundleListUrl = pInstance.UrlWithContextPath + "/system/console/bundles/.json";
              Stopwatch responseTimeStopwatch = new Stopwatch();
              try {
            mLog.Debug("Get bundle list from URL: " + bundleListUrl);

            WebRequest request = pInstance.WebRequestCreate(bundleListUrl);
            request.Method = "GET";
            request.Timeout = AEMManager.Properties.Settings.Default.BundleListTimeout;

            responseTimeStopwatch.Start();
            using (WebResponse response = request.GetResponse()) {
              responseTimeStopwatch.Stop();

              String responseText;
              using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) {
            responseText = streamReader.ReadToEnd();
              }

              // parse JSON
              bool success = false;
              object value = JSON.JsonDecode(responseText, ref success);
              if (success) {
            bundleStatus = GetCombinedBundleStatus(value, responseTimeStopwatch.ElapsedMilliseconds);
              }
              else {
            mLog.Warn("Parsing JSON response failed: " + responseText);
              }
            }

              }
              catch (WebException ex) {
            if (ex.Status == WebExceptionStatus.Timeout) {
              mLog.Debug("Unable to connect to " + bundleListUrl + " due to timeout. "
            + "Configured timeout: " + AEMManager.Properties.Settings.Default.BundleListTimeout + "ms, "
            + "measured response time: " + responseTimeStopwatch.ElapsedMilliseconds + "ms");
            }
            else {
              mLog.Debug("Unable to connect to " + bundleListUrl + ": " + ex.Message);
              bundleStatus = BundleStatus.UNKNOWN;
            }
              }
              catch (Exception ex) {
            mLog.Error("Error getting bundle list from URL: " + bundleListUrl, ex);
            bundleStatus = BundleStatus.UNKNOWN;
              }

              return bundleStatus;
        }