/// <summary> /// Connect to the Jolokia server, with the given Jolokia URL /// </summary> /// <returns></returns> public async Task Connect() { CanConnect = false; NotifyOfPropertyChange(nameof(CanConnect)); try { _jolokia = await Jolokia.Create(new Uri(JolokiaUri)); } catch (Exception ex) { // show the error message await Dialogcoordinator.ShowMessageAsync(this, "Error", ex.Message, MessageDialogStyle.AffirmativeAndNegative); // Enable the connect button again CanConnect = true; NotifyOfPropertyChange(nameof(CanConnect)); return; } await _jolokia.LoadListAsync("java.lang", "type=Memory"); var javaLangDomain = _jolokia.Domains["java.lang"]; var memoryMBean = (from mbean in javaLangDomain.Values where mbean.Name == "type=Memory" select mbean).First(); _garbageCollectOperation = (from operation in memoryMBean.Operations where operation.Key == "gc" select operation.Value).First(); _heapMemoryUsageAttribute = (from attribute in memoryMBean.Attributes where attribute.Key == "HeapMemoryUsage" select attribute.Value).First(); _nonHeapMemoryUsageAttribute = (from attribute in memoryMBean.Attributes where attribute.Key == "NonHeapMemoryUsage" select attribute.Value).First(); await ReadValuesAsync(); Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(10)) .SubscribeOn(NewThreadScheduler.Default) .ObserveOn(DispatcherScheduler.Current) .Subscribe(async tick => await ReadValuesAsync()); CanGarbageCollect = true; NotifyOfPropertyChange(nameof(CanGarbageCollect)); }
/// <summary> /// Connect to the Jolokia server, with the given Jolokia URL /// </summary> /// <returns></returns> public async Task Connect() { UpdateCanConnect(disable: true); try { _jolokia = await Jolokia.Create(JolokiaConfiguration.JolokiaUri); } catch (Exception ex) { // show the error message await Dialogcoordinator.ShowMessageAsync(this, "Error", ex.Message, MessageDialogStyle.AffirmativeAndNegative); // Enable the connect button again UpdateCanConnect(); return; } await _jolokia.LoadListAsync("java.lang", "type=Memory"); var javaLangDomain = _jolokia.Domains["java.lang"]; var memoryMBean = (from mbean in javaLangDomain.Values where mbean.Name == "type=Memory" select mbean).First(); _garbageCollectOperation = (from operation in memoryMBean.Operations where operation.Key == "gc" select operation.Value).First(); _heapMemoryUsageAttribute = (from attribute in memoryMBean.Attributes where attribute.Key == "HeapMemoryUsage" select attribute.Value).First(); _nonHeapMemoryUsageAttribute = (from attribute in memoryMBean.Attributes where attribute.Key == "NonHeapMemoryUsage" select attribute.Value).First(); await ReadValuesAsync(); Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(10)) .SubscribeOn(NewThreadScheduler.Default) .ObserveOn(DispatcherScheduler.Current) .Subscribe(async tick => await ReadValuesAsync()); CanGarbageCollect = true; NotifyOfPropertyChange(nameof(CanGarbageCollect)); }