@Override
  public ReplaceLabelsOnNodeResponse replaceLabelsOnNode(ReplaceLabelsOnNodeRequest request)
      throws YarnException, IOException {
    // parameter verification.
    if (request == null) {
      routerMetrics.incrReplaceLabelsOnNodeFailedRetrieved();
      RouterServerUtil.logAndThrowException("Missing ReplaceLabelsOnNode request.", null);
    }

    String subClusterId = request.getSubClusterId();
    if (StringUtils.isBlank(subClusterId)) {
      routerMetrics.incrReplaceLabelsOnNodeFailedRetrieved();
      RouterServerUtil.logAndThrowException("Missing ReplaceLabelsOnNode SubClusterId.", null);
    }

    try {
      long startTime = clock.getTime();
      RMAdminProtocolMethod remoteMethod = new RMAdminProtocolMethod(
          new Class[]{ReplaceLabelsOnNodeRequest.class}, new Object[]{request});
      Collection<ReplaceLabelsOnNodeResponse> replaceLabelsOnNodeResps =
          remoteMethod.invokeConcurrent(this, ReplaceLabelsOnNodeResponse.class, subClusterId);
      if (CollectionUtils.isNotEmpty(replaceLabelsOnNodeResps)) {
        long stopTime = clock.getTime();
        routerMetrics.succeededRemoveFromClusterNodeLabelsRetrieved(stopTime - startTime);
        return ReplaceLabelsOnNodeResponse.newInstance();
      }
    } catch (YarnException e) {
      routerMetrics.incrReplaceLabelsOnNodeFailedRetrieved();
      RouterServerUtil.logAndThrowException(e,
          "Unable to replaceLabelsOnNode due to exception. " + e.getMessage());
    }

    routerMetrics.incrReplaceLabelsOnNodeFailedRetrieved();
    throw new YarnException("Unable to replaceLabelsOnNode.");
  }
@Test
  public void testReplaceLabelsOnNodeEmptyRequest() throws Exception {
    // null request1.
    LambdaTestUtils.intercept(YarnException.class, "Missing ReplaceLabelsOnNode request.",
        () -> interceptor.replaceLabelsOnNode(null));

    // null request2.
    Map<NodeId, Set<String>> labelMap = new HashMap<>();
    ReplaceLabelsOnNodeRequest request = ReplaceLabelsOnNodeRequest.newInstance(labelMap, null);
    LambdaTestUtils.intercept(YarnException.class, "Missing ReplaceLabelsOnNode SubClusterId.",
        () -> interceptor.replaceLabelsOnNode(request));
  }