001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.hadoop.yarn.api.protocolrecords;
020
021import java.util.ArrayList;
022import java.util.List;
023import java.util.Set;
024
025import org.apache.hadoop.classification.InterfaceAudience.Public;
026import org.apache.hadoop.classification.InterfaceStability.Evolving;
027import org.apache.hadoop.yarn.api.records.NodeLabel;
028import org.apache.hadoop.yarn.util.Records;
029
030@Public
031@Evolving
032public abstract class GetClusterNodeLabelsResponse {
033  /**
034   * Creates a new instance.
035   *
036   * @param labels Node labels
037   * @return response
038   * @deprecated Use {@link #newInstance(List)} instead.
039   */
040  @Deprecated
041  public static GetClusterNodeLabelsResponse newInstance(Set<String> labels) {
042    List<NodeLabel> list = new ArrayList<>();
043    for (String label : labels) {
044      list.add(NodeLabel.newInstance(label));
045    }
046    return newInstance(list);
047  }
048
049  public static GetClusterNodeLabelsResponse newInstance(List<NodeLabel> labels) {
050    GetClusterNodeLabelsResponse response =
051        Records.newRecord(GetClusterNodeLabelsResponse.class);
052    response.setNodeLabelList(labels);
053    return response;
054  }
055
056  public abstract void setNodeLabelList(List<NodeLabel> labels);
057
058  public abstract List<NodeLabel> getNodeLabelList();
059
060  /**
061   * Set node labels to the response.
062   *
063   * @param labels Node labels
064   * @deprecated Use {@link #setNodeLabelList(List)} instead.
065   */
066  @Deprecated
067  public abstract void setNodeLabels(Set<String> labels);
068
069  /**
070   * Get node labels of the response.
071   *
072   * @return Node labels
073   * @deprecated Use {@link #getNodeLabelList()} instead.
074   */
075  @Deprecated
076  public abstract Set<String> getNodeLabels();
077}