Skip to content

Commit

Permalink
#66 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjstevo committed Apr 12, 2021
1 parent 3695a8a commit e5a08c1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ class NiaiveImmutableArray[T :ClassTag](val array: Array[T] = Array.empty) exten
new NiaiveImmutableArray[T](previous ++ after)
}

override def toString: String = "ImmutableArray(" + array.mkString(",") + ")"
override def toString: String = "ImmutableArray(" + array.take(5).mkString(",") + "...)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ class CoreServerApiHander(viewPortContainer: ViewPortContainer,

val groupByColumns = msg.groupBy.filter(table.getTableDef.columnForName(_) != null).map(table.getTableDef.columnForName(_)).toList

val aggregations = groupByColumns.map( col => {
if( col.dataType == DataType.DoubleDataType || col.dataType == DataType.LongDataType || col.dataType == DataType.IntegerDataType) Aggregation(col, AggregationType.Sum)
else viewport.Aggregation(col, AggregationType.Count)
})
val aggregations = List()//groupByColumns.map( col => {
// if( col.dataType == DataType.DoubleDataType || col.dataType == DataType.LongDataType || col.dataType == DataType.IntegerDataType) Aggregation(col, AggregationType.Sum)
// else viewport.Aggregation(col, AggregationType.Count)
// })

val groupBy = new GroupBy(groupByColumns, aggregations)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@ class MetricsViewPortProvider(table: DataTable, viewPortContainer: ViewPortConta

override val lifecycleId: String = "metricsViewPortProvider"

private var viewportIds = Map[String, String]()

def runOnce(): Unit ={

try {

val histograms = viewPortContainer.viewPortHistograms
val histograms = viewPortContainer.viewPortHistograms

val mapOfHistograms = MapHasAsScala(histograms).asScala

val toDelete = viewportIds.filterNot(kv => mapOfHistograms.contains(kv._1)).toMap

MapHasAsScala(histograms).asScala.foreach({case(key, histogram) => {
mapOfHistograms.foreach({case(key, histogram) => {
val snapshot = histogram.getSnapshot
val vp = viewPortContainer.getViewPortById(key)
if(vp != null){
Expand All @@ -47,6 +53,12 @@ class MetricsViewPortProvider(table: DataTable, viewPortContainer: ViewPortConta
}
}})

toDelete.foreach({case(key, _) =>
table.processDelete(key)
})

viewportIds = mapOfHistograms.map({case(key, _) => (key -> key)}).toMap

} catch {
case e: Exception =>
logger.error("Error occured in metrics", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ViewPortContainer(tableContainer: TableContainer)(implicit timeProvider: C
logger.error(s"Could not find viewport to remove ${vpId}")
case vp: ViewPort =>
logger.info(s"Removing ${vpId} from container")
viewPortHistograms.remove(vpId)
vp.delete()
this.viewPorts.remove(vp.id)
}
Expand Down Expand Up @@ -417,7 +418,9 @@ class ViewPortContainer(tableContainer: TableContainer)(implicit timeProvider: C

logger.info(s"Removing ${viewports.length} on disconnect of $clientSession")

viewports.foreach(entry => viewPorts.remove(entry.getKey))
viewports.foreach(entry => {
this.removeViewPort(entry.getKey)
})
}

def getViewPortVisualLinks(clientSession: ClientSessionId, vpId: String): List[(Link, ViewPort)] = {
Expand Down

0 comments on commit e5a08c1

Please sign in to comment.