Exemple #1
0
    def initialize(self):
        """
    Flags useESForJobParametersFlag (in /Operations/[]/Services/JobMonitoring/) have bool value (True/False)
    and determines the switching of backends from MySQL to ElasticSearch for the JobParameters DB table.
    For version v7r0, the MySQL backend is (still) the default.
    """

        credDict = self.getRemoteCredentials()
        self.ownerDN = credDict['DN']
        self.ownerGroup = credDict['group']
        operations = Operations(group=self.ownerGroup)
        self.globalJobsInfo = operations.getValue(
            '/Services/JobMonitoring/GlobalJobsInfo', True)
        self.jobPolicy = JobPolicy(self.ownerDN, self.ownerGroup,
                                   self.globalJobsInfo)
        self.jobPolicy.jobDB = gJobDB

        useESForJobParametersFlag = operations.getValue(
            '/Services/JobMonitoring/useESForJobParametersFlag', False)
        global gElasticJobDB
        if useESForJobParametersFlag:
            gElasticJobDB = ElasticJobDB()
            self.log.verbose("Using ElasticSearch for JobParameters")

        return S_OK()
Exemple #2
0
  def initialize(self):
    """
    Flags gESFlag and gMySQLFlag have bool values (True/False)
    derived from dirac.cfg configuration file

    Determines the switching of ElasticSearch and MySQL backends
    """
    global gElasticJobDB, gJobDB

    gESFlag = self.srv_getCSOption('useES', False)
    if gESFlag:
      gElasticJobDB = ElasticJobDB()

    gMySQLFlag = self.srv_getCSOption('useMySQL', True)
    if not gMySQLFlag:
      gJobDB = False

    credDict = self.getRemoteCredentials()
    self.ownerDN = credDict['DN']
    self.ownerGroup = credDict['group']
    operations = Operations(group=self.ownerGroup)
    self.globalJobsInfo = operations.getValue('/Services/JobMonitoring/GlobalJobsInfo', True)
    self.jobPolicy = JobPolicy(self.ownerDN, self.ownerGroup, self.globalJobsInfo)
    self.jobPolicy.jobDB = gJobDB

    return S_OK()
Exemple #3
0
class Transaction(object):
    def __init__(self):

        self.ElasticJobDB = ElasticJobDB()
        self.custom_timers = {}

    def run(self):

        start_time = time.time()

        for i in xrange(0, random.randint(1000, 3000)):

            key = random_generator()
            value = random_generator(size=12)
            self.ElasticJobDB.setJobParameter(2, key, value)

        end_time = time.time()

        self.custom_timers['Execution_Time'] = end_time - start_time
Exemple #4
0
  def initialize(self):
    """
    Flags gESFlag and gMySQLFlag have bool values (True/False)
    derived from dirac.cfg configuration file

    Determines the switching of ElasticSearch and MySQL backends
    """
    global elasticJobDB

    useESForJobParametersFlag = Operations().getValue('/Services/JobMonitoring/useESForJobParametersFlag', False)
    if useESForJobParametersFlag:
      elasticJobDB = ElasticJobDB()
      self.log.verbose("Using ElasticSearch for JobParameters")

    return S_OK()
Exemple #5
0
    def initialize(self):
        """
    Flags gESFlag and gMySQLFlag have bool values (True/False)
    derived from dirac.cfg configuration file

    Determines the switching of ElasticSearch and MySQL backends
    """
        global elasticJobDB, jobDB

        gESFlag = self.srv_getCSOption('useES', False)
        if gESFlag:
            elasticJobDB = ElasticJobDB()

        gMySQLFlag = self.srv_getCSOption('useMySQL', True)
        if not gMySQLFlag:
            jobDB = False

        return S_OK()
Exemple #6
0
    def __init__(self):

        self.ElasticJobDB = ElasticJobDB()
        self.custom_timers = {}
Exemple #7
0
""" This tests only need the JobElasticDB, and connects directly to it
"""

import time

from DIRAC.Core.Base.Script import parseCommandLine
parseCommandLine()

from DIRAC import gLogger
from DIRAC.WorkloadManagementSystem.DB.ElasticJobDB import ElasticJobDB

#  Add a time delay to allow updating the modified index before querying it.
SLEEP_DELAY = 2

gLogger.setLevel('DEBUG')
elasticJobDB = ElasticJobDB()


def test_setAndGetJobFromDB():
    res = elasticJobDB.setJobParameter(100, 'DIRAC', 'dirac@cern')
    assert res['OK']
    time.sleep(SLEEP_DELAY)

    res = elasticJobDB.getJobParameters(100)
    assert res['OK']
    assert res['Value'][100]['DIRAC'] == 'dirac@cern'

    # update it
    res = elasticJobDB.setJobParameter(100, 'DIRAC', '*****@*****.**')
    assert res['OK']
    time.sleep(SLEEP_DELAY)
Exemple #8
0
 def setUp(self):
     gLogger.setLevel('DEBUG')
     self.jobDB = ElasticJobDB()