Current File : //proc/3/task/3/cwd/proc/2/cwd/usr/lib/python2.7/site-packages/yum/failover.pyc
�
�v_c@sUdZddlZdd d��YZdefd��YZdefd��YZdS(
s/Classes for handling failovers for server URLs.i����NtbaseFailOverMethodcBsJeZdZd�Zdd�Zd�Zdd�Zd�Zd�Z RS( s_A base class to provide a failover to switch to a new server if
the current one fails.
cCs||_d|_dS(Ni(trepotfailures(tselfR((s0/usr/lib/python2.7/site-packages/yum/failover.pyt__init__s cCsdS(s�Return a server URL based on this failover method, or None
if there is a complete failure. This method should always be
used to translate an index into a URL, as this object may
change how indexes map.
:param i: if given, this is the index of the server URL to
return, instead of using the failures counter
:return: the next server URL
N(tNone(Rti((s0/usr/lib/python2.7/site-packages/yum/failover.pyt
get_serverurl"s
cCs|jd|_dS(sONotify the failover method that the current server has
failed.
iN(R(R((s0/usr/lib/python2.7/site-packages/yum/failover.pyt
server_failed.sicCs
||_dS(suReset the failures counter to the given index.
:param i: the index to reset the failures counter to
N(R(RR((s0/usr/lib/python2.7/site-packages/yum/failover.pytreset4scCs|jS(s{Return the current number of failures, which is also the
current index into the list of URLs that this object
represents. :fun:`get_serverurl` should always be used to
translate an index into a URL, as this object may change how
indexes map.
:return: the current number of failures, which is also the
current index
(R(R((s0/usr/lib/python2.7/site-packages/yum/failover.pyt get_index;s
cCst|jj�S(s�Return the total number of URLs available to cycle through
in this object.
:return: the total number of URLs available
(tlenRturls(R((s0/usr/lib/python2.7/site-packages/yum/failover.pyRGsN(
t__name__t
__module__t__doc__RRRRR R
R(((s0/usr/lib/python2.7/site-packages/yum/failover.pyRs tprioritycBseZdZdd�ZRS(s�A class to provide a failover to switch to a new server
if the current one fails. This classes chooses the next server
based on the first success in the list of servers.
cCsH|dkr|j}n|}|t|jj�kr:dS|jj|S(s�Return the next successful server URL in the list, or None
if there is a complete failure. This method should always be
used to translate an index into a URL, as this object may
change how indexes map.
:param i: if given, this is the index of the server URL to
return, instead of using the failures counter
:return: the next server URL
N(RRRRR(RRtindex((s0/usr/lib/python2.7/site-packages/yum/failover.pyRVs
N(R
RRRR(((s0/usr/lib/python2.7/site-packages/yum/failover.pyRQst
roundRobincBs#eZdZd�Zdd�ZRS(sjA class to provide a failover to switch to a new server
if the current one fails. When an object of this class is
created, it selects a random place in the list of URLs to begin
with, then each time :func:`get_serveurl` is called, the next URL
in the list is returned, cycling back to the beginning of the list
after the end is reached.
cCs3tj||�tj�tjdd�|_dS(Nii%(RRtrandomtseedtrandinttoffset(RR((s0/usr/lib/python2.7/site-packages/yum/failover.pyRts
cCse|dkr|j}n|}|t|jj�kr:dS||jt|jj�}|jj|S(s�Return the next successful server URL in the list, using
the round robin scheme, or None if there is a complete
failure. This method should always be used to translate an
index into a URL, as this object may change how indexes map.
:param i: if given, this is the index of the server URL to
return, instead of using the failures counter
:return: the next server URL
N(RRRRRR(RRRtrr((s0/usr/lib/python2.7/site-packages/yum/failover.pyRys
N(R
RRRRR(((s0/usr/lib/python2.7/site-packages/yum/failover.pyRls ((RRRRR(((s0/usr/lib/python2.7/site-packages/yum/failover.pyt<module>s7