Search in sources :

Example 1 with CheckForDecommissioningNodesResponse

use of org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse in project hadoop by apache.

the class AdminService method checkForDecommissioningNodes.

@Override
public CheckForDecommissioningNodesResponse checkForDecommissioningNodes(CheckForDecommissioningNodesRequest checkForDecommissioningNodesRequest) throws IOException, YarnException {
    final String operation = "checkForDecommissioningNodes";
    final String msg = "check for decommissioning nodes.";
    UserGroupInformation user = checkAcls("checkForDecommissioningNodes");
    checkRMStatus(user.getShortUserName(), operation, msg);
    Set<NodeId> decommissioningNodes = rmContext.getNodesListManager().checkForDecommissioningNodes();
    RMAuditLogger.logSuccess(user.getShortUserName(), operation, "AdminService");
    CheckForDecommissioningNodesResponse response = recordFactory.newRecordInstance(CheckForDecommissioningNodesResponse.class);
    response.setDecommissioningNodes(decommissioningNodes);
    return response;
}
Also used : NodeId(org.apache.hadoop.yarn.api.records.NodeId) CheckForDecommissioningNodesResponse(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 2 with CheckForDecommissioningNodesResponse

use of org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse in project hadoop by apache.

the class RMAdminCLI method refreshNodes.

private int refreshNodes(int timeout, String trackingMode) throws IOException, YarnException {
    boolean serverTracking = !"client".equals(trackingMode);
    // Graceful decommissioning with timeout
    ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
    RefreshNodesRequest gracefulRequest = RefreshNodesRequest.newInstance(DecommissionType.GRACEFUL, timeout);
    adminProtocol.refreshNodes(gracefulRequest);
    if (serverTracking) {
        return 0;
    }
    CheckForDecommissioningNodesRequest checkForDecommissioningNodesRequest = recordFactory.newRecordInstance(CheckForDecommissioningNodesRequest.class);
    long waitingTime;
    boolean nodesDecommissioning = true;
    // As RM enforces timeout automatically, client usually don't need
    // to forcefully decommission nodes upon timeout.
    // Here we let the client waits a small additional seconds so to avoid
    // unnecessary double decommission.
    final int gracePeriod = 5;
    // decommissioned
    for (waitingTime = 0; timeout == -1 || (timeout >= 0 && waitingTime < timeout + gracePeriod); waitingTime++) {
        // wait for one second to check nodes decommissioning status
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        // Ignore the InterruptedException
        }
        CheckForDecommissioningNodesResponse checkForDecommissioningNodes = adminProtocol.checkForDecommissioningNodes(checkForDecommissioningNodesRequest);
        Set<NodeId> decommissioningNodes = checkForDecommissioningNodes.getDecommissioningNodes();
        if (decommissioningNodes.isEmpty()) {
            nodesDecommissioning = false;
            break;
        } else {
            StringBuilder nodes = new StringBuilder();
            for (NodeId nodeId : decommissioningNodes) {
                nodes.append(nodeId).append(",");
            }
            nodes.deleteCharAt(nodes.length() - 1);
            System.out.println("Nodes '" + nodes + "' are still decommissioning.");
        }
    }
    if (nodesDecommissioning) {
        System.out.println("Graceful decommissioning not completed in " + timeout + " seconds, issuing forceful decommissioning command.");
        RefreshNodesRequest forcefulRequest = RefreshNodesRequest.newInstance(DecommissionType.FORCEFUL);
        adminProtocol.refreshNodes(forcefulRequest);
    } else {
        System.out.println("Graceful decommissioning completed in " + waitingTime + " seconds.");
    }
    return 0;
}
Also used : CheckForDecommissioningNodesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest) ResourceManagerAdministrationProtocol(org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol) RefreshNodesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest) NodeId(org.apache.hadoop.yarn.api.records.NodeId) CheckForDecommissioningNodesResponse(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse)

Example 3 with CheckForDecommissioningNodesResponse

use of org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse in project hadoop by apache.

the class TestRMAdminCLI method testRefreshNodesGracefulBeforeTimeout.

@Test
public void testRefreshNodesGracefulBeforeTimeout() throws Exception {
    // graceful decommission before timeout
    String[] args = { "-refreshNodes", "-g", "1", "-client" };
    CheckForDecommissioningNodesResponse response = Records.newRecord(CheckForDecommissioningNodesResponse.class);
    HashSet<NodeId> decomNodes = new HashSet<NodeId>();
    response.setDecommissioningNodes(decomNodes);
    when(admin.checkForDecommissioningNodes(any(CheckForDecommissioningNodesRequest.class))).thenReturn(response);
    assertEquals(0, rmAdminCLI.run(args));
    verify(admin).refreshNodes(RefreshNodesRequest.newInstance(DecommissionType.GRACEFUL, 1));
    verify(admin, never()).refreshNodes(RefreshNodesRequest.newInstance(DecommissionType.FORCEFUL));
}
Also used : CheckForDecommissioningNodesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest) NodeId(org.apache.hadoop.yarn.api.records.NodeId) CheckForDecommissioningNodesResponse(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with CheckForDecommissioningNodesResponse

use of org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse in project hadoop by apache.

the class TestRMAdminCLI method testRefreshNodesGracefulHitTimeout.

@Test
public void testRefreshNodesGracefulHitTimeout() throws Exception {
    // Forceful decommission when timeout occurs
    String[] forcefulDecomArgs = { "-refreshNodes", "-g", "1", "-client" };
    HashSet<NodeId> decomNodes = new HashSet<NodeId>();
    CheckForDecommissioningNodesResponse response = Records.newRecord(CheckForDecommissioningNodesResponse.class);
    response.setDecommissioningNodes(decomNodes);
    decomNodes.add(NodeId.newInstance("node1", 100));
    response.setDecommissioningNodes(decomNodes);
    when(admin.checkForDecommissioningNodes(any(CheckForDecommissioningNodesRequest.class))).thenReturn(response);
    assertEquals(0, rmAdminCLI.run(forcefulDecomArgs));
    verify(admin).refreshNodes(RefreshNodesRequest.newInstance(DecommissionType.FORCEFUL));
}
Also used : CheckForDecommissioningNodesRequest(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest) NodeId(org.apache.hadoop.yarn.api.records.NodeId) CheckForDecommissioningNodesResponse(org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

NodeId (org.apache.hadoop.yarn.api.records.NodeId)4 CheckForDecommissioningNodesResponse (org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse)4 CheckForDecommissioningNodesRequest (org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest)3 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 ResourceManagerAdministrationProtocol (org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)1 RefreshNodesRequest (org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest)1