XRootD
Loading...
Searching...
No Matches
XrdSsiScale Class Reference

#include <XrdSsiScale.hh>

Collaboration diagram for XrdSsiScale:

Public Member Functions

 XrdSsiScale ()
 ~XrdSsiScale ()
int getEnt ()
void retEnt (int xEnt)
bool rsvEnt (int xEnt)
void setSpread (short sval)

Static Public Attributes

static const uint16_t defSprd = 4
static const uint16_t maxPend = 64000
static const uint16_t maxSprd = 1024
static const uint16_t maxTune = 128
static const uint16_t midTune = 64
static const uint16_t minTune = 3
static const uint16_t zipTune = 512

Detailed Description

Definition at line 37 of file XrdSsiScale.hh.

Constructor & Destructor Documentation

◆ XrdSsiScale()

XrdSsiScale::XrdSsiScale ( )
inline

Definition at line 57 of file XrdSsiScale.hh.

57 : Active(0), reActive(0), begEnt(0), nowEnt(0),
58 curSpread(defSprd), autoTune(false), needTune(false)
59 {memset(pendCnt, 0, sizeof(uint16_t)*maxSprd);}
static const uint16_t maxSprd
static const uint16_t defSprd

References defSprd, and maxSprd.

◆ ~XrdSsiScale()

XrdSsiScale::~XrdSsiScale ( )
inline

Definition at line 61 of file XrdSsiScale.hh.

61{}

Member Function Documentation

◆ getEnt()

int XrdSsiScale::getEnt ( )

Definition at line 50 of file XrdSsiScale.cc.

51{
52 static const int tuneMLen = 80;
53 char tuneMsg[tuneMLen]; *tuneMsg = 0;
54
55// We assign channel in a round-robbin fashion. This can be across all
56// channels or only the subset that was recently added due to tuning. Note
57// that we apply tuning only if we are working in the partitioned channels
58// as the non-partitioned channels should no longer be getting requests.
59//
60 entMutex.Lock();
61 uint16_t endEnt = curSpread;
62 do {for (uint16_t i = nowEnt; i < endEnt; i++)
63 {if (pendCnt[i] < maxPend)
64 {pendCnt[i]++;
65 nowEnt = i+1;
66 if (!begEnt || i < begEnt) Active++;
67 else reActive++;
68 entMutex.UnLock();
69 if (*tuneMsg) Log.Emsg("Scale", tuneMsg);
70 return int(i);
71 }
72 }
73
74 // If we did a whole round and cannot autotune up, then we have failed.
75 // If we didn't do the whole round or did tune, try again.
76 //
77 if (nowEnt == begEnt)
78 {if (!autoTune || !Tune(tuneMsg, tuneMLen)) break;
79 endEnt = curSpread;
80 } else endEnt = nowEnt;
81 nowEnt = begEnt;
82 } while(true);
83
84// We have no more stream resources left.
85//
86 entMutex.UnLock();
87 if (*tuneMsg) Log.Emsg("Scale", tuneMsg);
88 return -1;
89}
static const uint16_t maxPend
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysError Log

References XrdSsi::Log, and maxPend.

◆ retEnt()

void XrdSsiScale::retEnt ( int xEnt)

Definition at line 95 of file XrdSsiScale.cc.

96{
97
98// Perform action only if the specified channel is valid. Retune the channels
99// if necessary.
100//
101 if (xEnt >= 0 && xEnt < int(maxSprd))
102 {entMutex.Lock();
103 if (pendCnt[xEnt])
104 {pendCnt[xEnt]--;
105 if (!begEnt || xEnt < (int)begEnt)
106 {if (Active) Active--;
107 if (begEnt && needTune && Active <= (reActive + (reActive>>1)))
108 {Retune(); // Unlocks the entMutex!
109 return;
110 }
111 } else if (reActive) reActive--;
112 }
113 }
114
115// Unlock the mutex as we are done.
116//
117 entMutex.UnLock();
118}

References maxSprd.

◆ rsvEnt()

bool XrdSsiScale::rsvEnt ( int xEnt)

Definition at line 154 of file XrdSsiScale.cc.

155{
156
157// If the channel number is within range see if we can reserve a slot.
158//
159 if (xEnt >= 0 && xEnt < int(maxSprd))
160 {entMutex.Lock();
161 if (pendCnt[xEnt] < maxPend)
162 {pendCnt[xEnt]++;
163 entMutex.UnLock();
164 return true;
165 }
166 entMutex.UnLock();
167 }
168 return false;
169}

References maxPend, and maxSprd.

◆ setSpread()

void XrdSsiScale::setSpread ( short sval)

Definition at line 175 of file XrdSsiScale.cc.

176{
177 entMutex.Lock();
178
179 if (sval <= 0)
180 {autoTune = true;
181 if (sval < 0) sval = -sval;
182 } else {
183 autoTune = needTune = false;
184 begEnt = 0;
185 }
186
187 if (sval)
188 {uint16_t newSpread;
189 if (sval < short(maxSprd)) newSpread = static_cast<uint16_t>(sval);
190 else newSpread = maxSprd;
191 if (autoTune && newSpread < curSpread)
192 {needTune = false;
193 begEnt = 0;
194 }
195 curSpread = newSpread;
196 }
197
198 entMutex.UnLock();
199}

References maxSprd.

Member Data Documentation

◆ defSprd

const uint16_t XrdSsiScale::defSprd = 4
static

Definition at line 41 of file XrdSsiScale.hh.

Referenced by XrdSsiScale().

◆ maxPend

const uint16_t XrdSsiScale::maxPend = 64000
static

Definition at line 43 of file XrdSsiScale.hh.

Referenced by getEnt(), and rsvEnt().

◆ maxSprd

const uint16_t XrdSsiScale::maxSprd = 1024
static

Definition at line 42 of file XrdSsiScale.hh.

Referenced by XrdSsiScale(), retEnt(), rsvEnt(), and setSpread().

◆ maxTune

const uint16_t XrdSsiScale::maxTune = 128
static

Definition at line 46 of file XrdSsiScale.hh.

◆ midTune

const uint16_t XrdSsiScale::midTune = 64
static

Definition at line 45 of file XrdSsiScale.hh.

◆ minTune

const uint16_t XrdSsiScale::minTune = 3
static

Definition at line 44 of file XrdSsiScale.hh.

◆ zipTune

const uint16_t XrdSsiScale::zipTune = 512
static

Definition at line 47 of file XrdSsiScale.hh.


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