NTP Analyzer  0.8.2
Analyze the operation of time servers
ImportFactory.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using Ntp.Analyzer.Objects;
23 using Ntp.Common.Log;
24 
25 namespace Ntp.Analyzer.Import
26 {
27  public static class ImportFactory
28  {
30  string file,
31  ServerType type,
32  Host host,
33  ReadingBulk bulk,
34  LogBase log)
35  {
36  return new DriftFileImporter(host, file, bulk, log);
37  }
38 
40  string address,
41  ServerType type,
42  Host host,
43  ReadingBulk bulk,
44  LogBase log)
45  {
46  switch (type)
47  {
48  case ServerType.Ntpdc:
49  return new NtpdcImporter(address, host, bulk, log);
50  case ServerType.Ntpq:
51  return new NtpqHostImporter(address, host, bulk, log);
52  case ServerType.Ntpctl:
53  return new NtpctlHostImporter(host, bulk, log);
54  default:
55  return null;
56  }
57  }
58 
60  string address,
61  ServerType type,
62  LogBase log)
63  {
64  return new IoStatsImporter(address, type == ServerType.Ntpq, log);
65  }
66 
68  string address,
69  ServerType type,
70  Host host,
71  LogBase log)
72  {
73  switch (type)
74  {
75  case ServerType.Ntpdc:
76  case ServerType.Ntpq:
77  return new NtpqPeerImporter(address, host.Id, log);
78  case ServerType.Ntpctl:
79  return new NtpctlPeerImporter(host.Id, log);
80  default:
81  return null;
82  }
83  }
84  }
85 }
Ntpq mapper parses status importLines from ntpq into objects.
static Importer< HostReading > CreateHostImporter(string address, ServerType type, Host host, ReadingBulk bulk, LogBase log)
static Importer< AssociationEntry > CreatePeerImporter(string address, ServerType type, Host host, LogBase log)
static Importer< IoStatsEntry > CreateIoImporter(string address, ServerType type, LogBase log)
static DriftFileImporter CreateDriftImporter(string file, ServerType type, Host host, ReadingBulk bulk, LogBase log)