Skip to content

Commit

Permalink
Merge pull request #108 from lucidsoftware/PROD-2562
Browse files Browse the repository at this point in the history
PROD-2562 Get rid of Medium monitoring priority
  • Loading branch information
James Judd authored Mar 15, 2024
2 parents 671b6cc + b9d3a7c commit 53d2e17
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object TriggerHelper {
trigger.getKey,
).map { monitoringRecord =>
(monitoringRecord.priority, monitoringRecord.maxSecondsInError)
}.getOrElse((TriggerMonitoringPriority.Medium, 300))
}.getOrElse((TriggerMonitoringPriority.Low, 300))
val jobDataMap = trigger.getJobDataMap
val job = trigger.getJobKey
Json.obj(
Expand All @@ -65,7 +65,7 @@ object TriggerHelper {
"name" -> triggerKey.getName,
"description" -> trigger.getDescription,
"job-data-map" -> JsObject(jobDataMap.getKeys.toSeq.map(key => key -> JsString(jobDataMap.getString(key)))),
"triggerMonitoringPriority" -> monitoringPriority.toString,
"triggerMonitoringPriority" -> monitoringPriority.name,
"triggerMaxErrorTime" -> maxSecondsInError
) ++ schedule
}
Expand Down
14 changes: 6 additions & 8 deletions admin/app/com/lucidchart/piezo/admin/controllers/Triggers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ class Triggers(schedulerFactory: WorkerSchedulerFactory, cc: ControllerComponent
triggerDetail.getKey
).map { triggerMonitoringRecord =>
(triggerMonitoringRecord.priority, triggerMonitoringRecord.maxSecondsInError)
}.getOrElse((TriggerMonitoringPriority.Medium, 300))
}.getOrElse((TriggerMonitoringPriority.Low, 300))
}.getOrElse {
logger.error("Failed to get trigger monitoring info")
(TriggerMonitoringPriority.Medium, 300)
(TriggerMonitoringPriority.Low, 300)
}

Ok(
Expand Down Expand Up @@ -149,9 +149,7 @@ class Triggers(schedulerFactory: WorkerSchedulerFactory, cc: ControllerComponent
jobGroup: String = "",
jobName: String = "",
templateGroup: Option[String] = None,
templateName: Option[String] = None,
triggerMonitoringPriority: TriggerMonitoringPriority.Value = TriggerMonitoringPriority.Medium,
triggerMaxErrorTime: Int = 300
templateName: Option[String] = None
) = Action { implicit request =>
templateGroup match {
case Some(group) => getEditTrigger(group, templateName.get, true)
Expand All @@ -161,7 +159,7 @@ class Triggers(schedulerFactory: WorkerSchedulerFactory, cc: ControllerComponent
case "simple" => new DummySimpleTrigger(jobGroup, jobName)
}
val newTriggerForm = triggerFormHelper.buildTriggerForm.fill(
(dummyTrigger, TriggerMonitoringPriority.Medium, 300)
(dummyTrigger, TriggerMonitoringPriority.Low, 300)
)
Ok(
com.lucidchart.piezo.admin.views.html.editTrigger(
Expand Down Expand Up @@ -189,10 +187,10 @@ class Triggers(schedulerFactory: WorkerSchedulerFactory, cc: ControllerComponent
triggerDetail.getKey,
).map { triggerMonitoringRecord =>
(triggerMonitoringRecord.priority, triggerMonitoringRecord.maxSecondsInError)
}.getOrElse((TriggerMonitoringPriority.Medium, 300))
}.getOrElse((TriggerMonitoringPriority.Low, 300))
}.getOrElse {
logger.error("Failed to get trigger monitoring info")
(TriggerMonitoringPriority.Medium, 300)
(TriggerMonitoringPriority.Low, 300)
}
val editTriggerForm = triggerFormHelper.buildTriggerForm.fill(
(triggerDetail, triggerMonitoringPriority, triggerMaxErrorTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h4 class="text-danger">@triggerForm.errors.filter(_.key == "").map(_.message).m
<input type="text" class="job-name-type-ahead form-control form-inline-control " name="@name" id="@id" @toHtmlArgs(args)>
}
}
@helper.select(triggerForm("triggerMonitoringPriority"), TriggerMonitoringPriority.values.toList.map(tp => tp.toString -> tp.toString), Symbol("_label") -> "Monitoring Priority", Symbol("labelClass") -> "col-sm-2 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("class") -> "form-control", Symbol("value") -> triggerForm.data.get("triggerMonitoringPriority").getOrElse(TriggerMonitoringPriority.Medium), Symbol("placeholder") -> TriggerMonitoringPriority.Medium)
@helper.select(triggerForm("triggerMonitoringPriority"), TriggerMonitoringPriority.values.map(tp => tp.name -> tp.name), Symbol("_label") -> "Monitoring Priority", Symbol("labelClass") -> "col-sm-2 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("class") -> "form-control", Symbol("value") -> triggerForm.data.get("triggerMonitoringPriority").getOrElse(TriggerMonitoringPriority.Low), Symbol("placeholder") -> TriggerMonitoringPriority.Low)
@helper.input(triggerForm("triggerMaxErrorTime"), Symbol("_label") -> "Monitoring - Max Seconds Between Successes", Symbol("labelClass") -> "col-sm-2 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("placeholder") -> "", Symbol("value") -> triggerForm.data.get("triggerMaxErrorTime").getOrElse(300)) { (id, name, value, args) =>
<input type="number" class="form-control form-inline-control " name="@name" id="@id" @toHtmlArgs(args)>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ import java.util.{Date, Properties}
import org.quartz.TriggerKey
import org.slf4j.LoggerFactory

object TriggerMonitoringPriority extends Enumeration {
object TriggerMonitoringPriority {
case class Value(id: Int, name: String) {
override def toString: String = name
}
type TriggerMonitoringPriority = Value
val Off = Value(0, "Off")
val Low = Value(1, "Low")
val Medium = Value(2, "Medium")
val High = Value(3, "High")

val values = List(Off, Low, High)

// map values that formerly identified a Medium priority to Low
val valuesById: Map[Int, Value] = Map(2 -> Low) ++ values.map(p => p.id -> p)
val valuesByName: Map[String, Value] = Map("Medium" -> Low) ++ values.map(p => p.name -> p)

def withName: Function[String, Value] = valuesByName
}

case class TriggerMonitoringRecord (
Expand Down Expand Up @@ -101,7 +111,7 @@ class TriggerMonitoringModel(props: Properties) {
prepared.setString(2, triggerKey.getGroup)
val rs = prepared.executeQuery()
if (rs.next()) {
TriggerMonitoringPriority.values.find(_.id == rs.getInt("priority")).map { priority =>
TriggerMonitoringPriority.valuesById.get(rs.getInt("priority")).map { priority =>
TriggerMonitoringRecord(
rs.getString("trigger_name"),
rs.getString("trigger_group"),
Expand All @@ -127,4 +137,4 @@ class TriggerMonitoringModel(props: Properties) {
connection.close()
}
}
}
}

0 comments on commit 53d2e17

Please sign in to comment.