public void Exit() { isRunning = false; if (communicator != null) { Status = BundleStatus.Exiting; try { communicator.shutdown(); communicator.destroy(); Status = BundleStatus.Shutdown; } catch (System.Exception ex) { Status = BundleStatus.Exception; OnExceptionOccured?.Invoke(ex); } communicator = null; } else { Status = BundleStatus.Unknown; } counter = 0; }
private static BundleStatus GetCombinedBundleStatus(object pJsonObject, long pRepsonseTime) { BundleStatus bundleStatus = BundleStatus.RUNNING; Hashtable root = GetHashtable(pJsonObject); string status = (string)root["status"]; ArrayList data = GetArrayList(root["data"]); foreach (object dataItem in data) { Hashtable bundle = GetHashtable(dataItem); string state = (string)bundle["state"]; if (!string.IsNullOrEmpty(state)) { if (!(state.Equals("Active") || state.Equals("Fragment"))) { bundleStatus = BundleStatus.STARTING_STOPPING; break; } } } mLog.Debug("Status: " + status + ", result: " + bundleStatus + " (response time: " + pRepsonseTime + "ms)"); return(bundleStatus); }
private void IceClient_OnStatusChanged(BundleStatus status) { AddMessage($"Client Status: {status}"); if (status != BundleStatus.Running) { App.Current.Dispatcher.Invoke(() => { tbTime.Text = ""; }); timer?.Change(Timeout.Infinite, Timeout.Infinite); } Application.Current.Dispatcher.Invoke(delegate { if (status != BundleStatus.Unknown) { textBoxContentSize.IsEnabled = true; } labelClientStatus.Content = $"{status}"; labelClientStatus.Foreground = Brushes.SteelBlue; cbClientHeartbeat.IsEnabled = (status != BundleStatus.Running); checkBoxAsync.IsEnabled = (status == BundleStatus.Running); buttonIdleClient.IsEnabled = (status == BundleStatus.Running); buttonIdleClient.Content = iceClient.Hold ? "Active" : "Idle"; switch (status) { case BundleStatus.Unknown: labelClientStatus.Background = Brushes.Gray; labelClientStatus.Foreground = Brushes.White; break; case BundleStatus.Exception: labelClientStatus.Background = Brushes.OrangeRed; labelClientStatus.Foreground = Brushes.White; break; case BundleStatus.Running: labelClientStatus.Background = Brushes.LightGreen; labelClientStatus.Foreground = Brushes.DarkBlue; break; case BundleStatus.Stopped: labelClientStatus.Foreground = Brushes.Red; break; case BundleStatus.Idle: labelClientStatus.Background = Brushes.LightGray; labelClientStatus.Foreground = Brushes.DarkGreen; break; default: labelClientStatus.Background = Brushes.LightGoldenrodYellow; break; } }); }
/// <summary> /// Updates tooltip text and icon of tray icon /// </summary> public void UpdateNofiyIconText(BundleStatus pBundleStatus) { mCurrentBundleStatus = pBundleStatus; string trayIcon = "trayicon_default"; string statusText = ""; switch (pBundleStatus) { case BundleStatus.NO_ACTIVE_INSTANCE: trayIcon = "trayicon_default"; break; case BundleStatus.DISABLED: trayIcon = "trayicon_disabled"; statusText = "not running"; break; case BundleStatus.UNKNOWN: trayIcon = "trayicon_unknown"; statusText = "server starting/stopping"; break; case BundleStatus.STARTING_STOPPING: trayIcon = "trayicon_starting"; statusText = "bundles starting/stopping"; break; case BundleStatus.RUNNING: trayIcon = "trayicon_running"; statusText = "running"; break; } this.NotifyIcon.Text = this.Name + " (" + statusText + ")"; this.NotifyIcon.Icon = IconCache.GetIcon(this.IconSet, this.CustomIconPath, trayIcon); // show baloon message if instance was started up if (mLastBundleStatus != pBundleStatus) { mLastBundleStatus = pBundleStatus; mLastBundleStatusChange = DateTime.Now; if (pBundleStatus == BundleStatus.RUNNING) { mBundleStatusRunningReported = false; } } if (pBundleStatus == BundleStatus.RUNNING && !mBundleStatusRunningReported && (DateTime.Now.Subtract(mLastBundleStatusChange).TotalMilliseconds > AEMManager.Properties.Settings.Default.ReportStatusChangeTimeout)) { mBundleStatusRunningReported = true; ShowNotfiyIconMessage("AEM instance is ready.", ToolTipIcon.Info); } }
private void IceServer_OnStatusChanged(BundleStatus status) { if (App.IsNewInstance) { return; } AddMessage($"Server Status: {status}"); if (status != BundleStatus.Running) { App.Current.Dispatcher.Invoke(() => { tbTime.Text = ""; }); timer?.Change(Timeout.Infinite, Timeout.Infinite); } Application.Current.Dispatcher.Invoke(delegate { labelServerStatus.Content = $"{status}"; labelServerStatus.Foreground = Brushes.SteelBlue; cbServerClose.IsEnabled = (status != BundleStatus.Running); cbServerHeartbeat.IsEnabled = (status != BundleStatus.Running); switch (status) { case BundleStatus.Unknown: labelServerStatus.Background = Brushes.Gray; labelServerStatus.Foreground = Brushes.White; break; case BundleStatus.Exception: labelServerStatus.Background = Brushes.OrangeRed; labelServerStatus.Foreground = Brushes.White; break; case BundleStatus.Running: labelServerStatus.Background = Brushes.LightGreen; labelServerStatus.Foreground = Brushes.DarkBlue; break; case BundleStatus.Stopped: labelServerStatus.Foreground = Brushes.Red; break; case BundleStatus.Idle: labelServerStatus.Background = Brushes.LightGray; labelServerStatus.Foreground = Brushes.DarkGreen; break; default: labelServerStatus.Background = Brushes.LightGoldenrodYellow; break; } }); }
internal void SetBundleStatus(string bundleId, BundleStatus status, string errorMessage = null) { var bundleInfo = Get(bundleId); bundleInfo.Status = status; if (!string.IsNullOrEmpty(errorMessage)) { bundleInfo.ErrorMessage = errorMessage; } if (status == BundleStatus.Finished || status == BundleStatus.Failed || status == BundleStatus.Duplication) { bundleInfo.Finished = DateTime.Now; } storage.Store(bundleInfo); }
public void Start(string args, ACMCloseFlag close = ACMCloseFlag.CloseOff, ACMHeartbeatFlag heartbeat = ACMHeartbeatFlag.HeartbeatOff) { acmClose = close; acmHeartbeat = heartbeat; if (communicator == null || communicator.isShutdown()) { Status = BundleStatus.Starting; try { const int SIZE_MAX = 128 * 1024 * 1024; var initData = new InitializationData(); initData.properties = Util.createProperties(); initData.properties.setProperty("Ice.Trace.Network", "2"); initData.properties.setProperty("Ice.MessageSizeMax", $"{SIZE_MAX}"); initData.properties.setProperty("Filesystem.MaxFileSize", $"{SIZE_MAX}"); initData.properties.setProperty("Ice.ACM.Close", $"{(int)acmClose}"); initData.properties.setProperty("Ice.ACM.Heartbeat", $"{(int)acmHeartbeat}"); communicator = Util.initialize(initData); var pos = args.IndexOf(':'); var name = "SimpleMessenger"; if (pos > 0) { name = args.Substring(0, pos); args = args.Substring(pos + 1).TrimStart(); } ObjectAdapter objectAdapter = communicator.createObjectAdapterWithEndpoints("SimpleMessengerAdapter", args); servant = new WorkerImpl(OnMethodInvoked); Identity id = Util.stringToIdentity(name); objectAdapter.add(servant, id); objectAdapter.activate(); Status = BundleStatus.Running; communicator.waitForShutdown(); Status = BundleStatus.Idle; } catch (System.Exception ex) { Status = BundleStatus.Exception; OnExceptionOccured?.Invoke(ex); } } else { Status = BundleStatus.Unknown; } }
public void Stop() { if (communicator != null) { Status = BundleStatus.Stopping; try { communicator.shutdown(); } catch (System.Exception ex) { Status = BundleStatus.Exception; OnExceptionOccured?.Invoke(ex); } Status = BundleStatus.Stopped; } else { Status = BundleStatus.Unknown; } }
public StdResult<Bundle> SetBundleStatus(DateTime date, BundleStatus status) { BundleDataService dal = new BundleDataService(); StdResult<Bundle> result = dal.Get(date); if (result.ReturnObject == null) throw new CollecteException("Bundle introuvable."); result.ReturnObject.Status = status; result = dal.Update(result.ReturnObject); return result; }
/// <summary> /// Updates tooltip text and icon of tray icon /// </summary> public void UpdateNofiyIconText(BundleStatus pBundleStatus) { mCurrentBundleStatus = pBundleStatus; string trayIcon = "trayicon_default"; string statusText = ""; switch (pBundleStatus) { case BundleStatus.NO_ACTIVE_INSTANCE: trayIcon = "trayicon_default"; break; case BundleStatus.DISABLED: trayIcon = "trayicon_disabled"; statusText = "not running"; break; case BundleStatus.UNKNOWN: trayIcon = "trayicon_unknown"; statusText = "server starting/stopping"; break; case BundleStatus.STARTING_STOPPING: trayIcon = "trayicon_starting"; statusText = "bundles starting/stopping"; break; case BundleStatus.RUNNING: trayIcon = "trayicon_running"; statusText = "running"; break; } this.NotifyIcon.Text = this.Name + " (" + statusText + ")"; this.NotifyIcon.Icon = IconCache.GetIcon(this.IconSet, this.CustomIconPath, trayIcon); // show baloon message if instance was started up if (mLastBundleStatus!=pBundleStatus) { mLastBundleStatus = pBundleStatus; mLastBundleStatusChange = DateTime.Now; if (pBundleStatus == BundleStatus.RUNNING) { mBundleStatusRunningReported = false; } } if (pBundleStatus == BundleStatus.RUNNING && !mBundleStatusRunningReported && (DateTime.Now.Subtract(mLastBundleStatusChange).TotalMilliseconds > AEMManager.Properties.Settings.Default.ReportStatusChangeTimeout)) { mBundleStatusRunningReported = true; ShowNotfiyIconMessage("AEM instance is ready.", ToolTipIcon.Info); } }
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 BundleInfo(string BundleID, LoadOrderType LoadOrderType) { this.BundleID = BundleID; this.LoadOrderType = LoadOrderType; Status = BundleStatus.Waiting; }
public async void Start(string args, bool hold = false, bool ami = false, ACMHeartbeatFlag heartbeat = ACMHeartbeatFlag.HeartbeatOff) { Hold = hold; amiEnabled = ami; acmHeartbeat = heartbeat; if (communicator == null || communicator.isShutdown()) { Status = BundleStatus.Starting; try { const int SIZE_MB = 128; const int SIZE_MAX = SIZE_MB * 1024 * 1024; if (contentSizeMB < 0 || contentSizeMB > SIZE_MB) { contentSizeMB = 1; } var initData = new InitializationData(); initData.properties = Util.createProperties(); initData.properties.setProperty("Ice.MessageSizeMax", $"{SIZE_MAX}"); initData.properties.setProperty("Filesystem.MaxFileSize", $"{SIZE_MAX}"); initData.properties.setProperty("Ice.ACM.Heartbeat", $"{(int)acmHeartbeat}"); communicator = Util.initialize(initData); WorkerPrx workerPrx = WorkerPrxHelper.checkedCast(communicator.stringToProxy(args)); if (workerPrx == null) { throw new ApplicationException("Invalid Proxy"); } isRunning = true; Status = BundleStatus.Running; while (isRunning && communicator != null) { if (Hold) { Thread.Sleep(100); continue; } var operation = operations[counter % operations.Count]; ++counter; OnMethodInvoked?.Invoke(operation, amiEnabled); if (amiEnabled) { try { var result = workerPrx?.PerformActionEx(operation, contentSizeMB); } catch (OperationException ex) { OnExceptionOccured?.Invoke(ex); } Thread.Sleep(rand.Next(200, 1000)); } else { try { var result = workerPrx?.PerformAction(operation, contentSizeMB); } catch (OperationException ex) { OnExceptionOccured?.Invoke(ex); } Thread.Sleep(500); } } Status = BundleStatus.Idle; } catch (System.Exception ex) { Status = BundleStatus.Exception; OnExceptionOccured?.Invoke(ex); } } else { isRunning = false; Status = BundleStatus.Unknown; } }