Beispiel #1
0
    def __init__(self, config):
        TransactionHistoryInterface.__init__(self, config)

        self._mysql = MySQL(config.db_params)
        self._cache_db = MySQL(config.cache_db_params)

        self._site_id_map = {}
        self._dataset_id_map = {}
Beispiel #2
0
    def __init__(self, config):
        AppManager.__init__(self, config)

        if not hasattr(self, '_mysql'):
            db_params = Configuration(config.db_params)
            db_params.reuse_connection = True  # we use locks

            self._mysql = MySQL(db_params)

        # make sure applications row with id 0 exists
        count = self._mysql.query(
            'SELECT COUNT(*) FROM `applications` WHERE `id` = 0')[0]

        if count == 0:
            # Cannot insert with id = 0 (will be interpreted as next auto_increment id unless server-wide setting is changed)
            # Inesrt with an implicit id first and update later
            columns = ('auth_level', 'title', 'path', 'status', 'user_id',
                       'user_host')
            values = (AppManager.LV_WRITE, 'wsgi', '', 'done', 0, '')
            insert_id = self._mysql.insert_get_id('applications',
                                                  columns=columns,
                                                  values=values)

            self._mysql.query(
                'UPDATE `applications` SET `id` = 0 WHERE `id` = %s',
                insert_id)
Beispiel #3
0
    def __init__(self, config=None):
        if config is None:
            config = HistoryDatabase._config

        self.db = MySQL(config.db_params)

        self.set_read_only(config.get('read_only', False))
Beispiel #4
0
    def __init__(self, config):
        FileTransferOperation.__init__(self, config)
        FileTransferQuery.__init__(self, config)
        FileDeletionOperation.__init__(self, config)
        FileDeletionQuery.__init__(self, config)

        self.db = MySQL(config.db_params)
Beispiel #5
0
    def update(config, inventory):
        htcondor = HTCondor(config.htcondor.config)
        store = MySQL(config.store.db_params)

        last_update = store.query(
            'SELECT UNIX_TIMESTAMP(`dataset_requests_last_update`) FROM `system`'
        )[0]
        try:
            store.query(
                'UPDATE `system` SET `dataset_requests_last_update` = NOW()',
                retries=0,
                silent=True)
        except MySQLdb.OperationalError:
            # We have a read-only config
            read_only = True
        else:
            read_only = False

        source_records = GlobalQueueRequestHistory._get_source_records(
            htcondor, inventory, last_update)

        if not read_only:
            GlobalQueueRequestHistory._save_records(source_records, store)
            # remove old entries
            store.query(
                'DELETE FROM `dataset_requests` WHERE `queue_time` < DATE_SUB(NOW(), INTERVAL 1 YEAR)'
            )
            store.query(
                'UPDATE `system` SET `dataset_requests_last_update` = NOW()')
Beispiel #6
0
    def __init__(self, config = None):
        if config is None:
            if MySQLReplicaLock._default_config is None:
                raise ConfigurationError('MySQLReplicaLock default config is not set')

            config = MySQLReplicaLock._default_config

        self._mysql = MySQL(config.get('db_params', None))

        self.users = []
        for user_id, role_id in config.get('users', []):
            self.users.append((user_id, role_id))
Beispiel #7
0
    def update(config, inventory):
        popdb = PopDB(config.popdb.config)
        store = MySQL(config.store.db_params)

        last_update = store.query(
            'SELECT UNIX_TIMESTAMP(`dataset_accesses_last_update`) FROM `system`'
        )[0]
        try:
            store.query(
                'UPDATE `system` SET `dataset_accesses_last_update` = NOW()',
                retries=0,
                silent=True)
        except MySQLdb.OperationalError:
            # We have a read-only config
            read_only = True
            LOG.info('Running update() in read-only mode.')
        else:
            read_only = False

        start_time = max(last_update,
                         (time.time() - 3600 * 24 * config.max_back_query))
        start_date = datetime.date(*time.gmtime(start_time)[:3])

        included_sites = list(config.included_sites)
        excluded_sites = list(config.excluded_sites)

        source_records = CRABAccessHistory._get_source_records(
            popdb, inventory, included_sites, excluded_sites, start_date)

        if not read_only:
            CRABAccessHistory._save_records(source_records, store)
            # remove old entries
            store.query(
                'DELETE FROM `dataset_accesses` WHERE `date` < DATE_SUB(NOW(), INTERVAL 2 YEAR)'
            )
            store.query(
                'UPDATE `system` SET `dataset_accesses_last_update` = NOW()')
Beispiel #8
0
    def __init__(self, config):
        FileTransferOperation.__init__(self, config)
        FileTransferQuery.__init__(self, config)
        FileDeletionOperation.__init__(self, config)
        FileDeletionQuery.__init__(self, config)

        self.server_url = config.fts_server
        self.server_id = 0  # server id in the DB

        # Parameter "retry" for fts3.new_job. 0 = server default
        self.fts_retry = config.get('fts_retry', 0)

        # String passed to fts3.new_*_job(metadata = _)
        self.metadata_string = config.get('metadata_string', 'Dynamo')

        # Proxy to be forwarded to FTS
        self.x509proxy = config.get('x509proxy', None)

        # Bookkeeping device
        self.db = MySQL(config.db_params)

        # Reuse the context object
        self.keep_context = config.get('keep_context', True)
        self._context = None
 def __init__(self, config = None):
     CopyInterface.__init__(self, config)
     self.rlfsm = RLFSM(config.get('rlfsm', None))
     self.mysql = MySQL(config.reserve_db_params)
Beispiel #10
0
 def __init__(self):
     BaseHandler.__init__(self, 'Direct')
     self._mysql = MySQL(**config.registry.db_params)
Beispiel #11
0
 def __init__(self, config):
     self._store = MySQL(config.store.db_params)
Beispiel #12
0
    def __init__(self, config):
        InventoryStore.__init__(self, config)

        self._mysql = MySQL(config.db_params)
Beispiel #13
0
    def __init__(self, config):
        self._store = MySQL(config.store.db_params)

        # Weight computation halflife constant (given in days in config)
        self.weight_halflife = config.weight_halflife * 3600. * 24.