pva2pva 1.4.2
Loading...
Searching...
No Matches
ServerConfig Struct Reference

Public Types

typedef std::map< std::string, GWServerChannelProvider::shared_pointer > clients_t
typedef std::map< std::string, epics::pvAccess::ServerContext::shared_pointer > servers_t

Public Member Functions

void drop (const char *client, const char *channel)
void status_server (int lvl, const char *server)
void status_client (int lvl, const char *client, const char *channel)

Public Attributes

int debug
bool interactive
epics::pvData::PVStructure::shared_pointer conf
clients_t clients
servers_t servers

Detailed Description

Definition at line 38 of file server.h.

Member Typedef Documentation

◆ clients_t

typedef std::map<std::string, GWServerChannelProvider::shared_pointer> ServerConfig::clients_t

Definition at line 43 of file server.h.

◆ servers_t

typedef std::map<std::string, epics::pvAccess::ServerContext::shared_pointer> ServerConfig::servers_t

Definition at line 46 of file server.h.

Constructor & Destructor Documentation

◆ ServerConfig()

ServerConfig::ServerConfig ( )
inline

Definition at line 49 of file server.h.

49:debug(1), interactive(true) {}

Member Function Documentation

◆ drop()

void ServerConfig::drop ( const char * client,
const char * channel )

Definition at line 102 of file server.cpp.

103{
104 if(!client)
105 client= "";
106 if(!channel)
107 channel = "";
108 // TODO: channel glob match
109
110 FOREACH(clients_t::const_iterator, it, end, clients)
111 {
112 if(client[0]!='\0' && client[0]!='*' && it->first!=client)
113 continue;
114
115 const GWServerChannelProvider::shared_pointer& prov(it->second);
116
117 ChannelCacheEntry::shared_pointer entry;
118
119 // find the channel, if it's there
120 {
121 Guard G(prov->cache.cacheLock);
122
123 ChannelCache::entries_t::iterator it = prov->cache.entries.find(channel);
124 if(it==prov->cache.entries.end())
125 continue;
126
127 std::cout<<"Drop from "<<it->first<<" : "<<it->second->channelName<<"\n";
128
129 entry = it->second;
130 prov->cache.entries.erase(it); // drop out of cache (TODO: not required)
131 }
132
133 // trigger client side disconnect (recursively calls call CRequester::channelStateChange())
134 // TODO: shouldn't need this
135 entry->channel->destroy();
136
137 }
138}

◆ status_client()

void ServerConfig::status_client ( int lvl,
const char * client,
const char * channel )

Definition at line 158 of file server.cpp.

