/** * Get the entry for a role -and remove it if present * @param role the role index * @return the entry that WAS there */ public synchronized NodeEntry remove(int role) { NodeEntry nodeEntry = get(role); if (nodeEntry != null) { nodeEntries.remove(nodeEntry); } return nodeEntry; }
@Override public int compare(NodeInstance left, NodeInstance right) { int activeLeft = left.getActiveRoleInstances(role); int activeRight = right.getActiveRoleInstances(role); return activeRight - activeLeft; } }
/** * Is this node instance a suitable candidate for the specific role? * @param role role ID * @param label label which must match, or "" for no label checks * @return true if the node has space for this role, is running and the labels * match. */ public boolean canHost(int role, String label) { return isOnline() && (SliderUtils.isUnset(label) || label.equals(nodeLabels)) // label match && getOrCreate(role).isAvailable(); // no live role }
NodeInstance nodeInstance = nodeInstanceEntry.getValue(); for (RoleStatus roleStatus : roleStatuses) { if (nodeInstance.exceedsFailureThreshold(roleStatus)) { shouldBeBlacklisted = true; break; if (!nodeInstance.isBlacklisted()) { blacklistAdditions.add(nodeHost); nodeInstance.setBlacklisted(true); if (nodeInstance.isBlacklisted()) { blacklistRemovals.add(nodeHost); nodeInstance.setBlacklisted(false);
for (int i = 0; i < cnt && nodeInstance == null; i++) { NodeInstance candidate = targets.get(i); if (candidate.getActiveRoleInstances(roleId) == 0) { || (candidate.isOnline() && !candidate.exceedsFailureThreshold(role))) { targets.remove(i);
/** * 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); }
if (node.canHost(role.getKey(), role.getLabelExpression())) { log.error("Assigned node still declares as available {}", node.toFullString() );
/** * Create a new Anti-affine request for the specific role * <p> * It is added to {@link #openRequests} * <p> * This does not update the node instance's role's request count * @param role role index * @param nodes list of suitable nodes * @param label label to use * @return a new request */ public synchronized OutstandingRequest newAARequest(int role, List<NodeInstance> nodes, String label) { Preconditions.checkArgument(!nodes.isEmpty()); // safety check to verify the allocation will hold for (NodeInstance node : nodes) { Preconditions.checkState(node.canHost(role, label), "Cannot allocate role ID %d to node %s", role, node); } OutstandingRequest request = new OutstandingRequest(role, nodes); openRequests.add(request); return request; }
/** * reset the failed recently counters */ public void resetFailedRecently() { for (Map.Entry<String, NodeInstance> entry : entrySet()) { NodeInstance ni = entry.getValue(); ni.resetFailedRecently(); } }
/** * 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; }
public synchronized void set(int role, NodeEntry nodeEntry) { remove(role); nodeEntries.add(nodeEntry); }
NodeInstance nodeInstance = nodeInstanceEntry.getValue(); for (RoleStatus roleStatus : roleStatuses) { if (nodeInstance.exceedsFailureThreshold(roleStatus)) { shouldBeBlacklisted = true; break; if (!nodeInstance.isBlacklisted()) { blacklistAdditions.add(nodeHost); nodeInstance.setBlacklisted(true); if (nodeInstance.isBlacklisted()) { blacklistRemovals.add(nodeHost); nodeInstance.setBlacklisted(false);
for (int i = 0; i < cnt && nodeInstance == null; i++) { NodeInstance candidate = targets.get(i); if (candidate.getActiveRoleInstances(roleId) == 0) { || (candidate.isOnline() && !candidate.exceedsFailureThreshold(role))) { targets.remove(i);
/** * 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)); }
if (node.canHost(role.getKey(), role.getLabelExpression())) { log.error("Assigned node still declares as available {}", node.toFullString() );
/** * Create a new Anti-affine request for the specific role * <p> * It is added to {@link #openRequests} * <p> * This does not update the node instance's role's request count * @param role role index * @param nodes list of suitable nodes * @param label label to use * @return a new request */ public synchronized OutstandingRequest newAARequest(int role, List<NodeInstance> nodes, String label) { Preconditions.checkArgument(!nodes.isEmpty()); // safety check to verify the allocation will hold for (NodeInstance node : nodes) { Preconditions.checkState(node.canHost(role, label), "Cannot allocate role ID %d to node %s", role, node); } OutstandingRequest request = new OutstandingRequest(role, nodes); openRequests.add(request); return request; }
/** * reset the failed recently counters */ public void resetFailedRecently() { for (Map.Entry<String, NodeInstance> entry : entrySet()) { NodeInstance ni = entry.getValue(); ni.resetFailedRecently(); } }
/** * 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; }
public synchronized void set(int role, NodeEntry nodeEntry) { remove(role); nodeEntries.add(nodeEntry); }
/** * Get the entry for a role -and remove it if present * @param role the role index * @return the entry that WAS there */ public synchronized NodeEntry remove(int role) { NodeEntry nodeEntry = get(role); if (nodeEntry != null) { nodeEntries.remove(nodeEntry); } return nodeEntry; }