Class FixedTimeoutHandler

java.lang.Object
org.tinyradius.io.client.timeout.FixedTimeoutHandler
All Implemented Interfaces:
TimeoutHandler

public class FixedTimeoutHandler
extends java.lang.Object
implements TimeoutHandler
TimeoutHandler that waits a fixed period for every timeout, up to a predefined max attempt count.
  • Constructor Summary

    Constructors 
    Constructor Description
    FixedTimeoutHandler​(io.netty.util.Timer timer)  
    FixedTimeoutHandler​(io.netty.util.Timer timer, int maxAttempts, int timeoutMs)  
  • Method Summary

    Modifier and Type Method Description
    void onTimeout​(java.lang.Runnable callback, int totalAttempts, io.netty.util.concurrent.Promise<RadiusResponse> promise)
    Schedule a retry in the future.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FixedTimeoutHandler

      public FixedTimeoutHandler​(io.netty.util.Timer timer)
    • FixedTimeoutHandler

      public FixedTimeoutHandler​(io.netty.util.Timer timer, int maxAttempts, int timeoutMs)
      Parameters:
      timer - netty timer for timing out requests
      maxAttempts - max number of attempts to try before returning failure
      timeoutMs - time to wait before timeout or next retry, in milliseconds
  • Method Details

    • onTimeout

      public void onTimeout​(java.lang.Runnable callback, int totalAttempts, io.netty.util.concurrent.Promise<RadiusResponse> promise)
      Description copied from interface: TimeoutHandler
      Schedule a retry in the future. Invoked immediately after a request is sent to schedule next retry.

      When retry is due to run, should also check if promise isDone() before running.

      Implemented here instead of RadiusClient so custom scheduling / retry backoff can be used depending on implementation, and actual retry can be deferred. Scheduling and logic should be implemented here, while RadiusClient only deals with IO.

      Specified by:
      onTimeout in interface TimeoutHandler
      Parameters:
      callback - runnable to invoke to retry
      totalAttempts - current attempt count
      promise - request promise that resolves when a response is received