159{
160 if(!client)
161 client= "";
162 if(!channel)
163 channel = "";
164
165 bool iswild = strchr(channel, '?') || strchr(channel, '*');
166
167 FOREACH(clients_t::const_iterator, it, end, clients)
168 {
169 if(client[0]!='\0' && client[0]!='*' && it->first!=client)
170 continue;
171
172 const GWServerChannelProvider::shared_pointer& prov(it->second);
173
174 std::cout<<"==> Client: "<<it->first<<"\n";
175
176 ChannelCache::entries_t entries;
177
178 size_t ncache, ncleaned, ndust;
179 {
180 Guard G(prov->cache.cacheLock);
181
182 ncache = prov->cache.entries.size();
183 ncleaned = prov->cache.cleanerRuns;
184 ndust = prov->cache.cleanerDust;
185
186 if(lvl>0) {
187 if(!iswild) { // no string or some glob pattern
188 entries = prov->cache.entries; // copy of std::map
189 } else { // just one channel
190 ChannelCache::entries_t::iterator it(prov->cache.entries.find(channel));
191 if(it!=prov->cache.entries.end())
192 entries[it->first] = it->second;
193 }
194 }
195 }
196
197 std::cout<<"Cache has "<<ncache<<" channels. Cleaned "
198 <<ncleaned<<" times closing "<<ndust<<" channels\n";
199
200 if(lvl<=0)
201 continue;
202
203 FOREACH(ChannelCache::entries_t::const_iterator, it2, end2, entries)
204 {
205 const std::string& channame = it2->first;
206 if(iswild && !epicsStrGlobMatch(channame.c_str(), channel))
207 continue;
208
209 ChannelCacheEntry& E = *it2->second;
210 ChannelCacheEntry::mon_entries_t::lock_vector_type mons;
211 size_t nsrv, nmon;
212 bool dropflag;
213 const char *chstate;
214 {
215 Guard G(E.mutex());
216 chstate = pva::Channel::ConnectionStateNames[E.channel->getConnectionState()];
217 nsrv = E.interested.size();
218 nmon = E.mon_entries.size();
219 dropflag = E.dropPoke;
220
221 if(lvl>1)
222 mons = E.mon_entries.lock_vector();
223 }
224
225 std::cout<<chstate
226 <<" Client Channel '"<<channame
227 <<"' used by "<<nsrv<<" Server channel(s) with "
228 <<nmon<<" unique subscription(s) "
229 <<(dropflag?'!':'_')<<"\n";
230
231 if(lvl<=1)
232 continue;
233
234 FOREACH(ChannelCacheEntry::mon_entries_t::lock_vector_type::const_iterator, it2, end2, mons) {
235 MonitorCacheEntry& ME = *it2->second;
236
237 MonitorCacheEntry::interested_t::vector_type usrs;
238 size_t nsrvmon;
239#ifdef USE_MSTATS
240 pvd::Monitor::Stats mstats;
241#endif
242 bool hastype, hasdata, isdone;
243 {
244 Guard G(ME.mutex());
245
246 nsrvmon = ME.interested.size();
247 hastype = !!ME.typedesc;
248 hasdata = !!ME.lastelem;
249 isdone = ME.done;
250
251#ifdef USE_MSTATS
252 if(ME.mon)
253 ME.mon->getStats(mstats);
254#endif
255
256 if(lvl>2)
257 usrs = ME.interested.lock_vector();
258 }
259
260 // TODO: how to describe pvRequest in a compact way...
261 std::cout<<" Client Monitor used by "<<nsrvmon<<" Server monitors, "
262 <<"Has "<<(hastype?"":"not ")
263 <<"opened, Has "<<(hasdata?"":"not ")
264 <<"recv'd some data, Has "<<(isdone?"":"not ")<<"finalized\n"
265 " "<< epicsAtomicGetSizeT(&ME.nwakeups)<<" wakeups "
266 <<epicsAtomicGetSizeT(&ME.nevents)<<" events\n";
267#ifdef USE_MSTATS
268 if(mstats.nempty || mstats.nfilled || mstats.noutstanding)
269 std::cout<<" US monitor queue "<<mstats.nfilled
270 <<" filled, "<<mstats.noutstanding
271 <<" outstanding, "<<mstats.nempty<<" empty\n";
272#endif
273 if(lvl<=2)
274 continue;
275
276 FOREACH(MonitorCacheEntry::interested_t::vector_type::const_iterator, it3, end3, usrs) {
277 MonitorUser& MU = **it3;
278
279 size_t nempty, nfilled, nused, total;
280 std::string remote;
281 bool isrunning;
282 {
283 Guard G(MU.mutex());
284
285 nempty = MU.empty.size();
286 nfilled = MU.filled.size();
287 nused = MU.inuse.size();
288 isrunning = MU.running;
289
290 GWChannel::shared_pointer srvchan(MU.srvchan.lock());
291 if(srvchan)
292 remote = srvchan->address;
293 else
294 remote = "<unknown>";
295 }
296 total = nempty + nfilled + nused;
297
298 std::cout<<" Server monitor from "
299 <<remote
300 <<(isrunning?"":" Paused")
301 <<" buffer "<<nfilled<<"/"<<total
302 <<" out "<<nused<<"/"<<total
303 <<" "<<epicsAtomicGetSizeT(&MU.nwakeups)<<" wakeups "
304 <<epicsAtomicGetSizeT(&MU.nevents)<<" events "
305 <<epicsAtomicGetSizeT(&MU.ndropped)<<" drops\n";
306 }
307 }
308
309
310
311 }
312
313
314 std::cout<<"<== Client: "<<it->first<<"\n\n";
315 }
316}
size_t size() const
Definition weakset.h:168
vector_type lock_vector() const
Definition weakset.h:268
lock_vector_type lock_vector() const
Definition weakmap.h:237
size_t size() const
Definition weakmap.h:147
epics::pvData::MonitorElement::shared_pointer lastelem
Definition chancache.h:46

◆ status_server()

void ServerConfig::status_server ( int lvl,
const char * server )

Definition at line 140 of file server.cpp.

141{
142 if(!server)
143 server = "";
144
145 FOREACH(servers_t::const_iterator, it, end, servers)
146 {
147 if(server[0]!='\0' && server[0]!='*' && it->first!=server)
148 continue;
149
150 const pva::ServerContext::shared_pointer& serv(it->second);
151 std::cout<<"==> Server: "<<it->first<<"\n";
152 serv->printInfo(std::cout);
153 std::cout<<"<== Server: "<<it->first<<"\n\n";
154 // TODO: print client list somehow
155 }
156}

Member Data Documentation

◆ clients

clients_t ServerConfig::clients

Definition at line 44 of file server.h.

◆ conf

epics::pvData::PVStructure::shared_pointer ServerConfig::conf

Definition at line 41 of file server.h.

◆ debug

int ServerConfig::debug

Definition at line 39 of file server.h.

◆ interactive

bool ServerConfig::interactive

Definition at line 40 of file server.h.

◆ servers

servers_t ServerConfig::servers

Definition at line 47 of file server.h.


The documentation for this struct was generated from the following files: