NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper Class Reference

OR/M mapper for table hostIoReading. More...

Inheritance diagram for Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper:
Collaboration diagram for Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper:

Public Member Functions

override IEnumerator< HostIoReadingGetEnumerator ()
 Read all data from table in a sequential manner. More...
 

Protected Member Functions

override void Insert (HostIoReading item)
 
override void ReadContent ()
 
override void Update (HostIoReading item)
 
- Protected Member Functions inherited from Ntp.Analyzer.Data.Sql.FilteredSqlDatabaseMapper< HostIoReading >
 FilteredSqlDatabaseMapper (LogBase log)
 
override string PrepareSql (string sql)
 

Protected Attributes

override string CreateSql
 
override string TableName => "hostIoReading"
 
override bool UseCache => false
 

Package Functions

 HostIoReadingDatabaseMapper (HostDatabaseMapper hostMapper, LogBase log)
 

Private Attributes

readonly HostDatabaseMapper hostMapper
 
const string InsertSql
 
const string SelectSql
 

Additional Inherited Members

- Properties inherited from Ntp.Analyzer.Data.Sql.FilteredSqlDatabaseMapper< HostIoReading >
Host FilterHost [get, set]
 Gets or sets the host More...
 
Peer FilterPeer [get, set]
 Gets or sets the peer to use when extracting data. More...
 
DateTime FilterTime [get, set]
 Gets or sets the time to use when extracting data. Only readings with a timestamp later than FilterTime gets extracted. More...
 

Detailed Description

OR/M mapper for table hostIoReading.

Definition at line 35 of file HostIoReadingDatabaseMapper.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.HostIoReadingDatabaseMapper ( HostDatabaseMapper  hostMapper,
LogBase  log 
)
inlinepackage

Definition at line 37 of file HostIoReadingDatabaseMapper.cs.

38  : base(log)
39  {
40  this.hostMapper = hostMapper;
41  }

Member Function Documentation

override IEnumerator<HostIoReading> Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.GetEnumerator ( )
inline

Read all data from table in a sequential manner.

Returns
The enumerator.

Definition at line 94 of file HostIoReadingDatabaseMapper.cs.

References e.

95  {
96  lock (MapperLocker)
97  {
98  bool error = false;
99 
100  try
101  {
102  Open();
103  Command.CommandText = PrepareSql(SelectSql);
104  Log.SqlExecute(Command.CommandText);
105  Reader = Command.ExecuteReader();
106  }
107  catch (Exception e)
108  {
109  Log.ReadError(TableName, e);
110  error = true;
111  }
112 
113  if (error)
114  yield break;
115 
116  while (Reader.Read())
117  {
118  int id = Convert.ToInt32(Reader["id"]);
119  var time = Convert.ToDateTime(Reader["time"]);
120  int zone = Convert.ToInt32(Reader["zone"]);
121  int hostId = Convert.ToInt32(Reader["hostId"]);
122  var host = hostMapper[hostId];
123  int timeSinceReset = Convert.ToInt32(Reader["timeSinceReset"]);
124  int receiveBuffers = Convert.ToInt32(Reader["receiveBuffers"]);
125  int freeReceiveBuffers = Convert.ToInt32(Reader["freeReceiveBuffers"]);
126  int usedReceiveBuffers = Convert.ToInt32(Reader["usedReceiveBuffers"]);
127  int lowWaterRefills = Convert.ToInt32(Reader["lowWaterRefills"]);
128  long droppedPackets = Convert.ToInt64(Reader["droppedPackets"]);
129  long ignoredPackets = Convert.ToInt64(Reader["ignoredPackets"]);
130  long receivedPackets = Convert.ToInt64(Reader["receivedPackets"]);
131  long packetsSent = Convert.ToInt64(Reader["packetsSent"]);
132  long packetsNotSent = Convert.ToInt64(Reader["packetsNotSent"]);
133  int interruptsHandled = Convert.ToInt32(Reader["interruptsHandled"]);
134  int receivedByInt = Convert.ToInt32(Reader["receivedByInt"]);
135 
136  var reading = new HostIoReading(
137  id, time, zone, host, timeSinceReset,
138  receiveBuffers, freeReceiveBuffers, usedReceiveBuffers, lowWaterRefills,
139  droppedPackets, ignoredPackets, receivedPackets,
140  packetsSent, packetsNotSent,
141  interruptsHandled, receivedByInt);
142 
143  yield return reading;
144  }
145 
146  Close();
147  }
148  }
var e
Definition: bootstrap.min.js:6
override void Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.Insert ( HostIoReading  item)
inlineprotected

Definition at line 151 of file HostIoReadingDatabaseMapper.cs.

References Ntp.Analyzer.Objects.HostIoReading.DroppedPackets, e, Ntp.Analyzer.Objects.HostIoReading.FreeReceiveBuffers, Ntp.Analyzer.Objects.Reading.Host, Ntp.Analyzer.Objects.PersistentObject.Id, Ntp.Analyzer.Objects.HostIoReading.IgnoredPackets, Ntp.Analyzer.Objects.HostIoReading.InterruptsHandled, Ntp.Analyzer.Objects.HostIoReading.LowWaterRefills, Ntp.Analyzer.Objects.HostIoReading.PacketsNotSent, Ntp.Analyzer.Objects.HostIoReading.PacketsSent, Ntp.Analyzer.Objects.HostIoReading.ReceiveBuffers, Ntp.Analyzer.Objects.HostIoReading.ReceivedByInt, Ntp.Analyzer.Objects.HostIoReading.ReceivedPackets, Ntp.Analyzer.Objects.PersistentObject.SetId(), Ntp.Analyzer.Objects.Reading.Time, Ntp.Analyzer.Objects.HostIoReading.TimeSinceReset, Ntp.Analyzer.Objects.HostIoReading.UsedReceiveBuffers, and Ntp.Analyzer.Objects.Reading.UtcOffset.

