"Zhengze Shen" [email protected] wrote:
Hello,
Does an instance of the class StudentListIterator receive so many retries in total or is the number of retries simply for each getPage() operation? (say, 200 pages, each getPage() requires 3 retries, and if we iterate through all 200 pages, then the total number of retries is 600?)
I think your wording is a little unclear, so I am not 100% sure I understand what you are asking. I believe you are asking whether the specified number of retries is for the whole lifetime of the StudentListIterator, or for each attempt to call getPage()
.
I will draw your attention to the documentation on the StudentListIterator
class that says:
/**
* Construct an iterator over the given {@link StudentList} with the specified retry quota.
*
* @param list The API interface.
* @param retries The number of times to retry a query after getting {@link
* QueryTimedOutException} before declaring the API unreachable and throwing an {@link
* ApiUnreachableException}.
*/
public StudentListIterator(StudentList list, int retries) {
// TASK(8): Implement StudentListIterator
}
retries
is "The number of times to retry a query after getting QueryTimedOutException
before declaring the API unreachable and throwing an ApiUnreachableException
."
Additionally, the instructions say "Since calls to getPage()
may fail with a QueryTimedOutException
, your implementation should retry the connection in case it was just a momentary failure. A retry quota is given when constructing the iterator. If the API is still not reachable after exceeding the retry quota, you should raise an ApiUnreachableException
."
Of note is that we specify that it should "retry a query", and that we are looking to handle a momentary failure.
As such, I think it is clear that you should throw an ApiUnreachableException
only after getting retries
timeouts while trying to perform a single query.
This is also clear from the tests. In particular, testRetries()
ensures that your solution does not throw an ApiUnreachableException
even though it receives many scattered QueryTimedOutException
s, but when receiving too many QueryTimedOutException
s in a row, it does throw an ApiUnreachableException
.
I hope that has clarified the issue for you.
Gozz