/** * Reset the variables -this does not adjust the fixed attributes * of the history, but the nodemap and failed node map are cleared. */ protected synchronized void reset() throws BadConfigException { nodemap = new NodeMap(roleSize); resetAvailableNodeLists(); outstandingRequests = new OutstandingRequestTracker(); }
@Override public NodeInformation getNodeInformation(String hostname) { return appState.getRoleHistory() .getNodeInformation(hostname, appState.buildNamingMap()); }
/** * Get the node instance for the specific node -creating it if needed * @param hostname node * @return the instance */ public NodeInstance getOrCreate(String hostname) { NodeInstance node = get(hostname); if (node == null) { node = new NodeInstance(hostname, roleSize); put(hostname, node); } return node; }
@Override public Map<String, NodeInformation> getNodeInformationSnapshot() { return appState.getRoleHistory() .getNodeInformationSnapshot(appState.buildNamingMap()); }
/** * Get the information on a node * @param hostname hostname * @param naming naming map of priority to enty name; entries must be unique. * It's OK to be incomplete, for those the list falls back to numbers. * @return the information about that host, or null if there is none */ public synchronized NodeInformation getNodeInformation(String hostname, Map<Integer, String> naming) { NodeInstance nodeInstance = nodemap.get(hostname); return nodeInstance != null ? nodeInstance.serialize(naming) : null; }
/** * Cancel a number of outstanding requests for a role -that is, not * actual containers, just requests for new ones. * @param role role * @param toCancel number to cancel * @return a list of cancellable operations. */ public List<AbstractRMOperation> cancelRequestsForRole(RoleStatus role, int toCancel) { return role.isAntiAffinePlacement() ? cancelRequestsForAARole(role, toCancel) : cancelRequestsForSimpleRole(role, toCancel); }
/** * Look up the status entry of a container or raise an exception * * @param c container * @return the status entry * @throws RuntimeException if the role cannot be found */ public RoleStatus lookupRoleStatus(Container c) { return lookupRoleStatus(ContainerPriority.extractRole(c)); }
/** * A container release request was issued * @param container container submitted */ public void onContainerReleaseSubmitted(Container container) { NodeEntry nodeEntry = getOrCreateNodeEntry(container); nodeEntry.release(); }
/** * 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; }
/** * Mark the request as completed (or canceled). * <p> * Current action: if a node is defined, its request count is decremented */ public void completed() { if (node != null) { node.getOrCreate(roleId).requestCompleted(); } }
/** * Get the node entry matching a container on this node * @param container container * @return matching node instance for the role */ public NodeEntry getOrCreate(Container container) { return getOrCreate(ContainerPriority.extractRole(container)); }
/** * Get the node entry of a container * @param container container to look up * @return the entry * @throws RuntimeException if the container has no hostname */ public NodeEntry getOrCreateNodeEntry(Container container) { return getOrCreateNodeInstance(container).getOrCreate(container); }
/** * Count the number of active role instances on this node * @param role role index * @return 0 if there are none, otherwise the #of nodes that are running and * not being released already. */ public int getActiveRoleInstances(int role) { NodeEntry nodeEntry = get(role); return (nodeEntry != null ) ? nodeEntry.getActive() : 0; }
/** * Increment the request count of a role. * <p> * Also updates application state counters * @param role role being requested. */ protected void incrementRequestCount(RoleStatus role) { role.incRequested(); incOutstandingContainerRequests(); }
/** * Get the node instance of a container -always returns something * @param container container to look up * @return a (possibly new) node instance * @throws RuntimeException if the container has no hostname */ public synchronized NodeInstance getOrCreateNodeInstance(Container container) { return nodemap.getOrCreate(RoleHistoryUtils.hostnameOf(container)); }
/** * Reset the variables -this does not adjust the fixed attributes * of the history, but the nodemap and failed node map are cleared. */ protected synchronized void reset() throws BadConfigException { nodemap = new NodeMap(roleSize); resetAvailableNodeLists(); outstandingRequests = new OutstandingRequestTracker(); }
/** * Look up the status entry of a container or raise an exception * * @param c container * @return the status entry * @throws RuntimeException if the role cannot be found */ public RoleStatus lookupRoleStatus(Container c) { return lookupRoleStatus(ContainerPriority.extractRole(c)); }
/** * A container release request was issued * @param container container submitted */ public void onContainerReleaseSubmitted(Container container) { NodeEntry nodeEntry = getOrCreateNodeEntry(container); nodeEntry.release(); }