/** * Add a grant to a node * * @param node the node the grant is on * @param sessionId the session the grant is given to * @param req the request this grant satisfies * @return true if the grant can be added to the node, false otherwise */ public boolean addGrant(ClusterNode node, String sessionId, ResourceRequestInfo req) { synchronized (node) { if (node.deleted) { return false; } if (!node.checkForGrant(Utilities.getUnitResourceRequest(req.getType()), resourceLimit)) { return false; } node.addGrant(sessionId, req); loadManager.incrementLoad(req.getType()); hostsToSessions.get(node).add(sessionId); if (!node.checkForGrant(Utilities.getUnitResourceRequest(req.getType()), resourceLimit)) { RunnableIndices r = typeToIndices.get(req.getType()); r.deleteRunnable(node); } } return true; }
/** * This method rebuilds members related to the NodeManager instance, which were not directly * persisted themselves. * * @throws IOException */ public void restoreAfterSafeModeRestart() throws IOException { if (!clusterManager.safeMode) { throw new IOException( "restoreAfterSafeModeRestart() called while the " + "Cluster Manager was not in Safe Mode"); } // Restoring all the ClusterNode(s) for (ClusterNode clusterNode : nameToNode.values()) { restoreClusterNode(clusterNode); } // Restoring all the RequestedNodes(s) for (ClusterNode clusterNode : nameToNode.values()) { for (ResourceRequestInfo resourceRequestInfo : clusterNode.grants.values()) { // Fix the RequestedNode(s) restoreResourceRequestInfo(resourceRequestInfo); loadManager.incrementLoad(resourceRequestInfo.getType()); } } }