XRootD
Loading...
Searching...
No Matches
XrdCmsSupervisor.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d C m s S u p e r v i s o r . c c */
4/* */
5/* */
6/* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University */
7/* All Rights Reserved */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include "Xrd/XrdInet.hh"
33#include "Xrd/XrdLink.hh"
34
38#include "XrdCms/XrdCmsTrace.hh"
39
41
42#include "XrdSys/XrdSysError.hh"
43
44using namespace XrdCms;
45
46/******************************************************************************/
47/* G l o b a l s */
48/******************************************************************************/
49
51
52XrdInet *XrdCmsSupervisor::NetTCPr = 0;
53
54/******************************************************************************/
55/* I n i t */
56/******************************************************************************/
57
58int XrdCmsSupervisor::Init(const char *AdminPath, int AdminMode)
59{
60 char spbuff[1024];
61
62// Create the supervisor unix domain socket. We use this for the redirector
63// assigned to this supervisor node (one one redirector allowed)
64//
65 if (!XrdNetSocket::socketPath(&Say, spbuff, AdminPath,
66 "olbd.super", AdminMode | S_IFSOCK)) return 1;
67
68// Create a new network suitable for use with XrdLink objects
69//
70 if (!(NetTCPr = new XrdInet(&Say)))
71 {Say.Emsg("Supervisor","Unable to create supervisor interface.");
72 return 0;
73 }
74
75// Set out domain name for this network
76//
78
79// Bind the unix domain path to the network
80//
81 if (NetTCPr->Bind(spbuff, "tcp")) return 0;
82
83// We need to force the minimum number of subscribers to be one and never a
84// percentage, regardless of what was specified in the config file. This is
85// because supervisors may loose their subscribers in unusual ways. We also
86// set the drop delay to zero to immediately drop servers from the config to
87// avoid stalling clients at a supervisor node.
88//
89 Config.SUPCount = 1;
90 Config.SUPLevel = 0;
91 Config.DRPDelay = 0;
92
93// All done
94//
95 superOK = 1;
96 return 1;
97}
98
99/******************************************************************************/
100/* S t a r t */
101/******************************************************************************/
102
104{
105 XrdCmsProtocol *pP;
106 XrdLink *lP;
107
108// Accept single connections and dispatch the supervisor data interface
109//
110 while(1)
111 if ((lP = NetTCPr->Accept(XRDNET_NODNTRIM)))
112 {if ((pP = XrdCmsProtocol::Alloc("redirector")))
113 {lP->setProtocol((XrdProtocol *)pP);
114 pP->Process(lP);
115 lP->Close();
116 }
117 }
118}
#define XRDNET_NODNTRIM
Definition XrdNetOpts.hh:51
const char * myDomain
static XrdCmsProtocol * Alloc(const char *theRole="", XrdCmsManager *mP=0, const char *theMan=0, int thePort=0)
static int Init(const char *AdminPath, int AdminMode)
XrdLink * Accept(int opts=0, int timeout=-1, XrdSysSemaphore *theSem=0)
Definition XrdInet.cc:72
static char * socketPath(XrdSysError *Say, char *inbuff, const char *path, const char *fn, mode_t mode)
int Bind(int port, const char *contype="tcp")
Definition XrdNet.cc:164
void setDomain(const char *dname)
Definition XrdNet.hh:233
virtual int Process(XrdLink *lp)=0
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysError Say
XrdCmsConfig Config