diff --git a/INSTALL b/INSTALL
index 0a1e8dd5..c0d62d6c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -37,7 +37,7 @@ example to /etc/ntpa.conf.
On FreeBSD copy content of bin to /usr/local/ntpa/
Copy ntpa.stat.conf from example to /usr/local/etc/ntpa/ntpa.conf
-Copy script/ntpa.rc to /usr/local/etc/rc.d/ntpa/ntpa
+Copy script/ntpa.rc to /usr/local/etc/rc.d/ntpa
Touch /var/log/ntpa.log and adjust pid file location if needed.
@@ -72,7 +72,7 @@ Ask ntpa how long time it has been running:
# ntpac 127.0.0.1 9070 uptime
GTK GUI
-Run Ntp.Analyzer.Gui.exe and connect to ntpa with the a port specified
-in the listener section. The GTK GUI is experimental as does not support
+Run Ntp.Analyzer.Gui.exe and connect to ntpa with the port specified in
+the listener section. The GTK GUI is experimental as does not support
SQL configuration and error handling. Use it at your own risk.
diff --git a/Ntp.Analyzer.Data/Static/HostDatabaseMapper.cs b/Ntp.Analyzer.Data/Static/HostDatabaseMapper.cs
index 8e2bd3e0..4900d5e2 100644
--- a/Ntp.Analyzer.Data/Static/HostDatabaseMapper.cs
+++ b/Ntp.Analyzer.Data/Static/HostDatabaseMapper.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
using MySql.Data.MySqlClient;
using Ntp.Analyzer.Log;
using Ntp.Analyzer.Objects;
+using System.Linq;
namespace Ntp.Analyzer.Data.Static
{
@@ -114,34 +115,36 @@ namespace Ntp.Analyzer.Data.Static
/// The enumerator.
public override IEnumerator GetEnumerator ()
{
- IEnumerator result = null;
-
lock (Locker) {
- if (HasContent)
- result = Content.GetEnumerator ();
- else {
- try {
- Open ();
- Command.CommandText = selectSql;
- Reader = Command.ExecuteReader ();
- while (Reader.Read ()) {
- int id = Convert.ToInt32 (Reader ["id"]);
- string name = Reader ["name"].ToString ();
- string ip = Reader ["ip"].ToString ();
- int? orgId = Reader ["orgId"] != DBNull.Value ?
+ // TODO: Rewrite - not thread safe
+ if (HasContent) {
+ foreach (Host host in Content)
+ yield return host;
+
+ yield break;
+ }
+
+ try {
+ Open ();
+ Command.CommandText = selectSql;
+ Reader = Command.ExecuteReader ();
+
+ while (Reader.Read ()) {
+ int id = Convert.ToInt32 (Reader ["id"]);
+ string name = Reader ["name"].ToString ();
+ string ip = Reader ["ip"].ToString ();
+ int? orgId = Reader ["orgId"] != DBNull.Value ?
(int?)Convert.ToInt32 (Reader ["orgId"]) : (int?)null;
- Host host = new Host (id, name, ip, orgId, false);
- AddItem (host);
- }
- } finally {
- Close ();
+ Host host = new Host (id, name, ip, orgId, false);
+ AddItem (host);
+
+ yield return host;
}
- result = Content.GetEnumerator ();
+ } finally {
+ Close ();
}
}
-
- return result;
}
}
}
\ No newline at end of file
diff --git a/Ntp.Analyzer.Data/Static/PeerActivityDatabaseMapper.cs b/Ntp.Analyzer.Data/Static/PeerActivityDatabaseMapper.cs
index ca5b0b97..cf603df8 100644
--- a/Ntp.Analyzer.Data/Static/PeerActivityDatabaseMapper.cs
+++ b/Ntp.Analyzer.Data/Static/PeerActivityDatabaseMapper.cs
@@ -28,6 +28,7 @@ using System;
using Ntp.Analyzer.Log;
using Ntp.Analyzer.Objects;
using System.Collections.Generic;
+using System.Linq;
namespace Ntp.Analyzer.Data.Static
{
@@ -123,35 +124,37 @@ namespace Ntp.Analyzer.Data.Static
/// The enumerator.
public override IEnumerator GetEnumerator ()
{
- IEnumerator result = null;
-
lock (Locker) {
- if (HasContent)
- result = Content.GetEnumerator ();
- else {
- try {
- Open ();
- Command.CommandText = selectSql;
- Reader = Command.ExecuteReader ();
- while (Reader.Read ()) {
- int id = Convert.ToInt32 (Reader ["id"]);
- DateTime time = Convert.ToDateTime (Reader ["lastActive"]);
- int hostId = Convert.ToInt32 (Reader ["hostId"]);
- Host host = hostMapper [hostId];
- int peerId = Convert.ToInt32 (Reader ["peerId"]);
- Peer peer = peerMapper [peerId];
- PeerActivity item = new PeerActivity (id, peer, host, time);
- AddItem (item);
- }
- } finally {
- Close ();
+ // TODO: Rewrite - not thread safe
+ if (HasContent) {
+ foreach (PeerActivity peer in Content)
+ yield return peer;
+
+ yield break;
+ }
+
+ try {
+ Open ();
+ Command.CommandText = selectSql;
+ Reader = Command.ExecuteReader ();
+
+ while (Reader.Read ()) {
+ int id = Convert.ToInt32 (Reader ["id"]);
+ DateTime time = Convert.ToDateTime (Reader ["lastActive"]);
+ int hostId = Convert.ToInt32 (Reader ["hostId"]);
+ Host host = hostMapper [hostId];
+ int peerId = Convert.ToInt32 (Reader ["peerId"]);
+ Peer peer = peerMapper [peerId];
+ PeerActivity item = new PeerActivity (id, peer, host, time);
+ AddItem (item);
+
+ yield return item;
}
- result = Content.GetEnumerator ();
+ } finally {
+ Close ();
}
}
-
- return result;
}
}
}
\ No newline at end of file
diff --git a/Ntp.Analyzer.Data/Static/PeerDatabaseMapper.cs b/Ntp.Analyzer.Data/Static/PeerDatabaseMapper.cs
index 3e1c4ef6..d695ba26 100644
--- a/Ntp.Analyzer.Data/Static/PeerDatabaseMapper.cs
+++ b/Ntp.Analyzer.Data/Static/PeerDatabaseMapper.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
using MySql.Data.MySqlClient;
using Ntp.Analyzer.Log;
using Ntp.Analyzer.Objects;
+using System.Linq;
namespace Ntp.Analyzer.Data.Static
{
@@ -124,38 +125,40 @@ namespace Ntp.Analyzer.Data.Static
/// The enumerator.
public override IEnumerator GetEnumerator ()
{
- IEnumerator result = null;
-
lock (Locker) {
- if (HasContent)
- result = Content.GetEnumerator ();
- else {
- try {
- Open ();
- Command.CommandText = selectSql;
- Reader = Command.ExecuteReader ();
- while (Reader.Read ()) {
- int id = Convert.ToInt32 (Reader ["id"]);
- string name = Reader ["name"].ToString ();
- string ip = Reader ["ip"].ToString ();
- int? orgId = Reader ["orgId"] != DBNull.Value ?
+ // TODO: Rewrite - not thread safe
+ if (HasContent) {
+ foreach (Peer peer in Content)
+ yield return peer;
+
+ yield break;
+ }
+
+ try {
+ Open ();
+ Command.CommandText = selectSql;
+ Reader = Command.ExecuteReader ();
+
+ while (Reader.Read ()) {
+ int id = Convert.ToInt32 (Reader ["id"]);
+ string name = Reader ["name"].ToString ();
+ string ip = Reader ["ip"].ToString ();
+ int? orgId = Reader ["orgId"] != DBNull.Value ?
(int?)Convert.ToInt32 (Reader ["orgId"]) : (int?)null;
- TimeServer server = orgId.HasValue ?
+ TimeServer server = orgId.HasValue ?
timeServerMapper [orgId.Value] : null;
- Peer peer = new Peer (id, name, ip, server);
- AddItem (peer);
- }
- } finally {
- Close ();
+ Peer peer = new Peer (id, name, ip, server);
+ AddItem (peer);
+
+ yield return peer;
}
- result = Content.GetEnumerator ();
+ } finally {
+ Close ();
}
}
-
- return result;
}
}
}
\ No newline at end of file
diff --git a/Ntp.Analyzer.Objects/PersistentObject.cs b/Ntp.Analyzer.Objects/PersistentObject.cs
index ae602aa1..0f080a45 100644
--- a/Ntp.Analyzer.Objects/PersistentObject.cs
+++ b/Ntp.Analyzer.Objects/PersistentObject.cs
@@ -97,12 +97,18 @@ namespace Ntp.Analyzer.Objects
if (obj.GetType () != GetType ())
return false;
- return id == ((PersistentObject)obj).Id;
+ return
+ newObject ?
+ base.Equals(obj) :
+ id == ((PersistentObject)obj).Id;
}
public override int GetHashCode()
{
- return (int)(id * 2654435761 % 2 ^ 32);
+ return
+ newObject ?
+ base.GetHashCode() :
+ (int)(id * 2654435761 % 2 ^ 32);
}
///
diff --git a/Ntp.Analyzer/Config/Root/NodeConfiguration.cs b/Ntp.Analyzer/Config/Root/NodeConfiguration.cs
index 2bedd6be..4344a51a 100644
--- a/Ntp.Analyzer/Config/Root/NodeConfiguration.cs
+++ b/Ntp.Analyzer/Config/Root/NodeConfiguration.cs
@@ -69,7 +69,7 @@ namespace Ntp.Analyzer.Config.Root
GetOptionConfigName (options, Identifier, String.Empty, false),
config.IndentLevel,
GetOptionString (options, ConfigurationKeyword.ClusterNodeIp, Identifier, false, "127.0.0.1"),
- GetOptionInteger (options, ConfigurationKeyword.ClusterNodeIp, Identifier, false, 9090)
+ GetOptionInteger (options, ConfigurationKeyword.ClusterNodePort, Identifier, false, 9090)
);
}
}
diff --git a/Ntp.Analyzer/Config/Stats/HostStatConfiguration.cs b/Ntp.Analyzer/Config/Stats/HostStatConfiguration.cs
index aafb3ea4..2bc96e49 100644
--- a/Ntp.Analyzer/Config/Stats/HostStatConfiguration.cs
+++ b/Ntp.Analyzer/Config/Stats/HostStatConfiguration.cs
@@ -71,7 +71,7 @@ namespace Ntp.Analyzer.Config.Stats
Bulk == null ?
ConfigText (Params, Items) :
ConfigText (
- new[] { ConfigurationKeyword.HostIOStats, ConfigurationKeyword.Frequency },
+ new[] { ConfigurationKeyword.HostStats, ConfigurationKeyword.Frequency },
new[] { ConfigName, Bulk.Name });
}
diff --git a/Ntp.Analyzer/Config/Stats/PeerStatConfiguration.cs b/Ntp.Analyzer/Config/Stats/PeerStatConfiguration.cs
index 81d4282a..98514fc7 100644
--- a/Ntp.Analyzer/Config/Stats/PeerStatConfiguration.cs
+++ b/Ntp.Analyzer/Config/Stats/PeerStatConfiguration.cs
@@ -71,7 +71,7 @@ namespace Ntp.Analyzer.Config.Stats
Bulk == null ?
ConfigText (Params, Items) :
ConfigText (
- new[] { ConfigurationKeyword.HostIOStats, ConfigurationKeyword.Frequency },
+ new[] { ConfigurationKeyword.PeerStats, ConfigurationKeyword.Frequency },
new[] { ConfigName, Bulk.Name });
}