private async void RetrieveZookeeperBrokerTopics()
        {
            if (string.IsNullOrEmpty(ZookeeperHostServer))
            {
                CurrentStatus = $"Zookeeper hosts is empty!";
                MessageBox.Show("Please specify at least one zookeeper server!");
                settings_valid = false;
                return;
            }
            if (!ValidateZookeeperSettings())
            {
                CurrentStatus  = $"Zookeeper hosts specified is not valid!";
                settings_valid = false;
                MessageBox.Show("Zookeeper hosts specified is invalid! \r\n Please see format indicated in wartermark text!", "Zookeeper host is invalid");
                return;
            }

            if (TopicItems.Any())
            {
                TopicItems.Clear();
            }

            using (IZookeeperClient client = new ZookeeperClient(new ZookeeperClientOptions(ZookeeperHostServer)
            {
                BasePath = "/",                               //default value
                ConnectionTimeout = TimeSpan.FromSeconds(10), //default value
                SessionTimeout = TimeSpan.FromSeconds(20),    //default value
                OperatingTimeout = TimeSpan.FromSeconds(60),  //default value
                ReadOnly = false,                             //default value
                SessionId = 0,                                //default value
                SessionPasswd = null,                         //default value
                EnableEphemeralNodeRestore = true             //default value
            }))
            {
                CurrentStatus = $"Retrieving data from Zookeeper server {ZookeeperHostServer}.";
                try
                {
                    var childNodes = await client.GetChildrenAsync("/brokers/topics");

                    if (childNodes.Any())
                    {
                        Dispatcher.CurrentDispatcher.Invoke(() => {
                            TopicItems.AddRange(childNodes);
                            CanSelectTopic = true;
                            CurrentStatus  = $"Zookeeper topics has been fetched successfully.";
                        });
                    }
                }
                catch (Exception ex)
                {
                    settings_valid = false;
                    TopicItems.Clear();
                    CurrentStatus = $"Error occurs when communicating with Zookeeper '{ZookeeperHostServer}'. {ex.Message}";
                }
                finally
                {
                    client.Dispose();
                }
            }
        }
예제 #2
0
        private async Task QueryTopics()
        {
            if (page == 1)
            {
                if (TopicItems == null)
                {
                    TopicItems = new ObservableCollection <TopicItem>();
                }
                else
                {
                    TopicItems.Clear();
                }
            }

            UserContentProvider   user   = new UserContentProvider();
            List <DiscoverResult> reuslt = await user.QueryTopic(TypeSelectedItem.Type, page, GlobalValue.CurrentUserContext.UserId, GlobalValue.CurrentUserContext.MobileToken);

            reuslt.ForEach(x => TopicItems.Add(ConvertToTopicItem(x)));

            page++;
        }