public static void MonitorHBase() { LOG.DebugFormat("Monitoring records in HBase: {0}. Use 'Ctrl-C' to break out of the application.", HDInsightHelper.HBaseCluster.Name); var hbClient = new HBaseReaderClient( HDInsightHelper.HBaseCluster.ConnectionUrl, HDInsightHelper.HBaseCluster.HttpUserName, HDInsightHelper.HBaseCluster.HttpPassword); List <string> RandomResponses = new List <string>() { HttpStatusCode.OK.ToString(), HttpStatusCode.BadRequest.ToString(), HttpStatusCode.NotFound.ToString(), HttpStatusCode.InternalServerError.ToString() }; while (true) { foreach (var response in RandomResponses) { var dateTime = DateTime.UtcNow; var startKey = response + KEY_DELIMITER + dateTime.AddMinutes(-30).Floor().ToString(DATE_TIME_FORMAT); var endKey = response + KEY_DELIMITER + dateTime.Floor().ToString(DATE_TIME_FORMAT); //TODO - Change table name according to aggregation primary or secondary key var tableName = "EHResultClientTable"; LOG.InfoFormat("Scanning HBase Aggreagations - " + "Table: {0}, StartKey: {1}, EndKey: {2}", tableName, startKey, endKey); var records = hbClient.AggregateAndOrderHBaseResultSetByValues( hbClient.ScanHBase(tableName, startKey, endKey)); if (records.Count > 0) { var sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(String.Format("Table: {0}, StartKey: {1}, EndKey: {2}", tableName, startKey, endKey)); foreach (var r in records) { sb.AppendLine(String.Format("Column = {0}, AggreagatedValue = {1}", r.Key, r.Value)); } sb.AppendLine(); LOG.InfoFormat(sb.ToString()); } else { LOG.Info("No records found!"); } } Thread.Sleep(TimeSpan.FromMinutes(1)); } }
public static void MonitorHBase() { LOG.DebugFormat("Monitoring records in HBase: {0}. Use 'Ctrl-C' to break out of the application.", HDInsightHelper.HBaseCluster.Name); var hbClient = new HBaseReaderClient( HDInsightHelper.HBaseCluster.ConnectionUrl, HDInsightHelper.HBaseCluster.HttpUserName, HDInsightHelper.HBaseCluster.HttpPassword); List<string> RandomResponses = new List<string>() { HttpStatusCode.OK.ToString(), HttpStatusCode.BadRequest.ToString(), HttpStatusCode.NotFound.ToString(), HttpStatusCode.InternalServerError.ToString()}; while (true) { foreach (var response in RandomResponses) { var dateTime = DateTime.UtcNow; var startKey = response + KEY_DELIMITER + dateTime.AddMinutes(-30).Floor().ToString(DATE_TIME_FORMAT); var endKey = response + KEY_DELIMITER + dateTime.Floor().ToString(DATE_TIME_FORMAT); //TODO - Change table name according to aggregation primary or secondary key var tableName = "EHResultClientTable"; LOG.InfoFormat("Scanning HBase Aggreagations - " + "Table: {0}, StartKey: {1}, EndKey: {2}", tableName, startKey, endKey); var records = hbClient.AggregateAndOrderHBaseResultSetByValues( hbClient.ScanHBase(tableName, startKey, endKey)); if (records.Count > 0) { var sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(String.Format("Table: {0}, StartKey: {1}, EndKey: {2}", tableName, startKey, endKey)); foreach (var r in records) { sb.AppendLine(String.Format("Column = {0}, AggreagatedValue = {1}", r.Key, r.Value)); } sb.AppendLine(); LOG.InfoFormat(sb.ToString()); } else { LOG.Info("No records found!"); } } Thread.Sleep(TimeSpan.FromMinutes(1)); } }