/** * Query for a node being considered unreliable * @param role role key * @param threshold threshold above which a node is considered unreliable * @return true if the node is considered unreliable */ public boolean isConsideredUnreliable(int role, int threshold) { NodeEntry entry = get(role); return entry != null && entry.getFailedRecently() > threshold; }
/** * Query for a node being considered unreliable * @param role role key * @param threshold threshold above which a node is considered unreliable * @return true if the node is considered unreliable */ public boolean isConsideredUnreliable(int role, int threshold) { NodeEntry entry = get(role); return entry != null && entry.getFailedRecently() > threshold; }
/** * run through each entry; gc'ing & removing old ones that don't have * a recent failure count (we care about those) * @param absoluteTime age in millis * @return true if there are still entries left */ public synchronized boolean purgeUnusedEntries(long absoluteTime) { boolean active = false; ListIterator<NodeEntry> entries = nodeEntries.listIterator(); while (entries.hasNext()) { NodeEntry entry = entries.next(); if (entry.notUsedSince(absoluteTime) && entry.getFailedRecently() == 0) { entries.remove(); } else { active = true; } } return active; }
/** * run through each entry; gc'ing & removing old ones that don't have * a recent failure count (we care about those) * @param absoluteTime age in millis * @return true if there are still entries left */ public synchronized boolean purgeUnusedEntries(long absoluteTime) { boolean active = false; ListIterator<NodeEntry> entries = nodeEntries.listIterator(); while (entries.hasNext()) { NodeEntry entry = entries.next(); if (entry.notUsedSince(absoluteTime) && entry.getFailedRecently() == 0) { entries.remove(); } else { active = true; } } return active; }
/** * Predicate to query if the number of recent failures of a role * on this node exceeds that role's failure threshold. * If there is no record of a deployment of that role on this * node, the failure count is taken as "0". * @param role role to look up * @return true if the failure rate is above the threshold. */ public boolean exceedsFailureThreshold(RoleStatus role) { NodeEntry entry = get(role.getKey()); int numFailuresOnLastHost = entry != null ? entry.getFailedRecently() : 0; int failureThreshold = role.getNodeFailureThreshold(); return failureThreshold < 0 || numFailuresOnLastHost > failureThreshold; }
/** * Predicate to query if the number of recent failures of a role * on this node exceeds that role's failure threshold. * If there is no record of a deployment of that role on this * node, the failure count is taken as "0". * @param role role to look up * @return true if the failure rate is above the threshold. */ public boolean exceedsFailureThreshold(RoleStatus role) { NodeEntry entry = get(role.getKey()); int numFailuresOnLastHost = entry != null ? entry.getFailedRecently() : 0; int failureThreshold = role.getNodeFailureThreshold(); return failureThreshold < 0 || numFailuresOnLastHost > failureThreshold; }