This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-9417-103a0ebba1cbc42ad4622ab72d39087ad5765a14 in repository https://gitbox.apache.org/repos/asf/texera.git
commit 99a8ced7251a02556ed1be5c7e790d2883633984 Author: Xinyuan Lin <[email protected]> AuthorDate: Mon Nov 16 22:47:45 2026 +0000 refactor(amber): remove unused engine adapters and obsolete helpers (#9417) ### What changes were proposed in this PR? Removes unused engine adapters, uncalled queries, and dead helpers across the Amber engine: - `FutureBijection`: removes uncalled `RichTwitterFuture.asScala` adapter and its 11 reverse/roundtrip test cases; retains production `asTwitter()`. - `PekkoActorService`: removes uncalled `sendToSelfOnce`, `ask`, and their unneeded imports and timeout. - `AsyncRPCClient`: removes unreferenced `IgnoreReply` sentinel. - `RecordingInlineTimer`: removes uncalled `recordedDelays` accessor, keeping `recordedDelaysInMillis`. - `PauseHandler`: removes empty unread tuple buffer and its unused imports. - `WorkflowLifecycleManagerSpec`: removes unused defaults on private test helper. - `EngineCommonConversionsSpec`: removes unused implicit `ec` and `asScala` tests. - `DatasetStatisticsUtils`: removes uncalled `getUserCreatedDatasetCount` query and eliminates redundant `.copy(size = 0)` mapping. ### Any related issues, documentation, discussions? Closes #9416. ### How was this PR tested? All 110 cases in the affected test suites passed: ```powershell sbt "WorkflowExecutionService/testOnly *FutureBijectionSpec *EngineCommonConversionsSpec *DatasetStatisticsUtilsSpec *UtilsSpec" sbt "WorkflowExecutionService/testOnly *WorkflowLifecycleManagerSpec" sbt "WorkflowExecutionService/scalafixAll --check" "WorkflowExecutionService/Test/scalafmtCheck" ``` Retained cases passed with matching names and outcomes. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Antigravity (Gemini 2.5 Pro) Generated-by: Codex (GPT-6) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> --- .../architecture/common/PekkoActorService.scala | 13 +--- .../coordinator/promisehandlers/PauseHandler.scala | 11 +-- .../amber/engine/common/FutureBijection.scala | 16 +---- .../amber/engine/common/rpc/AsyncRPCClient.scala | 1 - .../dataset/utils/DatasetStatisticsUtils.scala | 24 +------ .../common/EngineCommonConversionsSpec.scala | 38 +---------- .../amber/engine/common/FutureBijectionSpec.scala | 78 +--------------------- .../amber/engine/common/RecordingInlineTimer.scala | 2 - .../texera/web/WorkflowLifecycleManagerSpec.scala | 4 +- .../dataset/utils/DatasetStatisticsUtilsSpec.scala | 42 +----------- 10 files changed, 13 insertions(+), 216 deletions(-) diff --git a/amber/src/main/scala/org/apache/texera/amber/engine/architecture/common/PekkoActorService.scala b/amber/src/main/scala/org/apache/texera/amber/engine/architecture/common/PekkoActorService.scala index f5bbd0619c..54c7d90d5d 100644 --- a/amber/src/main/scala/org/apache/texera/amber/engine/architecture/common/PekkoActorService.scala +++ b/amber/src/main/scala/org/apache/texera/amber/engine/architecture/common/PekkoActorService.scala @@ -21,18 +21,15 @@ package org.apache.texera.amber.engine.architecture.common import org.apache.pekko import pekko.actor.{ActorContext, ActorRef, Address, Cancellable, Props} -import pekko.util.Timeout import org.apache.texera.amber.core.virtualidentity.ActorVirtualIdentity -import org.apache.texera.amber.engine.common.FutureBijection._ import scala.concurrent.ExecutionContext -import scala.concurrent.duration.{DurationInt, FiniteDuration} +import scala.concurrent.duration.FiniteDuration class PekkoActorService(val id: ActorVirtualIdentity, actorContext: ActorContext) { implicit def ec: ExecutionContext = actorContext.dispatcher - implicit val timeout: Timeout = 5.seconds implicit val self: ActorRef = actorContext.self def parent: ActorRef = actorContext.parent @@ -61,10 +58,6 @@ class PekkoActorService(val id: ActorVirtualIdentity, actorContext: ActorContext actorContext.system.scheduler.scheduleWithFixedDelay(initialDelay, delay)(() => callable()) } - def sendToSelfOnce(delay: FiniteDuration, msg: Any): Cancellable = { - actorContext.system.scheduler.scheduleOnce(delay, actorContext.self, msg) - } - def sendToSelfWithFixedDelay( initialDelay: FiniteDuration, delay: FiniteDuration, @@ -78,8 +71,4 @@ class PekkoActorService(val id: ActorVirtualIdentity, actorContext: ActorContext ) } - def ask(ref: ActorRef, message: Any): com.twitter.util.Future[Any] = { - pekko.pattern.ask(ref, message).asTwitter() - } - } diff --git a/amber/src/main/scala/org/apache/texera/amber/engine/architecture/coordinator/promisehandlers/PauseHandler.scala b/amber/src/main/scala/org/apache/texera/amber/engine/architecture/coordinator/promisehandlers/PauseHandler.scala index 98b33dc783..e48e37b8f7 100644 --- a/amber/src/main/scala/org/apache/texera/amber/engine/architecture/coordinator/promisehandlers/PauseHandler.scala +++ b/amber/src/main/scala/org/apache/texera/amber/engine/architecture/coordinator/promisehandlers/PauseHandler.scala @@ -20,8 +20,6 @@ package org.apache.texera.amber.engine.architecture.coordinator.promisehandlers import com.twitter.util.Future -import org.apache.texera.amber.core.tuple.Tuple -import org.apache.texera.amber.core.virtualidentity.ActorVirtualIdentity import org.apache.texera.amber.engine.architecture.coordinator.{ CoordinatorAsyncRPCHandlerInitializer, ExecutionStateUpdate, @@ -37,8 +35,6 @@ import org.apache.texera.amber.engine.architecture.rpc.controlreturns.{ WorkerMetricsResponse } -import scala.collection.mutable - /** pause the entire workflow * * possible sender: client, coordinator @@ -54,10 +50,7 @@ trait PauseHandler { cp.workflowExecution.getRunningRegionExecutions .flatMap(_.getAllOperatorExecutions) .map { - case (physicalOpId, opExecution) => - // create a buffer for the current input tuple - // since we need to show them on the frontend - val buffer = mutable.ArrayBuffer[(Tuple, ActorVirtualIdentity)]() + case (_, opExecution) => Future .collect( opExecution.getWorkerIds @@ -71,7 +64,7 @@ trait PauseHandler { workerExecution.updateState(resp.stateVersion, resp.state) workerInterface .queryStatistics(EmptyRequest(), mkContext(worker)) - // get the stats and current input tuple from the worker + // get the stats from the worker .map { case WorkerMetricsResponse(metrics) => workerExecution.updateStats( diff --git a/amber/src/main/scala/org/apache/texera/amber/engine/common/FutureBijection.scala b/amber/src/main/scala/org/apache/texera/amber/engine/common/FutureBijection.scala index 41f8113ef5..c6aa3377e9 100644 --- a/amber/src/main/scala/org/apache/texera/amber/engine/common/FutureBijection.scala +++ b/amber/src/main/scala/org/apache/texera/amber/engine/common/FutureBijection.scala @@ -19,26 +19,14 @@ package org.apache.texera.amber.engine.common -import com.twitter.util.{Return, Throw, Future => TwitterFuture, Promise => TwitterPromise} +import com.twitter.util.{Future => TwitterFuture, Promise => TwitterPromise} import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.{Future => ScalaFuture, Promise => ScalaPromise} +import scala.concurrent.{Future => ScalaFuture} import scala.util.{Failure, Success} object FutureBijection { - /** Convert from a Twitter Future to a Scala Future */ - implicit class RichTwitterFuture[A](val tf: TwitterFuture[A]) extends AnyVal { - def asScala: ScalaFuture[A] = { - val promise: ScalaPromise[A] = ScalaPromise() - tf.respond { - case Return(value) => promise.success(value) - case Throw(exception) => promise.failure(exception) - } - promise.future - } - } - /** Convert from a Scala Future to a Twitter Future */ implicit class RichScalaFuture[A](val sf: ScalaFuture[A]) extends AnyVal { def asTwitter(): TwitterFuture[A] = { diff --git a/amber/src/main/scala/org/apache/texera/amber/engine/common/rpc/AsyncRPCClient.scala b/amber/src/main/scala/org/apache/texera/amber/engine/common/rpc/AsyncRPCClient.scala index 2e70f25ce0..4feaaa07ab 100644 --- a/amber/src/main/scala/org/apache/texera/amber/engine/common/rpc/AsyncRPCClient.scala +++ b/amber/src/main/scala/org/apache/texera/amber/engine/common/rpc/AsyncRPCClient.scala @@ -69,7 +69,6 @@ import scala.reflect.ClassTag */ object AsyncRPCClient { - final val IgnoreReply = -1 final val IgnoreReplyAndDoNotLog = -2 object ControlInvocation { diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtils.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtils.scala index 01a949e94c..51e0d9cdb4 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtils.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtils.scala @@ -30,19 +30,8 @@ object DatasetStatisticsUtils { SqlServer .getInstance() .createDSLContext() - // this function retrieves the total counts of dataset that belongs to the user - def getUserCreatedDatasetCount(uid: Integer): Int = { - val count = context - .selectCount() - .from(DATASET) - .where(DATASET.OWNER_UID.eq(uid)) - .fetchOne(0, classOf[Int]) - - count - } - - // this function would return a list of dataset ids that belongs to the user - private def getUserCreatedDatasetList(uid: Integer): List[DatasetQuota] = { + // this function returns the datasets that belong to the user + def getUserCreatedDatasets(uid: Integer): List[DatasetQuota] = { val result = context .select( DATASET.DID, @@ -59,17 +48,10 @@ object DatasetStatisticsUtils { did = record.getValue(DATASET.DID), name = record.getValue(DATASET.NAME), creationTime = record.getValue(DATASET.CREATION_TIME).getTime, + // we disabled the size calculation due to the switch of dataset implementation size = 0 ) ) .toList } - - def getUserCreatedDatasets(uid: Integer): List[DatasetQuota] = { - val datasetList = getUserCreatedDatasetList(uid) - datasetList.map { dataset => - val size = 0 // we disabled the size calculation due to the switch of dataset implementation - dataset.copy(size = size) - } - } } diff --git a/amber/src/test/scala/org/apache/texera/amber/engine/common/EngineCommonConversionsSpec.scala b/amber/src/test/scala/org/apache/texera/amber/engine/common/EngineCommonConversionsSpec.scala index 1632029e7a..80c700ed4a 100644 --- a/amber/src/test/scala/org/apache/texera/amber/engine/common/EngineCommonConversionsSpec.scala +++ b/amber/src/test/scala/org/apache/texera/amber/engine/common/EngineCommonConversionsSpec.scala @@ -31,8 +31,7 @@ import org.apache.texera.amber.engine.common.FutureBijection._ import org.scalatest.BeforeAndAfterAll import org.scalatest.flatspec.AnyFlatSpec -import scala.concurrent.duration._ -import scala.concurrent.{Await, ExecutionContext, Future => ScalaFuture} +import scala.concurrent.{Future => ScalaFuture} class EngineCommonConversionsSpec extends AnyFlatSpec with BeforeAndAfterAll { @@ -52,41 +51,6 @@ class EngineCommonConversionsSpec extends AnyFlatSpec with BeforeAndAfterAll { super.afterAll() } - // --------------------------------------------------------------------------- - // FutureBijection — Twitter Future → Scala Future - // --------------------------------------------------------------------------- - - private implicit val ec: ExecutionContext = ExecutionContext.global - private val awaitTimeout: FiniteDuration = 5.seconds - - "FutureBijection.RichTwitterFuture.asScala" should - "resolve the Scala Future with the value of a Twitter Return" in { - val tf: TwitterFuture[Int] = TwitterFuture.value(42) - val sf: ScalaFuture[Int] = tf.asScala - assert(Await.result(sf, awaitTimeout) == 42) - } - - it should "fail the Scala Future with the exception of a Twitter Throw" in { - val boom = new RuntimeException("boom") - val tf: TwitterFuture[Int] = TwitterFuture.exception(boom) - val sf: ScalaFuture[Int] = tf.asScala - val caught = intercept[RuntimeException] { - Await.result(sf, awaitTimeout) - } - assert(caught eq boom, "the original exception must be preserved without rewrapping") - } - - it should "propagate completion asynchronously (Scala Future is not pre-resolved)" in { - // A Twitter Promise resolved later must propagate to the Scala Future - // only when the Promise completes. Pin so a regression that pre- - // resolves on conversion breaks here. - val tp = com.twitter.util.Promise[String]() - val sf: ScalaFuture[String] = (tp: TwitterFuture[String]).asScala - assert(!sf.isCompleted, "Scala Future must not pre-resolve before the Twitter source completes") - tp.setValue("late") - assert(Await.result(sf, awaitTimeout) == "late") - } - // --------------------------------------------------------------------------- // FutureBijection — Scala Future → Twitter Future // --------------------------------------------------------------------------- diff --git a/amber/src/test/scala/org/apache/texera/amber/engine/common/FutureBijectionSpec.scala b/amber/src/test/scala/org/apache/texera/amber/engine/common/FutureBijectionSpec.scala index 1ff59594dd..dcf2299b02 100644 --- a/amber/src/test/scala/org/apache/texera/amber/engine/common/FutureBijectionSpec.scala +++ b/amber/src/test/scala/org/apache/texera/amber/engine/common/FutureBijectionSpec.scala @@ -23,61 +23,12 @@ import com.twitter.util.{Await => TwitterAwait, Future => TwitterFuture} import org.apache.texera.amber.engine.common.FutureBijection._ import org.scalatest.flatspec.AnyFlatSpec -import scala.concurrent.duration._ -import scala.concurrent.{Await => ScalaAwait, Future => ScalaFuture} +import scala.concurrent.{Future => ScalaFuture} class FutureBijectionSpec extends AnyFlatSpec { - // Short timeout — the futures complete synchronously (or near-so) for - // the values used here; we keep the bound tight so a regression that - // *fails to resolve* surfaces as a timeout rather than hanging CI. - private val timeout: FiniteDuration = 5.seconds private val twitterTimeout: com.twitter.util.Duration = com.twitter.util.Duration.fromSeconds(5) - // --------------------------------------------------------------------------- - // Twitter Future → Scala Future - // --------------------------------------------------------------------------- - - "RichTwitterFuture.asScala" should "resolve to the same value as the wrapped TwitterFuture" in { - val tf = TwitterFuture.value(42) - val result = ScalaAwait.result(tf.asScala, timeout) - assert(result == 42) - } - - it should "preserve the exception type and message on the failure path" in { - val cause = new IllegalStateException("boom") - val tf = TwitterFuture.exception[Int](cause) - val ex = intercept[IllegalStateException] { - ScalaAwait.result(tf.asScala, timeout) - } - assert(ex.getMessage == "boom") - assert(ex eq cause, "the same Throwable instance should propagate through") - } - - it should "preserve a null value on the value path (Twitter Return wraps any AnyRef)" in { - // The conversion calls `promise.success(value)` directly; for a `null` - // value, the Scala promise resolves to `null`. Pin that the wire does - // not coerce null into an exception. - val tf = TwitterFuture.value[String](null) - val result = ScalaAwait.result(tf.asScala, timeout) - assert(result == null) - } - - it should "preserve the value type (compile-time enforced)" in { - val tf: TwitterFuture[String] = TwitterFuture.value("hello") - val sf: ScalaFuture[String] = tf.asScala - assert(ScalaAwait.result(sf, timeout) == "hello") - } - - it should "produce a future that has already completed when the source TwitterFuture is already resolved" in { - val tf = TwitterFuture.value(7) - val sf = tf.asScala - // The conversion uses `respond` which fires synchronously for already- - // resolved futures, so the scala future is complete by the time the - // implicit returns. - assert(sf.isCompleted, "the converted future should be completed immediately") - } - // --------------------------------------------------------------------------- // Scala Future → Twitter Future // --------------------------------------------------------------------------- @@ -109,31 +60,4 @@ class FutureBijectionSpec extends AnyFlatSpec { val tf: TwitterFuture[String] = sf.asTwitter() assert(TwitterAwait.result(tf, twitterTimeout) == "hello") } - - // --------------------------------------------------------------------------- - // Round-trip — Twitter → Scala → Twitter and vice versa - // --------------------------------------------------------------------------- - - "FutureBijection" should "round-trip a value through Twitter → Scala → Twitter" in { - val tf1 = TwitterFuture.value("payload") - val tf2: TwitterFuture[String] = tf1.asScala.asTwitter() - assert(TwitterAwait.result(tf2, twitterTimeout) == "payload") - } - - it should "round-trip a value through Scala → Twitter → Scala" in { - val sf1 = ScalaFuture.successful("payload") - val sf2: ScalaFuture[String] = sf1.asTwitter().asScala - assert(ScalaAwait.result(sf2, timeout) == "payload") - } - - it should "round-trip an exception through Twitter → Scala → Twitter (type + message preserved)" in { - val cause = new RuntimeException("round-trip-err") - val tf1 = TwitterFuture.exception[Int](cause) - val tf2: TwitterFuture[Int] = tf1.asScala.asTwitter() - val ex = intercept[RuntimeException] { - TwitterAwait.result(tf2, twitterTimeout) - } - assert(ex.getMessage == "round-trip-err") - assert(ex eq cause) - } } diff --git a/amber/src/test/scala/org/apache/texera/amber/engine/common/RecordingInlineTimer.scala b/amber/src/test/scala/org/apache/texera/amber/engine/common/RecordingInlineTimer.scala index 7efe791bbf..6d6d17d466 100644 --- a/amber/src/test/scala/org/apache/texera/amber/engine/common/RecordingInlineTimer.scala +++ b/amber/src/test/scala/org/apache/texera/amber/engine/common/RecordingInlineTimer.scala @@ -34,8 +34,6 @@ import scala.collection.mutable class RecordingInlineTimer extends Timer { private val delays: mutable.ArrayBuffer[Duration] = mutable.ArrayBuffer() - def recordedDelays: Seq[Duration] = delays.toSeq - def recordedDelaysInMillis: Seq[Long] = delays.map(_.inMilliseconds).toSeq def scheduleOnce(when: Time)(f: => Unit): TimerTask = { diff --git a/amber/src/test/scala/org/apache/texera/web/WorkflowLifecycleManagerSpec.scala b/amber/src/test/scala/org/apache/texera/web/WorkflowLifecycleManagerSpec.scala index 77f8aa675a..cd0aa1ddf0 100644 --- a/amber/src/test/scala/org/apache/texera/web/WorkflowLifecycleManagerSpec.scala +++ b/amber/src/test/scala/org/apache/texera/web/WorkflowLifecycleManagerSpec.scala @@ -90,8 +90,8 @@ class WorkflowLifecycleManagerSpec extends AnyFlatSpec with BeforeAndAfterAll { /** Counts the clean-ups instead of latching on the first one, so a repeat is observable. */ private def managerWithCounter( - cleanUpTimeout: Int = 1, - id: String = "workflow-lifecycle-manager-spec" + cleanUpTimeout: Int, + id: String ): (WorkflowLifecycleManager, AtomicInteger) = { val cleanUps = new AtomicInteger(0) val manager = new WorkflowLifecycleManager( diff --git a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtilsSpec.scala b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtilsSpec.scala index c40e69387e..7dc0878c3d 100644 --- a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtilsSpec.scala +++ b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/dataset/utils/DatasetStatisticsUtilsSpec.scala @@ -99,46 +99,6 @@ class DatasetStatisticsUtilsSpec extends AnyFlatSpec with BeforeAndAfterAll with private def didOf(dataset: Dataset): Integer = datasetDao.fetchByName(dataset.getName).get(0).getDid - /** - * Two datasets for `ownerUid` whose visibility flags disagree on both axes, one - * for `otherUid`, none for `strangerUid`. Both queries under test filter on - * OWNER_UID only, so any visibility predicate added to either of them would drop - * one of the owner's two rows. - */ - private def seedTwoOwners(): Unit = { - resetFixtures() - insertDataset(ownerUid, now(), isPublic = true, isDownloadable = false) - insertDataset(ownerUid, now(), isPublic = false, isDownloadable = true) - insertDataset(otherUid, now()) - } - - // --------------------------------------------------------------------------- - // getUserCreatedDatasetCount - // --------------------------------------------------------------------------- - - "getUserCreatedDatasetCount" should - "aggregate only the datasets owned by the given uid, and report 0 for a uid that owns none" in { - seedTwoOwners() - - // The zero case shares this fixture on purpose: on its own it cannot - // distinguish a count from a null projection, and on its own the two-dataset - // case cannot distinguish an owner-filtered count from an unfiltered one. - assert(DatasetStatisticsUtils.getUserCreatedDatasetCount(ownerUid) == 2) - assert(DatasetStatisticsUtils.getUserCreatedDatasetCount(otherUid) == 1) - assert(DatasetStatisticsUtils.getUserCreatedDatasetCount(strangerUid) == 0) - } - - it should "agree with the length of the list getUserCreatedDatasets returns" in { - seedTwoOwners() - - Seq(ownerUid, otherUid, strangerUid).foreach { uid => - assert( - DatasetStatisticsUtils.getUserCreatedDatasetCount(uid) == - DatasetStatisticsUtils.getUserCreatedDatasets(uid).size - ) - } - } - // --------------------------------------------------------------------------- // getUserCreatedDatasets // --------------------------------------------------------------------------- @@ -155,7 +115,7 @@ class DatasetStatisticsUtilsSpec extends AnyFlatSpec with BeforeAndAfterAll with // Two owned rows with distinct names AND distinct creation times, so a mapping // that reads any field off one fixed record instead of the record it is // projecting (the classic row-collapse regression) cannot pass. They also - // disagree on both visibility flags, so neither query may filter on those. + // disagree on both visibility flags, so the query must not filter on those. val firstTime = new Timestamp(1_700_000_000_000L) val secondTime = new Timestamp(1_500_000_000_000L) val owned = insertDataset(ownerUid, firstTime, isPublic = true, isDownloadable = false)
