Make netty and aeron dependencies optional (#27017)

* Make netty and aeron dependencies optional
* Include agrona as a mandatory dependency (used in compression tables)
Refs #25169
This commit is contained in:
Christopher Batey 2019-05-29 09:50:28 +01:00 committed by GitHub
parent cd6d90097e
commit 96eed177dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 92 additions and 9 deletions

View file

@ -12,6 +12,7 @@ import akka.event.Logging.Error
import akka.pattern.pipe
import scala.util.control.NonFatal
import scala.util.Failure
import akka.actor.SystemGuardian.{ RegisterTerminationHook, TerminationHook, TerminationHookDone }
import scala.util.control.Exception.Catcher
@ -22,6 +23,7 @@ import akka.dispatch.{ RequiresMessageQueue, UnboundedMessageQueueSemantics }
import akka.remote.artery.ArteryTransport
import akka.remote.artery.aeron.ArteryAeronUdpTransport
import akka.remote.artery.ArterySettings
import akka.remote.artery.ArterySettings.AeronUpd
import akka.util.{ ErrorMessages, OptionVal }
import akka.remote.artery.OutboundEnvelope
import akka.remote.artery.SystemMessageDelivery.SystemMessageEnvelope
@ -35,6 +37,7 @@ import com.github.ghik.silencer.silent
*/
@InternalApi
private[akka] object RemoteActorRefProvider {
private final case class Internals(transport: RemoteTransport, remoteDaemon: InternalActorRef)
extends NoSerializationVerificationNeeded
@ -207,6 +210,12 @@ private[akka] class RemoteActorRefProvider(
remoteSettings.configureDispatcher(Props(classOf[RemotingTerminator], local.systemGuardian)),
"remoting-terminator")
if (remoteSettings.Artery.Enabled && remoteSettings.Artery.Transport == AeronUpd) {
checkAeronOnClassPath(system)
} else if (!remoteSettings.Artery.Enabled) {
checkNettyOnClassPath(system)
} // artery tcp has no dependencies
val internals = Internals(
remoteDaemon = {
val d = new RemoteSystemDaemon(
@ -239,6 +248,38 @@ private[akka] class RemoteActorRefProvider(
remoteDeploymentWatcher = createRemoteDeploymentWatcher(system)
}
private def checkNettyOnClassPath(system: ActorSystemImpl): Unit = {
// TODO change link to current once 2.6 is out
checkClassOrThrow(
system,
"org.jboss.netty.channel.Channel",
"Classic",
"Netty",
"https://doc.akka.io/docs/akka/2.6/remoting.html")
}
private def checkAeronOnClassPath(system: ActorSystemImpl): Unit = {
// TODO change link to current once 2.6 is out
val arteryLink = "https://doc.akka.io/docs/akka/2.6/remoting-artery.html"
// using classes that are used so will fail to compile if they get removed from Aeron
checkClassOrThrow(system, "io.aeron.driver.MediaDriver", "Artery", "Aeron driver", arteryLink)
checkClassOrThrow(system, "io.aeron.Aeron", "Artery", "Aeron client", arteryLink)
}
private def checkClassOrThrow(
system: ActorSystemImpl,
className: String,
remoting: String,
libraryMissing: String,
link: String): Unit = {
system.dynamicAccess.getClassFor(className) match {
case Failure(_: ClassNotFoundException | _: NoClassDefFoundError) =>
throw new IllegalStateException(
s"$remoting remoting is enabled but $libraryMissing is not on the classpath, it must be added explicitly. See $link")
case _ =>
}
}
protected def createRemoteWatcher(system: ActorSystemImpl): ActorRef = {
import remoteSettings._
val failureDetector = createRemoteWatcherFailureDetector(system)