Beispiel #1
0
        public ViewTableRegionForm(string tableName)
        {
            InitializeComponent();

            HBaseThriftClient client = SetThriftServerForm.GetHBaseThriftClient();
            var regions = client.TableRegionQuery(tableName);

            foreach (var regiongroup in regions.GroupBy(r => r.ServerName.GetUTF8String()))
            {
                TreeNode servernode = this.tvMain.Nodes.Add(regiongroup.Key);
                servernode.SetImageIndex(0);
                foreach (var region in regiongroup)
                {
                    TreeNode regionnode = servernode.Nodes.Add(region.Name.GetUTF8String());
                    regionnode.SetImageIndex(1);

                    TreeNode infonode = regionnode.Nodes.Add(string.Concat("StartKey:" + region.StartKey.GetUTF8String()));
                    infonode.SetImageIndex(2);
                    infonode = regionnode.Nodes.Add(string.Concat("EndKey:" + region.EndKey.GetUTF8String()));
                    infonode.SetImageIndex(2);
                }
            }

            this.tvMain.ExpandAll();
        }
Beispiel #2
0
 private void tsmiEnableTable_Click(object sender, EventArgs e)
 {
     try
     {
         HBaseThriftClient client = SetThriftServerForm.GetHBaseThriftClient();
         client.EnableTable(this.tvMain.SelectedNode.Text);
         this.btnRefresh_Click(null, null);
     }
     catch (Exception ex)
     {
         LogOperator.Get().Error(ex.ToString());
         MessageBoxOperator.ShowError(ex.Message);
     }
 }
Beispiel #3
0
        private void btnScanOpen_Click(object sender, EventArgs e)
        {
            try
            {
                List <string> checkedcolumns = new List <string>();
                foreach (TreeNode cnode in this.tvScanColumns.Nodes[0].Nodes)
                {
                    if (cnode.Checked)
                    {
                        checkedcolumns.Add(cnode.Text.Substring(0, cnode.Text.Length - 1));
                    }
                    else
                    {
                        foreach (TreeNode qnode in cnode.Nodes)
                        {
                            if (qnode.Checked)
                            {
                                checkedcolumns.Add(string.Concat(cnode.Text, qnode.Text));
                            }
                        }
                    }
                }

                if (checkedcolumns.Count != 0)
                {
                    if (this.cboScanMode.SelectedIndex == 0)
                    {
                        _scanID = SetThriftServerForm.GetHBaseThriftClient().GetScan(this.TableName, new byte[0], checkedcolumns);
                    }
                    else if (this.cboScanMode.SelectedIndex == 1)
                    {
                        _scanID = SetThriftServerForm.GetHBaseThriftClient().GetScanWithPrefix(this.TableName, this.txtScanValue1.Text.Trim().GetUTF8Bytes(), checkedcolumns);
                    }
                    else if (this.cboScanMode.SelectedIndex == 2)
                    {
                        _scanID = SetThriftServerForm.GetHBaseThriftClient().GetScanWithStop(this.TableName, this.txtScanValue1.Text.Trim().GetUTF8Bytes(), this.txtScanValue2.Text.Trim().GetUTF8Bytes(), checkedcolumns);
                    }
                    ChangeScanStatus(true);
                }
                else
                {
                    MessageBoxOperator.ShowInfo("Please Check one Column at least");
                }
            }
            catch (Exception ex)
            {
                MessageBoxOperator.ShowError(ex.Message);
                LogOperator.Get().Error(ex.ToString());
            }
        }
