-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PMM-347 coordinator and monitoring support
- Loading branch information
1 parent
cf2eaac
commit c50f0c1
Showing
10 changed files
with
158 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
http/src/main/scala/ru/itclover/tsp/http/routes/MonitoringRoutes.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ru.itclover.tsp.http.routes | ||
|
||
import akka.actor.ActorSystem | ||
import akka.http.scaladsl.model.StatusCodes.{BadRequest, InternalServerError} | ||
import akka.http.scaladsl.model.{HttpResponse, StatusCodes, Uri} | ||
import akka.http.scaladsl.server.Directives._ | ||
import akka.http.scaladsl.server.Route | ||
import akka.stream.ActorMaterializer | ||
import cats.data.Reader | ||
import com.typesafe.scalalogging.Logger | ||
import ru.itclover.tsp.BuildInfo | ||
import ru.itclover.tsp.http.domain.output.{FailureResponse, SuccessfulResponse} | ||
import ru.itclover.tsp.http.protocols.RoutesProtocols | ||
import ru.itclover.tsp.http.services.queuing.QueueManagerService | ||
import ru.itclover.tsp.streaming.checkpointing.CheckpointingService | ||
|
||
import scala.concurrent.ExecutionContextExecutor | ||
import scala.util.Success | ||
|
||
object MonitoringRoutes { | ||
|
||
private val log = Logger[MonitoringRoutes] | ||
|
||
def fromExecutionContext( | ||
queueManagerService: QueueManagerService | ||
)(implicit as: ActorSystem, am: ActorMaterializer): Reader[ExecutionContextExecutor, Route] = { | ||
|
||
log.debug("fromExecutionContext started") | ||
|
||
Reader { execContext => | ||
new MonitoringRoutes { | ||
implicit override val executionContext = execContext | ||
implicit override val actors = as | ||
implicit override val materializer = am | ||
implicit override val qm = queueManagerService | ||
}.route | ||
} | ||
|
||
} | ||
log.debug("fromExecutionContext finished") | ||
} | ||
|
||
trait MonitoringRoutes extends RoutesProtocols { | ||
implicit val qm: QueueManagerService | ||
|
||
implicit val executionContext: ExecutionContextExecutor | ||
implicit val actors: ActorSystem | ||
implicit val materializer: ActorMaterializer | ||
|
||
val route: Route = path("job" / Segment / "status") { uuid => | ||
CheckpointingService.getCheckpoint(uuid) match { | ||
case Some(details) => complete(Map("rowsRead" -> details.readRows, "rowsWritten" -> details.writtenRows)) | ||
case None => complete((BadRequest, FailureResponse(4006, "No such job.", Seq.empty))) | ||
//case Failure(err) => complete((InternalServerError, FailureResponse(5005, err))) | ||
} | ||
} ~ path("jobs" / "overview") { | ||
complete(qm.getRunningJobsIds) | ||
} ~ | ||
path("metainfo" / "getVersion") { | ||
complete( | ||
SuccessfulResponse( | ||
Map( | ||
"tsp" -> BuildInfo.version, | ||
"scala" -> BuildInfo.scalaVersion, | ||
) | ||
) | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 0 additions & 107 deletions
107
http/src/main/scala/ru/itclover/tsp/http/services/streaming/MonitoringServiceModel.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.