import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.*;
import org.apache.hadoop.yarn.client.ClientRMProxy;
import org.apache.hadoop.yarn.client.api.YarnClient;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
import org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol;
import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeRequest;
import java.io.IOException;
import java.util.*;
/**
* for node135、node136、node137集群
*/
public class YarnLabelTest {
public static void main(String[] args) throws Exception {
//创建所有标签
createLables();
//标签绑定节点 FIXME 节点名需要使用hostname,使用ip会失败
replaceLabelsOnNode();
//移除没有与队列关联的标签
removeFromClusterNodeLabels();
listDetailedClusterNodes();
queueRelatedLabels();
}
public static int removeFromClusterNodeLabels() throws IOException, YarnException {
Set<String> labels = new HashSet<>();
labels.add("cpu")
Yarn节点标签功能的java接口封装
最新推荐文章于 2024-11-07 10:15:41 发布
本文介绍如何利用Java编程语言封装Apache Hadoop Yarn的节点标签管理功能,详细阐述了接口的调用过程和实现细节,旨在帮助开发者更高效地操作和管理Yarn集群的节点标签。
摘要由CSDN通过智能技术生成