james-deee commented on code in PR #1628: URL: https://github.com/apache/samza/pull/1628#discussion_r976687067
########## samza-yarn3/src/test/scala/org/apache/samza/job/yarn/TestSamzaYarnAppMasterLifecycle.scala: ########## @@ -0,0 +1,204 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.samza.job.yarn + +import java.net.URL +import java.nio.ByteBuffer + +import org.apache.hadoop.conf.Configuration +import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse +import org.apache.hadoop.yarn.api.records._ +import org.apache.hadoop.yarn.client.api.AMRMClient.ContainerRequest +import org.apache.hadoop.yarn.client.api.async.AMRMClientAsync.CallbackHandler +import org.apache.hadoop.yarn.client.api.async.impl.AMRMClientAsyncImpl +import org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes +import org.apache.hadoop.yarn.util.ConverterUtils +import org.apache.samza.SamzaException +import org.apache.samza.clustermanager.SamzaApplicationState +import org.apache.samza.clustermanager.SamzaApplicationState.SamzaAppStatus +import org.apache.samza.coordinator.JobModelManager +import org.junit.Assert._ +import org.junit.Test +import org.mockito.{ArgumentCaptor, Mockito} + +class TestSamzaYarnAppMasterLifecycle { + private def YARN_CONTAINER_ID = "container_123_123_123" + private def YARN_CONTAINER_HOST = "host" + private def YARN_CONTAINER_MEM = 1024 + private def YARN_CONTAINER_VCORE = 1 + val coordinator = new JobModelManager(null, null) + val amClient = new AMRMClientAsyncImpl[ContainerRequest](1, Mockito.mock(classOf[CallbackHandler])) { + var host = "" + var port = 0 + var status: FinalApplicationStatus = null + override def registerApplicationMaster(appHostName: String, appHostPort: Int, appTrackingUrl: String): RegisterApplicationMasterResponse = { + this.host = appHostName + this.port = appHostPort + new RegisterApplicationMasterResponse { + override def setApplicationACLs(map: java.util.Map[ApplicationAccessType, String]): Unit = () + override def getApplicationACLs = null + override def setResourceTypes(types: java.util.List[org.apache.hadoop.yarn.api.records.ResourceTypeInfo]): Unit = () + override def getResourceTypes = null + override def setMaximumResourceCapability(r: Resource): Unit = () + override def getMaximumResourceCapability = new Resource { + def getMemory = 512 + def getVirtualCores = 2 + def setMemory(memory: Int) {} + def setVirtualCores(vCores: Int) {} + override def compareTo(o: Resource) = 0 + } + override def getClientToAMTokenMasterKey = null + override def setClientToAMTokenMasterKey(buffer: ByteBuffer) {} + // to test AM high availability - return a running container from previous attempt + val prevAttemptCotainers = new java.util.ArrayList[Container]() + prevAttemptCotainers.add(getMockContainer) + override def getContainersFromPreviousAttempts(): java.util.List[Container] = prevAttemptCotainers + override def getNMTokensFromPreviousAttempts(): java.util.List[NMToken] = java.util.Collections.emptyList[NMToken] + override def getQueue(): String = null + override def setContainersFromPreviousAttempts(containers: java.util.List[Container]): Unit = Unit + override def setNMTokensFromPreviousAttempts(nmTokens: java.util.List[NMToken]): Unit = Unit + override def setQueue(queue: String): Unit = Unit + + override def setSchedulerResourceTypes(types: java.util.EnumSet[SchedulerResourceTypes]): Unit = {} + override def getSchedulerResourceTypes: java.util.EnumSet[SchedulerResourceTypes] = null + override def getResourceProfiles(): java.util.Map[String,org.apache.hadoop.yarn.api.records.Resource] = ??? Review Comment: The `getResourceProfiles` and `setResourceProfiles` are 2 required overrides for Yarn3. Yarn2 does NOT have these overrides. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
