private def awaitEndpointCompletion()

in sagemaker-spark-sdk/src/main/scala/com/amazonaws/services/sagemaker/sparksdk/SageMakerModel.scala [452:486]


  private def awaitEndpointCompletion(endpointName : String) : Unit = {
    val startTime = this.timeProvider.currentTimeMillis
    val describeEndpointRequest = new DescribeEndpointRequest().withEndpointName(endpointName)
    InternalUtils.applyUserAgent(describeEndpointRequest)
    log.info(s"Begin waiting for endpoint completion for endpoint $endpointName")
    while (this.timeProvider.currentTimeMillis - startTime <
      SageMakerModel.EndpointCreationTimeout.toMillis) {
      try {
        val response = sagemakerClient.describeEndpoint(describeEndpointRequest)
        val currentStatus = EndpointStatus.fromValue(response.getEndpointStatus)
        log.info(s"Endpoint creation status: $currentStatus")
        currentStatus match {
          case EndpointStatus.InService => return
          case EndpointStatus.Failed =>
            val message = s"Endpoint '$endpointName' failed for reason:" +
              s" '${response.getFailureReason}'"
            throw new RuntimeException(message)
          case _ => // for any other statuses, continue polling
        }
      } catch {
        case e : SdkBaseException =>
          if (!RetryUtils.isRetryableServiceException(e)) {
            throw e
          }
          log.warn(s"Retryable exception: ${e.getMessage}")
        case t : Throwable => throw t
      }

      timeProvider.sleep(SageMakerModel.EndpointPollInterval.toMillis)
    }

    throw new RuntimeException(
      s"Timed out after ${SageMakerModel.EndpointCreationTimeout.toString}" +
      s" while waiting for Endpoint '$endpointName' to finish creating.")
  }