Skip to content

Commit 61a8436

Browse files
committed
YARN-9870. Remove unused function from OpportunisticContainerAllocatorAMService. Contributed by Abhishek Modi.
1 parent f1ba9bf commit 61a8436

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/OpportunisticContainerAllocatorAMService.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.apache.hadoop.yarn.api.records.NodeId;
3939
import org.apache.hadoop.yarn.api.records.ResourceRequest;
4040
import org.apache.hadoop.yarn.event.EventHandler;
41-
import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
4241
import org.apache.hadoop.yarn.server.api.DistributedSchedulingAMProtocol;
4342
import org.apache.hadoop.yarn.api.impl.pb.service.ApplicationMasterProtocolPBServiceImpl;
4443

@@ -77,7 +76,6 @@
7776

7877
import org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerAllocator;
7978
import org.apache.hadoop.yarn.server.scheduler.OpportunisticContainerContext;
80-
import org.apache.hadoop.yarn.server.utils.YarnServerSecurityUtils;
8179

8280
import java.io.IOException;
8381
import java.net.InetSocketAddress;
@@ -103,7 +101,7 @@ public class OpportunisticContainerAllocatorAMService
103101
private final NodeQueueLoadMonitor nodeMonitor;
104102
private final OpportunisticContainerAllocator oppContainerAllocator;
105103

106-
private final int k;
104+
private final int numNodes;
107105

108106
private final long cacheRefreshInterval;
109107
private volatile List<RemoteNode> cachedNodes;
@@ -176,7 +174,7 @@ public void allocate(ApplicationAttemptId appAttemptId,
176174

177175
if (!appAttempt.getApplicationAttemptId().equals(appAttemptId)){
178176
LOG.error("Calling allocate on previous or removed or non "
179-
+ "existent application attempt " + appAttemptId);
177+
+ "existent application attempt {}", appAttemptId);
180178
return;
181179
}
182180

@@ -238,7 +236,7 @@ public OpportunisticContainerAllocatorAMService(RMContext rmContext,
238236
new DistributedOpportunisticContainerAllocator(
239237
rmContext.getContainerTokenSecretManager(),
240238
maxAllocationsPerAMHeartbeat);
241-
this.k = rmContext.getYarnConfiguration().getInt(
239+
this.numNodes = rmContext.getYarnConfiguration().getInt(
242240
YarnConfiguration.OPP_CONTAINER_ALLOCATION_NODES_NUMBER_USED,
243241
YarnConfiguration.DEFAULT_OPP_CONTAINER_ALLOCATION_NODES_NUMBER_USED);
244242
long nodeSortInterval = rmContext.getYarnConfiguration().getLong(
@@ -440,12 +438,12 @@ public void handle(SchedulerEvent event) {
440438
// <-- IGNORED EVENTS : END -->
441439
default:
442440
LOG.error("Unknown event arrived at" +
443-
"OpportunisticContainerAllocatorAMService: " + event.toString());
441+
"OpportunisticContainerAllocatorAMService: {}", event);
444442
}
445443

446444
}
447445

448-
public QueueLimitCalculator getNodeManagerQueueLimitCalculator() {
446+
QueueLimitCalculator getNodeManagerQueueLimitCalculator() {
449447
return nodeMonitor.getThresholdCalculator();
450448
}
451449

@@ -455,7 +453,7 @@ synchronized List<RemoteNode> getLeastLoadedNodes() {
455453
if ((currTime - lastCacheUpdateTime > cacheRefreshInterval)
456454
|| (cachedNodes == null)) {
457455
cachedNodes = convertToRemoteNodes(
458-
this.nodeMonitor.selectLeastLoadedNodes(this.k));
456+
this.nodeMonitor.selectLeastLoadedNodes(this.numNodes));
459457
if (cachedNodes.size() > 0) {
460458
lastCacheUpdateTime = currTime;
461459
}
@@ -485,12 +483,4 @@ private RemoteNode convertToRemoteNode(NodeId nodeId) {
485483
}
486484
return null;
487485
}
488-
489-
private static ApplicationAttemptId getAppAttemptId() throws YarnException {
490-
AMRMTokenIdentifier amrmTokenIdentifier =
491-
YarnServerSecurityUtils.authorizeRequest();
492-
ApplicationAttemptId applicationAttemptId =
493-
amrmTokenIdentifier.getApplicationAttemptId();
494-
return applicationAttemptId;
495-
}
496486
}

0 commit comments

Comments
 (0)