Java Code Examples for org.apache.hadoop.yarn.api.records.Resource#setGpuCores()
The following examples show how to use
org.apache.hadoop.yarn.api.records.Resource#setGpuCores() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestYarnServerApiClasses.java From hadoop with Apache License 2.0 | 6 votes |
/** * Test RegisterNodeManagerRequestPBImpl. */ @Test public void testRegisterNodeManagerRequestPBImpl() { RegisterNodeManagerRequestPBImpl original = new RegisterNodeManagerRequestPBImpl(); original.setHttpPort(8080); original.setNodeId(getNodeId()); Resource resource = recordFactory.newRecordInstance(Resource.class); resource.setMemory(10000); resource.setVirtualCores(2); resource.setGpuCores(3); original.setResource(resource); RegisterNodeManagerRequestPBImpl copy = new RegisterNodeManagerRequestPBImpl( original.getProto()); assertEquals(8080, copy.getHttpPort()); assertEquals(9090, copy.getNodeId().getPort()); assertEquals(10000, copy.getResource().getMemory()); assertEquals(2, copy.getResource().getVirtualCores()); assertEquals(3, copy.getResource().getGpuCores()); }
Example 2
Source File: TestApplicationClientProtocolOnHA.java From hadoop with Apache License 2.0 | 6 votes |
@Test(timeout = 15000) public void testSubmitApplicationOnHA() throws Exception { ApplicationSubmissionContext appContext = Records.newRecord(ApplicationSubmissionContext.class); appContext.setApplicationId(cluster.createFakeAppId()); ContainerLaunchContext amContainer = Records.newRecord(ContainerLaunchContext.class); appContext.setAMContainerSpec(amContainer); Resource capability = Records.newRecord(Resource.class); capability.setMemory(10); capability.setVirtualCores(1); capability.setGpuCores(1); appContext.setResource(capability); ApplicationId appId = client.submitApplication(appContext); Assert.assertTrue(getActiveRM().getRMContext().getRMApps() .containsKey(appId)); }
Example 3
Source File: Resources.java From hadoop with Apache License 2.0 | 5 votes |
public static Resource createResource(int memory, int cores, int gcores) { Resource resource = Records.newRecord(Resource.class); resource.setMemory(memory); resource.setVirtualCores(cores); resource.setGpuCores(gcores); return resource; }
Example 4
Source File: Resources.java From hadoop with Apache License 2.0 | 5 votes |
public static Resource multiplyAndRoundDown(Resource lhs, double by) { Resource out = clone(lhs); out.setMemory((int)(lhs.getMemory() * by)); out.setVirtualCores((int)(lhs.getVirtualCores() * by)); out.setGpuCores((int)(lhs.getGpuCores() * by)); return out; }
Example 5
Source File: BuilderUtils.java From hadoop with Apache License 2.0 | 5 votes |
public static Resource newResource(int memory, int vCores) { Resource resource = recordFactory.newRecordInstance(Resource.class); resource.setMemory(memory); resource.setVirtualCores(vCores); resource.setGpuCores(0); return resource; }
Example 6
Source File: BuilderUtils.java From hadoop with Apache License 2.0 | 5 votes |
public static Resource newResource(int memory, int vCores, int gCores) { Resource resource = recordFactory.newRecordInstance(Resource.class); resource.setMemory(memory); resource.setVirtualCores(vCores); resource.setGpuCores(gCores); return resource; }
Example 7
Source File: ComputeFairShares.java From hadoop with Apache License 2.0 | 5 votes |
private static void setResourceValue(int val, Resource resource, ResourceType type) { switch (type) { case MEMORY: resource.setMemory(val); break; case CPU: resource.setVirtualCores(val); break; case GPU: resource.setGpuCores(val); break; default: throw new IllegalArgumentException("Invalid resource"); } }
Example 8
Source File: Resources.java From hadoop with Apache License 2.0 | 4 votes |
public static Resource addTo(Resource lhs, Resource rhs) { lhs.setMemory(lhs.getMemory() + rhs.getMemory()); lhs.setVirtualCores(lhs.getVirtualCores() + rhs.getVirtualCores()); lhs.setGpuCores(lhs.getGpuCores() + rhs.getGpuCores()); return lhs; }
Example 9
Source File: Resources.java From hadoop with Apache License 2.0 | 4 votes |
public static Resource subtractFrom(Resource lhs, Resource rhs) { lhs.setMemory(lhs.getMemory() - rhs.getMemory()); lhs.setVirtualCores(lhs.getVirtualCores() - rhs.getVirtualCores()); lhs.setGpuCores(lhs.getGpuCores() - rhs.getGpuCores()); return lhs; }
Example 10
Source File: Resources.java From hadoop with Apache License 2.0 | 4 votes |
public static Resource multiplyTo(Resource lhs, double by) { lhs.setMemory((int)(lhs.getMemory() * by)); lhs.setVirtualCores((int)(lhs.getVirtualCores() * by)); lhs.setGpuCores((int) (lhs.getGpuCores() * by)); return lhs; }
Example 11
Source File: TestNodeManagerMetrics.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testNames() { DefaultMetricsSystem.initialize("NodeManager"); NodeManagerMetrics metrics = NodeManagerMetrics.create(); Resource total = Records.newRecord(Resource.class); total.setMemory(8*GiB); total.setVirtualCores(16); total.setGpuCores(16); Resource resource = Records.newRecord(Resource.class); resource.setMemory(512); //512MiB resource.setVirtualCores(2); resource.setGpuCores(1); metrics.addResource(total); for (int i = 10; i-- > 0;) { // allocate 10 containers(allocatedGB: 5GiB, availableGB: 3GiB) metrics.launchedContainer(); metrics.allocateContainer(resource); } metrics.initingContainer(); metrics.endInitingContainer(); metrics.runningContainer(); metrics.endRunningContainer(); // Releasing 3 containers(allocatedGB: 3.5GiB, availableGB: 4.5GiB) metrics.completedContainer(); metrics.releaseContainer(resource); metrics.failedContainer(); metrics.releaseContainer(resource); metrics.killedContainer(); metrics.releaseContainer(resource); metrics.initingContainer(); metrics.runningContainer(); Assert.assertTrue(!metrics.containerLaunchDuration.changed()); metrics.addContainerLaunchDuration(1); Assert.assertTrue(metrics.containerLaunchDuration.changed()); // availableGB is expected to be floored, // while allocatedGB is expected to be ceiled. // allocatedGB: 3.5GB allocated memory is shown as 4GB // availableGB: 4.5GB available memory is shown as 4GB checkMetrics(10, 1, 1, 1, 1, 1, 4, 7, 4, 14, 2, 7, 9); }
Example 12
Source File: TestResourceTrackerService.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testNodeRegistrationWithMinimumAllocations() throws Exception { Configuration conf = new Configuration(); conf.set(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, "2048"); conf.set(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, "4"); conf.set(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_GCORES, "4"); rm = new MockRM(conf); rm.start(); ResourceTrackerService resourceTrackerService = rm.getResourceTrackerService(); RegisterNodeManagerRequest req = Records.newRecord( RegisterNodeManagerRequest.class); NodeId nodeId = BuilderUtils.newNodeId("host", 1234); req.setNodeId(nodeId); Resource capability = BuilderUtils.newResource(1024, 1, 1); req.setResource(capability); RegisterNodeManagerResponse response1 = resourceTrackerService.registerNodeManager(req); Assert.assertEquals(NodeAction.SHUTDOWN,response1.getNodeAction()); capability.setMemory(2048); capability.setVirtualCores(1); capability.setGpuCores(1); req.setResource(capability); RegisterNodeManagerResponse response2 = resourceTrackerService.registerNodeManager(req); Assert.assertEquals(NodeAction.SHUTDOWN,response2.getNodeAction()); capability.setMemory(1024); capability.setVirtualCores(4); capability.setGpuCores(4); req.setResource(capability); RegisterNodeManagerResponse response3 = resourceTrackerService.registerNodeManager(req); Assert.assertEquals(NodeAction.SHUTDOWN,response3.getNodeAction()); capability.setMemory(2048); capability.setVirtualCores(4); capability.setGpuCores(4); req.setResource(capability); RegisterNodeManagerResponse response4 = resourceTrackerService.registerNodeManager(req); Assert.assertEquals(NodeAction.NORMAL,response4.getNodeAction()); }