Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import scala.concurrent.duration._
import scala.jdk.CollectionConverters._
import scala.util.Try
import scala.util.control.NonFatal

import com.github.dockerjava.api.DockerClient
import com.github.dockerjava.api.async.ResultCallback
import com.github.dockerjava.api.command.CreateContainerCmd
Expand All @@ -29,10 +30,11 @@ import com.github.dockerjava.httpclient5.ApacheDockerHttpClient
import org.apache.pekko
import pekko.actor.Props
import pekko.io.dns.internal.DnsClient
import pekko.testkit.PekkoSpec
import pekko.util.Timeout

import pekko.testkit.PekkoSpec
import org.scalatest.concurrent.Eventually

import com.typesafe.config.Config

abstract class DockerBindDnsService(config: Config) extends PekkoSpec(config) with Eventually {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package org.apache.pekko.util

import java.nio.ByteOrder

import org.scalatest.wordspec.AnyWordSpec
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

class SWARUtilSpec extends AnyWordSpec with Matchers {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import pekko.annotation.InternalApi
@InternalApi private[receptionist] object Platform {
type Aux[P] = AbstractServiceKey { type Protocol = P }

type Service[K <: Aux[_]] = K match {
type Service[K <: Aux[?]] = K match {
case Aux[t] => ActorRef[t]
}

type Subscriber[K <: Aux[_]] = K match {
type Subscriber[K <: Aux[?]] = K match {
case Aux[t] => ActorRef[ReceptionistMessages.Listing[t]]
}
}
36 changes: 18 additions & 18 deletions actor/src/main/scala-3/org/apache/pekko/util/ByteIterator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -256,28 +256,28 @@ object ByteIterator {
override def getShort(implicit byteOrder: ByteOrder): Short = {
val cur = current
if cur.len >= java.lang.Short.BYTES then {
val r = cur.getShort(byteOrder)
val r = cur.getShort(using byteOrder)
normalize()
r
} else super.getShort(byteOrder)
} else super.getShort(using byteOrder)
}

override def getInt(implicit byteOrder: ByteOrder): Int = {
val cur = current
if cur.len >= java.lang.Integer.BYTES then {
val r = cur.getInt(byteOrder)
val r = cur.getInt(using byteOrder)
normalize()
r
} else super.getInt(byteOrder)
} else super.getInt(using byteOrder)
}

override def getLong(implicit byteOrder: ByteOrder): Long = {
val cur = current
if cur.len >= java.lang.Long.BYTES then {
val r = cur.getLong(byteOrder)
val r = cur.getLong(using byteOrder)
normalize()
r
} else super.getLong(byteOrder)
} else super.getLong(using byteOrder)
}

final override def len: Int = iterators.foldLeft(0) { _ + _.len }
Expand Down Expand Up @@ -417,19 +417,19 @@ object ByteIterator {
getToArray(xs, offset, n, 1) { getByte } { current.getBytes(_, _, _) }

def getShorts(xs: Array[Short], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 2) { getShort(byteOrder) } { current.getShorts(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 2) { getShort(using byteOrder) } { current.getShorts(_, _, _)(using byteOrder) }

def getInts(xs: Array[Int], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 4) { getInt(byteOrder) } { current.getInts(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 4) { getInt(using byteOrder) } { current.getInts(_, _, _)(using byteOrder) }

def getLongs(xs: Array[Long], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 8) { getLong(byteOrder) } { current.getLongs(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 8) { getLong(using byteOrder) } { current.getLongs(_, _, _)(using byteOrder) }

def getFloats(xs: Array[Float], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 8) { getFloat(byteOrder) } { current.getFloats(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 8) { getFloat(using byteOrder) } { current.getFloats(_, _, _)(using byteOrder) }

def getDoubles(xs: Array[Double], offset: Int, n: Int)(implicit byteOrder: ByteOrder): this.type =
getToArray(xs, offset, n, 8) { getDouble(byteOrder) } { current.getDoubles(_, _, _)(byteOrder) }
getToArray(xs, offset, n, 8) { getDouble(using byteOrder) } { current.getDoubles(_, _, _)(using byteOrder) }

/** For performance sensitive code, call copyToBuffer() directly on ByteString (it's optimised there) */
override def copyToBuffer(buffer: ByteBuffer): Int = {
Expand Down Expand Up @@ -649,10 +649,10 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
}

def getFloat(implicit byteOrder: ByteOrder): Float =
java.lang.Float.intBitsToFloat(getInt(byteOrder))
java.lang.Float.intBitsToFloat(getInt(using byteOrder))

def getDouble(implicit byteOrder: ByteOrder): Double =
java.lang.Double.longBitsToDouble(getLong(byteOrder))
java.lang.Double.longBitsToDouble(getLong(using byteOrder))

/**
* Get a specific number of Bytes from this iterator. In contrast to
Expand Down Expand Up @@ -690,7 +690,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Shorts from this iterator.
*/
def getShorts(xs: Array[Short])(implicit byteOrder: ByteOrder): this.type =
getShorts(xs, 0, xs.length)(byteOrder)
getShorts(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Shorts from this iterator.
Expand All @@ -701,7 +701,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Ints from this iterator.
*/
def getInts(xs: Array[Int])(implicit byteOrder: ByteOrder): this.type =
getInts(xs, 0, xs.length)(byteOrder)
getInts(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Ints from this iterator.
Expand All @@ -712,7 +712,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Longs from this iterator.
*/
def getLongs(xs: Array[Long])(implicit byteOrder: ByteOrder): this.type =
getLongs(xs, 0, xs.length)(byteOrder)
getLongs(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Longs from this iterator.
Expand All @@ -723,7 +723,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Floats from this iterator.
*/
def getFloats(xs: Array[Float])(implicit byteOrder: ByteOrder): this.type =
getFloats(xs, 0, xs.length)(byteOrder)
getFloats(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Floats from this iterator.
Expand All @@ -734,7 +734,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
* Get a number of Doubles from this iterator.
*/
def getDoubles(xs: Array[Double])(implicit byteOrder: ByteOrder): this.type =
getDoubles(xs, 0, xs.length)(byteOrder)
getDoubles(xs, 0, xs.length)(using byteOrder)

/**
* Get a number of Doubles from this iterator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ package org.apache.pekko.dispatch

import java.util.concurrent.{ ExecutorService, ForkJoinPool, ForkJoinTask, ThreadFactory, TimeUnit }

import com.typesafe.config.Config

import org.apache.pekko.annotation.InternalApi
import org.apache.pekko.util.JavaVersion

import com.typesafe.config.Config

object ForkJoinExecutorConfigurator {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ private[io] trait PeriodicCacheCleanup {

class SimpleDnsCache extends Dns with PeriodicCacheCleanup with NoSerializationVerificationNeeded {
import SimpleDnsCache._
private implicit val expiryOrdering: Ordering[ExpiryEntry[(String, RequestType)]] =
expiryEntryOrdering[(String, RequestType)]()
private val cacheRef = new AtomicReference(
new Cache[(String, RequestType), Resolved](
immutable.SortedSet()(expiryEntryOrdering()),
immutable.SortedSet.empty[ExpiryEntry[(String, RequestType)]],
immutable.Map(),
() => clock()))

Expand Down
13 changes: 8 additions & 5 deletions actor/src/main/scala/org/apache/pekko/pattern/Patterns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ object Patterns {
*/
def askWithReplyTo(actor: ActorRef, messageFactory: japi.function.Function[ActorRef, Any], timeout: Timeout)
: Future[AnyRef] =
extended.ask(actor, messageFactory.apply _)(timeout).asInstanceOf[Future[AnyRef]]
extended.ask(actor, ref => messageFactory.apply(ref))(timeout).asInstanceOf[Future[AnyRef]]

/**
* A variation of ask which allows to implement "replyTo" pattern by including
Expand All @@ -150,7 +150,8 @@ object Patterns {
actor: ActorRef,
messageFactory: japi.function.Function[ActorRef, Any],
timeout: java.time.Duration): CompletionStage[AnyRef] =
extended.ask(actor, messageFactory.apply _)(Timeout.create(timeout)).asJava.asInstanceOf[CompletionStage[AnyRef]]
extended.ask(actor, ref => messageFactory.apply(ref))(Timeout.create(timeout)).asJava.asInstanceOf[CompletionStage[
AnyRef]]

/**
* <i>Java API for `org.apache.pekko.pattern.ask`:</i>
Expand Down Expand Up @@ -201,7 +202,7 @@ object Patterns {
actor: ActorRef,
messageFactory: japi.function.Function[ActorRef, Any],
timeoutMillis: Long): Future[AnyRef] =
extended.ask(actor, messageFactory.apply _)(Timeout(timeoutMillis.millis)).asInstanceOf[Future[AnyRef]]
extended.ask(actor, ref => messageFactory.apply(ref))(Timeout(timeoutMillis.millis)).asInstanceOf[Future[AnyRef]]

/**
* <i>Java API for `org.apache.pekko.pattern.ask`:</i>
Expand Down Expand Up @@ -316,7 +317,8 @@ object Patterns {
selection: ActorSelection,
messageFactory: japi.function.Function[ActorRef, Any],
timeoutMillis: Long): Future[AnyRef] =
extended.ask(selection, messageFactory.apply _)(Timeout(timeoutMillis.millis)).asInstanceOf[Future[AnyRef]]
extended.ask(selection, ref => messageFactory.apply(ref))(Timeout(timeoutMillis.millis)).asInstanceOf[Future[
AnyRef]]

/**
* A variation of ask which allows to implement "replyTo" pattern by including
Expand All @@ -333,7 +335,8 @@ object Patterns {
selection: ActorSelection,
messageFactory: japi.function.Function[ActorRef, Any],
timeout: java.time.Duration): CompletionStage[AnyRef] =
extended.ask(selection, messageFactory.apply _)(timeout.toScala).asJava.asInstanceOf[CompletionStage[AnyRef]]
extended.ask(selection, ref => messageFactory.apply(ref))(timeout.toScala).asJava.asInstanceOf[CompletionStage[
AnyRef]]

/**
* Register an onComplete callback on this [[scala.concurrent.Future]] to send
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ object LineNumbers {
private def readAttributes(d: DataInputStream)(implicit c: Constants): Option[String] = {
val count = d.readUnsignedShort()
if (debug) println(s"LNB: reading $count attributes")
if (c contains "SourceFile") {
if (c.contains("SourceFile")) {
val s = c("SourceFile")
val attributes =
for (_ <- 1 to count) yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ import java.util.concurrent.TimeUnit
import scala.collection.immutable
import scala.concurrent.Promise

import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
import org.openjdk.jmh.annotations.Mode
import org.openjdk.jmh.annotations.OutputTimeUnit
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.State
import org.openjdk.jmh.infra.Blackhole

import org.apache.pekko.NotUsed
import org.apache.pekko.stream.impl.LinearTraversalBuilder
import org.apache.pekko.stream.impl.Stages.DefaultAttributes
Expand All @@ -32,13 +40,6 @@ import org.apache.pekko.stream.scaladsl.Keep
import org.apache.pekko.stream.scaladsl.Sink
import org.apache.pekko.stream.scaladsl.Source
import org.apache.pekko.stream.stage.GraphStageWithMaterializedValue
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.BenchmarkMode
import org.openjdk.jmh.annotations.Mode
import org.openjdk.jmh.annotations.OutputTimeUnit
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.State
import org.openjdk.jmh.infra.Blackhole

@State(Scope.Benchmark)
@BenchmarkMode(Array(Mode.Throughput))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import scala.concurrent.Await
import scala.concurrent.duration._
import scala.util.{ Success, Try }

import com.typesafe.config.{ Config, ConfigFactory }
import org.openjdk.jmh.annotations._

import org.apache.pekko
Expand All @@ -37,6 +36,8 @@ import pekko.stream.impl.io.{ TlsGraphStage, TlsModule }
import pekko.stream.scaladsl._
import pekko.util.ByteString

import com.typesafe.config.{ Config, ConfigFactory }

/**
* JMH benchmark comparing the legacy actor-based TLS path (`TlsModule`) to the
* GraphStage path (`TlsGraphStage`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package org.apache.pekko.util

import java.util.concurrent.TimeUnit

import org.openjdk.jmh.annotations._

import org.apache.pekko
import pekko.stream.impl.io.ByteStringParser

import org.openjdk.jmh.annotations._

@State(Scope.Benchmark)
@Measurement(timeUnit = TimeUnit.MILLISECONDS)
class ByteStringParser_readNum_Benchmark {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
package org.apache.pekko.cluster.sharding.typed.javadsl

import java.util.Optional
import java.util.function.IntFunction
import java.util.function.{ Function => JFunction }
import java.util.function.IntFunction

import org.apache.pekko
import pekko.actor.typed.ActorRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.apache.pekko.cluster.sharding.typed.internal

import org.apache.pekko.cluster.sharding.typed.internal.ShardedDaemonProcessId.DecodedId

import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpecLike

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,10 @@ private[pekko] class ShardRegion(
// sort by age, oldest first
val ageOrdering = Member.ageOrdering
// membersByAge is only used for tracking where coordinator is running
var membersByAge: immutable.SortedSet[Member] = immutable.SortedSet.empty(ageOrdering)
var membersByAge: immutable.SortedSet[Member] = {
implicit val ord: Ordering[Member] = ageOrdering
immutable.SortedSet.empty[Member]
}
// membersByAge contains members with these status
private val memberStatusOfInterest: Set[MemberStatus] =
Set(MemberStatus.Up, MemberStatus.Leaving, MemberStatus.Exiting)
Expand Down Expand Up @@ -772,9 +775,10 @@ private[pekko] class ShardRegion(
}

def receiveClusterState(state: CurrentClusterState): Unit = {
implicit val ord: Ordering[Member] = ageOrdering
changeMembers(
immutable.SortedSet
.empty(ageOrdering)
.empty[Member]
.union(state.members.filter(m => memberStatusOfInterest(m.status) && matchingCoordinatorRole(m))))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ package org.apache.pekko.cluster.sharding

import scala.concurrent.duration._

import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory

import org.apache.pekko
import pekko.actor.ActorRef
import pekko.actor.PoisonPill
import pekko.actor.Props
import pekko.cluster.sharding.MultiNodeClusterShardingSpec.EntityActor
import pekko.testkit._

import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory

class ClusterShardingCoordinatorRoleSpecConfig(
mode: String,
rememberEntities: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package org.apache.pekko.cluster.sharding

import scala.concurrent.duration._

import org.apache.pekko
import pekko.actor.Actor
import pekko.actor.ActorRef
Expand All @@ -30,7 +32,6 @@ import pekko.testkit.WithLogCapturing

import org.scalatest.wordspec.AnyWordSpecLike

import scala.concurrent.duration._
import com.typesafe.config.ConfigFactory

object RememberEntitiesAndStartEntitySpec {
Expand Down
Loading