Class KubernetesDistributedCache<K,V>
- java.lang.Object
-
- io.github.dhruv1110.jcachex.distributed.impl.AbstractDistributedCache<K,V>
-
- io.github.dhruv1110.jcachex.distributed.impl.KubernetesDistributedCache<K,V>
-
- Type Parameters:
K
- the type of keys maintained by this cacheV
- the type of mapped values
- All Implemented Interfaces:
DistributedCache<K,V>
public class KubernetesDistributedCache<K,V> extends AbstractDistributedCache<K,V>
Kubernetes-specific distributed cache implementation.This implementation extends
AbstractDistributedCache
and provides Kubernetes-specific node discovery and identification. It integrates seamlessly with Kubernetes environments using pod names and service discovery.Kubernetes Integration Features:
- Pod Name Identification: Uses Kubernetes pod names as node IDs
- Service Discovery: Integrates with Kubernetes service discovery
- Pod Lifecycle: Handles pod restarts and scaling events gracefully
- Resource Management: Respects Kubernetes resource limits
- Since:
- 1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KubernetesDistributedCache.Builder<K,V>
-
Nested classes/interfaces inherited from class io.github.dhruv1110.jcachex.distributed.impl.AbstractDistributedCache
AbstractDistributedCache.ConsistentHashRing, AbstractDistributedCache.NodeUpdateResult
-
Nested classes/interfaces inherited from interface io.github.dhruv1110.jcachex.distributed.DistributedCache
DistributedCache.ClusterTopology, DistributedCache.DistributedMetrics, DistributedCache.NodeInfo, DistributedCache.NodeStatus
-
-
Field Summary
-
Fields inherited from class io.github.dhruv1110.jcachex.distributed.impl.AbstractDistributedCache
clusterName, clusterNodes, communicationProtocol, conflictResolutions, currentMemoryBytes, currentNodeId, discoveryScheduler, distributionExecutor, hashRing, healthyNodes, isRunning, localCache, maxMemoryBytes, networkFailures, networkRequests, networkTimeout, nodeDiscovery, partitionCount, perNodeLatencies, readRepairEnabled, replicationLag, topologyVersion
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
KubernetesDistributedCache.Builder<K,V>builder()
protected String
generateNodeId()
Generate a unique node ID for this cache instance.DistributedCache.ClusterTopology
getClusterTopology()
Returns the current cluster topology.DistributedCache.DistributedMetrics
getDistributedMetrics()
Returns detailed metrics about distributed operations.Map<String,DistributedCache.NodeStatus>
getNodeStatuses()
Returns the status of each node in the cluster.Map<String,CacheStats>
getPerNodeStats()
Returns cache statistics for each node in the cluster.int
getReplicationFactor()
Returns the replication factor for this cache.protected void
initializeCluster()
Initialize cluster-specific functionality.CompletableFuture<Void>
migrateData(String fromNode, String toNode, Set<String> keys)
-
Methods inherited from class io.github.dhruv1110.jcachex.distributed.impl.AbstractDistributedCache
clearGlobally, estimateSize, evictToFreeMemory, get, getAsync, getFromRemoteNode, invalidateGlobally, invalidateGlobally, put, putAsync, putToRemoteNode, rebalance, rebalance, recordMemoryRemoval, recordMemoryUsage, remove, removeFromRemoteNode
-
-
-
-
Method Detail
-
generateNodeId
protected String generateNodeId()
Description copied from class:AbstractDistributedCache
Generate a unique node ID for this cache instance. Subclasses can override this for platform-specific node identification.- Overrides:
generateNodeId
in classAbstractDistributedCache<K,V>
-
initializeCluster
protected void initializeCluster()
Description copied from class:AbstractDistributedCache
Initialize cluster-specific functionality. Subclasses should implement this for their specific discovery mechanism.- Specified by:
initializeCluster
in classAbstractDistributedCache<K,V>
-
migrateData
public CompletableFuture<Void> migrateData(String fromNode, String toNode, Set<String> keys)
-
getClusterTopology
public DistributedCache.ClusterTopology getClusterTopology()
Description copied from interface:DistributedCache
Returns the current cluster topology.- Returns:
- cluster topology information
-
getPerNodeStats
public Map<String,CacheStats> getPerNodeStats()
Description copied from interface:DistributedCache
Returns cache statistics for each node in the cluster.- Returns:
- map of node ID to cache statistics
-
getNodeStatuses
public Map<String,DistributedCache.NodeStatus> getNodeStatuses()
Description copied from interface:DistributedCache
Returns the status of each node in the cluster.- Returns:
- map of node ID to node status
-
getDistributedMetrics
public DistributedCache.DistributedMetrics getDistributedMetrics()
Description copied from interface:DistributedCache
Returns detailed metrics about distributed operations.- Returns:
- distributed cache metrics
-
getReplicationFactor
public int getReplicationFactor()
Description copied from interface:DistributedCache
Returns the replication factor for this cache.- Returns:
- number of replicas maintained for each entry
-
builder
public static <K,V> KubernetesDistributedCache.Builder<K,V> builder()
-
-