152  {
153  lock (MapperLocker)
154  {
155  try
156  {
157  Open();
158  Command.CommandText = PrepareInsertSql(InsertSql);
159  Command.Parameters.Add(CreateParameter("@time", item.Time));
160  Command.Parameters.Add(CreateParameter("@zone", item.UtcOffset));
161  Command.Parameters.Add(CreateParameter("@hostId", item.Host.Id));
162  Command.Parameters.Add(CreateParameter("@timeSinceReset", item.TimeSinceReset));
163  Command.Parameters.Add(CreateParameter("@receiveBuffers", item.ReceiveBuffers));
164  Command.Parameters.Add(CreateParameter("@freeReceiveBuffers", item.FreeReceiveBuffers));
165  Command.Parameters.Add(CreateParameter("@usedReceiveBuffers", item.UsedReceiveBuffers));
166  Command.Parameters.Add(CreateParameter("@lowWaterRefills", item.LowWaterRefills));
167  Command.Parameters.Add(CreateParameter("@droppedPackets", item.DroppedPackets));
168  Command.Parameters.Add(CreateParameter("@ignoredPackets", item.IgnoredPackets));
169  Command.Parameters.Add(CreateParameter("@receivedPackets", item.ReceivedPackets));
170  Command.Parameters.Add(CreateParameter("@packetsSent", item.PacketsSent));
171  Command.Parameters.Add(CreateParameter("@packetsNotSent", item.PacketsNotSent));
172  Command.Parameters.Add(CreateParameter("@interruptsHandled", item.InterruptsHandled));
173  Command.Parameters.Add(CreateParameter("@receivedByInt", item.ReceivedByInt));
174  Command.Prepare();
175  Log.SqlExecute(Command.CommandText, Command.Parameters);
176  var idObject = Command.ExecuteScalar();
177  item.SetId(Convert.ToInt32(idObject));
178  }
179  catch (Exception e)
180  {
181  Log.InsertError(TableName, e);
182  }
183  finally
184  {
185  Close();
186  }
187  }
188  }
void SetId(int id)
Sets the identifier after the object have been stored in persistent storage.
var e
Definition: bootstrap.min.js:6

Here is the call graph for this function:

override void Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.ReadContent ( )
inlineprotected

Definition at line 190 of file HostIoReadingDatabaseMapper.cs.

References Ntp.Analyzer.Data.Log.LogMessages.DatabaseCacheError.

191  {
192  throw new NotSupportedException(LogMessages.DatabaseCacheError);
193  }
override void Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.Update ( HostIoReading  item)
inlineprotected

Member Data Documentation

override string Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.CreateSql
protected
Initial value:
=> "CREATE TABLE hostIoReading ( " +
" id {0} PRIMARY KEY, " +
" time TIMESTAMP NOT NULL, " +
" zone INT NOT NULL, " +
" hostId INT NOT NULL, " +
" timeSinceReset INT NOT NULL, " +
" receiveBuffers INT NOT NULL, " +
" freeReceiveBuffers INT NOT NULL, " +
" usedReceiveBuffers INT NOT NULL, " +
" lowWaterRefills INT NOT NULL, " +
" droppedPackets BIGINT NOT NULL, " +
" ignoredPackets BIGINT NOT NULL, " +
" receivedPackets BIGINT NOT NULL, " +
" packetsSent BIGINT NOT NULL, " +
" packetsNotSent BIGINT NOT NULL, " +
" interruptsHandled INT NOT NULL, " +
" receivedByInt INT NOT NULL, " +
" FOREIGN KEY (hostId) REFERENCES host(id) " +
"){1};"

Definition at line 69 of file HostIoReadingDatabaseMapper.cs.

readonly HostDatabaseMapper Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.hostMapper
private

Definition at line 63 of file HostIoReadingDatabaseMapper.cs.

const string Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.InsertSql
private
Initial value:
=
"INSERT INTO hostIoReading ( " +
"time, zone, hostId, timeSinceReset, " +
"receiveBuffers, freeReceiveBuffers, usedReceiveBuffers, lowWaterRefills, " +
"droppedPackets, ignoredPackets, receivedPackets, " +
"packetsSent, packetsNotSent, interruptsHandled, receivedByInt ) " +
"VALUES ( " +
"@time, @zone, @hostId, @timeSinceReset, " +
"@receiveBuffers, @freeReceiveBuffers, @usedReceiveBuffers, @lowWaterRefills, " +
"@droppedPackets, @ignoredPackets, @receivedPackets, " +
"@packetsSent, @packetsNotSent, @interruptsHandled, @receivedByInt );{0};"

Definition at line 51 of file HostIoReadingDatabaseMapper.cs.

const string Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.SelectSql
private
Initial value:
=
"SELECT " +
"id, time, zone, hostId, timeSinceReset, " +
"receiveBuffers, freeReceiveBuffers, usedReceiveBuffers, lowWaterRefills, " +
"droppedPackets, ignoredPackets, receivedPackets, " +
"packetsSent, packetsNotSent, interruptsHandled, receivedByInt " +
"FROM hostIoReading"

Definition at line 43 of file HostIoReadingDatabaseMapper.cs.

override string Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.TableName => "hostIoReading"
protected

Definition at line 67 of file HostIoReadingDatabaseMapper.cs.

override bool Ntp.Analyzer.Data.Sql.HostIoReadingDatabaseMapper.UseCache => false
protected

Definition at line 65 of file HostIoReadingDatabaseMapper.cs.


The documentation for this class was generated from the following file: