xrootd
Loading...
Searching...
No Matches
XrdCmsRole.hh
Go to the documentation of this file.
1#ifndef __XRDCMSROLE_HH__
2#define __XRDCMSROLE_HH__
3/******************************************************************************/
4/* */
5/* X r d C m s R o l e . h h */
6/* */
7/* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* All Rights Reserved */
9/* Produced by Andrew Hanushevsky for Stanford University under contract */
10/* DE-AC02-76-SFO0515 with the Department of Energy */
11/* */
12/* This file is part of the XRootD software suite. */
13/* */
14/* XRootD is free software: you can redistribute it and/or modify it under */
15/* the terms of the GNU Lesser General Public License as published by the */
16/* Free Software Foundation, either version 3 of the License, or (at your */
17/* option) any later version. */
18/* */
19/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22/* License for more details. */
23/* */
24/* You should have received a copy of the GNU Lesser General Public License */
25/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27/* */
28/* The copyright holder's institutional names and contributor's names may not */
29/* be used to endorse or promote products derived from this software without */
30/* specific prior written permission of the institution or contributor. */
31/******************************************************************************/
32
33#include <cstring>
34
35// This class centralizes the naming of various roles servers can have.
36
38{
39public:
40
45 };
46
47static RoleID Convert(const char *Tok1, const char *Tok2)
48 {if (!Tok2)
49 {if (!strcmp( Tok1, "server")) return Server;
50 if (!strcmp( Tok1, "supervisor")) return Supervisor;
51 return (strcmp(Tok1, "manager") ? noRole:Manager);
52 }
53 if (!strcmp( Tok1, "proxy"))
54 {if (!strcmp( Tok2, "server")) return ProxyServer;
55 if (!strcmp( Tok2, "supervisor")) return ProxySuper;
56 return (strcmp(Tok2, "manager") ? noRole:ProxyManager);
57 }
58 if (!strcmp( Tok1, "meta"))
59 return (strcmp(Tok2, "manager") ? noRole:MetaManager);
60 return noRole;
61 }
62
63static const char *Name(RoleID rid)
64 {static const char *rName[] = {"meta manager", // MetaMan
65 "manager", // Manager
66 "supervisor", // Super
67 "server", // Server
68 "proxy manager", // ProxyMan
69 "proxy supervisor",
70 "proxy server", // ProxyServ
71 "peer manager", // PeerMan
72 "peer" // Peer
73 };
74 if (rid >= MetaManager && rid < noRole) return rName[rid];
75 return "??";
76 }
77
78static const char *Type(RoleID rid) // Maximum of 3 characters plus null byte!
79 {static const char *tName[] = {"MM", // MetaMan
80 "M", // Manager
81 "R", // Super
82 "S", // Server
83 "PM", // ProxyMan
84 "PR", // ProxySuper
85 "PS", // ProxyServ
86 "EM", // PeerMan
87 "E" // Peer
88 };
89 if (rid >= MetaManager && rid < noRole) return tName[rid];
90 return "??";
91 }
92
93static const char *Type(const char *rtype)
94 {if (*rtype == 'M') return "manager";
95 if (*rtype == 'R') return "supervisor";
96 if (*rtype == 'S') return "server";
97 if (*rtype == 'P') return "proxy";
98 if (*rtype == 'E') return "peer";
99 return "";
100 }
101
104};
105#endif
Definition XrdCmsRole.hh:38
static const char * Name(RoleID rid)
Definition XrdCmsRole.hh:63
RoleID
Definition XrdCmsRole.hh:41
@ ProxyServer
Definition XrdCmsRole.hh:43
@ Peer
Definition XrdCmsRole.hh:44
@ ProxyManager
Definition XrdCmsRole.hh:43
@ PeerManager
Definition XrdCmsRole.hh:44
@ Server
Definition XrdCmsRole.hh:42
@ noRole
Definition XrdCmsRole.hh:44
@ Manager
Definition XrdCmsRole.hh:42
@ MetaManager
Definition XrdCmsRole.hh:41
@ ProxySuper
Definition XrdCmsRole.hh:43
@ Supervisor
Definition XrdCmsRole.hh:42
static const char * Type(RoleID rid)
Definition XrdCmsRole.hh:78
static RoleID Convert(const char *Tok1, const char *Tok2)
Definition XrdCmsRole.hh:47
~XrdCmsRole()
Definition XrdCmsRole.hh:103
XrdCmsRole()
Definition XrdCmsRole.hh:102
static const char * Type(const char *rtype)
Definition XrdCmsRole.hh:93