From 5ce181a5fa518cd4c5779f0f248d62289f0193ac Mon Sep 17 00:00:00 2001 From: Harald Wolff Date: Tue, 6 Aug 2019 00:26:53 +0200 Subject: [PATCH] WIP --- SkyScanner.cs | 4 ++ ln.skyscanner.csproj | 2 +- packages.config | 2 +- services/CheckService.cs | 49 ++++++++++++++++++---- services/CrawlService.cs | 4 ++ services/EntityService.cs | 2 + templates/static/css/style.css | 9 ++++ templates/static/frame.html | 8 ++-- templates/static/index.html | 9 ++-- templates/static/skyapi.js | 23 +---------- templates/static/system/index.html | 66 ++++++++++++++++++++---------- 11 files changed, 117 insertions(+), 61 deletions(-) diff --git a/SkyScanner.cs b/SkyScanner.cs index b662bd3..c585e75 100644 --- a/SkyScanner.cs +++ b/SkyScanner.cs @@ -143,9 +143,12 @@ namespace ln.skyscanner webSocketInterface = new WebSocketInterface(rootResource, this); RPCContainer.Add("", new SkyScannerRpc(this)); + RPCContainer.Add("ServiceContainer",applicationInterface.ServiceContainer.RPC); long nextCycle = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + Ready(); + while (!StopRequested) { while ((nextCycle - DateTimeOffset.Now.ToUnixTimeMilliseconds()) < 0) @@ -199,6 +202,7 @@ namespace ln.skyscanner } + } diff --git a/ln.skyscanner.csproj b/ln.skyscanner.csproj index 909a8d3..a8fc04e 100644 --- a/ln.skyscanner.csproj +++ b/ln.skyscanner.csproj @@ -45,7 +45,7 @@ ..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll - ..\packages\MySql.Data.8.0.16\lib\net452\MySql.Data.dll + ..\packages\MySql.Data.8.0.17\lib\net452\MySql.Data.dll diff --git a/packages.config b/packages.config index 259e1db..51a0f32 100644 --- a/packages.config +++ b/packages.config @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/services/CheckService.cs b/services/CheckService.cs index b79ba54..b3d09a6 100644 --- a/services/CheckService.cs +++ b/services/CheckService.cs @@ -3,10 +3,18 @@ using ln.application; using System.Threading; using ln.logging; using ln.application.service; +using ln.skyscanner.entities; +using ln.skyscanner.checks; +using System.Collections.Generic; +using ln.types.threads; +using System.Linq; namespace ln.skyscanner.services { public class CheckService : ApplicationServiceBase { + Pool checkPool; + + public CheckService() :base("Check Service") { @@ -15,13 +23,20 @@ namespace ln.skyscanner.services public override void ServiceMain(IApplicationInterface applicationInterface) { + EntityService entityService = Dependency(); + + Dictionary checkJobs = new Dictionary(); + HashSet currentNodes = new HashSet(); + + checkPool = new Pool(64); + long nextMinute = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + Ready(); + while (!StopRequested) { /* - List checkJobs = new List(); - Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduler save CheckStates"); lock (saveQueue) @@ -32,17 +47,35 @@ namespace ln.skyscanner.services } saveQueue.Clear(); } - + */ Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduler starts"); - foreach (Node node in SkyScanner.Instance.Entities.NodeCollection) + currentNodes.Clear(); + foreach (Node node in entityService.NodeCollection) { - CheckJob checkJob = new CheckJob(node); - checkJobs.Add(checkJob); + currentNodes.Add(node); + if (!checkJobs.ContainsKey(node)) + { + CheckJob checkJob = new CheckJob(node); + checkJobs.Add(node, checkJob); + } } + foreach (Node node in checkJobs.Keys.ToArray()) + { + currentNodes.Remove(node); + } + + if (currentNodes.Count > 0) + { + foreach (Node node in currentNodes) + checkJobs.Remove(node); + } + currentNodes.Clear(); + + Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): prepared {0} checks", checkJobs.Count); - Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduled {0} checks", checkPool.Enqueue(checkJobs)); - */ + Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduled {0} checks", checkPool.Enqueue(checkJobs.Values)); + while (true) { diff --git a/services/CrawlService.cs b/services/CrawlService.cs index 361eb6f..1a4ed39 100644 --- a/services/CrawlService.cs +++ b/services/CrawlService.cs @@ -13,6 +13,10 @@ namespace ln.skyscanner.services public override void ServiceMain(IApplicationInterface applicationInterface) { + EntityService entityService = Dependency(); + + Ready(); + } } } diff --git a/services/EntityService.cs b/services/EntityService.cs index 6939d04..8a9f061 100644 --- a/services/EntityService.cs +++ b/services/EntityService.cs @@ -80,6 +80,8 @@ namespace ln.skyscanner.services + Ready(); + lock (Thread.CurrentThread) { Monitor.Wait(Thread.CurrentThread); diff --git a/templates/static/css/style.css b/templates/static/css/style.css index e6946d5..1bcc4c0 100644 --- a/templates/static/css/style.css +++ b/templates/static/css/style.css @@ -487,3 +487,12 @@ span#nWARN, span#nCRITICAL, span#nOK { .issue-box:hover .performance-value { height: 250px; } + +[bool=true] { + border: 1px solid white; + background-color: green; +} +[bool=false] { + border: 1px solid white; + background-color: red; +} diff --git a/templates/static/frame.html b/templates/static/frame.html index 0c76048..0b02b16 100644 --- a/templates/static/frame.html +++ b/templates/static/frame.html @@ -23,8 +23,9 @@ @@ -46,12 +47,13 @@
Crawler
Checks
Message Dispatcher
-
+
+
diff --git a/templates/static/index.html b/templates/static/index.html index 44e31f5..ca56471 100644 --- a/templates/static/index.html +++ b/templates/static/index.html @@ -1,8 +1,5 @@ <%frame "frame.html"%> - \ No newline at end of file + + + diff --git a/templates/static/skyapi.js b/templates/static/skyapi.js index f1e15af..42f9c10 100644 --- a/templates/static/skyapi.js +++ b/templates/static/skyapi.js @@ -32,22 +32,12 @@ function updateState(state) } } +/* function SKYAPI(baseurl){ this.baseurl = baseurl; this.refresh = [] -/* this.websocket = new WebSocket("ws://localhost:8080/socket"); - this.websocket.onerror = function(e){ - alert("WebSocket Error: " + e); - } - this.websocket.onmessage = function(e){ - var j = JSON.parse(e.data); - if (j.state){ - updateState(j.state); - } - } -*/ this.setBaseURL = function(url){ this.baseurl = url; } this.addRefresh = function( rh, seconds = null ){ this.refresh.push( { interval: seconds ? seconds : 5, refresh: rh } ); } @@ -199,6 +189,7 @@ function showStatistics(stats) $("#indDispatcher").attr("title","UNKNOWN"); } } +*/ function updateStatistics() { @@ -211,16 +202,6 @@ function updateStatistics() } } - -var __skyapi = new SKYAPI("/"); - -function skyapi() -{ - return __skyapi; -} - - - function ScaleSI(value) { if (value > 1000000000) diff --git a/templates/static/system/index.html b/templates/static/system/index.html index a44e137..f8ca5d2 100644 --- a/templates/static/system/index.html +++ b/templates/static/system/index.html @@ -25,28 +25,52 @@ +
+

Services

+ + + + + + + + + + + + + +
ServiceClassLoadedAliveReady
+