NewtonSoft.Json replaced by ln.json

broken
Harald Wolff 2019-08-19 14:15:10 +02:00
parent 5ce181a5fa
commit c60c0b4f20
24 changed files with 96 additions and 67 deletions

View File

@ -6,24 +6,20 @@ using ln.skyscanner.http;
using System.IO; using System.IO;
using ln.skyscanner.crawl; using ln.skyscanner.crawl;
using ln.types.threads; using ln.types.threads;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using ln.skyscanner.checks; using ln.skyscanner.checks;
using ln.skyscanner.import.skytron; using ln.skyscanner.import.skytron;
using System.Linq; using System.Linq;
using ln.skyscanner.entities; using ln.skyscanner.entities;
using Newtonsoft.Json.Linq;
using ln.types.net; using ln.types.net;
using ln.application; using ln.application;
using ln.application.service; using ln.application.service;
using ln.skyscanner.services; using ln.skyscanner.services;
using Renci.SshNet.Messages;
using System.Threading; using System.Threading;
using ln.http.resources; using ln.http.resources;
using ln.types.rpc; using ln.types.rpc;
using ln.json;
namespace ln.skyscanner namespace ln.skyscanner
{ {
[JsonConverter(typeof(StringEnumConverter))]
public enum ComponentState { STOPPED, INITIALIZED, STARTED, FAILED, STOPPING } public enum ComponentState { STOPPED, INITIALIZED, STARTED, FAILED, STOPPING }
public class SkyScanner : Application public class SkyScanner : Application
@ -168,9 +164,9 @@ namespace ln.skyscanner
/* Send Application State to WebSockets */ /* Send Application State to WebSockets */
JObject msg = new JObject(); JSONObject msg = new JSONObject();
JObject stateObject = new JObject(); JSONObject stateObject = new JSONObject();
stateObject["currentTime"] = DateTimeOffset.Now.ToUnixTimeMilliseconds(); stateObject.Add("currentTime", DateTimeOffset.Now.ToUnixTimeMilliseconds());
msg["state"] = stateObject; msg["state"] = stateObject;
@ -242,7 +238,7 @@ namespace ln.skyscanner
crawl.Prepare(); crawl.Prepare();
crawl.RunJob(); crawl.RunJob();
Logging.Log(LogLevel.INFO, "CrawledHost: {0}", JObject.FromObject(crawledHost).ToString()); Logging.Log(LogLevel.INFO, "CrawledHost: {0}", JSONObject.From(crawledHost).ToString());
} }
@ -257,7 +253,7 @@ namespace ln.skyscanner
} }
else else
{ {
Logging.Log(LogLevel.INFO, "DebugCheck(): Node: {0}",JObject.FromObject(node).ToString()); Logging.Log(LogLevel.INFO, "DebugCheck(): Node: {0}",JSONObject.From(node).ToString());
CheckJob checkJob = new CheckJob(node); CheckJob checkJob = new CheckJob(node);
Logging.Log(LogLevel.INFO, "Prepare..."); Logging.Log(LogLevel.INFO, "Prepare...");

View File

@ -11,7 +11,6 @@ using System;
using ln.types.threads; using ln.types.threads;
using ln.skyscanner.entities; using ln.skyscanner.entities;
using ln.logging; using ln.logging;
using Newtonsoft.Json;
using ln.types.odb; using ln.types.odb;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
@ -19,9 +18,25 @@ namespace ln.skyscanner.checks
{ {
public class CheckJob : PoolJob public class CheckJob : PoolJob
{ {
[JsonIgnore]
public Node Node { get; } public Node Node { get; }
public SkyCheckState[] CheckStates
{
get
{
return checkStates.Values.ToArray();
}
set
{
checkStates.Clear();
foreach (SkyCheckState checkState in value)
{
checkStates.Add(checkState.CheckName, checkState);
}
}
}
Dictionary<string, SkyCheckState> checkStates = new Dictionary<string, SkyCheckState>(); Dictionary<string, SkyCheckState> checkStates = new Dictionary<string, SkyCheckState>();
public CheckJob(Node node) public CheckJob(Node node)
@ -32,6 +47,7 @@ namespace ln.skyscanner.checks
public override void Prepare() public override void Prepare()
{ {
/*
Query stateQuery = Query.Equals<SkyCheckState>("Node", Node.ID); Query stateQuery = Query.Equals<SkyCheckState>("Node", Node.ID);
SkyCheckState[] skyCheckStates = SkyScanner.Instance.Entities.SkyCheckStates.Query(stateQuery).ToArray(); SkyCheckState[] skyCheckStates = SkyScanner.Instance.Entities.SkyCheckStates.Query(stateQuery).ToArray();
foreach (SkyCheckState checkState in skyCheckStates) foreach (SkyCheckState checkState in skyCheckStates)
@ -44,6 +60,7 @@ namespace ln.skyscanner.checks
checkStates.Add(check.Name, check.PrepareCheckState(SkyScanner.Instance.Checker, Node)); checkStates.Add(check.Name, check.PrepareCheckState(SkyScanner.Instance.Checker, Node));
SkyScanner.Instance.Entities.SkyCheckStates.Insert(checkStates[check.Name]); SkyScanner.Instance.Entities.SkyCheckStates.Insert(checkStates[check.Name]);
} }
*/
} }
public override void RunJob() public override void RunJob()

View File

@ -5,6 +5,7 @@ using ln.snmp;
using ln.logging; using ln.logging;
using ln.snmp.types; using ln.snmp.types;
using System.Drawing; using System.Drawing;
using ln.skyscanner.services;
namespace ln.skyscanner.checks namespace ln.skyscanner.checks
{ {
@ -57,7 +58,7 @@ namespace ln.skyscanner.checks
return (node.Vendor != null) && node.Vendor.Equals("mimosa"); return (node.Vendor != null) && node.Vendor.Equals("mimosa");
} }
public override SkyCheckState PrepareCheckState(SkyChecker skyChecker, Node node) public override SkyCheckState PrepareCheckState(CheckService skyChecker, Node node)
{ {
return new MimosaCheckState(this, node); return new MimosaCheckState(this, node);
} }

View File

@ -9,7 +9,6 @@
// **/ // **/
using System; using System;
using ln.perfdb.storage; using ln.perfdb.storage;
using Newtonsoft.Json;
namespace ln.skyscanner.checks namespace ln.skyscanner.checks
{ {
public class PerformanceValue public class PerformanceValue

View File

@ -11,6 +11,7 @@ using System;
using ln.skyscanner.entities; using ln.skyscanner.entities;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using ln.skyscanner.services;
namespace ln.skyscanner.checks namespace ln.skyscanner.checks
{ {
public abstract class SkyCheck public abstract class SkyCheck
@ -33,7 +34,7 @@ namespace ln.skyscanner.checks
public abstract bool IsValid(Node node); public abstract bool IsValid(Node node);
public abstract void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node); public abstract void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node);
public virtual SkyCheckState PrepareCheckState(SkyChecker skyChecker,Node node) public virtual SkyCheckState PrepareCheckState(CheckService skyChecker,Node node)
{ {
return new SkyCheckState(this, node); return new SkyCheckState(this, node);
} }

View File

@ -9,15 +9,10 @@
// **/ // **/
using System; using System;
using ln.skyscanner.entities; using ln.skyscanner.entities;
using ln.types.odb;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Linq;
using ln.types.odb.attributes; using ln.types.odb.attributes;
using System.Collections.Generic; using System.Collections.Generic;
namespace ln.skyscanner.checks namespace ln.skyscanner.checks
{ {
[JsonConverter(typeof(StringEnumConverter))]
public enum CheckState { OK, WARN, CRITICAL, FAIL, ERROR } public enum CheckState { OK, WARN, CRITICAL, FAIL, ERROR }
public struct CheckStateChange public struct CheckStateChange

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using ln.snmp.types; using ln.snmp.types;
using ln.logging; using ln.logging;
using System.Linq; using System.Linq;
using ln.skyscanner.services;
namespace ln.skyscanner.checks namespace ln.skyscanner.checks
{ {
@ -78,7 +79,7 @@ namespace ln.skyscanner.checks
return (node.Vendor != null) && node.Vendor.Equals("Ubiquiti"); return (node.Vendor != null) && node.Vendor.Equals("Ubiquiti");
} }
public override SkyCheckState PrepareCheckState(SkyChecker skyChecker, Node node) public override SkyCheckState PrepareCheckState(CheckService skyChecker, Node node)
{ {
return new UbiquityCheckState(this, node); return new UbiquityCheckState(this, node);
} }

View File

@ -18,7 +18,6 @@ using ln.snmp.types;
using System.Collections.Generic; using System.Collections.Generic;
using ln.snmp.rfc1213; using ln.snmp.rfc1213;
using ln.types; using ln.types;
using Newtonsoft.Json;
using ln.skyscanner.crawl.tests; using ln.skyscanner.crawl.tests;
using System.Runtime.Remoting.Messaging; using System.Runtime.Remoting.Messaging;
using ln.skyscanner.crawl.service; using ln.skyscanner.crawl.service;
@ -27,9 +26,7 @@ namespace ln.skyscanner.crawl
{ {
public class Crawl : PoolJob public class Crawl : PoolJob
{ {
[JsonIgnore]
public Crawler Crawler { get; } public Crawler Crawler { get; }
[JsonIgnore]
public CrawledHost Host { get; } public CrawledHost Host { get; }
List<CrawlService> servicesToCheck = new List<CrawlService>(); List<CrawlService> servicesToCheck = new List<CrawlService>();

View File

@ -13,7 +13,6 @@ using ln.types;
using ln.skyscanner.entities; using ln.skyscanner.entities;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using ln.logging; using ln.logging;
using Newtonsoft.Json;
using System.Linq; using System.Linq;
using ln.types.odb; using ln.types.odb;
using ln.types.net; using ln.types.net;
@ -21,7 +20,6 @@ namespace ln.skyscanner.crawl
{ {
public class CrawlNetwork : PoolJob public class CrawlNetwork : PoolJob
{ {
[JsonIgnoreAttribute]
public Crawler Crawler { get; } public Crawler Crawler { get; }
public CrawledSubnet Subnet { get; } public CrawledSubnet Subnet { get; }

View File

@ -13,8 +13,6 @@ using System.IO;
using ln.logging; using ln.logging;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using ln.types.odb; using ln.types.odb;
using ln.skyscanner.crawl.service; using ln.skyscanner.crawl.service;
using ln.skyscanner.crawl.tests; using ln.skyscanner.crawl.tests;
@ -53,7 +51,6 @@ namespace ln.skyscanner.crawl
public bool CrawlSubnets { get; set; } public bool CrawlSubnets { get; set; }
public bool CrawlHosts { get; set; } public bool CrawlHosts { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public ComponentState CrawlerState { get; private set; } public ComponentState CrawlerState { get; private set; }
public CredentialsGenerator Credentials { get; } = new CredentialsGenerator(); public CredentialsGenerator Credentials { get; } = new CredentialsGenerator();

View File

@ -8,11 +8,8 @@
// * // *
// **/ // **/
using System; using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ln.skyscanner.entities namespace ln.skyscanner.entities
{ {
[JsonConverter(typeof(StringEnumConverter))]
public enum CheckSeverity public enum CheckSeverity
{ {
OLD = 0, OLD = 0,

View File

@ -10,7 +10,6 @@
using System; using System;
using ln.types.odb; using ln.types.odb;
using ln.types; using ln.types;
using Newtonsoft.Json;
using ln.types.net; using ln.types.net;
using ln.types.odb.attributes; using ln.types.odb.attributes;
namespace ln.skyscanner.entities namespace ln.skyscanner.entities

View File

@ -1,9 +1,6 @@
using System; using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ln.skyscanner.entities namespace ln.skyscanner.entities
{ {
[JsonConverter(typeof(StringEnumConverter))]
public enum DeviceType public enum DeviceType
{ {
UNKNOWN, UNKNOWN,

View File

@ -12,7 +12,6 @@ using System.Collections.Generic;
using ln.types.odb; using ln.types.odb;
using System.Linq; using System.Linq;
using ln.types.btree; using ln.types.btree;
using Newtonsoft.Json;
using ln.types.net; using ln.types.net;
namespace ln.skyscanner.entities namespace ln.skyscanner.entities
{ {
@ -62,14 +61,11 @@ namespace ln.skyscanner.entities
public class HopNode : IComparable public class HopNode : IComparable
{ {
[JsonIgnore]
public HopMap HopMap { get; } public HopMap HopMap { get; }
[JsonIgnore]
public HopNode Parent { get; private set; } public HopNode Parent { get; private set; }
public Node Node; public Node Node;
[JsonIgnore]
public HopNode[] Peers => peers.ToArray(); public HopNode[] Peers => peers.ToArray();
private HashSet<HopNode> peers = new HashSet<HopNode>(); private HashSet<HopNode> peers = new HashSet<HopNode>();

View File

@ -12,7 +12,6 @@ using System.Collections.Generic;
using ln.types; using ln.types;
using ln.skyscanner.crawl; using ln.skyscanner.crawl;
using ln.types.odb; using ln.types.odb;
using Newtonsoft.Json;
using ln.logging; using ln.logging;
using ln.types.net; using ln.types.net;
using ln.types.odb.attributes; using ln.types.odb.attributes;

View File

@ -12,7 +12,6 @@ using ln.types;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ln.types.odb; using ln.types.odb;
using Newtonsoft.Json;
using ln.types.threads; using ln.types.threads;
using ln.types.net; using ln.types.net;
using ln.types.odb.attributes; using ln.types.odb.attributes;
@ -45,11 +44,8 @@ namespace ln.skyscanner.entities
public List<NetworkInterface> Interfaces { get; private set; } = new List<NetworkInterface>(); public List<NetworkInterface> Interfaces { get; private set; } = new List<NetworkInterface>();
[JsonIgnore]
public IEnumerable<IPv4> IPAdresses => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.IP)); public IEnumerable<IPv4> IPAdresses => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.IP));
[JsonIgnore]
public IEnumerable<Network4> Networks => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.Network)).Distinct(); public IEnumerable<Network4> Networks => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.Network)).Distinct();
[JsonIgnore]
public IEnumerable<Subnet> Subnets => SkyScanner.Instance.Entities.SubnetCollection.Query(Query.Equals<Network4>("Network", Networks.Select(net => net.Network))); public IEnumerable<Subnet> Subnets => SkyScanner.Instance.Entities.SubnetCollection.Query(Query.Equals<Network4>("Network", Networks.Select(net => net.Network)));
private string uniqueIdentity; private string uniqueIdentity;

View File

@ -13,7 +13,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using ln.types; using ln.types;
using ln.types.odb.attributes; using ln.types.odb.attributes;
using Newtonsoft.Json;
using ln.types.odb.collections; using ln.types.odb.collections;
namespace ln.skyscanner.entities namespace ln.skyscanner.entities
{ {
@ -30,7 +29,6 @@ namespace ln.skyscanner.entities
public GeoLocation GeoLocation { get; set; } public GeoLocation GeoLocation { get; set; }
public DateTime Created { get; private set; } = DateTime.Now; public DateTime Created { get; private set; } = DateTime.Now;
[JsonIgnore]
public IEnumerable<L2Segment> L2Segments public IEnumerable<L2Segment> L2Segments
{ {
get get

View File

@ -13,7 +13,6 @@ using ln.types.odb;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ln.types.net; using ln.types.net;
using Newtonsoft.Json;
using ln.types.odb.attributes; using ln.types.odb.attributes;
namespace ln.skyscanner.entities namespace ln.skyscanner.entities
{ {
@ -32,9 +31,7 @@ namespace ln.skyscanner.entities
public bool AutoScan { get; set; } public bool AutoScan { get; set; }
[JsonIgnore]
public IEnumerable<NetworkInterface> AttachedInterfaces => throw new NotImplementedException(); public IEnumerable<NetworkInterface> AttachedInterfaces => throw new NotImplementedException();
[JsonIgnore]
public IEnumerable<Node> AttachedNodes => throw new NotImplementedException(); public IEnumerable<Node> AttachedNodes => throw new NotImplementedException();
private Subnet() private Subnet()

View File

@ -13,11 +13,11 @@ using ln.http;
using ln.http.resources; using ln.http.resources;
using ln.types.threads; using ln.types.threads;
using ln.perfdb.storage; using ln.perfdb.storage;
using Newtonsoft.Json;
using System.Net; using System.Net;
using ln.skyscanner.checks; using ln.skyscanner.checks;
using ln.types.odb; using ln.types.odb;
using System.Linq; using System.Linq;
using ln.json.mapping;
namespace ln.skyscanner.http namespace ln.skyscanner.http
{ {
public class CheckerApi : JsonCallResource public class CheckerApi : JsonCallResource
@ -85,7 +85,7 @@ namespace ln.skyscanner.http
{ {
HttpResponse response = new HttpResponse(httpRequest); HttpResponse response = new HttpResponse(httpRequest);
response.SetHeader("content-type", "application/json"); response.SetHeader("content-type", "application/json");
response.ContentWriter.Write(JsonConvert.SerializeObject(SkyScanner.Instance.Checker.PerfNames)); response.ContentWriter.Write(JSONMapper.DefaultMapper.ToJson(SkyScanner.Instance.Checker.PerfNames));
return response; return response;
} }
@ -119,7 +119,7 @@ namespace ln.skyscanner.http
HttpResponse response = new HttpResponse(httpRequest); HttpResponse response = new HttpResponse(httpRequest);
response.SetHeader("content-type", "application/json"); response.SetHeader("content-type", "application/json");
response.ContentWriter.Write(JsonConvert.SerializeObject(perfValues)); response.ContentWriter.Write(JSONMapper.DefaultMapper.ToJson(perfValues).ToString());
return response; return response;
} }

View File

@ -1,13 +1,13 @@
using System; using System;
using ln.http.resources.websocket; using ln.http.resources.websocket;
using ln.http.resources; using ln.http.resources;
using Newtonsoft.Json.Linq;
using ln.logging; using ln.logging;
using System.Collections.Generic; using System.Collections.Generic;
using ln.http.websocket; using ln.http.websocket;
using System.Linq; using System.Linq;
using ln.types.rpc; using ln.types.rpc;
using Newtonsoft.Json; using ln.json;
using ln.json.mapping;
namespace ln.skyscanner.http namespace ln.skyscanner.http
{ {
@ -49,7 +49,7 @@ namespace ln.skyscanner.http
} }
} }
public void Broadcast(JObject json) public void Broadcast(JSONObject json)
{ {
Broadcast(json.ToString()); Broadcast(json.ToString());
} }
@ -66,13 +66,13 @@ namespace ln.skyscanner.http
{ {
try try
{ {
JObject json = JObject.Parse(textMessage); JSONObject json = (JSONObject)JSONParser.Parse(textMessage);
RPCCall rpcCall = new RPCCall(json); RPCCall rpcCall = json.ToObject<RPCCall>();
RPCResult rpcResult = SkyScannerService.RPCContainer.Invoke(rpcCall); RPCResult rpcResult = SkyScannerService.RPCContainer.Invoke(rpcCall);
requestContext.WebSocket.Send( requestContext.WebSocket.Send(
rpcResult.ToJSON().ToString() JSONObject.From(rpcResult).ToString()
); );
} }

View File

@ -33,16 +33,13 @@
<Reference Include="Renci.SshNet"> <Reference Include="Renci.SshNet">
<HintPath>..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll</HintPath> <HintPath>..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="BouncyCastle.Crypto"> <Reference Include="BouncyCastle.Crypto">
<HintPath>..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll</HintPath> <HintPath>..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference> </Reference>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll</HintPath> <HintPath>..\packages\Google.Protobuf.3.9.1\lib\net45\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="MySql.Data"> <Reference Include="MySql.Data">
<HintPath>..\packages\MySql.Data.8.0.17\lib\net452\MySql.Data.dll</HintPath> <HintPath>..\packages\MySql.Data.8.0.17\lib\net452\MySql.Data.dll</HintPath>
@ -299,6 +296,10 @@
<Project>{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}</Project> <Project>{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}</Project>
<Name>ln.application</Name> <Name>ln.application</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\ln.json\ln.json.csproj">
<Project>{D9342117-3249-4D8B-87C9-51A50676B158}</Project>
<Name>ln.json</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="BouncyCastle" version="1.8.5" targetFramework="net47" /> <package id="BouncyCastle" version="1.8.5" targetFramework="net47" />
<package id="Google.Protobuf" version="3.8.0" targetFramework="net47" /> <package id="Google.Protobuf" version="3.9.1" targetFramework="net47" />
<package id="MySql.Data" version="8.0.17" targetFramework="net47" /> <package id="MySql.Data" version="8.0.17" targetFramework="net47" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net47" />
<package id="SSH.NET" version="2016.1.0" targetFramework="net47" /> <package id="SSH.NET" version="2016.1.0" targetFramework="net47" />
</packages> </packages>

View File

@ -8,12 +8,14 @@ using ln.skyscanner.checks;
using System.Collections.Generic; using System.Collections.Generic;
using ln.types.threads; using ln.types.threads;
using System.Linq; using System.Linq;
using ln.types.odb;
namespace ln.skyscanner.services namespace ln.skyscanner.services
{ {
public class CheckService : ApplicationServiceBase public class CheckService : ApplicationServiceBase
{ {
Pool checkPool; Pool checkPool;
EntityService entityService;
public CheckService() public CheckService()
:base("Check Service") :base("Check Service")
@ -23,7 +25,7 @@ namespace ln.skyscanner.services
public override void ServiceMain(IApplicationInterface applicationInterface) public override void ServiceMain(IApplicationInterface applicationInterface)
{ {
EntityService entityService = Dependency<EntityService>(); entityService = Dependency<EntityService>();
Dictionary<Node, CheckJob> checkJobs = new Dictionary<Node, CheckJob>(); Dictionary<Node, CheckJob> checkJobs = new Dictionary<Node, CheckJob>();
HashSet<Node> currentNodes = new HashSet<Node>(); HashSet<Node> currentNodes = new HashSet<Node>();
@ -72,6 +74,10 @@ namespace ln.skyscanner.services
} }
currentNodes.Clear(); currentNodes.Clear();
foreach (CheckJob checkJob in checkJobs.Values)
{
}
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): prepared {0} checks", checkJobs.Count); Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): prepared {0} checks", checkJobs.Count);
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduled {0} checks", checkPool.Enqueue(checkJobs.Values)); Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduled {0} checks", checkPool.Enqueue(checkJobs.Values));
@ -93,6 +99,43 @@ namespace ln.skyscanner.services
} }
} }
} }
entityService = null;
} }
public SkyCheckState[] GetCheckStates(Node node)
{
Query stateQuery = Query.Equals<SkyCheckState>("Node", node.ID);
SkyCheckState[] skyCheckStates = entityService.SkyCheckStates.Query(stateQuery).ToArray();
Dictionary<string, SkyCheckState> checkStates = new Dictionary<string, SkyCheckState>();
foreach (SkyCheckState checkState in skyCheckStates)
{
checkStates.Add(checkState.CheckName, checkState);
}
foreach (SkyCheck check in SkyCheck.SkyChecks)
{
if (!checkStates.ContainsKey(check.Name) && check.IsValid(node))
{
checkStates.Add(check.Name, check.PrepareCheckState(this, node));
entityService.SkyCheckStates.Insert(checkStates[check.Name]);
}
}
return checkStates.Values.ToArray();
}
class CheckServiceRPC
{
CheckService checkService;
public CheckServiceRPC(CheckService checkService)
{
this.checkService = checkService;
}
}
} }
} }

View File

@ -23,7 +23,12 @@ function updateState(state)
$("#ServerTime").text("ServerTime: " + moment(state.currentTime).format()); $("#ServerTime").text("ServerTime: " + moment(state.currentTime).format());
lagDetector = setTimeout(function(){ lagDetector = setTimeout(function(){
$("#ServerTime").text("Server lag detected"); $("#ServerTime")
.empty()
.append(
$("<span style='color: white; background-color: red;'></span>")
.text("Server lag detected")
);
}, 2000); }, 2000);
} catch (e) } catch (e)