23 using System.Collections.Generic;
33 namespace Ntp.Analyzer.Process.Description
44 readings =
new List<PeerReading>();
45 activities =
new List<PeerActivity>();
46 entries =
new List<AssociationEntry>();
52 private readonly List<AssociationEntry>
entries;
59 public override string JobType =>
"Peer statistics";
61 public override int Priority => 2;
73 Log.PeerImportError(e);
82 var bulk = config.Bulk == null
87 entries.AddRange(importer);
96 Log.PeerImportError(e);
101 foreach (var entry
in entries)
104 var currentEntry = entry;
105 IEnumerable<Peer> peerList = peers.Where(p => p.Ip == currentEntry.Remote).ToList();
108 if (peerList.Count() == 1)
110 peer = peerList.Single();
112 else if (!peerList.Any())
114 Log.PeerIpNotFound(entry);
119 Log.PeerIpAmbiguous(entry);
123 var reading =
new PeerReading(host, peer, bulk, entry);
124 readings.Add(reading);
128 SingleOrDefault(
a => Equals(
a.Host, reading.Host) && Equals(
a.Peer, reading.Peer));
130 if (activity != null)
132 activity.LastActive = bulk.Time;
136 activity =
new PeerActivity(reading.Peer, host, bulk.Time);
139 activities.Add(activity);
158 Log.HostNotFound(config.HostId);
167 foreach (var reading
in readings)
172 foreach (var activity
in activities)
177 foreach (var entry
in entries)
HostDatabaseMapper Hosts
Gets the host mapper.
PeerReadingDatabaseMapper PeerReadings
Gets the peer reading mapper.
static Importer< AssociationEntry > CreatePeerImporter(string address, ServerType type, Host host, LogBase log)
override void InternalExecute()
Implementing method for descendants.
readonly List< PeerActivity > activities
readonly StatConfiguration config
PeerStatJob(StatConfiguration config, LogBase log)
AssociationEntryMapper AssociationEntries
Gets the association entry mapper.
void Initialize()
Initialize database context.
ReadingBulkMapper ReadingBulks
Gets the reading bulk mapper.
PeerDatabaseMapper Peers
Gets the peer mapper.
Singleton facade class used to access memory persistent data.
readonly List< PeerReading > readings
PeerActivityDatabaseMapper PeerActivities
Gets the peer activity mapper.
void Import()
Import statistics.
Base class for jobs following the GoF Command Pattern.
Job which read statistics about peers and saves the result to a database.
readonly List< AssociationEntry > entries
void SaveResult()
Saves the result of the import to database.
static DataFace Instance
Gets the Singleton instance.