diff --git a/build.sbt b/build.sbt index 0422e1a..ec53415 100644 --- a/build.sbt +++ b/build.sbt @@ -5,11 +5,11 @@ organization := "com.sclasen" name := "akka-zk-cluster-seed" version := "0.1.11-SNAPSHOT" -scalaVersion := "2.12.4" -crossScalaVersions := Seq(scalaVersion.value, "2.11.11") +scalaVersion := "2.13.0" +crossScalaVersions := Seq(scalaVersion.value, "2.12.8", "2.11.12") -val akkaVersion = "2.5.9" -val akkaHttpVersion = "10.0.11" +val akkaVersion = "2.5.+" +val akkaHttpVersion = "10.1.+" val akkaDependencies = Seq( "com.typesafe.akka" %% "akka-actor" % akkaVersion, @@ -25,7 +25,7 @@ val exhibitorOptionalDependencies = Seq( "com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion ).map(_ % Provided) -val curatorVersion = "2.12.0" +val curatorVersion = "4.2.0" val zkDependencies = Seq( "curator-framework", @@ -39,7 +39,7 @@ val testDependencies = Seq( "com.typesafe.akka" %% "akka-testkit" % akkaVersion, "com.typesafe.akka" %% "akka-actor" % akkaVersion, "com.typesafe.akka" %% "akka-cluster" % akkaVersion, - "org.scalatest" %% "scalatest" % "3.0.1", + "org.scalatest" %% "scalatest" % "3.0.8", "com.typesafe.akka" %% "akka-multi-node-testkit" % akkaVersion, "com.typesafe.akka" %% "akka-slf4j" % akkaVersion, "org.slf4j" % "log4j-over-slf4j" % "1.7.7", diff --git a/src/main/scala/akka/cluster/seed/ExhibitorClient.scala b/src/main/scala/akka/cluster/seed/ExhibitorClient.scala index cfa199c..4af809b 100644 --- a/src/main/scala/akka/cluster/seed/ExhibitorClient.scala +++ b/src/main/scala/akka/cluster/seed/ExhibitorClient.scala @@ -2,7 +2,6 @@ package akka.cluster.seed import java.security.cert.X509Certificate import javax.net.ssl.{SSLContext, X509TrustManager} - import akka.actor.ActorSystem import akka.http.scaladsl._ import akka.http.scaladsl.model.Uri.Path @@ -12,10 +11,8 @@ import akka.util.{ByteString, Timeout} import com.typesafe.sslconfig.akka.AkkaSSLConfig import spray.json.DefaultJsonProtocol._ import spray.json.JsonParser - import scala.concurrent.duration._ import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future} -import scala.language.postfixOps case class ExhibitorClient(system: ActorSystem, exhibitorUrl: String, requestPath: String, validateCerts: Boolean) extends Client { @@ -75,9 +72,9 @@ object SSL { lazy val nonValidatingContext: SSLContext = { class IgnoreX509TrustManager extends X509TrustManager { - def checkClientTrusted(chain: Array[X509Certificate], authType: String) {} + def checkClientTrusted(chain: Array[X509Certificate], authType: String):Unit = {} - def checkServerTrusted(chain: Array[X509Certificate], authType: String) {} + def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {} def getAcceptedIssuers = null } diff --git a/src/main/scala/akka/cluster/seed/ZookeeperClusterSeed.scala b/src/main/scala/akka/cluster/seed/ZookeeperClusterSeed.scala index 9d8d23b..4be8622 100644 --- a/src/main/scala/akka/cluster/seed/ZookeeperClusterSeed.scala +++ b/src/main/scala/akka/cluster/seed/ZookeeperClusterSeed.scala @@ -1,7 +1,6 @@ package akka.cluster.seed import java.io.Closeable - import akka.actor._ import akka.cluster.{AkkaCuratorClient, AutoDownUnresolvedStrategies, Cluster, ZookeeperClusterSeedSettings} import org.apache.curator.framework.CuratorFramework @@ -9,7 +8,6 @@ import org.apache.curator.framework.recipes.cache.{PathChildrenCache, PathChildr import org.apache.curator.framework.recipes.leader.{LeaderLatch, LeaderLatchListener} import org.apache.curator.framework.state.{ConnectionState, ConnectionStateListener} import org.apache.zookeeper.KeeperException.{NoNodeException, NodeExistsException} - import scala.annotation.tailrec import scala.collection.JavaConverters._ import scala.collection.{immutable, mutable} @@ -102,11 +100,11 @@ class ZookeeperClusterSeed(system: ExtendedActorSystem) extends Extension { def waitForLeaderChange(times: Int, delay: Int) (removedAddress: String): Either[Unit, Unit] = latch.getLeader.getId.equals(removedAddress) match { - case false => Left(null) + case false => Left(()) case _ if times > 0 => Thread.sleep(delay) waitForLeaderChange(times - 1, delay)(removedAddress) - case _ => Right(null) + case _ => Right(()) } val pathCache = new PathChildrenCache(client, path, true) @@ -206,7 +204,7 @@ class ZookeeperClusterSeed(system: ExtendedActorSystem) extends Extension { } } - private def createPathIfNeeded() { + private def createPathIfNeeded(): Unit = { Option(client.checkExists().forPath(path)).getOrElse { try { client.create().creatingParentsIfNeeded().forPath(path)