private async Task <Response> PostRequestAsync <TReq>(string endpoint, TReq request, RequestOptions options) where TReq : class { options.ArgumentNotNull("request options"); endpoint.ArgumentNotNull("endpoint"); return(await ExecuteMethodAsync("POST", null, endpoint, request, options)); }
/// <summary> /// Initializes a new instance of the <see cref="HBaseClient" /> class. /// </summary> /// <remarks> /// To find the cluster vnet domain visit: /// https://azure.microsoft.com/en-us/documentation/articles/hdinsight-hbase-provision-vnet/ /// </remarks> /// <param name="numRegionServers">The number of region servers in the cluster.</param> /// <param name="clusterDomain">The fully-qualified domain name of the cluster.</param> public HBaseClient(int numRegionServers, string clusterDomain = null) : this(null, RequestOptions.GetDefaultOptions(), new LoadBalancerRoundRobin(numRegionServers, clusterDomain)) { }
private async Task <T> GetRequestAndDeserializeAsync <T>(string endpoint, string query, RequestOptions options) { options.ArgumentNotNull("request options"); endpoint.ArgumentNotNull("endpoint"); using (var response = await _requester.IssueWebRequestAsync(endpoint, query, "GET", null, options)) { using (var responseStream = response.WebResponse.GetResponseStream()) { return(Serializer.Deserialize <T>(responseStream)); } } }
private async Task <Response> GetRequestAsync(string endpoint, string query, RequestOptions options) { options.ArgumentNotNull("request options"); endpoint.ArgumentNotNull("endpoint"); return(await _requester.IssueWebRequestAsync(endpoint, query, "GET", null, options)); }
private async Task <bool> StoreCellsAsyncInternal(string table, CellSet cells, RequestOptions options, string key = null, string query = null) { var path = key == null ? table + "/somefalsekey" : table + "/" + key; // note the fake row key to insert a set of cells using (var webResponse = await PutRequestAsync(path, query, cells, options)) { if (webResponse.WebResponse.StatusCode == HttpStatusCode.NotModified) { return(false); } if (webResponse.WebResponse.StatusCode != HttpStatusCode.OK) { using (var output = new StreamReader(webResponse.WebResponse.GetResponseStream())) { var message = output.ReadToEnd(); throw new WebException( string.Format( "Couldn't insert into table {0}! Response code was: {1}, expected 200! Response body was: {2}", table, webResponse.WebResponse.StatusCode, message)); } } } return(true); }
private async Task <Response> DeleteRequestAsync <TReq>(string endpoint, TReq request, RequestOptions options) where TReq : class { return(await ExecuteMethodAsync("DELETE", null, endpoint, request, options)); }
private async Task <IEnumerable <CellSet> > StatelessScannerAsyncInternal(string tableName, string optionalRowPrefix, string scanParameters, RequestOptions options) { using (var webResponse = await GetRequestAsync(tableName + "/" + optionalRowPrefix + "*", scanParameters, options)) { if (webResponse.WebResponse.StatusCode == HttpStatusCode.OK) { return(ReadProtobufStream(webResponse.WebResponse.GetResponseStream())); } return(null); } }
/// <summary> /// Initializes a new instance of the <see cref="HBaseClient" /> class. /// </summary> /// <param name="credentials">The credentials.</param> public HBaseClient(ClusterCredentials credentials) : this(credentials, RequestOptions.GetDefaultOptions()) { }
private async Task ModifyTableSchemaAsyncInternal(string table, TableSchema schema, RequestOptions options) { using (var webResponse = await PostRequestAsync(table + "/schema", schema, options)) { if (webResponse.WebResponse.StatusCode != HttpStatusCode.OK && webResponse.WebResponse.StatusCode != HttpStatusCode.Created) { using (var output = new StreamReader(webResponse.WebResponse.GetResponseStream())) { var message = output.ReadToEnd(); throw new WebException( string.Format( "Couldn't modify table schema {0}! Response code was: {1}, expected either 200 or 201! Response body was: {2}", table, webResponse.WebResponse.StatusCode, message)); } } } }
private async Task <CellSet> ScannerGetNextAsyncInternal(ScannerInformation scannerInfo, RequestOptions options) { using (var webResponse = await GetRequestAsync(scannerInfo.TableName + "/scanner/" + scannerInfo.ScannerId, null, options)) { if (webResponse.WebResponse.StatusCode == HttpStatusCode.OK) { return(Serializer.Deserialize <CellSet>(webResponse.WebResponse.GetResponseStream())); } return(null); } }
public async Task <IEnumerable <CellSet> > StatelessScannerAsync(string tableName, string optionalRowPrefix = null, string scanParameters = null, RequestOptions options = null) { tableName.ArgumentNotNullNorEmpty("tableName"); var optionToUse = options ?? _globalRequestOptions; var rowPrefix = optionalRowPrefix ?? string.Empty; return(await optionToUse.RetryPolicy.ExecuteAsync(() => StatelessScannerAsyncInternal(tableName, rowPrefix, scanParameters, optionToUse))); }
/// <summary> /// Scans the next set of messages. /// </summary> /// <param name="scannerInfo">the scanner information retrieved by #CreateScanner()</param> /// <param name="options"> /// the request options, scan requests must set endpoint(Gateway mode) or host(VNET mode) to receive /// the scan request /// </param> /// <returns>a cellset, or null if the scanner is exhausted</returns> public async Task <CellSet> ScannerGetNextAsync(ScannerInformation scannerInfo, RequestOptions options) { scannerInfo.ArgumentNotNull("scannerInfo"); options.ArgumentNotNull("options"); return(await options.RetryPolicy.ExecuteAsync(() => ScannerGetNextAsyncInternal(scannerInfo, options))); }
/// <summary> /// Gets the cells asynchronous. /// </summary> /// <param name="tableName">Name of the table.</param> /// <param name="rowKeys">The row keys.</param> /// <param name="options">The request options.</param> /// <returns>A cell set</returns> public async Task <CellSet> GetCellsAsync(string tableName, string[] rowKeys, RequestOptions options = null) { tableName.ArgumentNotNullNorEmpty("tableName"); rowKeys.ArgumentNotNull("rowKey"); var optionToUse = options ?? _globalRequestOptions; var endpoint = tableName + "/multiget"; string query = null; for (var i = 0; i < rowKeys.Length; i++) { var prefix = "&"; if (i == 0) { prefix = ""; } query += prefix + "row=" + rowKeys[i]; } return(await optionToUse.RetryPolicy.ExecuteAsync(() => GetRequestAndDeserializeAsync <CellSet>(endpoint, query, optionToUse))); }
/// <summary> /// Deletes a table. /// If something went wrong, a WebException is thrown. /// </summary> /// <param name="table">the table name</param> public async Task DeleteTableAsync(string table, RequestOptions options = null) { table.ArgumentNotNullNorEmpty("table"); var optionToUse = options ?? _globalRequestOptions; await optionToUse.RetryPolicy.ExecuteAsync(() => DeleteTableAsyncInternal(table, optionToUse)); }
/// <summary> /// Deletes scanner. /// </summary> /// <param name="tableName">the table the scanner is associated with.</param> /// <param name="scannerInfo">the scanner information retrieved by #CreateScanner()</param> /// <param name="options"> /// the request options, scan requests must set endpoint(Gateway mode) or host(VNET mode) to receive /// the scan request /// </param> public async Task DeleteScannerAsync(string tableName, ScannerInformation scannerInfo, RequestOptions options) { tableName.ArgumentNotNullNorEmpty("tableName"); scannerInfo.ArgumentNotNull("scannerInfo"); options.ArgumentNotNull("options"); await options.RetryPolicy.ExecuteAsync(() => DeleteScannerAsyncInternal(tableName, scannerInfo, options)); }