XRootD
XrdXrootdGSReal.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDGSREAL_HH_
2 #define __XRDXROOTDGSREAL_HH_
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d G S R e a l . h h */
6 /* */
7 /* (c) 2019 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 "Xrd/XrdJob.hh"
34 #include "XrdSys/XrdSysPthread.hh"
38 
39 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
44 
45 class XrdNetMsg;
46 class XrdSysError;
47 
48 class XrdXrootdGSReal : public XrdJob, public XrdXrootdGStream,
50 {
51 public:
52 
53 void DoIt(); // XrdJob override
54 
55 void Flush();
56 
57 uint32_t GetDictID(const char *text, bool isPath=false);
58 
59 bool HasHdr();
60 
61 void Ident();
62 
63 bool Insert(const char *data, int dlen);
64 
65 bool Insert(int dlen);
66 
67 char *Reserve(int dlen);
68 
69 int SetAutoFlush(int afsec);
70 
71 int GetAutoFlush();
72 
73 int Space();
74 
75 //-----------------------------------------------------------------------------
81 //-----------------------------------------------------------------------------
82 
83  static const int fmtNone = 0;
84  static const int fmtBin = 1;
85  static const int fmtCgi = 2;
86  static const int fmtJson = 3;
87 
88  static const int hdrNone = 0;
89  static const int hdrNorm = 1;
90  static const int hdrSite = 2;
91  static const int hdrHost = 3;
92  static const int hdrInst = 4;
93  static const int hdrFull = 5;
94 
95  static const int optNoID = 0x01;
96 
97  struct GSParms {const char *pin;
98  const char *dest;
99  int Mode;
100  int maxL;
101  int flsT;
103  char Opt;
104  char Fmt;
105  char Hdr;
106  };
107 
108  XrdXrootdGSReal(const GSParms &gsParms, bool &aOK);
109 
110 //-----------------------------------------------------------------------------
112 //-----------------------------------------------------------------------------
113 
115 
116 private:
117 
118 
119 void AutoFlush();
120 void Expel(int dlen);
121 int hdrBIN(const GSParms &gs);
122 int hdrCGI(const GSParms &gs, char *buff, int blen);
123 int hdrJSN(const GSParms &gs, char *buff, int blen);
124 
125 struct HdrInfo
126  {char *pseq;
127  char *tbeg;
128  char *tend;
129  } hInfo;
130 
131 char *dictHdr;
132 char *idntHdr0;
133 char *idntHdr1;
134 int idntHsz1;
135 int pSeq;
136 int pSeqID; // For ident records
137 int pSeqDID; // For dict records
138 XrdSysRecMutex gMutex;
139 XrdNetMsg *udpDest;
140 XrdXrootdMonGS *binHdr;
141 char *udpBuffer;
142 char *udpBFirst;
143 char *udpBNext;
144 char *udpBEnd;
145 int tBeg;
146 int tEnd;
147 int rsvbytes;
148 int monType;
149 int afTime;
150 bool afRunning;
151 bool isCGI;
152 
154 };
155 #endif
unsigned char kXR_char
Definition: XPtypes.hh:65
Definition: XrdJob.hh:43
uint32_t GetDictID(const char *text, bool isPath=false)
char * Reserve(int dlen)
static const int hdrNone
Format as JSON info.
kXR_char Type
the specific G-Stream identifier
const char * dest
Destination for records.
static const int hdrInst
Include site, host, port, inst.
~XrdXrootdGSReal()
Destructor. Normally, this object is never deleted.
int SetAutoFlush(int afsec)
static const int fmtBin
Do not include info.
XrdXrootdGSReal(const GSParms &gsParms, bool &aOK)
static const int fmtJson
Format as CGI info.
int maxL
Maximum packet length (default 32K)
static const int hdrSite
Include site.
int flsT
Flush time (default from monitor)
const char * pin
the plugin name.
static const int hdrHost
Include site, host.
char Fmt
How to handle the records.
static const int optNoID
Don't send ident records.
bool Insert(const char *data, int dlen)
int Mode
the monitor type for send routing.
static const int hdrNorm
Include standard header.
static const int fmtNone
static const int fmtCgi
Format as binary info.
static const int hdrFull
Include site, host, port, inst, pgm.