Class CacheableAwsRestHighLevelClient


  • public class CacheableAwsRestHighLevelClient
    extends Object
    • Field Detail

      • MAX_CACHE_AGE_MS

        protected static final long MAX_CACHE_AGE_MS
        The maximum age allowed for stored clients in milliseconds (15 minutes).
        See Also:
        Constant Field Values
      • MAX_CACHE_SIZE

        protected static final int MAX_CACHE_SIZE
        The maximum number of clients allowed in the cache.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CacheableAwsRestHighLevelClient

        public CacheableAwsRestHighLevelClient()
    • Method Detail

      • get

        public AwsRestHighLevelClient get​(String endpoint)
        Gets a client from the cache keyed on the endpoint. If the client retrieved has aged out, or is unhealthy, then evict it.
        Parameters:
        endpoint - is the http address associated with the client.
        Returns:
        a client (if one exist, is age-appropriate, and is healthy), or null (if none of the aforementioned conditions are met).
      • put

        public void put​(String endpoint,
                        AwsRestHighLevelClient client)
        Sets a client in the cache keyed on the endpoint and process cache eviction based on cache capacity limit.
        Parameters:
        endpoint - is the http address associated with the client.
        client - is a REST client used for communication with an Elasticsearch instance.
      • size

        public int size()
        Returns:
        the number of clients stored in the cache.