Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Bump ActiveMQ version
Browse files Browse the repository at this point in the history
  • Loading branch information
atooni committed Nov 15, 2023
1 parent 6a04d57 commit 51d38ef
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 82 deletions.
158 changes: 81 additions & 77 deletions blended.updater/src/main/scala/blended/updater/Updater.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import blended.updater.config._
import blended.util.logging.Logger

class Updater(
installBaseDir: File,
config: UpdaterConfig,
launchedProfileDir: Option[File],
launchedProfileId: Option[ProfileRef]
installBaseDir: File,
config: UpdaterConfig,
launchedProfileDir: Option[File],
launchedProfileId: Option[ProfileRef]
) extends Actor
with ActorLogging {

import Updater._

private[this] val log = Logger[Updater]
private val logger = Logger[Updater]

/////////////////////
// MUTABLE
Expand Down Expand Up @@ -59,12 +59,13 @@ class Updater(
private[this] def eventStream: EventStream = context.system.eventStream

override def preStart(): Unit = {
log.info("Initiating initial scanning for profiles")
logger.info("Initiating initial scanning for profiles")
self ! Scan

if (config.serviceInfoIntervalMSec > 0) {
log.info(
s"Enabling service info publishing [${config.serviceInfoIntervalMSec}]ms and lifetime [${config.serviceInfoLifetimeMSec}]ms")
logger.info(
s"Enabling service info publishing [${config.serviceInfoIntervalMSec}]ms and lifetime [${config.serviceInfoLifetimeMSec}]ms"
)
implicit val eCtx = context.system.dispatcher
tickers +:= context.system.scheduler.scheduleAtFixedRate(
Duration(100, TimeUnit.MILLISECONDS),
Expand All @@ -74,7 +75,7 @@ class Updater(
self ! PublishProfileInfo
}
} else {
log.info("Publishing of service infos and profile infos is disabled")
logger.info("Publishing of service infos and profile infos is disabled")
}

super.preStart()
Expand All @@ -83,24 +84,25 @@ class Updater(
override def postStop(): Unit = {

tickers.foreach { t =>
log.info(s"Disabling ticker: ${t}")
logger.info(s"Disabling ticker: ${t}")
t.cancel()
}
tickers = Nil
super.postStop()
}

def handleProtocol(msg: Protocol): Unit = msg match {
def handleProtocol(msg: Protocol): Unit =
msg match {

case GetRuntimeConfigs(reqId) =>
sender() ! Result(reqId, runtimeConfigs)
case GetRuntimeConfigs(reqId) =>
sender() ! Result(reqId, runtimeConfigs)

case GetProfiles(reqId) =>
sender() ! Result(reqId, profiles.values.toSet)
case GetProfiles(reqId) =>
sender() ! Result(reqId, profiles.values.toSet)

case GetProfileIds(reqId) =>
sender() ! Result(reqId, profiles.keySet)
}
case GetProfileIds(reqId) =>
sender() ! Result(reqId, profiles.keySet)
}

def scanForRuntimeConfigs(): List[LocalProfile] = {
ProfileFsHelper.scanForRuntimeConfigs(installBaseDir)
Expand All @@ -110,56 +112,57 @@ class Updater(
ProfileFsHelper.scanForProfiles(installBaseDir, runtimeConfigs)
}

override def receive: Actor.Receive = LoggingReceive {

// direct protocol
case p: Protocol =>
log.debug(s"Handling Protocol message: ${p}")
handleProtocol(p)

case Scan =>
log.debug("Handling Scan mesage")
val rcs = scanForRuntimeConfigs()
runtimeConfigs = rcs.toSet

val fullProfiles = scanForProfiles(Option(rcs))
profiles = fullProfiles.map { profile =>
profile.profileId -> profile
}.toMap
log.debug(s"Profiles (after scan): ${profiles}")

case PublishProfileInfo =>
log.debug("Handling PublishProfileInfo message")
val activeProfile = findActiveProfile().map(_.toSingleProfile)
val singleProfiles = profiles.values.toList.map(_.toSingleProfile).map { p =>
activeProfile match {
case Some(a) if p.name == a.name && p.version == a.version => p
case _ => p
}
override def receive: Actor.Receive =
LoggingReceive {

// direct protocol
case p: Protocol =>
logger.debug(s"Handling Protocol message: ${p}")
handleProtocol(p)

case Scan =>
logger.debug("Handling Scan mesage")
val rcs = scanForRuntimeConfigs()
runtimeConfigs = rcs.toSet

val fullProfiles = scanForProfiles(Option(rcs))
profiles = fullProfiles.map { profile =>
profile.profileId -> profile
}.toMap
logger.debug(s"Profiles (after scan): ${profiles}")

case PublishProfileInfo =>
logger.debug("Handling PublishProfileInfo message")
val activeProfile = findActiveProfile().map(_.toSingleProfile)
val singleProfiles = profiles.values.toList.map(_.toSingleProfile).map { p =>
activeProfile match {
case Some(a) if p.name == a.name && p.version == a.version => p
case _ => p
}

}
val toSend = singleProfiles
log.debug(s"Publishing profile info to event stream: ${toSend}")
eventStream.publish(ProfileInfo(System.currentTimeMillis(), toSend))

case PublishServiceInfo =>
log.debug("Handling PublishServiceInfo message")

val serviceInfo = ServiceInfo(
name = context.self.path.toString,
serviceType = "Updater",
timestampMsec = System.currentTimeMillis(),
lifetimeMsec = config.serviceInfoLifetimeMSec,
props = Map(
"installBaseDir" -> installBaseDir.getAbsolutePath(),
"launchedProfileDir" -> launchedProfileDir.map(_.getAbsolutePath()).getOrElse(""),
"launchedProfileId" -> launchedProfileId.map(_.toString()).getOrElse("")
}
val toSend = singleProfiles
logger.debug(s"Publishing profile info to event stream: ${toSend}")
eventStream.publish(ProfileInfo(System.currentTimeMillis(), toSend))

case PublishServiceInfo =>
logger.debug("Handling PublishServiceInfo message")

val serviceInfo = ServiceInfo(
name = context.self.path.toString,
serviceType = "Updater",
timestampMsec = System.currentTimeMillis(),
lifetimeMsec = config.serviceInfoLifetimeMSec,
props = Map(
"installBaseDir" -> installBaseDir.getAbsolutePath(),
"launchedProfileDir" -> launchedProfileDir.map(_.getAbsolutePath()).getOrElse(""),
"launchedProfileId" -> launchedProfileId.map(_.toString()).getOrElse("")
)
)
)
log.debug(s"About to publish service info: ${serviceInfo}")
eventStream.publish(serviceInfo)
logger.debug(s"About to publish service info: ${serviceInfo}")
eventStream.publish(serviceInfo)

}
}

}

Expand Down Expand Up @@ -214,10 +217,10 @@ object Updater {
* Create the actor properties.
*/
def props(
baseDir: File,
config: UpdaterConfig,
launchedProfileDir: File = null,
launchedProfileRef: ProfileRef = null
baseDir: File,
config: UpdaterConfig,
launchedProfileDir: File = null,
launchedProfileRef: ProfileRef = null
): Props = {

Props(
Expand All @@ -226,7 +229,8 @@ object Updater {
config,
Option(launchedProfileDir),
Option(launchedProfileRef)
))
)
)
}

/**
Expand All @@ -238,13 +242,13 @@ object Updater {
* Internal working state of in-progress stagings.
*/
private case class State(
requestId: String,
requestActor: ActorRef,
config: LocalProfile,
artifactsToDownload: List[ArtifactInProgress],
pendingArtifactsToUnpack: List[ArtifactInProgress],
artifactsToUnpack: List[ArtifactInProgress],
issues: List[String]
requestId: String,
requestActor: ActorRef,
config: LocalProfile,
artifactsToDownload: List[ArtifactInProgress],
pendingArtifactsToUnpack: List[ArtifactInProgress],
artifactsToUnpack: List[ArtifactInProgress],
issues: List[String]
) {

val profileRef = ProfileRef(config.runtimeConfig.name, config.runtimeConfig.version)
Expand Down
12 changes: 7 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import $ivy.`de.tototec::de.tobiasroeser.mill.osgi:0.3.0`
import de.tobiasroeser.mill.osgi._

// imports from the blended-mill plugin
import $ivy.`de.wayofquality.blended::blended-mill:0.4.14`
import $ivy.`de.wayofquality.blended::blended-mill:0.4.15`
import de.wayofquality.blended.mill.versioning.GitModule
import de.wayofquality.blended.mill.publish.BlendedPublishModule
import de.wayofquality.blended.mill.webtools.WebTools
Expand All @@ -34,7 +34,7 @@ object CoreDependencies {
Seq(Deps_2_13).map(d => d.scalaVersion -> d).toMap

object Deps_2_13 extends CoreDependencies {
override def scalaVersion = "2.13.4"
override def scalaVersion = "2.13.6"

override def slf4jVersion = "1.7.32"
override def logbackCore = ivy"ch.qos.logback:logback-core:1.2.11"
Expand Down Expand Up @@ -304,10 +304,10 @@ class BlendedCross(crossScalaVersion: String) extends GenIdeaModule { blended =>
object aws extends Module {
object s3 extends CoreModule {

override def description =
override def description =
"""A simple service to download files using the Amazon S3 protocol."""

override def ivyDeps =
override def ivyDeps =
T {
super.ivyDeps() ++ Agg(
deps.httpComponents
Expand Down Expand Up @@ -1276,7 +1276,9 @@ class BlendedCross(crossScalaVersion: String) extends GenIdeaModule { blended =>
}
override def embeddedJars: T[Seq[PathRef]] =
T {
compileClasspath().iterator.to(Seq).filter(f => f.path.last.startsWith("prickle") || f.path.last.startsWith("microjson"))
compileClasspath().iterator
.to(Seq)
.filter(f => f.path.last.startsWith("prickle") || f.path.last.startsWith("microjson"))
}

object akka extends Module {
Expand Down

0 comments on commit 51d38ef

Please sign in to comment.