Class CacheableAwsRestHighLevelClient
- java.lang.Object
-
- com.amazonaws.athena.connectors.elasticsearch.CacheableAwsRestHighLevelClient
-
public class CacheableAwsRestHighLevelClient extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static long
MAX_CACHE_AGE_MS
The maximum age allowed for stored clients in milliseconds (15 minutes).protected static int
MAX_CACHE_SIZE
The maximum number of clients allowed in the cache.
-
Constructor Summary
Constructors Constructor Description CacheableAwsRestHighLevelClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addClientEntry(String endpoint, AwsRestHighLevelClient client, long createTime)
AwsRestHighLevelClient
get(String endpoint)
Gets a client from the cache keyed on the endpoint.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.int
size()
-
-
-
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
-
-
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.
-
addClientEntry
protected void addClientEntry(String endpoint, AwsRestHighLevelClient client, long createTime)
-
-