From 815cde98103fe57dde4f6686626bc4fcc1278a2d Mon Sep 17 00:00:00 2001 From: Szilard Nemeth Date: Wed, 25 Jan 2023 17:28:29 +0100 Subject: [PATCH] YARN-6971. Clean up different ways to create resources. Contributed by Riya Khandelwal --- .../v2/app/rm/TestRMContainerAllocator.java | 29 +++---- .../uam/UnmanagedApplicationManager.java | 4 +- .../nodemanager/TestNodeStatusUpdater.java | 13 ++-- .../BaseContainerManagerTest.java | 5 +- .../container/TestContainer.java | 3 +- .../launcher/TestContainerLaunch.java | 3 +- .../TestLogAggregationService.java | 3 +- .../monitor/TestContainersMonitor.java | 3 +- ...ntainerSchedulerBehaviorCompatibility.java | 4 +- ...inerSchedulerOppContainersByResources.java | 8 +- .../TestContainerSchedulerQueuing.java | 78 +++++++++---------- .../TestNMContainerTokenSecretManager.java | 3 +- .../nodemanager/webapp/MockContainer.java | 3 +- .../nodemanager/webapp/TestNMWebServer.java | 4 +- .../resourcemanager/ClientRMService.java | 3 +- .../resourcemanager/DefaultAMSProcessor.java | 2 +- .../fair/FairSchedulerConfiguration.java | 3 +- .../resourcemanager/QueueACLsTestBase.java | 4 +- .../ReservationACLsTestBase.java | 4 +- .../resourcemanager/TestApplicationACLs.java | 6 +- .../resourcemanager/TestClientRMService.java | 8 +- .../resourcemanager/TestClientRMTokens.java | 5 +- .../TestResourceTrackerService.java | 35 +++++---- .../TestRMDelegatedNodeLabelsUpdater.java | 4 +- .../resourcetracker/TestNMExpiry.java | 4 +- .../resourcetracker/TestNMReconnect.java | 10 +-- .../TestRMNMRPCResponseId.java | 4 +- .../attempt/TestRMAppAttemptTransitions.java | 8 +- .../rmcontainer/TestRMContainerImpl.java | 9 ++- .../scheduler/TestAbstractYarnScheduler.java | 5 +- .../capacity/TestApplicationPriorityACLs.java | 4 +- .../TestCapacitySchedulerAmbiguousLeafs.java | 4 +- .../scheduler/fair/FairSchedulerTestBase.java | 3 +- .../scheduler/fair/TestFairScheduler.java | 6 +- .../fair/TestFairSchedulerConfiguration.java | 19 +++-- .../TestDominantResourceFairnessPolicy.java | 5 +- .../scheduler/fifo/TestFifoScheduler.java | 10 +-- .../webapp/TestRMWebServicesNodes.java | 4 +- 38 files changed, 170 insertions(+), 162 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java index fd7a2f0ced..fe2f307214 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java @@ -148,6 +148,7 @@ import org.apache.hadoop.yarn.util.Clock; import org.apache.hadoop.yarn.util.ControlledClock; import org.apache.hadoop.yarn.util.Records; +import org.apache.hadoop.yarn.util.resource.Resources; import org.apache.hadoop.yarn.util.SystemClock; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; @@ -502,8 +503,8 @@ public void testPreemptReducers() throws Exception { 0, 0, 0, 0, 0, 0, "jobfile", null, false, "")); MyContainerAllocator allocator = new MyContainerAllocator(rm, conf, appAttemptId, mockJob, SystemClock.getInstance()); - allocator.setMapResourceRequest(BuilderUtils.newResource(1024, 1)); - allocator.setReduceResourceRequest(BuilderUtils.newResource(1024, 1)); + allocator.setMapResourceRequest(Resources.createResource(1024)); + allocator.setReduceResourceRequest(Resources.createResource(1024)); RMContainerAllocator.AssignedRequests assignedRequests = allocator.getAssignedRequests(); RMContainerAllocator.ScheduledRequests scheduledRequests = @@ -557,8 +558,8 @@ public void testNonAggressivelyPreemptReducers() throws Exception { clock.setTime(1); MyContainerAllocator allocator = new MyContainerAllocator(rm, conf, appAttemptId, mockJob, clock); - allocator.setMapResourceRequest(BuilderUtils.newResource(1024, 1)); - allocator.setReduceResourceRequest(BuilderUtils.newResource(1024, 1)); + allocator.setMapResourceRequest(Resources.createResource(1024)); + allocator.setReduceResourceRequest(Resources.createResource(1024)); RMContainerAllocator.AssignedRequests assignedRequests = allocator.getAssignedRequests(); RMContainerAllocator.ScheduledRequests scheduledRequests = @@ -622,8 +623,8 @@ public void testUnconditionalPreemptReducers() throws Exception { clock.setTime(1); MyContainerAllocator allocator = new MyContainerAllocator(rm, conf, appAttemptId, mockJob, clock); - allocator.setMapResourceRequest(BuilderUtils.newResource(1024, 1)); - allocator.setReduceResourceRequest(BuilderUtils.newResource(1024, 1)); + allocator.setMapResourceRequest(Resources.createResource(1024)); + allocator.setReduceResourceRequest(Resources.createResource(1024)); RMContainerAllocator.AssignedRequests assignedRequests = allocator.getAssignedRequests(); RMContainerAllocator.ScheduledRequests scheduledRequests = @@ -2205,8 +2206,8 @@ public void testReduceScheduling() throws Exception { int scheduledReduces = 0; int assignedMaps = 2; int assignedReduces = 0; - Resource mapResourceReqt = BuilderUtils.newResource(1024, 1); - Resource reduceResourceReqt = BuilderUtils.newResource(2 * 1024, 1); + Resource mapResourceReqt = Resources.createResource(1024); + Resource reduceResourceReqt = Resources.createResource(2 * 1024); int numPendingReduces = 4; float maxReduceRampupLimit = 0.5f; float reduceSlowStart = 0.2f; @@ -2241,7 +2242,7 @@ public void testReduceScheduling() throws Exception { verify(allocator, never()).scheduleAllReduces(); succeededMaps = 3; - doReturn(BuilderUtils.newResource(0, 0)).when(allocator).getResourceLimit(); + doReturn(Resources.createResource(0)).when(allocator).getResourceLimit(); allocator.scheduleReduces( totalMaps, succeededMaps, scheduledMaps, scheduledReduces, @@ -2252,7 +2253,7 @@ public void testReduceScheduling() throws Exception { verify(allocator, times(1)).setIsReduceStarted(true); // Test reduce ramp-up - doReturn(BuilderUtils.newResource(100 * 1024, 100 * 1)).when(allocator) + doReturn(Resources.createResource(100 * 1024, 100 * 1)).when(allocator) .getResourceLimit(); allocator.scheduleReduces( totalMaps, succeededMaps, @@ -2266,7 +2267,7 @@ public void testReduceScheduling() throws Exception { // Test reduce ramp-down scheduledReduces = 3; - doReturn(BuilderUtils.newResource(10 * 1024, 10 * 1)).when(allocator) + doReturn(Resources.createResource(10 * 1024, 10 * 1)).when(allocator) .getResourceLimit(); allocator.scheduleReduces( totalMaps, succeededMaps, @@ -2282,7 +2283,7 @@ public void testReduceScheduling() throws Exception { // should be invoked twice. scheduledMaps = 2; assignedReduces = 2; - doReturn(BuilderUtils.newResource(10 * 1024, 10 * 1)).when(allocator) + doReturn(Resources.createResource(10 * 1024, 10 * 1)).when(allocator) .getResourceLimit(); allocator.scheduleReduces( totalMaps, succeededMaps, @@ -2300,7 +2301,7 @@ public void testReduceScheduling() throws Exception { // Test ramp-down when enough memory but not enough cpu resource scheduledMaps = 10; assignedReduces = 0; - doReturn(BuilderUtils.newResource(100 * 1024, 5 * 1)).when(allocator) + doReturn(Resources.createResource(100 * 1024, 5 * 1)).when(allocator) .getResourceLimit(); allocator.scheduleReduces(totalMaps, succeededMaps, scheduledMaps, scheduledReduces, assignedMaps, assignedReduces, mapResourceReqt, @@ -2309,7 +2310,7 @@ public void testReduceScheduling() throws Exception { verify(allocator, times(3)).rampDownReduces(anyInt()); // Test ramp-down when enough cpu but not enough memory resource - doReturn(BuilderUtils.newResource(10 * 1024, 100 * 1)).when(allocator) + doReturn(Resources.createResource(10 * 1024, 100 * 1)).when(allocator) .getResourceLimit(); allocator.scheduleReduces(totalMaps, succeededMaps, scheduledMaps, scheduledReduces, assignedMaps, assignedReduces, mapResourceReqt, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/uam/UnmanagedApplicationManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/uam/UnmanagedApplicationManager.java index c70a2db25f..01f9bc7dbe 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/uam/UnmanagedApplicationManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/uam/UnmanagedApplicationManager.java @@ -62,9 +62,9 @@ import org.apache.hadoop.yarn.security.AMRMTokenIdentifier; import org.apache.hadoop.yarn.server.AMHeartbeatRequestHandler; import org.apache.hadoop.yarn.server.AMRMClientRelayer; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.AsyncCallback; import org.apache.hadoop.yarn.util.ConverterUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -426,7 +426,7 @@ private void submitUnmanagedApp(ApplicationId appId) ContainerLaunchContext amContainer = this.recordFactory.newRecordInstance(ContainerLaunchContext.class); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(1024); context.setResource(resource); context.setAMContainerSpec(amContainer); submitRequest.setApplicationSubmissionContext(context); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java index 511013cad1..6b8d928b7b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java @@ -118,6 +118,7 @@ import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.server.utils.YarnServerBuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -243,7 +244,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) ContainerId.newContainerId(appAttemptID, heartBeatID.get()); ContainerLaunchContext launchContext = recordFactory .newRecordInstance(ContainerLaunchContext.class); - Resource resource = BuilderUtils.newResource(2, 1); + Resource resource = Resources.createResource(2, 1); long currentTime = System.currentTimeMillis(); String user = "testUser"; ContainerTokenIdentifier containerToken = BuilderUtils @@ -286,7 +287,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) .newRecordInstance(ContainerLaunchContext.class); long currentTime = System.currentTimeMillis(); String user = "testUser"; - Resource resource = BuilderUtils.newResource(3, 1); + Resource resource = Resources.createResource(3, 1); ContainerTokenIdentifier containerToken = BuilderUtils .newContainerTokenIdentifier(BuilderUtils.newContainerToken( secondContainerID, 0, InetAddress.getByName("localhost") @@ -990,7 +991,7 @@ public void testRemovePreviousCompletedContainersFromContext() throws Exception ContainerId cId = ContainerId.newContainerId(appAttemptId, 1); Token containerToken = BuilderUtils.newContainerToken(cId, 0, "anyHost", 1234, "anyUser", - BuilderUtils.newResource(1024, 1), 0, 123, + Resources.createResource(1024), 0, 123, "password".getBytes(), 0); Container anyCompletedContainer = new ContainerImpl(conf, null, null, null, null, @@ -1012,7 +1013,7 @@ public org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Cont ContainerId.newContainerId(appAttemptId, 3); Token runningContainerToken = BuilderUtils.newContainerToken(runningContainerId, 0, "anyHost", - 1234, "anyUser", BuilderUtils.newResource(1024, 1), 0, 123, + 1234, "anyUser", Resources.createResource(1024), 0, 123, "password".getBytes(), 0); Container runningContainer = new ContainerImpl(conf, null, null, null, null, @@ -1071,7 +1072,7 @@ public void testCompletedContainersIsRecentlyStopped() throws Exception { ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); Token containerToken = BuilderUtils.newContainerToken(containerId, 0, "host", 1234, "user", - BuilderUtils.newResource(1024, 1), 0, 123, + Resources.createResource(1024), 0, 123, "password".getBytes(), 0); Container completedContainer = new ContainerImpl(conf, null, @@ -1110,7 +1111,7 @@ public void testCleanedupApplicationContainerCleanup() throws IOException { ContainerId cId = ContainerId.newContainerId(appAttemptId, 1); Token containerToken = BuilderUtils.newContainerToken(cId, 0, "anyHost", 1234, "anyUser", - BuilderUtils.newResource(1024, 1), 0, 123, + Resources.createResource(1024), 0, 123, "password".getBytes(), 0); Container anyCompletedContainer = new ContainerImpl(conf, null, null, null, null, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java index 9ee3ce6bc8..37045dc74b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java @@ -93,6 +93,7 @@ import org.apache.hadoop.yarn.server.nodemanager.security.NMTokenSecretManagerInNM; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -439,7 +440,7 @@ public static Token createContainerToken(ContainerId cId, long rmIdentifier, NMContainerTokenSecretManager containerTokenSecretManager, LogAggregationContext logAggregationContext) throws IOException { - Resource r = BuilderUtils.newResource(1024, 1); + Resource r = Resources.createResource(1024); return createContainerToken(cId, rmIdentifier, nodeId, user, r, containerTokenSecretManager, logAggregationContext); } @@ -449,7 +450,7 @@ public static Token createContainerToken(ContainerId cId, long rmIdentifier, NMContainerTokenSecretManager containerTokenSecretManager, LogAggregationContext logAggregationContext, ContainerType containerType) throws IOException { - Resource r = BuilderUtils.newResource(1024, 1); + Resource r = Resources.createResource(1024); return createContainerToken(cId, rmIdentifier, nodeId, user, r, containerTokenSecretManager, logAggregationContext, containerType); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java index a2ef9d9186..3241cca276 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java @@ -106,6 +106,7 @@ import org.apache.hadoop.yarn.server.nodemanager.recovery.NMNullStateStoreService; import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.ControlledClock; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Test; import org.mockito.ArgumentMatcher; @@ -1391,7 +1392,7 @@ protected void scheduleContainer(Container container) { cId = BuilderUtils.newContainerId(appId, 1, timestamp, id); when(mockContainer.getId()).thenReturn(cId); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(1024); when(mockContainer.getResource()).thenReturn(resource); String host = "127.0.0.1"; int port = 1234; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java index ed22254906..15dac3daa5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java @@ -126,6 +126,7 @@ import org.apache.hadoop.yarn.util.AuxiliaryServiceHelper; import org.apache.hadoop.yarn.util.LinuxResourceCalculatorPlugin; import org.apache.hadoop.yarn.util.ResourceCalculatorPlugin; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Assume; import org.junit.Before; @@ -1481,7 +1482,7 @@ public void handle(Event event) { protected Token createContainerToken(ContainerId cId, Priority priority, long createTime) throws InvalidToken { - Resource r = BuilderUtils.newResource(1024, 1); + Resource r = Resources.createResource(1024); ContainerTokenIdentifier containerTokenIdentifier = new ContainerTokenIdentifier(cId, context.getNodeId().toString(), user, r, System.currentTimeMillis() + 10000L, 123, DUMMY_RM_IDENTIFIER, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java index 4ec8f462f5..746826a136 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java @@ -143,6 +143,7 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.Records; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -2293,7 +2294,7 @@ private ContainerId createContainer(ApplicationAttemptId appAttemptId1, long cId, ContainerType containerType) { ContainerId containerId = BuilderUtils.newContainerId(appAttemptId1, cId); - Resource r = BuilderUtils.newResource(1024, 1); + Resource r = Resources.createResource(1024); ContainerTokenIdentifier containerToken = new ContainerTokenIdentifier( containerId, context.getNodeId().toString(), user, r, System.currentTimeMillis() + 100000L, 123, DUMMY_RM_IDENTIFIER, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java index 1719e1b11d..c4a2cfc0d7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java @@ -86,6 +86,7 @@ import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree; import org.apache.hadoop.yarn.util.ResourceCalculatorPlugin; import org.apache.hadoop.yarn.util.TestProcfsBasedProcessTree; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -301,7 +302,7 @@ public void testContainerKillOnMemoryOverflow() throws IOException, commands.add("/bin/bash"); commands.add(scriptFile.getAbsolutePath()); containerLaunchContext.setCommands(commands); - Resource r = BuilderUtils.newResource(0, 0); + Resource r = Resources.createResource(0); ContainerTokenIdentifier containerIdentifier = new ContainerTokenIdentifier(cId, context.getNodeId().toString(), user, r, System.currentTimeMillis() + 120000, 123, DUMMY_RM_IDENTIFIER, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerBehaviorCompatibility.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerBehaviorCompatibility.java index 5b99285d2e..f7d0b1f1af 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerBehaviorCompatibility.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerBehaviorCompatibility.java @@ -25,7 +25,7 @@ import org.apache.hadoop.yarn.api.records.ExecutionType; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.nodemanager.containermanager.BaseContainerManagerTest; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -70,7 +70,7 @@ public void testForceStartGuaranteedContainersWhenOppContainerDisabled() // on the RM side it won't check vcores at all. list.add(StartContainerRequest.newInstance(containerLaunchContext, createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, - context.getNodeId(), user, BuilderUtils.newResource(2048, 4), + context.getNodeId(), user, Resources.createResource(2048, 4), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerOppContainersByResources.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerOppContainersByResources.java index 30fbbde129..e4be5f4993 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerOppContainersByResources.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerOppContainersByResources.java @@ -33,7 +33,7 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.BaseContainerManagerTest; import org.apache.hadoop.yarn.server.nodemanager.containermanager.BaseContainerSchedulerTest; import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Test; @@ -161,7 +161,7 @@ public void testKillOpportunisticWhenNoResourcesAvailable() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); @@ -170,7 +170,7 @@ public void testKillOpportunisticWhenNoResourcesAvailable() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -219,7 +219,7 @@ public void testOpportunisticRunsWhenResourcesAvailable() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(i), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.java index 218d03afe7..fab3061304 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/scheduler/TestContainerSchedulerQueuing.java @@ -41,7 +41,7 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEventType; import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; import org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.resources.ResourceHandlerChain; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Test; @@ -86,14 +86,14 @@ public void testStartMultipleContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(1024, 1), + user, Resources.createResource(1024), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(1024, 1), + user, Resources.createResource(1024), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -141,14 +141,14 @@ public void testQueueMultipleContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(3072, 1), + user, Resources.createResource(3072), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(3072, 1), + user, Resources.createResource(3072), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -198,21 +198,21 @@ public void testStartAndQueueMultipleContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(1024, 1), + user, Resources.createResource(1024), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(2), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(1024, 1), + user, Resources.createResource(1024), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -269,7 +269,7 @@ public void testStartOpportunisticsWhenOppQueueIsFull() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); @@ -281,7 +281,7 @@ public void testStartOpportunisticsWhenOppQueueIsFull() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(i), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); } @@ -354,21 +354,21 @@ public void testKillOpportunisticForGuaranteedContainer() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(2), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); @@ -447,7 +447,7 @@ public void testPauseOpportunisticForGuaranteedContainer() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -463,7 +463,7 @@ public void testPauseOpportunisticForGuaranteedContainer() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); allRequests = @@ -560,7 +560,7 @@ public void testQueueShedding() throws Exception { containerLaunchContext, createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); @@ -573,42 +573,42 @@ public void testQueueShedding() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(2), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(3), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(4), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(5), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(6), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -681,7 +681,7 @@ public void testContainerDeQueuedAfterAMKill() throws Exception { containerLaunchContext, createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); @@ -694,14 +694,14 @@ public void testContainerDeQueuedAfterAMKill() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(2), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -743,21 +743,21 @@ public void testKillMultipleOpportunisticContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(2), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -770,7 +770,7 @@ public void testKillMultipleOpportunisticContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(3), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(1500, 1), + user, Resources.createResource(1500), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); @@ -824,7 +824,7 @@ public void testKillOnlyRequiredOpportunisticContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(i), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); } @@ -840,7 +840,7 @@ public void testKillOnlyRequiredOpportunisticContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(i), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); } @@ -888,21 +888,21 @@ public void testStopQueuedContainer() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(2), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -994,14 +994,14 @@ public void testPromotionOfOpportunisticContainers() throws Exception { recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(0), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(2048, 1), + user, Resources.createResource(2048), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); list.add(StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(createContainerId(1), DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(1024, 1), + user, Resources.createResource(1024), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC))); @@ -1044,7 +1044,7 @@ public void testPromotionOfOpportunisticContainers() throws Exception { // Promote Queued Opportunistic Container Token updateToken = createContainerToken(createContainerId(1), 1, DUMMY_RM_IDENTIFIER, - context.getNodeId(), user, BuilderUtils.newResource(1024, 1), + context.getNodeId(), user, Resources.createResource(1024), context.getContainerTokenSecretManager(), null, ExecutionType.GUARANTEED); List updateTokens = new ArrayList(); @@ -1115,7 +1115,7 @@ public void testContainerUpdateExecTypeGuaranteedToOpportunistic() StartContainerRequest.newInstance( recordFactory.newRecordInstance(ContainerLaunchContext.class), createContainerToken(cId, DUMMY_RM_IDENTIFIER, - context.getNodeId(), user, BuilderUtils.newResource(512, 1), + context.getNodeId(), user, Resources.createResource(512), context.getContainerTokenSecretManager(), null)); List list = new ArrayList<>(); list.add(scRequest); @@ -1130,7 +1130,7 @@ public void testContainerUpdateExecTypeGuaranteedToOpportunistic() List updateTokens = new ArrayList<>(); Token containerToken = createContainerToken(cId, 1, DUMMY_RM_IDENTIFIER, context.getNodeId(), - user, BuilderUtils.newResource(512, 1), + user, Resources.createResource(512), context.getContainerTokenSecretManager(), null, ExecutionType.OPPORTUNISTIC); updateTokens.add(containerToken); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/security/TestNMContainerTokenSecretManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/security/TestNMContainerTokenSecretManager.java index f2a46adaf8..2f6698229b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/security/TestNMContainerTokenSecretManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/security/TestNMContainerTokenSecretManager.java @@ -38,6 +38,7 @@ import org.apache.hadoop.yarn.server.nodemanager.recovery.NMMemoryStateStoreService; import org.apache.hadoop.yarn.server.security.BaseContainerTokenSecretManager; import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Test; public class TestNMContainerTokenSecretManager { @@ -122,7 +123,7 @@ private static ContainerTokenIdentifier createContainerTokenId( long rmid = cid.getApplicationAttemptId().getApplicationId() .getClusterTimestamp(); ContainerTokenIdentifier ctid = new ContainerTokenIdentifier(cid, - nodeId.toString(), user, BuilderUtils.newResource(1024, 1), + nodeId.toString(), user, Resources.createResource(1024), System.currentTimeMillis() + 100000L, secretMgr.getCurrentKey().getKeyId(), rmid, Priority.newInstance(0), 0); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java index 6e07fa5034..274d84858b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java @@ -42,6 +42,7 @@ import org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ResourceSet; import org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerExecutionException; import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import java.io.IOException; import java.util.HashMap; @@ -73,7 +74,7 @@ public MockContainer(ApplicationAttemptId appAttemptId, this.containerTokenIdentifier = BuilderUtils.newContainerTokenIdentifier(BuilderUtils .newContainerToken(id, 0, "127.0.0.1", 1234, user, - BuilderUtils.newResource(1024, 1), currentTime + 10000, 123, + Resources.createResource(1024), currentTime + 10000, 123, "password".getBytes(), currentTime)); this.state = ContainerState.NEW; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java index cbfaa17792..3d070ea3d1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java @@ -53,7 +53,7 @@ import org.apache.hadoop.yarn.server.nodemanager.recovery.NMStateStoreService; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.utils.BuilderUtils; - +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -211,7 +211,7 @@ public boolean isPmemCheckEnabled() { long currentTime = System.currentTimeMillis(); Token containerToken = BuilderUtils.newContainerToken(containerId, 0, "127.0.0.1", 1234, - user, BuilderUtils.newResource(1024, 1), currentTime + 10000L, + user, Resources.createResource(1024), currentTime + 10000L, 123, "password".getBytes(), currentTime); Context context = mock(Context.class); Container container = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java index 6f262dc5f1..08c664472a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java @@ -199,6 +199,7 @@ import org.apache.hadoop.classification.VisibleForTesting; import org.apache.hadoop.yarn.util.resource.ResourceUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.apache.hadoop.yarn.util.timeline.TimelineUtils; @@ -1086,7 +1087,7 @@ public GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request) private NodeReport createNodeReports(RMNode rmNode) { SchedulerNodeReport schedulerNodeReport = scheduler.getNodeReport(rmNode.getNodeID()); - Resource used = BuilderUtils.newResource(0, 0); + Resource used = Resources.createResource(0); int numContainers = 0; if (schedulerNodeReport != null) { used = schedulerNodeReport.getUsedResource(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/DefaultAMSProcessor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/DefaultAMSProcessor.java index bab7e521dc..98fb9b3494 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/DefaultAMSProcessor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/DefaultAMSProcessor.java @@ -407,7 +407,7 @@ private void handleNodeUpdates(RMApp app, AllocateResponse allocateResponse) { RMNode rmNode = rmNodeEntry.getKey(); SchedulerNodeReport schedulerNodeReport = getScheduler().getNodeReport(rmNode.getNodeID()); - Resource used = BuilderUtils.newResource(0, 0); + Resource used = Resources.createResource(0); int numContainers = 0; if (schedulerNodeReport != null) { used = schedulerNodeReport.getUsedResource(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java index 2a74d56d92..878546a439 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerConfiguration.java @@ -34,7 +34,6 @@ import org.apache.hadoop.yarn.api.records.ResourceInformation; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.ResourceNotFoundException; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.UnitsConversionUtil; import org.apache.hadoop.yarn.util.resource.ResourceUtils; import org.apache.hadoop.yarn.util.resource.Resources; @@ -629,7 +628,7 @@ private static ConfigurableResource parseOldStyleResource(String input) final int memory = parseOldStyleResourceMemory(resources); final int vcores = parseOldStyleResourceVcores(resources); return new ConfigurableResource( - BuilderUtils.newResource(memory, vcores)); + Resources.createResource(memory, vcores)); } private static String[] findOldStyleResourcesInSpaceSeparatedInput( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java index ae9487e2de..84e86fa616 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java @@ -40,7 +40,7 @@ import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.After; import org.junit.Test; @@ -291,7 +291,7 @@ private ApplicationId submitAppAndGetAppId(String submitter, ApplicationId applicationId = submitterClient.getNewApplication(newAppRequest).getApplicationId(); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(1024); Map acls = createACLs(submitter, setupACLs); ContainerLaunchContext amContainerSpec = ContainerLaunchContext.newInstance(null, null, null, null, null, acls); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ReservationACLsTestBase.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ReservationACLsTestBase.java index 45060e25be..af4fe7d6c6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ReservationACLsTestBase.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ReservationACLsTestBase.java @@ -57,7 +57,7 @@ .allocationfile.AllocationFileQueue; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair .allocationfile.AllocationFileWriter; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.After; import org.junit.Assert; import org.junit.Test; @@ -69,7 +69,7 @@ public class ReservationACLsTestBase extends ACLsTestBase { private final int defaultDuration = 600000; private final ReservationRequest defaultRequest = ReservationRequest - .newInstance(BuilderUtils.newResource(1024, 1), 1, 1, + .newInstance(Resources.createResource(1024), 1, 1, defaultDuration); private final ReservationRequests defaultRequests = ReservationRequests .newInstance(Collections.singletonList(defaultRequest), diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java index 846c77d401..7e8cf7e6f4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java @@ -75,7 +75,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Before; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; @@ -246,7 +246,7 @@ private ApplicationId submitAppAndGetAppId(AccessControlList viewACL, ContainerLaunchContext amContainer = recordFactory .newRecordInstance(ContainerLaunchContext.class); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(1024); context.setResource(resource); amContainer.setApplicationACLs(acls); if (conf.get(YarnConfiguration.RM_SCHEDULER) @@ -456,7 +456,7 @@ private void verifyInvalidQueueWithAcl() throws Exception { new HashMap(); ContainerLaunchContext amContainer = recordFactory.newRecordInstance(ContainerLaunchContext.class); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(1024); context.setResource(resource); amContainer.setApplicationACLs(acls); context.setQueue("InvalidQueue"); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java index 4c4040a00e..e001bc9bd6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java @@ -2728,9 +2728,9 @@ protected ClientRMService createClientRMService() { resourceManager = rm; rm.start(); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(976562); resource.setResourceInformation("memory-mb", - ResourceInformation.newInstance("memory-mb", "G", 1024)); + ResourceInformation.newInstance("memory-mb", "G", 976562)); resource.setResourceInformation("resource1", ResourceInformation.newInstance("resource1", "T", 1)); resource.setResourceInformation("resource2", @@ -2771,8 +2771,8 @@ protected ClientRMService createClientRMService() { Assert.assertEquals(1000000000, nodeReports.get(0).getCapability(). getResourceInformation("resource2").getValue()); - //Resource 'memory-mb' has been passed as 1024G while registering NM - //1024G should be converted to 976562Mi + //Resource 'memory-mb' has been passed as 976562G while registering NM + //976562G should be converted to 976562Mi Assert.assertEquals("Mi", nodeReports.get(0).getCapability(). getResourceInformation("memory-mb").getUnits()); Assert.assertEquals(976562, nodeReports.get(0).getCapability(). diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java index 90ba812632..928f5f5066 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java @@ -77,6 +77,7 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.Records; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -570,9 +571,9 @@ protected void serviceStop() throws Exception { private static ResourceScheduler createMockScheduler(Configuration conf) { ResourceScheduler mockSched = mock(ResourceScheduler.class); - doReturn(BuilderUtils.newResource(512, 0)).when(mockSched) + doReturn(Resources.createResource(512)).when(mockSched) .getMinimumResourceCapability(); - doReturn(BuilderUtils.newResource(5120, 0)).when(mockSched) + doReturn(Resources.createResource(5120)).when(mockSched) .getMaximumResourceCapability(); return mockSched; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java index 6a8806572c..e4f0b79e37 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java @@ -146,6 +146,7 @@ import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.server.utils.YarnServerBuilderUtils; import org.apache.hadoop.yarn.util.Records; +import org.apache.hadoop.yarn.util.resource.Resources; import org.apache.hadoop.yarn.util.YarnVersionInfo; import org.junit.After; import org.junit.Assert; @@ -613,7 +614,7 @@ public void testNodeRegistrationSuccess() throws Exception { RegisterNodeManagerRequest req = Records.newRecord( RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); req.setResource(capability); req.setNodeId(nodeId); req.setHttpPort(1234); @@ -655,7 +656,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234); @@ -704,7 +705,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234); @@ -757,7 +758,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { RegisterNodeManagerRequest req = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); req.setResource(capability); req.setNodeId(nodeId); req.setHttpPort(1234); @@ -808,7 +809,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { RegisterNodeManagerRequest req = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); req.setResource(capability); req.setNodeId(nodeId); req.setHttpPort(1234); @@ -851,7 +852,7 @@ public void testNodeRegistrationWithAttributes() throws Exception { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); NodeAttribute nodeAttribute1 = NodeAttribute .newInstance(NodeAttribute.PREFIX_DISTRIBUTED, "Attr1", NodeAttributeType.STRING, "V1"); @@ -898,7 +899,7 @@ public void testNodeRegistrationWithInvalidAttributes() throws Exception { RegisterNodeManagerRequest req = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); NodeAttribute validNodeAttribute = NodeAttribute .newInstance(NodeAttribute.PREFIX_DISTRIBUTED, "Attr1", NodeAttributeType.STRING, "V1"); @@ -1001,7 +1002,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234); @@ -1073,7 +1074,7 @@ public void testNodeHeartbeatWithNodeAttributes() throws Exception { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234); @@ -1150,7 +1151,7 @@ public void testNodeHeartbeatWithInvalidNodeAttributes() throws Exception { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234); @@ -1284,7 +1285,7 @@ public Object answer(InvocationOnMock invocation) throws Exception { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234); @@ -1441,7 +1442,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234); @@ -1494,7 +1495,7 @@ protected RMNodeLabelsManager createNodeLabelManager() { RegisterNodeManagerRequest req = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); req.setResource(capability); req.setNodeId(nodeId); req.setHttpPort(1234); @@ -1542,7 +1543,7 @@ public void testNodeRegistrationVersionLessThanRM() throws Exception { RegisterNodeManagerRequest req = Records.newRecord( RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); req.setResource(capability); req.setNodeId(nodeId); req.setHttpPort(1234); @@ -1611,7 +1612,7 @@ public void testNodeRegistrationWithMinimumAllocations() throws Exception { NodeId nodeId = BuilderUtils.newNodeId("host", 1234); req.setNodeId(nodeId); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); req.setResource(capability); RegisterNodeManagerResponse response1 = resourceTrackerService.registerNodeManager(req); @@ -2777,7 +2778,7 @@ protected Dispatcher createDispatcher() { RegisterNodeManagerRequest req = Records.newRecord( RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host2", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); NodeStatus mockNodeStatus = createMockNodeStatus(); @@ -3058,7 +3059,7 @@ public void testSystemCredentialsAfterTokenSequenceNoChange() recordFactory.newRecordInstance(RegisterNodeManagerRequest.class); request.setNodeId(nodeId); request.setHttpPort(1234); - request.setResource(BuilderUtils.newResource(1024, 1)); + request.setResource(Resources.createResource(1024)); resourceTrackerService.registerNodeManager(request); org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMDelegatedNodeLabelsUpdater.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMDelegatedNodeLabelsUpdater.java index 993b05e24e..def531f9c5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMDelegatedNodeLabelsUpdater.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMDelegatedNodeLabelsUpdater.java @@ -34,9 +34,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.MockRM; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.YarnVersionInfo; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -133,7 +133,7 @@ private void registerNode(ResourceManager rm, NodeId nodeId) rm.getResourceTrackerService(); RegisterNodeManagerRequest req = Records.newRecord(RegisterNodeManagerRequest.class); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); req.setResource(capability); req.setNodeId(nodeId); req.setHttpPort(1234); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java index 017a1e021d..328f3b46a4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMExpiry.java @@ -46,8 +46,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEventType; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType; import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Before; import org.junit.Test; @@ -136,7 +136,7 @@ public void testNMExpiry() throws Exception { String hostname1 = "localhost1"; String hostname2 = "localhost2"; String hostname3 = "localhost3"; - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); NodeStatus mockNodeStatus = createMockNodeStatus(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMReconnect.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMReconnect.java index 817fb9dfc3..f5a3bf85bc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMReconnect.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestNMReconnect.java @@ -55,7 +55,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType; import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM; import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -133,7 +133,7 @@ public void tearDown() { @Test public void testReconnect() throws Exception { String hostname1 = "localhost1"; - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); RegisterNodeManagerRequest request1 = recordFactory .newRecordInstance(RegisterNodeManagerRequest.class); @@ -152,7 +152,7 @@ public void testReconnect() throws Exception { rmNodeEvents.clear(); resourceTrackerService.registerNodeManager(request1); - capability = BuilderUtils.newResource(1024, 2); + capability = Resources.createResource(1024, 2); request1.setResource(capability); Assert.assertEquals(RMNodeEventType.RECONNECTED, rmNodeEvents.get(0).getType()); @@ -176,7 +176,7 @@ public void testCompareRMNodeAfterReconnect() throws Exception { dispatcher.register(SchedulerEventType.class, scheduler); String hostname1 = "localhost1"; - Resource capability = BuilderUtils.newResource(4096, 4); + Resource capability = Resources.createResource(4096, 4); RegisterNodeManagerRequest request1 = recordFactory .newRecordInstance(RegisterNodeManagerRequest.class); @@ -195,7 +195,7 @@ public void testCompareRMNodeAfterReconnect() throws Exception { context.getRMNodes().get(nodeId1)); Assert.assertEquals(context.getRMNodes().get(nodeId1). getTotalCapability(), capability); - Resource capability1 = BuilderUtils.newResource(2048, 2); + Resource capability1 = Resources.createResource(2048, 2); request1.setResource(capability1); resourceTrackerService.registerNodeManager(request1); Assert.assertNotNull(context.getRMNodes().get(nodeId1)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java index 4f9469548a..6e36c533a4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/resourcetracker/TestRMNMRPCResponseId.java @@ -44,8 +44,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEventType; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType; import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -94,7 +94,7 @@ public void tearDown() { @Test public void testRPCResponseId() throws IOException, YarnException { String node = "localhost"; - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); RegisterNodeManagerRequest request = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class); nodeId = NodeId.newInstance(node, 1234); request.setNodeId(nodeId); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java index 4e5ff3f768..9e8f2f5edb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java @@ -311,7 +311,7 @@ public void setUp() throws Exception { final String queue = MockApps.newQueue(); submissionContext = mock(ApplicationSubmissionContext.class); when(submissionContext.getQueue()).thenReturn(queue); - Resource resource = BuilderUtils.newResource(1536, 1); + Resource resource = Resources.createResource(1536); ContainerLaunchContext amContainerSpec = BuilderUtils.newContainerLaunchContext(null, null, null, null, null, null); @@ -629,7 +629,7 @@ private Container allocateApplicationAttempt() { // Mock the allocation of AM container Container container = mock(Container.class); - Resource resource = BuilderUtils.newResource(2048, 1); + Resource resource = Resources.createResource(2048); when(container.getId()).thenReturn( BuilderUtils.newContainerId(applicationAttempt.getAppAttemptId(), 1)); when(container.getResource()).thenReturn(resource); @@ -1199,7 +1199,7 @@ public void testLaunchedFailWhileAHSEnabled() { RMAppAttemptEventType.ATTEMPT_ADDED)); Container amContainer = mock(Container.class); - Resource resource = BuilderUtils.newResource(2048, 1); + Resource resource = Resources.createResource(2048); when(amContainer.getId()).thenReturn( BuilderUtils.newContainerId(myApplicationAttempt.getAppAttemptId(), 1)); when(amContainer.getResource()).thenReturn(resource); @@ -1763,7 +1763,7 @@ public void testContainerRemovedBeforeAllocate() { // Mock the allocation of AM container Container container = mock(Container.class); - Resource resource = BuilderUtils.newResource(2048, 1); + Resource resource = Resources.createResource(2048); when(container.getId()).thenReturn( BuilderUtils.newContainerId(applicationAttempt.getAppAttemptId(), 1)); when(container.getResource()).thenReturn(resource); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java index 72f420eea8..c16116f22c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java @@ -73,6 +73,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.constraint.AllocationTagsManager; import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey; import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -100,7 +101,7 @@ public void testReleaseWhileRunning() { ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1); ContainerAllocationExpirer expirer = mock(ContainerAllocationExpirer.class); - Resource resource = BuilderUtils.newResource(512, 1); + Resource resource = Resources.createResource(512); Priority priority = BuilderUtils.newPriority(5); Container container = BuilderUtils.newContainer(containerId, nodeId, @@ -206,7 +207,7 @@ public void testExpireWhileRunning() { ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1); ContainerAllocationExpirer expirer = mock(ContainerAllocationExpirer.class); - Resource resource = BuilderUtils.newResource(512, 1); + Resource resource = Resources.createResource(512); Priority priority = BuilderUtils.newPriority(5); Container container = BuilderUtils.newContainer(containerId, nodeId, @@ -407,7 +408,7 @@ public void testContainerTransitionNotifyAllocationTagsManager() ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1); ContainerAllocationExpirer expirer = mock(ContainerAllocationExpirer.class); - Resource resource = BuilderUtils.newResource(512, 1); + Resource resource = Resources.createResource(512); Priority priority = BuilderUtils.newPriority(5); Container container = BuilderUtils.newContainer(containerId, nodeId, @@ -582,7 +583,7 @@ public void testContainerAcquiredAtKilled() { ContainerId containerId = BuilderUtils.newContainerId(appAttemptId, 1); ContainerAllocationExpirer expirer = mock(ContainerAllocationExpirer.class); - Resource resource = BuilderUtils.newResource(512, 1); + Resource resource = Resources.createResource(512); Priority priority = BuilderUtils.newPriority(5); Container container = BuilderUtils.newContainer(containerId, nodeId, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java index 76fbf0936f..e53ac5aff2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestAbstractYarnScheduler.java @@ -84,7 +84,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM; import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; import org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; @@ -1048,7 +1047,7 @@ public void testNodemanagerReconnect() throws Exception { // Register node1 String hostname1 = "localhost1"; - Resource capability = BuilderUtils.newResource(4096, 4); + Resource capability = Resources.createResource(4096, 4); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); @@ -1068,7 +1067,7 @@ public void testNodemanagerReconnect() throws Exception { Assert.assertEquals("Initial cluster resources don't match", capability, clusterResource); - Resource newCapability = BuilderUtils.newResource(1024, 1); + Resource newCapability = Resources.createResource(1024); RegisterNodeManagerRequest request2 = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class); request2.setNodeId(nodeId1); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLs.java index cf9a01045b..d319353704 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLs.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestApplicationPriorityACLs.java @@ -36,7 +36,7 @@ import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.server.resourcemanager.ACLsTestBase; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; import org.junit.Test; @@ -108,7 +108,7 @@ private ApplicationSubmissionContext prepareForAppSubmission(String submitter, ApplicationId applicationId = submitterClient .getNewApplication(newAppRequest).getApplicationId(); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(1024); ContainerLaunchContext amContainerSpec = ContainerLaunchContext .newInstance(null, null, null, null, null, null); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAmbiguousLeafs.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAmbiguousLeafs.java index 69824e3c3f..88e6aff253 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAmbiguousLeafs.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAmbiguousLeafs.java @@ -24,7 +24,7 @@ import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.server.resourcemanager.MockRM; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; +import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Test; import java.io.IOException; @@ -52,7 +52,7 @@ private ApplicationId submitApplication(MockRM rm, String queue) final ApplicationAttemptId appAttemptId = TestUtils .getMockApplicationAttemptId(appId++, 1); - Resource resource = BuilderUtils.newResource(1024, 1); + Resource resource = Resources.createResource(1024); ContainerLaunchContext amContainerSpec = ContainerLaunchContext .newInstance(null, null, null, null, null, null); ApplicationSubmissionContext asc = ApplicationSubmissionContext diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java index 5508f0f2bd..a3d8f10ab2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FairSchedulerTestBase.java @@ -51,7 +51,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAttemptAddedSchedulerEvent; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; @@ -124,7 +123,7 @@ protected ResourceRequest createResourceRequest( int memory, int vcores, String host, int priority, int numContainers, boolean relaxLocality) { ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class); - request.setCapability(BuilderUtils.newResource(memory, vcores)); + request.setCapability(Resources.createResource(memory, vcores)); request.setResourceName(host); request.setNumContainers(numContainers); Priority prio = recordFactory.newRecordInstance(Priority.class); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java index 2b768bebe9..2f700f3d82 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java @@ -3295,7 +3295,7 @@ public void testBasicDRFAssignment() throws Exception { scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); - RMNode node = MockNodes.newNodeInfo(1, BuilderUtils.newResource(8192, 5)); + RMNode node = MockNodes.newNodeInfo(1, Resources.createResource(8192, 5)); NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node); scheduler.handle(nodeEvent); @@ -3337,7 +3337,7 @@ public void testBasicDRFWithQueues() throws Exception { scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); - RMNode node = MockNodes.newNodeInfo(1, BuilderUtils.newResource(8192, 7), + RMNode node = MockNodes.newNodeInfo(1, Resources.createResource(8192, 7), 1, "127.0.0.1"); NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node); scheduler.handle(nodeEvent); @@ -3375,7 +3375,7 @@ public void testDRFHierarchicalQueues() throws Exception { scheduler.start(); scheduler.reinitialize(conf, resourceManager.getRMContext()); - RMNode node = MockNodes.newNodeInfo(1, BuilderUtils.newResource(12288, 12), + RMNode node = MockNodes.newNodeInfo(1, Resources.createResource(12288, 12), 1, "127.0.0.1"); NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node); scheduler.handle(nodeEvent); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java index 2ec1af363b..38fbcd8415 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairSchedulerConfiguration.java @@ -24,7 +24,6 @@ import org.apache.hadoop.yarn.api.records.ResourceInformation; import org.apache.hadoop.yarn.api.records.impl.LightWeightResource; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.UnitsConversionUtil; import org.apache.hadoop.yarn.util.resource.CustomResourceTypesConfigurationProvider; import org.apache.hadoop.yarn.util.resource.DominantResourceCalculator; @@ -125,8 +124,8 @@ private void expectNegativeValueOfResource(String resource) { @Test public void testParseResourceConfigValue() throws Exception { - Resource expected = BuilderUtils.newResource(5 * 1024, 2); - Resource clusterResource = BuilderUtils.newResource(10 * 1024, 4); + Resource expected = Resources.createResource(5 * 1024, 2); + Resource clusterResource = Resources.createResource(10 * 1024, 4); assertEquals(expected, parseResourceConfigValue("5120 mb 2 vcores").getResource()); @@ -155,13 +154,13 @@ public void testParseResourceConfigValue() throws Exception { assertEquals(expected, parseResourceConfigValue("50% Memory, 50% CpU"). getResource(clusterResource)); - assertEquals(BuilderUtils.newResource(5 * 1024, 4), + assertEquals(Resources.createResource(5 * 1024, 4), parseResourceConfigValue("50% memory, 100% cpu"). getResource(clusterResource)); - assertEquals(BuilderUtils.newResource(5 * 1024, 4), + assertEquals(Resources.createResource(5 * 1024, 4), parseResourceConfigValue(" 100% cpu, 50% memory"). getResource(clusterResource)); - assertEquals(BuilderUtils.newResource(5 * 1024, 0), + assertEquals(Resources.createResource(5 * 1024, 0), parseResourceConfigValue("50% memory, 0% cpu"). getResource(clusterResource)); assertEquals(expected, @@ -176,7 +175,7 @@ public void testParseResourceConfigValue() throws Exception { assertEquals(expected, parseResourceConfigValue("50.% memory, 50.% cpu"). getResource(clusterResource)); - assertEquals(BuilderUtils.newResource((int)(1024 * 10 * 0.109), 2), + assertEquals(Resources.createResource((int)(1024 * 10 * 0.109), 2), parseResourceConfigValue("10.9% memory, 50.6% cpu"). getResource(clusterResource)); assertEquals(expected, @@ -187,8 +186,8 @@ public void testParseResourceConfigValue() throws Exception { conf.set(YarnConfiguration.RESOURCE_TYPES, "test1"); ResourceUtils.resetResourceTypes(conf); - clusterResource = BuilderUtils.newResource(10 * 1024, 4); - expected = BuilderUtils.newResource(5 * 1024, 2); + clusterResource = Resources.createResource(10 * 1024, 4); + expected = Resources.createResource(5 * 1024, 2); expected.setResourceValue("test1", Long.MAX_VALUE); assertEquals(expected, @@ -233,7 +232,7 @@ public void testParseResourceConfigValue() throws Exception { parseResourceConfigValue(" vcores = 2 , memory-mb = 5120 , " + "test1 = 4 ").getResource()); - expected = BuilderUtils.newResource(4 * 1024, 3); + expected = Resources.createResource(4 * 1024, 3); expected.setResourceValue("test1", 8L); assertEquals(expected, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java index 197651a64c..1cb25242b1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/policies/TestDominantResourceFairnessPolicy.java @@ -39,7 +39,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.Schedulable; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.DominantResourceFairnessPolicy.DominantResourceFairnessComparatorN; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.DominantResourceFairnessPolicy.DominantResourceFairnessComparator2; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.resource.ResourceUtils; import org.apache.hadoop.yarn.util.resource.Resources; import org.junit.Assert; @@ -84,8 +83,8 @@ private Schedulable createSchedulable(int memUsage, int cpuUsage, private Schedulable createSchedulable(int memUsage, int cpuUsage, float weights, int minMemShare, int minCpuShare) { - Resource usage = BuilderUtils.newResource(memUsage, cpuUsage); - Resource minShare = BuilderUtils.newResource(minMemShare, minCpuShare); + Resource usage = Resources.createResource(memUsage, cpuUsage); + Resource minShare = Resources.createResource(minMemShare, minCpuShare); return new FakeSchedulable(minShare, Resources.createResource(Integer.MAX_VALUE, Integer.MAX_VALUE), weights, Resources.none(), usage, 0l); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java index 7183f7f782..b58dd0b6a6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fifo/TestFifoScheduler.java @@ -955,10 +955,10 @@ public void testBlackListNodes() throws Exception { // Ask for a 1 GB container for app 1 List ask1 = new ArrayList(); ask1.add(BuilderUtils.newResourceRequest(BuilderUtils.newPriority(0), - "rack1", BuilderUtils.newResource(GB, 1), 1, + "rack1", Resources.createResource(GB), 1, RMNodeLabelsManager.NO_LABEL)); ask1.add(BuilderUtils.newResourceRequest(BuilderUtils.newPriority(0), - ResourceRequest.ANY, BuilderUtils.newResource(GB, 1), 1, + ResourceRequest.ANY, Resources.createResource(GB), 1, RMNodeLabelsManager.NO_LABEL)); fs.allocate(appAttemptId1, ask1, null, emptyId, Collections.singletonList(host_1_0), null, NULL_UPDATE_REQUESTS); @@ -991,7 +991,7 @@ public void testBlackListNodes() throws Exception { // this time, rack0 is also in blacklist, so only host_1_1 is available to // be assigned ask2.add(BuilderUtils.newResourceRequest(BuilderUtils.newPriority(0), - ResourceRequest.ANY, BuilderUtils.newResource(GB, 1), 1)); + ResourceRequest.ANY, Resources.createResource(GB), 1)); fs.allocate(appAttemptId1, ask2, null, emptyId, Collections.singletonList("rack0"), null, NULL_UPDATE_REQUESTS); @@ -1077,14 +1077,14 @@ public void testHeadroom() throws Exception { // Ask for a 1 GB container for app 1 List ask1 = new ArrayList(); ask1.add(BuilderUtils.newResourceRequest(BuilderUtils.newPriority(0), - ResourceRequest.ANY, BuilderUtils.newResource(GB, 1), 1)); + ResourceRequest.ANY, Resources.createResource(GB), 1)); fs.allocate(appAttemptId1, ask1, null, emptyId, null, null, NULL_UPDATE_REQUESTS); // Ask for a 2 GB container for app 2 List ask2 = new ArrayList(); ask2.add(BuilderUtils.newResourceRequest(BuilderUtils.newPriority(0), - ResourceRequest.ANY, BuilderUtils.newResource(2 * GB, 1), 1)); + ResourceRequest.ANY, Resources.createResource(2 * GB), 1)); fs.allocate(appAttemptId2, ask2, null, emptyId, null, null, NULL_UPDATE_REQUESTS); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java index e507267703..20bdb64ee3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesNodes.java @@ -59,7 +59,6 @@ import org.apache.hadoop.yarn.api.records.ResourceOption; import org.apache.hadoop.yarn.api.records.ResourceUtilization; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.server.api.records.NodeHealthStatus; import org.apache.hadoop.yarn.server.api.records.NodeStatus; import org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus; @@ -83,6 +82,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceOptionInfo; import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.RackResolver; +import org.apache.hadoop.yarn.util.resource.Resources; import org.apache.hadoop.yarn.util.YarnVersionInfo; import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; import org.apache.hadoop.yarn.webapp.GuiceServletConfig; @@ -1006,7 +1006,7 @@ public void testNodeAttributesInfo() throws Exception { RegisterNodeManagerRequest registerReq = Records.newRecord(RegisterNodeManagerRequest.class); NodeId nodeId = NodeId.newInstance("host1", 1234); - Resource capability = BuilderUtils.newResource(1024, 1); + Resource capability = Resources.createResource(1024); registerReq.setResource(capability); registerReq.setNodeId(nodeId); registerReq.setHttpPort(1234);