Skip to content

Commit

Permalink
chore: akka-http to 2.7.0-M1, akka to 2.10.0-M1, align with changes f…
Browse files Browse the repository at this point in the history
…rom upstream (#1321)

* chore: akka-http to 2.7.0-M1, akka to 2.10.0-M1, align with changes from upstream

* use log4j-slf4j2-impl instead of log4j-slf4j-impl

* revert versions in sample
  • Loading branch information
sebastian-alfers authored Sep 25, 2024
1 parent fc6a485 commit 555ed88
Show file tree
Hide file tree
Showing 31 changed files with 122 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pullRequests.frequency = "@monthly"

updates.pin = [
# To be updated in tandem with upstream Akka
{groupId = "com.fasterxml.jackson.core", version = "2.15."}
{groupId = "com.fasterxml.jackson.core", version = "2.17."}
{groupId = "org.scalatest", artifactId = "scalatest", version = "3.2."}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ import java.util.concurrent.TimeUnit

import akka.actor.ActorSystem
import akka.event.LoggingAdapter

import com.typesafe.config.Config

import scala.concurrent.duration.{ FiniteDuration, _ }
import scala.compat.java8.OptionConverters._
import akka.util.JavaDurationConverters._
import scala.jdk.DurationConverters._
import scala.jdk.OptionConverters._

final class ClusterBootstrapSettings(config: Config, log: LoggingAdapter) {
import akka.management.AkkaManagementSettings._

val managementBasePath: Option[String] =
Option(config.getString("akka.management.http.base-path")).filter(_.trim.nonEmpty)

def getManagementBasePath: Optional[String] = managementBasePath.asJava
def getManagementBasePath: Optional[String] = managementBasePath.toJava

private val bootConfig = config.getConfig("akka.management.cluster.bootstrap")

Expand Down Expand Up @@ -84,16 +86,16 @@ final class ClusterBootstrapSettings(config: Config, log: LoggingAdapter) {
}

/** Java API */
def getContactPointDiscoveryServiceName: Optional[String] = contactPointDiscovery.serviceName.asJava
def getContactPointDiscoveryServiceName: Optional[String] = contactPointDiscovery.serviceName.toJava

/** Java API */
def getContactPointDiscoveryServiceNamespace: Optional[String] = contactPointDiscovery.serviceNamespace.asJava
def getContactPointDiscoveryServiceNamespace: Optional[String] = contactPointDiscovery.serviceNamespace.toJava

/** Java API */
def getContactPointDiscoveryPortName: Optional[String] = contactPointDiscovery.portName.asJava
def getContactPointDiscoveryPortName: Optional[String] = contactPointDiscovery.portName.toJava

/** Java API */
def getContactPointDiscoveryProtocol: Optional[String] = contactPointDiscovery.protocol.asJava
def getContactPointDiscoveryProtocol: Optional[String] = contactPointDiscovery.protocol.toJava

/** Java API */
def getContactPointDiscoveryEffectiveName(system: ActorSystem): String = contactPointDiscovery.effectiveName(system)
Expand All @@ -102,24 +104,24 @@ final class ClusterBootstrapSettings(config: Config, log: LoggingAdapter) {
def getContactPointDiscoveryMethod: String = contactPointDiscovery.discoveryMethod

/** Java API */
def getContactPointDiscoveryStableMargin: java.time.Duration = contactPointDiscovery.stableMargin.asJava
def getContactPointDiscoveryStableMargin: java.time.Duration = contactPointDiscovery.stableMargin.toJava

/** Java API */
def getContactPointDiscoveryInterval: java.time.Duration = contactPointDiscovery.interval.asJava
def getContactPointDiscoveryInterval: java.time.Duration = contactPointDiscovery.interval.toJava

/** Java API */
def getContactPointDiscoveryExponentialBackoffRandomFactor: Double =
contactPointDiscovery.exponentialBackoffRandomFactor

/** Java API */
def getContactPointDiscoveryExponentialBackoffMax: java.time.Duration =
contactPointDiscovery.exponentialBackoffMax.asJava
contactPointDiscovery.exponentialBackoffMax.toJava

/** Java API */
def getContactPointDiscoveryRequiredContactPointsNr: Int = contactPointDiscovery.requiredContactPointsNr

/** Java API */
def getContactPointDiscoveryResolveTimeout: java.time.Duration = contactPointDiscovery.resolveTimeout.asJava
def getContactPointDiscoveryResolveTimeout: java.time.Duration = contactPointDiscovery.resolveTimeout.toJava

object contactPoint {
private val contactPointConfig = bootConfig.getConfig("contact-point")
Expand Down Expand Up @@ -149,7 +151,7 @@ final class ClusterBootstrapSettings(config: Config, log: LoggingAdapter) {
def getContactPointFallbackPort: Int = contactPoint.fallbackPort

/** Java API */
def getContactPointProbingFailureTimeout: java.time.Duration = contactPoint.probingFailureTimeout.asJava
def getContactPointProbingFailureTimeout: java.time.Duration = contactPoint.probingFailureTimeout.toJava

object joinDecider {
val implClass: String = bootConfig.getString("join-decider.class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ package akka.management.cluster.bootstrap

import java.time.LocalDateTime

import scala.collection.JavaConverters._
import scala.concurrent.Future
import scala.jdk.CollectionConverters._

import akka.actor.Address
import akka.discovery.ServiceDiscovery.ResolvedTarget

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package akka.management.cluster.bootstrap

import java.time.Duration

import scala.annotation.nowarn
import scala.concurrent.Future

import akka.actor.ActorSystem
import akka.actor.Address
import akka.discovery.ServiceDiscovery.ResolvedTarget
import akka.util.unused

/**
* The decision of joining "self" is made by deterministically sorting the discovered services
Expand Down Expand Up @@ -140,7 +141,8 @@ class LowestAddressJoinDecider(system: ActorSystem, settings: ClusterBootstrapSe
* contact points have not been confirmed (unreachable or not running).
* `hasEnoughContactPoints` and `isPastStableMargin` must still be fulfilled.
*/
protected def isConfirmedCommunicationWithAllContactPointsRequired(@unused info: SeedNodesInformation): Boolean =
protected def isConfirmedCommunicationWithAllContactPointsRequired(
@nowarn("msg=never used") info: SeedNodesInformation): Boolean =
settings.contactPointDiscovery.contactWithAllContactPoints

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ import java.util.concurrent.CompletionStage

import akka.management.cluster.scaladsl.{ ClusterMembershipCheck => ScalaClusterReadinessCheck }

import scala.compat.java8.FutureConverters._
import scala.concurrent.ExecutionContext
import scala.jdk.FutureConverters._

import akka.actor.ActorSystem
import akka.dispatch.ExecutionContexts

class ClusterMembershipCheck(system: ActorSystem)
extends java.util.function.Supplier[CompletionStage[java.lang.Boolean]] {

private val delegate = new ScalaClusterReadinessCheck(system)

override def get(): CompletionStage[java.lang.Boolean] = {
delegate.apply().map(Boolean.box)(ExecutionContexts.parasitic).toJava
delegate.apply().map(Boolean.box)(ExecutionContext.parasitic).asJava
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import akka.cluster.{ Cluster, MemberStatus }
import akka.util.Helpers
import com.typesafe.config.Config

import scala.collection.JavaConverters._
import scala.concurrent.Future
import scala.jdk.CollectionConverters._

/**
* Internal API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package akka.discovery.awsapi.ecs

import java.net.{ InetAddress, NetworkInterface }

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

import akka.annotation.ApiMayChange

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ package akka.discovery.awsapi.ecs
import java.net.InetAddress
import java.util.concurrent.TimeoutException

import scala.collection.JavaConverters._
import scala.collection.immutable.Seq
import scala.compat.java8.FutureConverters.toScala
import scala.concurrent.duration._
import scala.concurrent.{ ExecutionContext, Future }
import scala.jdk.CollectionConverters._
import scala.jdk.FutureConverters._
import scala.util.Try

import akka.actor.ActorSystem
Expand Down Expand Up @@ -98,8 +98,8 @@ object AsyncEcsServiceDiscovery {
accumulator: Seq[String] = Seq.empty
)(implicit ec: ExecutionContext): Future[Seq[String]] =
for {
listTasksResponse <- toScala(
ecsClient.listTasks(
listTasksResponse <- ecsClient
.listTasks(
ListTasksRequest
.builder()
.cluster(cluster)
Expand All @@ -108,7 +108,7 @@ object AsyncEcsServiceDiscovery {
.desiredStatus(DesiredStatus.RUNNING)
.build()
)
)
.asScala
accumulatedTasksArns = accumulator ++ listTasksResponse.taskArns().asScala
taskArns <- listTasksResponse.nextToken() match {
case null =>
Expand All @@ -131,11 +131,11 @@ object AsyncEcsServiceDiscovery {
for {
// Each DescribeTasksRequest can contain at most 100 task ARNs.
describeTasksResponses <- Future.traverse(taskArns.grouped(100))(taskArnGroup =>
toScala(
ecsClient.describeTasks(
ecsClient
.describeTasks(
DescribeTasksRequest.builder().cluster(cluster).tasks(taskArnGroup.asJava).include(TaskField.TAGS).build()
)
))
.asScala)
tasks = describeTasksResponses.flatMap(_.tasks().asScala).toList
} yield tasks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ package akka.discovery.awsapi.ecs
import java.net.InetAddress
import java.util.concurrent.TimeoutException

import scala.collection.JavaConverters._
import scala.collection.immutable.Seq
import scala.compat.java8.FutureConverters.toScala
import scala.concurrent.duration._
import scala.concurrent.{ ExecutionContext, Future }
import scala.jdk.FutureConverters._
import scala.jdk.CollectionConverters._
import scala.util.Try

import akka.actor.ActorSystem
Expand Down Expand Up @@ -131,11 +131,13 @@ object AsyncEcsTaskSetDiscovery {
private[this] def resolveTaskSet(ecsClient: EcsAsyncClient, cluster: String, taskArn: String)(
implicit ec: ExecutionContext
): Future[Option[TaskSet]] =
toScala(
ecsClient.describeTasks(
ecsClient
.describeTasks(
DescribeTasksRequest.builder().cluster(cluster).tasks(taskArn).include(TaskField.TAGS).build()
)
).map(_.tasks().asScala.headOption).map(_.map(task => TaskSet(task.startedBy())))
.asScala
.map(_.tasks().asScala.headOption)
.map(_.map(task => TaskSet(task.startedBy())))

private[this] def listTaskArns(
ecsClient: EcsAsyncClient,
Expand All @@ -145,8 +147,8 @@ object AsyncEcsTaskSetDiscovery {
accumulator: Seq[String] = Seq.empty
)(implicit ec: ExecutionContext): Future[Seq[String]] =
for {
listTasksResponse <- toScala(
ecsClient.listTasks(
listTasksResponse <- ecsClient
.listTasks(
ListTasksRequest
.builder()
.cluster(cluster)
Expand All @@ -155,7 +157,7 @@ object AsyncEcsTaskSetDiscovery {
.desiredStatus(DesiredStatus.RUNNING)
.build()
)
)
.asScala
accumulatedTasksArns = accumulator ++ listTasksResponse.taskArns().asScala
taskArns <- listTasksResponse.nextToken() match {
case null =>
Expand All @@ -178,11 +180,11 @@ object AsyncEcsTaskSetDiscovery {
for {
// Each DescribeTasksRequest can contain at most 100 task ARNs.
describeTasksResponses <- Future.traverse(taskArns.grouped(100))(taskArnGroup =>
toScala(
ecsClient.describeTasks(
ecsClient
.describeTasks(
DescribeTasksRequest.builder().cluster(cluster).tasks(taskArnGroup.asJava).include(TaskField.TAGS).build()
)
))
.asScala)
tasks = describeTasksResponses.flatMap(_.tasks().asScala).toList
} yield tasks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import com.amazonaws.retry.PredefinedRetryPolicies
import com.amazonaws.services.ec2.model.{ DescribeInstancesRequest, Filter, Reservation }
import com.amazonaws.services.ec2.{ AmazonEC2, AmazonEC2ClientBuilder }
import scala.annotation.tailrec
import scala.collection.JavaConverters._
import scala.collection.immutable.Seq
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{ ExecutionContext, Future }
import scala.jdk.CollectionConverters._
import scala.util.{ Failure, Success, Try }

/** INTERNAL API */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import com.amazonaws.retry.PredefinedRetryPolicies
import com.amazonaws.services.ecs.model.{ DescribeTasksRequest, DesiredStatus, ListTasksRequest, Task }
import com.amazonaws.services.ecs.{ AmazonECS, AmazonECSClientBuilder }
import scala.annotation.tailrec
import scala.collection.JavaConverters._
import scala.collection.immutable.Seq
import scala.concurrent.{ ExecutionContext, Future }
import scala.concurrent.duration._
import scala.jdk.CollectionConverters._
import scala.util.Try

final class EcsServiceDiscovery(system: ActorSystem) extends ServiceDiscovery {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.scalatest.matchers.should.Matchers

class FiltersParsingTest extends AnyFunSuite with Matchers {

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

test("empty string does not break parsing") {
val filters = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.Optional
import akka.actor._
import com.typesafe.config.Config

import scala.compat.java8.OptionConverters._
import scala.jdk.OptionConverters._

final class Settings(system: ExtendedActorSystem) extends Extension {

Expand Down Expand Up @@ -48,7 +48,7 @@ final class Settings(system: ExtendedActorSystem) extends Extension {
kubernetesApi.optDefinedValue("pod-namespace")

/** Java API */
def getPodNamespace: Optional[String] = podNamespace.asJava
def getPodNamespace: Optional[String] = podNamespace.toJava

val podDomain: String =
kubernetesApi.getString("pod-domain")
Expand Down
2 changes: 1 addition & 1 deletion integration-test/aws-api-ec2/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ libraryDependencies += "com.amazonaws" % "aws-java-sdk-cloudformation" % "1.12.6

libraryDependencies += "com.amazonaws" % "aws-java-sdk-autoscaling" % "1.12.635" % Test

libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.15.3" // aws SDK depends on insecure jackson
libraryDependencies += "com.fasterxml.jackson.core" % "jackson-databind" % "2.17.2" // aws SDK depends on insecure jackson

libraryDependencies += "org.scalatest" %% "scalatest" % Dependencies.ScalaTestVersion % Test
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class IntegrationTest
with SpanSugar
with Matchers {

import collection.JavaConverters._
import scala.jdk.CollectionConverters._

private val buildId: String = System.getenv("BUILD_ID")
assert(buildId != null, "BUILD_ID environment variable has to be defined")
Expand Down
17 changes: 17 additions & 0 deletions integration-test/dns-api-mesos/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
enablePlugins(JavaAppPackaging)

resolvers += "Akka library repository".at("https://repo.akka.io/maven")

name := "bootstrap-demo-dns-api"

scalaVersion := "2.13.14"

def akkaManagementVersion(version: String) = version.split('+')(0)

libraryDependencies += "com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % akkaManagementVersion(
version.value)

libraryDependencies += "com.lightbend.akka.management" %% "akka-management-cluster-http" % akkaManagementVersion(
version.value)

libraryDependencies += "com.typesafe.akka" %% "akka-discovery" % "2.10.0-M1"
6 changes: 3 additions & 3 deletions integration-test/kubernetes-api-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<properties>
<encoding>UTF-8</encoding>
<maven.compiler.release>11</maven.compiler.release>
<akka.version>2.9.3</akka.version>
<akka.http.version>10.6.3</akka.http.version>
<akka.version>2.10.0-M1</akka.version>
<akka.http.version>10.7.0-M1</akka.http.version>
<akka-management.version>1.5.2</akka-management.version>
<scala.binary.version>2.13</scala.binary.version>
</properties>
Expand Down Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.13</version>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>com.lightbend.akka.management</groupId>
Expand Down
Loading

0 comments on commit 555ed88

Please sign in to comment.