iota-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonyfaust...@apache.org
Subject [6/8] incubator-iota git commit: Adding draft visualization for Monitoring Events on Fey
Date Mon, 11 Jul 2016 18:50:36 GMT
Adding draft visualization for Monitoring Events on Fey


Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/4cda6c76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/4cda6c76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/4cda6c76

Branch: refs/heads/master
Commit: 4cda6c76e1df1ceb02b8214b3d01369cf38fb87d
Parents: 788b90a
Author: Barbara Gomes <barbaramaltagomes@gmail.com>
Authored: Mon Jul 11 10:40:22 2016 -0700
Committer: Barbara Gomes <barbaramaltagomes@gmail.com>
Committed: Mon Jul 11 10:52:19 2016 -0700

----------------------------------------------------------------------
 fey-core/src/main/resources/eventsTable.html    | 35 ++++++++++++++++++++
 .../scala/org/apache/iota/fey/Monitor.scala     | 24 ++++++++++++++
 .../scala/org/apache/iota/fey/MyService.scala   | 10 ++++++
 .../scala/org/apache/iota/fey/TrieNode.scala    |  4 +++
 4 files changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/4cda6c76/fey-core/src/main/resources/eventsTable.html
----------------------------------------------------------------------
diff --git a/fey-core/src/main/resources/eventsTable.html b/fey-core/src/main/resources/eventsTable.html
new file mode 100644
index 0000000..9f6734a
--- /dev/null
+++ b/fey-core/src/main/resources/eventsTable.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+table {
+    font-family: arial, sans-serif;
+    border-collapse: collapse;
+    width: 100%;
+}
+
+td, th {
+    border: 1px solid #dddddd;
+    text-align: left;
+    padding: 8px;
+}
+
+tr:nth-child(even) {
+    background-color: #dddddd;
+}
+</style>
+</head>
+<body>
+
+<table>
+    <tr>
+        <th>GUID</th>
+        <th>Event</th>
+        <th>Info</th>
+        <th>Timestamp</th>
+    </tr>
+    $EVENTS_TABLE_CONTENT
+</table>
+
+</body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/4cda6c76/fey-core/src/main/scala/org/apache/iota/fey/Monitor.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/Monitor.scala b/fey-core/src/main/scala/org/apache/iota/fey/Monitor.scala
index 3cff0fb..3c02e73 100644
--- a/fey-core/src/main/scala/org/apache/iota/fey/Monitor.scala
+++ b/fey-core/src/main/scala/org/apache/iota/fey/Monitor.scala
@@ -20,6 +20,8 @@ package org.apache.iota.fey
 import akka.actor.Actor
 import akka.event.{DiagnosticLoggingAdapter, Logging}
 
+import scala.collection.mutable.ArrayBuffer
+
 /**
   * Created by barbaragomes on 7/8/16.
   */
@@ -80,6 +82,28 @@ protected object Monitor{
     */
   val events: Trie = new Trie()
 
+  //Static HTML content from d3
+  val html = scala.io.Source.fromInputStream(getClass.getResourceAsStream("/eventsTable.html"),
"UTF-8")
+    .getLines()
+    .mkString("\n")
+
+  def getHTMLevents: String = {
+    html.replace("$EVENTS_TABLE_CONTENT", mapEventsToRows(events.getRootChildren(), "").mkString("\n"))
+  }
+
+  def mapEventsToRows(actors: ArrayBuffer[TrieNode], prefix:String): ArrayBuffer[String]
= {
+    actors.map(actor => {
+      val currentPath = if (prefix == "/user/FEY-CORE") actor.path else s"$prefix/${actor.path}"
+      val events = actor.events.map(event => {
+        getTableLine(currentPath, event.timestamp, event.event, event.info)
+      })
+      mapEventsToRows(actor.children, currentPath) ++ events
+    }).flatten
+  }
+
+  private def getTableLine(path: String,timestamp: Long, event: String, info: String):String
= {
+    s"<tr><td>$path</td><td>$event</td><td>$info</td><td>$timestamp</td></tr>"
+  }
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/4cda6c76/fey-core/src/main/scala/org/apache/iota/fey/MyService.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/MyService.scala b/fey-core/src/main/scala/org/apache/iota/fey/MyService.scala
index bc1cfa0..41a6982 100644
--- a/fey-core/src/main/scala/org/apache/iota/fey/MyService.scala
+++ b/fey-core/src/main/scala/org/apache/iota/fey/MyService.scala
@@ -40,6 +40,7 @@ sealed trait MyService extends HttpService {
   val home = pathPrefix("fey")
   val activeActors = path("activeactors")
   val actorLifecycle = path("actorslifecycle")
+  val eventsTable = path("monitoringevents")
   val test = path("test")
 
   val myRoute =
@@ -64,6 +65,15 @@ sealed trait MyService extends HttpService {
             }
           }
         }
+      } ~
+        eventsTable {
+        get{
+          respondWithMediaType(`text/html`) {
+            complete {
+              Monitor.getHTMLevents
+            }
+          }
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/4cda6c76/fey-core/src/main/scala/org/apache/iota/fey/TrieNode.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/TrieNode.scala b/fey-core/src/main/scala/org/apache/iota/fey/TrieNode.scala
index 95deacc..517abd5 100644
--- a/fey-core/src/main/scala/org/apache/iota/fey/TrieNode.scala
+++ b/fey-core/src/main/scala/org/apache/iota/fey/TrieNode.scala
@@ -59,6 +59,10 @@ class Trie{
     getObjectEvent(root, null)
   }
 
+  def getRootChildren():ArrayBuffer[TrieNode] = {
+    root.children
+  }
+
   private def getObject(root: TrieNode, parent: TrieNode):JsObject = {
     if(root != null) {
      Json.obj("name" -> root.path,


Mime
View raw message