/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param> /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param> /// <param name="cancellationToken">An optional token for canceling the call.</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request, Grpc.Core.Metadata headers = null, DateTime?deadline = null, CancellationToken cancellationToken = default) { HashResponse response = new HashResponse(); bool success = false; int retryCount = 0; while (!success) { try { response = await _balancer.GetConnection().maintenanceClient .HashAsync(request, headers, deadline, cancellationToken); success = true; } catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable) { retryCount++; if (retryCount >= _balancer._numNodes) { throw; } } } return(response); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request, Metadata headers = null) { HashResponse response = new HashResponse(); bool success = false; int retryCount = 0; while (!success) { try { response = await _balancer.GetConnection().maintenanceClient.HashAsync(request, headers); success = true; } catch (RpcException ex) when(ex.StatusCode == StatusCode.Unavailable) { retryCount++; if (retryCount >= _balancer._numNodes) { throw ex; } } } return(response); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request, Metadata headers = null) { HashResponse response = new HashResponse(); response = await _balancer.GetConnection().maintenanceClient.HashAsync(request, headers); return(response); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public HashResponse Hash(HashRequest request, Metadata headers = null) { HashResponse response = new HashResponse(); response = _balancer.GetConnection().maintenanceClient.Hash(request, headers); return(response); }
public override Task <HashResponse> GetHash(HashRequest request, ServerCallContext context) { _logger.LogDebug("Getting hash for {request}", request); var hashResponse = new HashResponse { Hash = GetSha256Hash(request.Input) }; _logger.LogDebug("Hash generated for {request} is {response}", request, hashResponse); return(Task.FromResult(hashResponse)); }
public async Task <IActionResult> Post([FromBody] UserCredential userCredential) { string key = $"{userCredential.Login}+{userCredential.Password}"; string hashVal = await client.GetHash(key); HashResponse resp = new HashResponse() { hash_value = hashVal }; return(Ok(resp)); }
public IHttpActionResult Post([FromBody] HashRequest hashRequest) { IHasher hasher = new HashFactory().Instantiate(hashRequest.Operation, hashRequest.Info.Key); byte[] stringToHash = CalculateStringToHash(hashRequest); byte[] hash = hasher.Hash(stringToHash); HashResponse hashResponse = new HashResponse { Hex = BitConverter.ToString(hash).Replace("-", ""), Base64 = Convert.ToBase64String(hash), Timestamp = DateTime.Now.ToString() }; return(Ok(hashResponse)); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage in async. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public async Task <HashResponse> HashAsync(HashRequest request) { HashResponse response = new HashResponse(); try { response = await _maintenanceClient.HashAsync(request); } catch (RpcException) { ResetConnection(); throw; } catch { throw; } return(response); }
/// <summary> /// Hash computes the hash of whole backend keyspace, /// including key, lease, and other buckets in storage. /// This is designed for testing ONLY! /// Do not rely on this in production with ongoing transactions, /// since Hash operation does not hold MVCC locks. /// Use "HashKV" API instead for "key" bucket consistency checks. /// </summary> /// <param name="request">Hash Request</param> /// <returns>Hash Response</returns> public HashResponse Hash(HashRequest request) { HashResponse response = new HashResponse(); try { response = _maintenanceClient.Hash(request); } catch (RpcException) { ResetConnection(); throw; } catch { throw; } return(response); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); var requestBody = await new StreamReader(req.Body).ReadToEndAsync(); var data = JsonSerializer.Deserialize <LoginDataRequest>(requestBody); var hash = new Hash().GenerateHash(data); var response = new HashResponse { Hash = hash }; log.LogInformation($"Generating hash {hash}"); var d = JsonSerializer.Serialize(response); return(new OkObjectResult(d)); }