Beispiel #4
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            try
            {
                HBaseThriftClient client = SetThriftServerForm.GetHBaseThriftClient();
                var tables = client.GetAllTableDefinition();
                this.tvMain.Nodes[0].Nodes[0].Nodes.Clear();
                foreach (var table in tables)
                {
                    var tn = this.tvMain.Nodes[0].Nodes[0].Nodes.Add(table.Key);
                    tn.SetImageIndex(table.Value.Item2 ? 2 : 3);
                    tn.Tag = table.Value.Item1;

                    var schema = TableSchemaManager.GetInstance().Get(table.Key);
                    if (schema != null)
                    {
                        var ktn = tn.Nodes.Add("Row", string.Concat("Row", "(", schema.RowKeyType, ")"));
                        ktn.SetImageIndex(6);
                    }

                    foreach (var column in table.Value.Item1)
                    {
                        var stn = tn.Nodes.Add(column.StringName, string.Concat(column.StringName, "(", column.Compression, ")", "[", column.MaxVersions, "]"));
                        stn.SetImageIndex(4);
                        stn.Tag = column;
                        if (schema != null && schema.ColumnQualifierTypeAndFormats.ContainsKey(column.StringName))
                        {
                            foreach (var qualifier in schema.ColumnQualifierTypeAndFormats[column.StringName])
                            {
                                var qtn = stn.Nodes.Add(qualifier.Key, string.Concat(qualifier.Key, "(", qualifier.Value, ")"));
                                qtn.SetImageIndex(5);
                            }
                        }
                    }
                }
                this.tvMain.ExpandAll();
            }
            catch (Exception ex)
            {
                LogOperator.Get().Error(ex.ToString());
                MessageBoxOperator.ShowError(ex.Message);
            }
            finally
            {
                this.Enabled = true;
            }
        }
Beispiel #5
0
        private void btnCreateTable_Click(object sender, EventArgs e)
        {
            NewTableForm form = new NewTableForm();

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    HBaseThriftClient client = SetThriftServerForm.GetHBaseThriftClient();
                    client.CreateTable(form.TableName, null, form.Columns);
                    this.btnRefresh_Click(null, null);
                }
                catch (Exception ex)
                {
                    LogOperator.Get().Error(ex.ToString());
                    MessageBoxOperator.ShowError(ex.Message);
                }
            }
        }
Beispiel #6
0
 private void tsmiHbaseMaster_Click(object sender, EventArgs e)
 {
     Process.Start(string.Concat("http://" + SetThriftServerForm.GetHBaseMasterServerIP() + ":60010/master-status"));
 }
Beispiel #7
0
        private void btnSingleQuery_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(this.txtSingleQueryRowKey.Text))
            {
                this.Enabled = false;
                try
                {
                    this.ClearSingleQuery();
                    var    schema = TableSchemaManager.GetInstance().Get(this.TableName);
                    Type   t      = TableSchemaManager.ColumnDataTypes[schema.RowKeyType];
                    object v      = Convert.ChangeType(this.txtSingleQueryRowKey.Text, t);

                    byte[] rowkey = Extension.GetBytes(v, schema.RowKeyType, schema.RowKeyFormat);

                    List <string> checkedcolumns = new List <string>();
                    foreach (TreeNode cnode in this.tvQueryColumn.Nodes[0].Nodes)
                    {
                        if (cnode.Checked)
                        {
                            checkedcolumns.Add(cnode.Text.Substring(0, cnode.Text.Length - 1));
                        }
                        else
                        {
                            foreach (TreeNode qnode in cnode.Nodes)
                            {
                                if (qnode.Checked)
                                {
                                    checkedcolumns.Add(string.Concat(cnode.Text, qnode.Text));
                                }
                            }
                        }
                    }

                    if (checkedcolumns.Count != 0)
                    {
                        List <TRowResult> result = null;
                        long timestamp           = 0;
                        if (_enableSingleQueryTS.Checked)
                        {
                            timestamp = _singleQueryTS.Value.GetHBaseTimestamp();
                        }
                        result = SetThriftServerForm.GetHBaseThriftClient().SingleQuery(this.TableName, rowkey, checkedcolumns, timestamp);
                        if (result != null)
                        {
                            this.txtSingleQueryResult.Text   = TableSchemaManager.GetInstance().ProcessTRowResultToString(this.TableName, result);
                            this.txtSingleQueryRowCount.Text = result.Count.ToString();
                        }
                    }
                    else
                    {
                        MessageBoxOperator.ShowInfo("Please Check one Column at least");
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxOperator.ShowError(ex.Message);
                    LogOperator.Get().Error(ex.ToString());
                }
                finally
                {
                    this.Enabled = true;
                }
            }
        }