HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
dc_crawler.DBProxyWrapper.DBProxyWrapper Class Reference
Inheritance diagram for dc_crawler.DBProxyWrapper.DBProxyWrapper:
Collaboration diagram for dc_crawler.DBProxyWrapper.DBProxyWrapper:

Public Member Functions

def __init__ (self, dbWrapper)
 
def getEnaibledProxies (self, siteId=DEFAULT_SITE_ID_VALUE, limitValue=DEFAULT_LIMIT_VALUE)
 
def addFaults (self, proxyName, incrementSize=1)
 

Public Attributes

 dbWrapper
 

Static Public Attributes

int DEFAULT_LIMIT_VALUE = 50
 
string DEFAULT_SITE_ID_VALUE = '*'
 
int PROXY_STATE_DISABLED = 0
 
int PROXY_STATE_ENABLED = 1
 
string TEMPLATE_WHERE_SELECT = "`State` = %s AND (`Site_Id` = '%s' OR `Site_Id` = '%s')"
 
string TEMPLATE_ORDER_SELECT = "`Priority`"
 
string PROXY_UPDATE_FAULTS_QUERY = "UPDATE `sites_proxy` SET `Faults`=`Faults` + %s WHERE `Host` = '%s'"
 
string PROXY_DISABLE_QUERY
 
string PROXY_DB_NAME = "dc_sites"
 

Detailed Description

Definition at line 23 of file DBProxyWrapper.py.

Constructor & Destructor Documentation

◆ __init__()

def dc_crawler.DBProxyWrapper.DBProxyWrapper.__init__ (   self,
  dbWrapper 
)

Definition at line 45 of file DBProxyWrapper.py.

45  def __init__(self, dbWrapper):
46  self.dbWrapper = dbWrapper
47 
48 
def __init__(self)
constructor
Definition: UIDGenerator.py:19

Member Function Documentation

◆ addFaults()

def dc_crawler.DBProxyWrapper.DBProxyWrapper.addFaults (   self,
  proxyName,
  incrementSize = 1 
)

Definition at line 79 of file DBProxyWrapper.py.

79  def addFaults(self, proxyName, incrementSize=1):
80  if proxyName is not None:
81  affectDB = self.dbWrapper.affect_db
82  self.dbWrapper.affect_db = True
83 
84  # increment faults counter
85  query = self.PROXY_UPDATE_FAULTS_QUERY % (incrementSize, proxyName)
86  self.dbWrapper.customRequest(query, self.PROXY_DB_NAME, dbi.EventObjects.CustomRequest.SQL_BY_NAME)
87 
88  # disable proxy if necessary (overlimits max allowed value)
89  query = self.PROXY_DISABLE_QUERY % (self.PROXY_STATE_DISABLED, proxyName)
90  self.dbWrapper.customRequest(query, self.PROXY_DB_NAME, dbi.EventObjects.CustomRequest.SQL_BY_NAME)
91 
92  self.dbWrapper.affect_db = affectDB
93 

◆ getEnaibledProxies()

def dc_crawler.DBProxyWrapper.DBProxyWrapper.getEnaibledProxies (   self,
  siteId = DEFAULT_SITE_ID_VALUE,
  limitValue = DEFAULT_LIMIT_VALUE 
)

Definition at line 54 of file DBProxyWrapper.py.

54  def getEnaibledProxies(self, siteId=DEFAULT_SITE_ID_VALUE, limitValue=DEFAULT_LIMIT_VALUE):
55  # variable for result
56  ret = None
57 
58  criterions = {}
59  criterions[app.SQLCriterions.CRITERION_WHERE] = self.TEMPLATE_WHERE_SELECT % \
60  (self.PROXY_STATE_ENABLED, str(siteId), self.DEFAULT_SITE_ID_VALUE)
61  criterions[app.SQLCriterions.CRITERION_LIMIT] = str(limitValue)
62  criterions[app.SQLCriterions.CRITERION_ORDER] = self.TEMPLATE_ORDER_SELECT
63 
64  proxyStatus = ProxyStatus(siteId=siteId, host=None, criterions=criterions)
65  affectDB = self.dbWrapper.affect_db
66  self.dbWrapper.affect_db = True
67  ret = self.dbWrapper.proxyStatus(proxyStatus)
68  self.dbWrapper.affect_db = affectDB
69 
70  return ret
71 
72 

Member Data Documentation

◆ dbWrapper

dc_crawler.DBProxyWrapper.DBProxyWrapper.dbWrapper

Definition at line 46 of file DBProxyWrapper.py.

◆ DEFAULT_LIMIT_VALUE

int dc_crawler.DBProxyWrapper.DBProxyWrapper.DEFAULT_LIMIT_VALUE = 50
static

Definition at line 26 of file DBProxyWrapper.py.

◆ DEFAULT_SITE_ID_VALUE

string dc_crawler.DBProxyWrapper.DBProxyWrapper.DEFAULT_SITE_ID_VALUE = '*'
static

Definition at line 27 of file DBProxyWrapper.py.

◆ PROXY_DB_NAME

string dc_crawler.DBProxyWrapper.DBProxyWrapper.PROXY_DB_NAME = "dc_sites"
static

Definition at line 40 of file DBProxyWrapper.py.

◆ PROXY_DISABLE_QUERY

string dc_crawler.DBProxyWrapper.DBProxyWrapper.PROXY_DISABLE_QUERY
static
Initial value:
= "UPDATE `sites_proxy` SET `State`= '%s' WHERE `Host` = '%s' AND `FaultsMax` <> '0' \
AND `Faults` >= `FaultsMax`"

Definition at line 37 of file DBProxyWrapper.py.

◆ PROXY_STATE_DISABLED

int dc_crawler.DBProxyWrapper.DBProxyWrapper.PROXY_STATE_DISABLED = 0
static

Definition at line 29 of file DBProxyWrapper.py.

◆ PROXY_STATE_ENABLED

int dc_crawler.DBProxyWrapper.DBProxyWrapper.PROXY_STATE_ENABLED = 1
static

Definition at line 30 of file DBProxyWrapper.py.

◆ PROXY_UPDATE_FAULTS_QUERY

string dc_crawler.DBProxyWrapper.DBProxyWrapper.PROXY_UPDATE_FAULTS_QUERY = "UPDATE `sites_proxy` SET `Faults`=`Faults` + %s WHERE `Host` = '%s'"
static

Definition at line 36 of file DBProxyWrapper.py.

◆ TEMPLATE_ORDER_SELECT

string dc_crawler.DBProxyWrapper.DBProxyWrapper.TEMPLATE_ORDER_SELECT = "`Priority`"
static

Definition at line 34 of file DBProxyWrapper.py.

◆ TEMPLATE_WHERE_SELECT

string dc_crawler.DBProxyWrapper.DBProxyWrapper.TEMPLATE_WHERE_SELECT = "`State` = %s AND (`Site_Id` = '%s' OR `Site_Id` = '%s')"
static

Definition at line 33 of file DBProxyWrapper.py.


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