public class NodeInstance extends Object
Operations on the array/set of roles are synchronized.
| Modifier and Type | Class and Description |
|---|---|
static class |
NodeInstance.CompareNames
A comparator for sorting entries alphabetically
|
static class |
NodeInstance.MoreActiveThan
A comparator for sorting entries where the role is newer than
the other.
|
static class |
NodeInstance.Preferred
A comparator for sorting entries where the node is preferred over another.
|
| Constructor and Description |
|---|
NodeInstance(String hostname,
int roles)
Create an instance and the (empty) array of nodes
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canHost(int role,
String label)
Is this node instance a suitable candidate for the specific role?
|
boolean |
equals(Object o)
Equality test is purely on the hostname of the node address
|
boolean |
exceedsFailureThreshold(RoleStatus role)
Predicate to query if the number of recent failures of a role
on this node exceeds that role's failure threshold.
|
NodeEntry |
get(int role)
Get the entry for a role -if present
|
int |
getActiveRoleInstances(int role)
Count the number of active role instances on this node
|
int |
getLiveRoleInstances(int role)
Count the number of live role instances on this node
|
String |
getNodeLabels() |
NodeEntry |
getOrCreate(org.apache.hadoop.yarn.api.records.Container container)
Get the node entry matching a container on this node
|
NodeEntry |
getOrCreate(int role)
Get the entry for a role -if present
|
int |
hashCode() |
boolean |
isConsideredUnreliable(int role,
int threshold)
Query for a node being considered unreliable
|
boolean |
isOnline()
Is the node considered online
|
boolean |
purgeUnusedEntries(long absoluteTime)
run through each entry; gc'ing & removing old ones that don't have
a recent failure count (we care about those)
|
NodeEntry |
remove(int role)
Get the entry for a role -and remove it if present
|
void |
resetFailedRecently()
run through each entry resetting the failure count
|
NodeInformation |
serialize(Map<Integer,String> naming)
Produced a serialized form which can be served up as JSON
|
void |
set(int role,
NodeEntry nodeEntry) |
String |
toFullString()
Full dump of entry including children
|
String |
toString() |
boolean |
updateNode(org.apache.hadoop.yarn.api.records.NodeReport report)
Update the node status.
|
public final String hostname
public NodeInstance(String hostname, int roles)
roles - role count -the no. of rolespublic boolean updateNode(org.apache.hadoop.yarn.api.records.NodeReport report)
report - latest node reportpublic String getNodeLabels()
public NodeEntry get(int role)
role - role indexpublic NodeEntry getOrCreate(int role)
role - role indexArrayIndexOutOfBoundsException - if the role is out of rangepublic NodeEntry getOrCreate(org.apache.hadoop.yarn.api.records.Container container)
container - containerpublic int getActiveRoleInstances(int role)
role - role indexpublic int getLiveRoleInstances(int role)
role - role indexpublic boolean isOnline()
public boolean isConsideredUnreliable(int role,
int threshold)
role - role keythreshold - threshold above which a node is considered unreliablepublic NodeEntry remove(int role)
role - the role indexpublic void set(int role,
NodeEntry nodeEntry)
public boolean purgeUnusedEntries(long absoluteTime)
absoluteTime - age in millispublic void resetFailedRecently()
public String toFullString()
public boolean equals(Object o)
public boolean exceedsFailureThreshold(RoleStatus role)
role - role to look uppublic NodeInformation serialize(Map<Integer,String> naming)
naming - map of priority -> value for naming entriespublic boolean canHost(int role,
String label)
role - role IDlabel - label which must match, or "" for no label checksCopyright © 2014–2015 The Apache Software Foundation. All rights reserved.