private void btnSave_Click(object sender, EventArgs e) { this.dgvColumn.EndEdit(); if (!string.IsNullOrWhiteSpace(this.txtTableName.Text)) { this.TableName = this.txtTableName.Text.Trim(); this.Columns.Clear(); List <string> names = new List <string>(); foreach (DataGridViewRow row in this.dgvColumn.Rows) { string name = row.GetCellStringValue(0); if (name != null) { if (!names.Contains(name)) { names.Add(name); if (!name.Contains(":")) { var cd = new ColumnDescriptor(); cd.StringName = name + ":"; cd.InMemory = row.Cells[1].Value == null ? false : (bool)row.Cells[1].Value; cd.Compression = row.Cells[2].Value == null ? null : row.Cells[2].Value.ToString(); int?timetolive = row.GetCellIntValue(3); if (timetolive.HasValue) { cd.TimeToLive = timetolive.Value; } int?maxversions = row.GetCellIntValue(4); cd.MaxVersions = maxversions.HasValue ? maxversions.Value : 1; this.Columns.Add(cd); } else { MessageBoxOperator.ShowError("Family Name Can't Contain ':'"); return; } } else { MessageBoxOperator.ShowError("Duplicate Family Name!"); return; } } } if (Columns.Count != 0) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxOperator.ShowError("Empty Family List!"); } } else { MessageBoxOperator.ShowError("Table Name is Empty!"); this.txtTableName.Focus(); } }
private void tsmiOperateData_Click(object sender, EventArgs e) { if (TableSchemaManager.GetInstance().Schemas.ContainsKey(this.tvMain.SelectedNode.Text)) { MainForm.AddDataManagementForm(this.tvMain.SelectedNode.Text, this.tvMain.SelectedNode.Tag as ColumnDescriptor[]); } else { MessageBoxOperator.ShowWarning("Please Set Table Schema First!"); } }
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); } }
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()); } }
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; } }
private void btnScanClose_Click(object sender, EventArgs e) { try { HBaseThriftClient.CloseScan(_scanID); } catch (Exception ex) { MessageBoxOperator.ShowError(ex.Message); LogOperator.Get().Error(ex.ToString()); } finally { ChangeScanStatus(false); } }
private void btnSave_Click(object sender, EventArgs e) { IPAddress address = null; if (IPAddress.TryParse(this.txtServerIP.Text, out address)) { ConfigOperator.SaveAppConfig(new Dictionary <string, object>() { { "ThriftServer", this.txtServerIP.Text.Trim() + ":" + ((int)this.nudServerPort.Value).ToString() }, }); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxOperator.ShowError("Illegal IP Address!"); } }
private void btnSave_Click(object sender, EventArgs e) { this.dgvColumn.EndEdit(); Dictionary <string, Tuple <string, string> > newcolumns = new Dictionary <string, Tuple <string, string> >(); foreach (DataGridViewRow row in this.dgvColumn.Rows) { if (row.Cells[0].Value != null && !string.IsNullOrWhiteSpace(row.Cells[0].Value.ToString()) && row.Cells[1].Value != null && !string.IsNullOrWhiteSpace(row.Cells[1].Value.ToString()) && row.Cells[2].Value != null && !string.IsNullOrWhiteSpace(row.Cells[2].Value.ToString())) { if (row.Cells[0].Value.ToString().Trim().Contains(":")) { if (row.Cells[0].Value.ToString().Trim().IndexOf(':') != row.Cells[0].Value.ToString().Trim().Length - 1) { newcolumns.Add(row.Cells[0].Value.ToString().Trim(), new Tuple <string, string>(row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString())); } else { MessageBoxOperator.ShowError("Empty Qualifier,like Family:Qualifier!"); return; } } else { MessageBoxOperator.ShowError("ColumnName Must Contain ':',like Family:Qualifier!"); return; } } } if (this.cboRowKeyType.SelectedItem != null) { TableSchemaManager.GetInstance().Schemas[this.lbSchema.SelectedItem.ToString()] = new TableSchema() { RowKeyType = this.cboRowKeyType.SelectedItem.ToString(), RowKeyFormat = this.cboRowKeyFormat.SelectedItem.ToString(), ColumnTypeAndFormats = newcolumns }; } else { MessageBoxOperator.ShowError("Must select row key type!"); return; } }
private void btnScanNext_Click(object sender, EventArgs e) { try { this.ClearScanQuery(); var result = HBaseThriftClient.DoScan(_scanID, (int)_maxScanCount.Value); if (result != null) { this.txtScanResult.Text = TableSchemaManager.GetInstance().ProcessTRowResultToString(this.TableName, result); this.txtScanRowCount.Text = result.Count.ToString(); } } catch (Exception ex) { MessageBoxOperator.ShowError(ex.Message); LogOperator.Get().Error(ex.ToString()); } }
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); } } }
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; } } }