NTP Analyzer  0.8.2
Analyze the operation of time servers
HostConfiguration.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 System;
23 using System.Collections.Generic;
28 using Ntp.Analyzer.Config.Table;
29 using Ntp.Analyzer.Import;
30 
31 namespace Ntp.Analyzer.Config.Node
32 {
33  public sealed class HostConfiguration : ConfigurationNode
34  {
36  string configName,
37  int hostId,
38  string serverName,
39  ServerType? serverType,
40  string filePath,
41  Uri webPath,
42  AboutPageConfiguration aboutPage,
43  HostGraphPageConfiguration hostGraphPage,
44  StatConfiguration hostIoStats,
45  StatConfiguration hostStats,
46  MenuConfiguration menu,
47  PeerGraphPageConfiguration peerGraphPage,
48  StatConfiguration peerStats,
49  DriftStatConfiguration driftStats,
50  IEnumerable<HostGraphConfiguration> hostGraphs,
51  IEnumerable<HostPageConfiguration> hostPages,
52  IEnumerable<PeerGraphConfiguration> peerGraphs,
53  IEnumerable<PeerPageConfiguration> peerPages,
54  IEnumerable<PeerSummaryPageConfiguration> peerSummaryPages,
55  IEnumerable<TrafficGraphConfiguration> trafficGraphs
56  )
57  : base(configName)
58  {
59  HostId = hostId;
60  ConfigFilePath = filePath;
61  AboutPage = aboutPage;
62  HostGraphPage = hostGraphPage;
63  HostIoStats = hostIoStats;
64  HostStats = hostStats;
65  Menu = menu;
66  PeerGraphPage = peerGraphPage;
67  PeerStats = peerStats;
68  DriftStats = driftStats;
69  this.serverName = serverName;
70  this.serverType = serverType;
71  this.hostPages = new List<HostPageConfiguration>(hostPages);
72  this.hostGraphs = new List<HostGraphConfiguration>(hostGraphs);
73  this.peerSummaryPages = new List<PeerSummaryPageConfiguration>(peerSummaryPages);
74  this.peerPages = new List<PeerPageConfiguration>(peerPages);
75  this.peerGraphs = new List<PeerGraphConfiguration>(peerGraphs);
76  TrafficGraphs = new List<TrafficGraphConfiguration>(trafficGraphs);
77  this.webPath = webPath;
78  webPathString = webPath?.OriginalString;
79  }
80 
81  private readonly List<HostGraphConfiguration> hostGraphs;
82  private readonly List<HostPageConfiguration> hostPages;
83  private readonly List<PeerGraphConfiguration> peerGraphs;
84  private readonly List<PeerPageConfiguration> peerPages;
85  private readonly List<PeerSummaryPageConfiguration> peerSummaryPages;
86  private readonly string serverName;
87  private readonly ServerType? serverType;
88  private readonly Uri webPath;
89  private readonly string webPathString;
90 
91  [NtpaIndex(1)]
92  [NtpaSetting(Symbol.KeywordHostId)]
93  public int HostId { get; }
94 
95  [NtpaIndex(2)]
96  [NtpaSetting(Symbol.KeywordHostAddress, "localhost")]
97  public string ServerName => serverName ?? "localhost";
98 
99  [NtpaIndex(3)]
100  [NtpaSetting(Symbol.KeywordHostType, ServerType.Ntpq)]
101  public ServerType ServerType => serverType ?? ServerType.Ntpq;
102 
103  [NtpaIndex(10)]
104  [NtpaSetting(Symbol.KeywordFilePath, Layout = Layout.Quoted)]
105  public string ConfigFilePath { get; }
106 
112  public override string FilePath => ConfigFilePath;
113 
114  [NtpaIndex(11)]
115  [NtpaSetting(Symbol.KeywordWebPath, "/")]
116  public string ConfigWebPath => webPathString ?? "/";
117 
118  public Uri WebPath => webPath ?? new Uri("/", UriKind.Relative);
119 
120  [NtpaIndex(20)]
121  [NtpaSetting(Symbol.KeywordHostStats)]
122  public StatConfiguration HostStats { get; }
123 
124  [NtpaIndex(21)]
125  [NtpaSetting(Symbol.KeywordHostIoStats)]
126  public StatConfiguration HostIoStats { get; }
127 
128  [NtpaIndex(22)]
129  [NtpaSetting(Symbol.KeywordPeerStats)]
130  public StatConfiguration PeerStats { get; }
131 
132  [NtpaIndex(23)]
133  [NtpaSetting(Symbol.KeywordDriftStats)]
134  public DriftStatConfiguration DriftStats { get; }
135 
136  [NtpaIndex(30)]
137  [NtpaSetting(Symbol.KeywordMenu)]
138  public MenuConfiguration Menu { get; }
139 
140  [NtpaIndex(40)]
141  [NtpaSetting(Symbol.KeywordAboutPage)]
142  public AboutPageConfiguration AboutPage { get; }
143 
144  [NtpaIndex(50)]
145  [NtpaSettingsCollection(Symbol.KeywordHostPage)]
146  public IEnumerable<HostPageConfiguration> HostPages => hostPages;
147 
148  [NtpaIndex(51)]
149  [NtpaSetting(Symbol.KeywordHostGraphPage)]
150  public HostGraphPageConfiguration HostGraphPage { get; }
151 
152  [NtpaIndex(60)]
153  [NtpaSettingsCollection(Symbol.KeywordPeerPage)]
154  public IEnumerable<PeerPageConfiguration> PeerPages => peerPages;
155 
156  [NtpaIndex(61)]
157  [NtpaSettingsCollection(Symbol.KeywordPeerSummaryPage)]
158  public IEnumerable<PeerSummaryPageConfiguration> PeerSummaryPages => peerSummaryPages;
159 
160  [NtpaIndex(62)]
161  [NtpaSetting(Symbol.KeywordPeerGraphPage)]
162  public PeerGraphPageConfiguration PeerGraphPage { get; }
163 
164  [NtpaIndex(70)]
165  [NtpaSettingsCollection(Symbol.KeywordHostGraph)]
166  public IEnumerable<HostGraphConfiguration> HostGraphs => hostGraphs;
167 
168  [NtpaIndex(72)]
169  [NtpaSettingsCollection(Symbol.KeywordTrafficGraph)]
170  public List<TrafficGraphConfiguration> TrafficGraphs { get; }
171 
172  [NtpaIndex(71)]
173  [NtpaSettingsCollection(Symbol.KeywordPeerGraph)]
174  public IEnumerable<PeerGraphConfiguration> PeerGraphs => peerGraphs;
175  }
176 }
readonly List< PeerSummaryPageConfiguration > peerSummaryPages
readonly List< PeerGraphConfiguration > peerGraphs
readonly List< HostGraphConfiguration > hostGraphs
readonly List< HostPageConfiguration > hostPages
readonly List< PeerPageConfiguration > peerPages
HostConfiguration(string configName, int hostId, string serverName, ServerType?serverType, string filePath, Uri webPath, AboutPageConfiguration aboutPage, HostGraphPageConfiguration hostGraphPage, StatConfiguration hostIoStats, StatConfiguration hostStats, MenuConfiguration menu, PeerGraphPageConfiguration peerGraphPage, StatConfiguration peerStats, DriftStatConfiguration driftStats, IEnumerable< HostGraphConfiguration > hostGraphs, IEnumerable< HostPageConfiguration > hostPages, IEnumerable< PeerGraphConfiguration > peerGraphs, IEnumerable< PeerPageConfiguration > peerPages, IEnumerable< PeerSummaryPageConfiguration > peerSummaryPages, IEnumerable< TrafficGraphConfiguration > trafficGraphs)