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 fd7a2f0ceda..fe2f3072141 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.server.utils.BuilderUtils; 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 class TestRMContainerAllocator { 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 class TestRMContainerAllocator { 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 class TestRMContainerAllocator { 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 class TestRMContainerAllocator { 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 class TestRMContainerAllocator { 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 class TestRMContainerAllocator { 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 class TestRMContainerAllocator { // 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 class TestRMContainerAllocator { // 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 class TestRMContainerAllocator { // 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 class TestRMContainerAllocator { 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 c70a2db25f1..01f9bc7dbea 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.factory.providers.RecordFactoryProvider; 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 @@ public class UnmanagedApplicationManager { 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 511013cad19..6b8d928b7b1 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.nodemanager.security.NMTokenSecretManagerIn 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 class TestNodeStatusUpdater extends NodeManagerTestBase { 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 class TestNodeStatusUpdater extends NodeManagerTestBase { .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 class TestNodeStatusUpdater extends NodeManagerTestBase { 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 class TestNodeStatusUpdater extends NodeManagerTestBase { 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 class TestNodeStatusUpdater extends NodeManagerTestBase { 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 class TestNodeStatusUpdater extends NodeManagerTestBase { 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 9ee3ce6bc8b..37045dc74b8 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.NMContainerTokenSecret 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 abstract class BaseContainerManagerTest { 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 abstract class BaseContainerManagerTest { 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 a2ef9d9186a..3241cca2760 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.NodeStatusUpdater; 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 @@ public class TestContainer { 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 ed22254906b..15dac3daa54 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.Apps; 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 class TestContainerLaunch extends BaseContainerManagerTest { 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 4ec8f462f51..746826a1362 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.nodemanager.executor.DeletionAsUserContext; 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 @@ public class TestLogAggregationService extends BaseContainerManagerTest { 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 1719e1b11db..c4a2cfc0d7c 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.LinuxResourceCalculatorPlugin; 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 class TestContainersMonitor extends BaseContainerManagerTest { 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 5b99285d2e5..f7d0b1f1aff 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.ContainerLaunchContext; 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 class TestContainerSchedulerBehaviorCompatibility // 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 30fbbde1299..e4be5f49932 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.conf.YarnConfiguration; 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 class TestContainerSchedulerOppContainersByResources 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 class TestContainerSchedulerOppContainersByResources 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 class TestContainerSchedulerOppContainersByResources 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 218d03afe7e..fab3061304e 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.BaseContainerS 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { // 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 class TestContainerSchedulerQueuing extends BaseContainerSchedulerTest { 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 f2a46adaf8a..2f6698229ba 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.api.records.MasterKey; 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 @@ public class TestNMContainerTokenSecretManager { 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 6e07fa5034d..274d84858b2 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.container.Reso 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 class MockContainer implements Container { 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 cbfaa177921..3d070ea3d10 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.NMNullStateStoreServic 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 class TestNMWebServer { 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 6f262dc5f12..08c664472a8 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.yarn.util.UTCClock; 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 class ClientRMService extends AbstractService implements 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 bab7e521dc0..98fb9b34942 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 @@ final class DefaultAMSProcessor implements ApplicationMasterServiceProcessor { 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 2a74d56d925..878546a4398 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.Resource; 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 @@ public class FairSchedulerConfiguration extends Configuration { 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 ae9487e2de7..84e86fa6168 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.ContainerLaunchContext; 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 @@ public abstract class QueueACLsTestBase extends ACLsTestBase { 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 45060e25be4..af4fe7d6c6e 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 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair .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 846c77d4017..7e8cf7e6f4f 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.recovery.RMStateStoreFactor 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 @@ public class TestApplicationACLs extends ParameterizedSchedulerTestBase { 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 @@ public class TestApplicationACLs extends ParameterizedSchedulerTestBase { 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 4c4040a00ed..e001bc9bd65 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 @@ public class TestClientRMService { 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 @@ public class TestClientRMService { 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 90ba8126328..928f5f50664 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.security.ApplicationACLsManager; 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 @@ public class TestClientRMTokens { 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 6a8806572cc..e4f0b79e373 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.timelineservice.storage.TimelineWriter; 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 @@ public class TestResourceTrackerService extends NodeLabelTestBase { 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 class TestResourceTrackerService extends NodeLabelTestBase { 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 993b05e24e0..def531f9c59 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.api.protocolrecords.RegisterNodeManagerRequ 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 @@ public class TestRMDelegatedNodeLabelsUpdater extends NodeLabelTestBase { 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 017a1e021d7..328f3b46a47 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.ResourceTrackerService; 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 class TestNMExpiry { 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 817fb9dfc33..f5a3bf85bcc 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.AbstractYarnSched 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 class TestNMReconnect extends ParameterizedSchedulerTestBase { @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 class TestNMReconnect extends ParameterizedSchedulerTestBase { 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 class TestNMReconnect extends ParameterizedSchedulerTestBase { 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 class TestNMReconnect extends ParameterizedSchedulerTestBase { 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 4f9469548ae..6e36c533a4b 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.ResourceTrackerService; 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 class TestRMNMRPCResponseId { @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 4e5ff3f7687..9e8f2f5edbd 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 class TestRMAppAttemptTransitions { 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 @@ public class TestRMAppAttemptTransitions { // 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 class TestRMAppAttemptTransitions { 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 class TestRMAppAttemptTransitions { // 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 72f420eea82..c16116f22c3 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.Alloca 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 class TestRMContainerImpl { 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 class TestRMContainerImpl { 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 class TestRMContainerImpl { 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 class TestRMContainerImpl { 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 76fbf0936f1..e53ac5aff2a 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.scheduler.event.SchedulerEv 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 class TestAbstractYarnScheduler extends ParameterizedSchedulerTestBase { // 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 class TestAbstractYarnScheduler extends ParameterizedSchedulerTestBase { 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 cf9a01045b9..d3193537046 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.conf.YarnConfiguration; 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 @@ public class TestApplicationPriorityACLs extends ACLsTestBase { 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 69824e3c3fa..88e6aff2537 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.conf.YarnConfiguration; 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 @@ public class TestCapacitySchedulerAmbiguousLeafs { 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 5508f0f2bde..a3d8f10ab2f 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.ResourceScheduler 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 @@ public class FairSchedulerTestBase { 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 2b768bebe92..2f700f3d82a 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 class TestFairScheduler extends FairSchedulerTestBase { 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 class TestFairScheduler extends FairSchedulerTestBase { 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 class TestFairScheduler extends FairSchedulerTestBase { 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 2ec1af363b1..38fbcd84153 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.Resource; 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 @@ public class TestFairSchedulerConfiguration { @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 class TestFairSchedulerConfiguration { 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 class TestFairSchedulerConfiguration { 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 class TestFairSchedulerConfiguration { 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 class TestFairSchedulerConfiguration { 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 197651a64c1..1cb25242b15 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.FakeSchedula 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 @@ public class TestDominantResourceFairnessPolicy { 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 7183f7f782f..b58dd0b6a65 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 class TestFifoScheduler { // 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 class TestFifoScheduler { // 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 class TestFifoScheduler { // 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 e5072677030..20bdb64ee32 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.Resource; 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.ResourceInfo; 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 class TestRMWebServicesNodes extends JerseyTestBase { 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);