@Override
  public Response addToClusterNodeLabels(NodeLabelsInfo newNodeLabels,
      HttpServletRequest hsr) throws Exception {

    if (newNodeLabels == null) {
      routerMetrics.incrAddToClusterNodeLabelsFailedRetrieved();
      RouterAuditLogger.logFailure(getUser().getShortUserName(), ADD_TO_CLUSTER_NODELABELS, UNKNOWN,
          TARGET_WEB_SERVICE, "Parameter error, the newNodeLabels is null.");
      throw new IllegalArgumentException("Parameter error, the newNodeLabels is null.");
    }

    List<NodeLabelInfo> nodeLabelInfos = newNodeLabels.getNodeLabelsInfo();
    if (CollectionUtils.isEmpty(nodeLabelInfos)) {
      routerMetrics.incrAddToClusterNodeLabelsFailedRetrieved();
      RouterAuditLogger.logFailure(getUser().getShortUserName(), ADD_TO_CLUSTER_NODELABELS, UNKNOWN,
          TARGET_WEB_SERVICE, "Parameter error, the nodeLabelsInfo is null or empty.");
      throw new IllegalArgumentException("Parameter error, the nodeLabelsInfo is null or empty.");
    }

    try {
      long startTime = clock.getTime();
      Collection<SubClusterInfo> subClustersActives = federationFacade.getActiveSubClusters();
      final HttpServletRequest hsrCopy = clone(hsr);
      Class[] argsClasses = new Class[]{NodeLabelsInfo.class, HttpServletRequest.class};
      Object[] args = new Object[]{newNodeLabels, hsrCopy};
      ClientMethod remoteMethod = new ClientMethod("addToClusterNodeLabels", argsClasses, args);
      Map<SubClusterInfo, Response> responseInfoMap =
          invokeConcurrent(subClustersActives, remoteMethod, Response.class);
      StringBuilder buffer = new StringBuilder();
      // SubCluster-0:SUCCESS,SubCluster-1:SUCCESS
      responseInfoMap.forEach((subClusterInfo, response) ->
          buildAppendMsg(subClusterInfo, buffer, response));
      long stopTime = clock.getTime();
      RouterAuditLogger.logSuccess(getUser().getShortUserName(), ADD_TO_CLUSTER_NODELABELS,
          TARGET_WEB_SERVICE);
      routerMetrics.succeededAddToClusterNodeLabelsRetrieved((stopTime - startTime));
      return Response.status(Status.OK).entity(buffer.toString()).build();
    } catch (NotFoundException e) {
      routerMetrics.incrAddToClusterNodeLabelsFailedRetrieved();
      RouterAuditLogger.logFailure(getUser().getShortUserName(), ADD_TO_CLUSTER_NODELABELS, UNKNOWN,
          TARGET_WEB_SERVICE, e.getLocalizedMessage());
      RouterServerUtil.logAndThrowIOException("get all active sub cluster(s) error.", e);
    } catch (YarnException e) {
      routerMetrics.incrAddToClusterNodeLabelsFailedRetrieved();
      RouterAuditLogger.logFailure(getUser().getShortUserName(), ADD_TO_CLUSTER_NODELABELS, UNKNOWN,
          TARGET_WEB_SERVICE, e.getLocalizedMessage());
      RouterServerUtil.logAndThrowIOException("addToClusterNodeLabels with yarn error.", e);
    }

    routerMetrics.incrAddToClusterNodeLabelsFailedRetrieved();
    RouterAuditLogger.logFailure(getUser().getShortUserName(), ADD_TO_CLUSTER_NODELABELS, UNKNOWN,
        TARGET_WEB_SERVICE, "addToClusterNodeLabels Failed.");
    throw new RuntimeException("addToClusterNodeLabels Failed.");
  }
@Test
  public void testAddToClusterNodeLabelsError() throws Exception {
    // the newNodeLabels is null
    LambdaTestUtils.intercept(IllegalArgumentException.class,
        "Parameter error, the newNodeLabels is null.",
        () -> interceptor.addToClusterNodeLabels(null, null));

    // the nodeLabelsInfo is null
    NodeLabelsInfo nodeLabelsInfo = new NodeLabelsInfo();
    LambdaTestUtils.intercept(IllegalArgumentException.class,
        "Parameter error, the nodeLabelsInfo is null or empty.",
        () -> interceptor.addToClusterNodeLabels(nodeLabelsInfo, null));

    // error nodeLabelsInfo
    NodeLabelsInfo nodeLabelsInfo1 = new NodeLabelsInfo();
    NodeLabelInfo nodeLabelInfo1 = new NodeLabelInfo("A", true);
    nodeLabelsInfo1.getNodeLabelsInfo().add(nodeLabelInfo1);
    LambdaTestUtils.intercept(YarnRuntimeException.class, "addToClusterNodeLabels Error",
        () -> interceptor.addToClusterNodeLabels(nodeLabelsInfo1, null));
  }