@ThreadSafe public class HubCluster extends Object implements ProtoConverter<HubCluster>, AutoCloseable
Constructor and Description |
---|
HubCluster(ScheduledExecutorService svc,
long lostThreshold,
long deleteThreshold)
Creates a new instance of
HubCluster . |
HubCluster(ScheduledExecutorService svc,
long lostThreshold,
long deleteThreshold,
AlluxioCluster alluxioCluster)
Creates a new instance of
HubCluster . |
Modifier and Type | Method and Description |
---|---|
void |
add(HubNodeAddress addr)
Add a new node to the cluster.
|
Set<HubNodeAddress> |
allNodes() |
void |
close() |
<T> Map<HubNodeAddress,T> |
exec(Set<HubNodeAddress> hosts,
AlluxioConfiguration conf,
java.util.function.Function<AgentManagerServiceGrpc.AgentManagerServiceBlockingStub,T> action,
ExecutorService svc)
Execute an RPC action on all nodes in the cluster.
|
AlluxioCluster |
getAlluxioCluster()
Get alluxio cluster.
|
void |
heartbeat(HubNodeAddress addr)
heartbeats to update the state of the node with the given address.
|
Set<String> |
hosts() |
Set<HubNodeAddress> |
nodesFromAlluxio(AlluxioCluster cluster,
AlluxioNodeType type)
Returns a set of Hub nodes corresponding to the given
AlluxioNodeType from an
AlluxioCluster . |
boolean |
remove(HubNodeAddress addr)
Removes a node from the cluster.
|
int |
size() |
HubCluster |
toProto()
Converts an objects representation into a protobuf type.
|
public HubCluster(ScheduledExecutorService svc, long lostThreshold, long deleteThreshold)
HubCluster
.svc
- the executor service used to run event handlerslostThreshold
- the amount of time before an agent should be considered
HubNodeState.LOST
deleteThreshold
- the amount fo time before an agent should be removed from the clusterpublic HubCluster(ScheduledExecutorService svc, long lostThreshold, long deleteThreshold, AlluxioCluster alluxioCluster)
HubCluster
.svc
- the executor service used to run event handlerslostThreshold
- the amount of time before an agent should be considered
HubNodeState.LOST
deleteThreshold
- the amount fo time before an agent should be removed from the clusteralluxioCluster
- the alluxio cluster that the hub cluster is managingpublic void add(HubNodeAddress addr)
addr
- the given addressIllegalArgumentException
- when either the hostname or port do not existpublic void heartbeat(HubNodeAddress addr)
addr
- the address to heartbeatpublic boolean remove(HubNodeAddress addr)
addr
- the node address to removepublic int size()
public <T> Map<HubNodeAddress,T> exec(Set<HubNodeAddress> hosts, AlluxioConfiguration conf, java.util.function.Function<AgentManagerServiceGrpc.AgentManagerServiceBlockingStub,T> action, ExecutorService svc) throws RuntimeException
T
- the type of response from the RPC functionhosts
- the hosts to execute onconf
- alluxio configurationaction
- the client action to performsvc
- an executor service to run the RPCs in parallelaction
argumentRuntimeException
- when the RPC client fail to be created or any of the RPCs failpublic Set<HubNodeAddress> nodesFromAlluxio(AlluxioCluster cluster, AlluxioNodeType type)
AlluxioNodeType
from an
AlluxioCluster
.cluster
- the alluxio cluster to query fromtype
- the type of Alluxio node to query forpublic Set<HubNodeAddress> allNodes()
public AlluxioCluster getAlluxioCluster()
public HubCluster toProto()
ProtoConverter
toProto
in interface ProtoConverter<HubCluster>
public void close()
close
in interface AutoCloseable
Copyright © 2023. All Rights Reserved.