This pull request aims to improve the reliability and efficiency of the Typesense Java client by enhancing node health checks and API call logic. It's addressing potential issues (#61) with node selection and improving testing coverage to ensure more robust behavior in cluster configuration scenarios.
Changes
Added Features:
New Methods in APICallTest.java:
setUpNoNearestNode(): Sets up test scenarios without a nearest node.
setUpNearestNode(): Sets up test scenarios with a nearest node.
New Test Cases in APICallTest.java:
testUnhealthyNearestNode(): Verifies correct node selection when the nearest node is unhealthy.
testHealthyNearestNode(): Ensures the nearest node is selected when healthy.
testUnhealthyNearestNodeDueForHealthCheck(): Checks if an unhealthy nearest node is selected for a health check after a certain time.
Code Changes:
In Node.java:
Added initialization of lastAccessTimestamp in the constructor to support health check scheduling.
In ApiCall.java:
Adjusted the condition in getNode() method to prioritize checking if the nearest node is healthy before checking if it's due for a health check, to avoid running more checks, as the first OR statement that resolves to true will make the condition exit.
What is this?
This pull request aims to improve the reliability and efficiency of the Typesense Java client by enhancing node health checks and API call logic. It's addressing potential issues (#61) with node selection and improving testing coverage to ensure more robust behavior in cluster configuration scenarios.
Changes
Added Features:
New Methods in
APICallTest.java
:setUpNoNearestNode()
: Sets up test scenarios without a nearest node.setUpNearestNode()
: Sets up test scenarios with a nearest node.New Test Cases in
APICallTest.java
:testUnhealthyNearestNode()
: Verifies correct node selection when the nearest node is unhealthy.testHealthyNearestNode()
: Ensures the nearest node is selected when healthy.testUnhealthyNearestNodeDueForHealthCheck()
: Checks if an unhealthy nearest node is selected for a health check after a certain time.Code Changes:
In
Node.java
:lastAccessTimestamp
in the constructor to support health check scheduling.In
ApiCall.java
:getNode()
method to prioritize checking if the nearest node is healthy before checking if it's due for a health check, to avoid running more checks, as the first OR statement that resolves to true will make the condition exit.PR Checklist