From 61a8436004294db0224dd20aa3997fa2e3136114 Mon Sep 17 00:00:00 2001 From: Abhishek Modi Date: Wed, 2 Oct 2019 17:55:07 +0530 Subject: [PATCH] YARN-9870. Remove unused function from OpportunisticContainerAllocatorAMService. Contributed by Abhishek Modi. --- ...ortunisticContainerAllocatorAMService.java | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java index 4475caf5df..d51afa2698 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java @@ -38,7 +38,6 @@ import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.event.EventHandler; -import org.apache.hadoop.yarn.security.AMRMTokenIdentifier; import org.apache.hadoop.yarn.server.api.DistributedSchedulingAMProtocol; import org.apache.hadoop.yarn.api.impl.pb.service.ApplicationMasterProtocolPBServiceImpl; @@ -77,7 +76,6 @@ import org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerAllocator; import org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerContext; -import org.apache.hadoop.yarn.server.utils.YarnServerSecurityUtils; import java.io.IOException; import java.net.InetSocketAddress; @@ -103,7 +101,7 @@ public class OpportunisticContainerAllocatorAMService private final NodeQueueLoadMonitor nodeMonitor; private final OpportunisticContainerAllocator oppContainerAllocator; - private final int k; + private final int numNodes; private final long cacheRefreshInterval; private volatile List cachedNodes; @@ -176,7 +174,7 @@ public void allocate(ApplicationAttemptId appAttemptId, if (!appAttempt.getApplicationAttemptId().equals(appAttemptId)){ LOG.error("Calling allocate on previous or removed or non " - + "existent application attempt " + appAttemptId); + + "existent application attempt {}", appAttemptId); return; } @@ -238,7 +236,7 @@ public OpportunisticContainerAllocatorAMService(RMContext rmContext, new DistributedOpportunisticContainerAllocator( rmContext.getContainerTokenSecretManager(), maxAllocationsPerAMHeartbeat); - this.k = rmContext.getYarnConfiguration().getInt( + this.numNodes = rmContext.getYarnConfiguration().getInt( YarnConfiguration.OPP_CONTAINER_ALLOCATION_NODES_NUMBER_USED, YarnConfiguration.DEFAULT_OPP_CONTAINER_ALLOCATION_NODES_NUMBER_USED); long nodeSortInterval = rmContext.getYarnConfiguration().getLong( @@ -440,12 +438,12 @@ public void handle(SchedulerEvent event) { // <-- IGNORED EVENTS : END --> default: LOG.error("Unknown event arrived at" + - "OpportunisticContainerAllocatorAMService: " + event.toString()); + "OpportunisticContainerAllocatorAMService: {}", event); } } - public QueueLimitCalculator getNodeManagerQueueLimitCalculator() { + QueueLimitCalculator getNodeManagerQueueLimitCalculator() { return nodeMonitor.getThresholdCalculator(); } @@ -455,7 +453,7 @@ synchronized List getLeastLoadedNodes() { if ((currTime - lastCacheUpdateTime > cacheRefreshInterval) || (cachedNodes == null)) { cachedNodes = convertToRemoteNodes( - this.nodeMonitor.selectLeastLoadedNodes(this.k)); + this.nodeMonitor.selectLeastLoadedNodes(this.numNodes)); if (cachedNodes.size() > 0) { lastCacheUpdateTime = currTime; } @@ -485,12 +483,4 @@ private RemoteNode convertToRemoteNode(NodeId nodeId) { } return null; } - - private static ApplicationAttemptId getAppAttemptId() throws YarnException { - AMRMTokenIdentifier amrmTokenIdentifier = - YarnServerSecurityUtils.authorizeRequest(); - ApplicationAttemptId applicationAttemptId = - amrmTokenIdentifier.getApplicationAttemptId(); - return applicationAttemptId; - } }