format source with scalafmt

This commit is contained in:
Auto Format 2019-03-11 10:38:24 +01:00 committed by Patrik Nordwall
parent 0f40491d42
commit ce404e4f53
1669 changed files with 43208 additions and 35404 deletions

View file

@ -11,7 +11,7 @@ import scala.collection.immutable
import scala.util.control.NonFatal
import akka.actor.{ ActorRef, ExtendedActorSystem }
import akka.event.{ Logging, LoggingAdapter }
import akka.util.{ OptionVal, unused }
import akka.util.{ unused, OptionVal }
import akka.util.ccompat._
/**
@ -27,6 +27,7 @@ import akka.util.ccompat._
* delegate to any shared instance it doesn't have to be thread-safe.
*/
abstract class RemoteInstrument {
/**
* Instrument identifier.
*
@ -93,10 +94,9 @@ abstract class RemoteInstrument {
* }}}
*
*/
private[remote] final class RemoteInstruments(
private val system: ExtendedActorSystem,
private val log: LoggingAdapter,
_instruments: Vector[RemoteInstrument]) {
private[remote] final class RemoteInstruments(private val system: ExtendedActorSystem,
private val log: LoggingAdapter,
_instruments: Vector[RemoteInstrument]) {
import RemoteInstruments._
def this(system: ExtendedActorSystem, log: LoggingAdapter) = this(system, log, RemoteInstruments.create(system, log))
@ -122,9 +122,9 @@ private[remote] final class RemoteInstruments(
serializeInstrument(instrument, oe, buffer)
} catch {
case NonFatal(t) =>
log.debug(
"Skipping serialization of RemoteInstrument {} since it failed with {}",
instrument.identifier, t.getMessage)
log.debug("Skipping serialization of RemoteInstrument {} since it failed with {}",
instrument.identifier,
t.getMessage)
buffer.position(rewindPos)
}
i += 1
@ -145,11 +145,16 @@ private[remote] final class RemoteInstruments(
}
}
private def serializeInstrument(instrument: RemoteInstrument, outboundEnvelope: OutboundEnvelope, buffer: ByteBuffer): Unit = {
private def serializeInstrument(instrument: RemoteInstrument,
outboundEnvelope: OutboundEnvelope,
buffer: ByteBuffer): Unit = {
val startPos = buffer.position()
buffer.putInt(0)
val dataPos = buffer.position()
instrument.remoteWriteMetadata(outboundEnvelope.recipient.orNull, outboundEnvelope.message, outboundEnvelope.sender.orNull, buffer)
instrument.remoteWriteMetadata(outboundEnvelope.recipient.orNull,
outboundEnvelope.message,
outboundEnvelope.sender.orNull,
buffer)
val endPos = buffer.position()
if (endPos == dataPos) {
// if the instrument didn't write anything, then rewind to the start
@ -188,9 +193,9 @@ private[remote] final class RemoteInstruments(
deserializeInstrument(instrument, inboundEnvelope, buffer)
} catch {
case NonFatal(t) =>
log.debug(
"Skipping deserialization of RemoteInstrument {} since it failed with {}",
instrument.identifier, t.getMessage)
log.debug("Skipping deserialization of RemoteInstrument {} since it failed with {}",
instrument.identifier,
t.getMessage)
}
i += 1
} else if (key > identifier) {
@ -205,9 +210,9 @@ private[remote] final class RemoteInstruments(
buffer.position(nextPos)
}
} else {
if (log.isDebugEnabled) log.debug(
"Skipping serialized data in message for RemoteInstrument(s) {} that has no local match",
remoteInstrumentIdIteratorRaw(buffer, endPos).mkString("[", ", ", "]"))
if (log.isDebugEnabled)
log.debug("Skipping serialized data in message for RemoteInstrument(s) {} that has no local match",
remoteInstrumentIdIteratorRaw(buffer, endPos).mkString("[", ", ", "]"))
}
} catch {
case NonFatal(t) =>
@ -217,8 +222,13 @@ private[remote] final class RemoteInstruments(
}
}
private def deserializeInstrument(instrument: RemoteInstrument, inboundEnvelope: InboundEnvelope, buffer: ByteBuffer): Unit = {
instrument.remoteReadMetadata(inboundEnvelope.recipient.orNull, inboundEnvelope.message, inboundEnvelope.sender.orNull, buffer)
private def deserializeInstrument(instrument: RemoteInstrument,
inboundEnvelope: InboundEnvelope,
buffer: ByteBuffer): Unit = {
instrument.remoteReadMetadata(inboundEnvelope.recipient.orNull,
inboundEnvelope.message,
inboundEnvelope.sender.orNull,
buffer)
}
def messageSent(outboundEnvelope: OutboundEnvelope, size: Int, time: Long): Unit = {
@ -237,8 +247,15 @@ private[remote] final class RemoteInstruments(
messageSent(0)
}
private def messageSentInstrument(instrument: RemoteInstrument, outboundEnvelope: OutboundEnvelope, size: Int, time: Long): Unit = {
instrument.remoteMessageSent(outboundEnvelope.recipient.orNull, outboundEnvelope.message, outboundEnvelope.sender.orNull, size, time)
private def messageSentInstrument(instrument: RemoteInstrument,
outboundEnvelope: OutboundEnvelope,
size: Int,
time: Long): Unit = {
instrument.remoteMessageSent(outboundEnvelope.recipient.orNull,
outboundEnvelope.message,
outboundEnvelope.sender.orNull,
size,
time)
}
def messageReceived(inboundEnvelope: InboundEnvelope, size: Int, time: Long): Unit = {
@ -257,8 +274,15 @@ private[remote] final class RemoteInstruments(
messageRecieved(0)
}
private def messageReceivedInstrument(instrument: RemoteInstrument, inboundEnvelope: InboundEnvelope, size: Int, time: Long): Unit = {
instrument.remoteMessageReceived(inboundEnvelope.recipient.orNull, inboundEnvelope.message, inboundEnvelope.sender.orNull, size, time)
private def messageReceivedInstrument(instrument: RemoteInstrument,
inboundEnvelope: InboundEnvelope,
size: Int,
time: Long): Unit = {
instrument.remoteMessageReceived(inboundEnvelope.recipient.orNull,
inboundEnvelope.message,
inboundEnvelope.sender.orNull,
size,
time)
}
private def remoteInstrumentIdIteratorRaw(buffer: ByteBuffer, endPos: Int): Iterator[Int] = {
@ -294,11 +318,16 @@ private[remote] object RemoteInstruments {
val c = system.settings.config
val path = "akka.remote.artery.advanced.instruments"
import scala.collection.JavaConverters._
c.getStringList(path).asScala.iterator.map { fqcn =>
system
.dynamicAccess.createInstanceFor[RemoteInstrument](fqcn, Nil)
.orElse(system.dynamicAccess.createInstanceFor[RemoteInstrument](fqcn, List(classOf[ExtendedActorSystem] -> system)))
.get
}.to(immutable.Vector)
c.getStringList(path)
.asScala
.iterator
.map { fqcn =>
system.dynamicAccess
.createInstanceFor[RemoteInstrument](fqcn, Nil)
.orElse(system.dynamicAccess
.createInstanceFor[RemoteInstrument](fqcn, List(classOf[ExtendedActorSystem] -> system)))
.get
}
.to(immutable.Vector)
}
}