Ejemplo n.º 1
0
 def _parseCreateDatabase(self, tokens):
     """
     Subparser - handles all CREATE DATABASE requests.
     Throws css.CssError, _ToolError
     """
     l = len(tokens)
     if l == 2:
         dbName = tokens[0]
         configFile = tokens[1]
         options = self._fetchOptionsFromConfigFile(configFile)
         options = self._processDbOptions(options)
         striping = css.StripingParams(int(options['nStripes']),
                                       int(options['nSubStripes']), 0,
                                       float(options['overlap']))
         self._css.createDb(dbName, striping, options['storageClass'],
                            'RELEASED')
     elif l == 3:
         if tokens[1].upper() != 'LIKE':
             raise _IllegalCommandError(
                 "Expected 'LIKE', found: '{0}'.".format(tokens[1]))
         dbName = tokens[0]
         dbName2 = tokens[2]
         self._css.createDbLike(dbName, dbName2)
     else:
         raise _IllegalCommandError("Unexpected number of arguments.")
Ejemplo n.º 2
0
    def _updateCss(self, database, table):
        """
        Update CSS with information about loaded table and database.
        """

        # create database in CSS if not there yet
        if not self.css.containsDb(database):
            self._log.info('Creating database CSS info')
            options = self.partOptions.cssDbOptions()
            striping = css.StripingParams(options['nStripes'],
                                          options['nSubStripes'], 0,
                                          options['overlap'])
            self.css.createDb(database, striping, options['storageClass'],
                              'RELEASED')

        # define options for table
        options = self.partOptions.cssTableOptions()
        schema = self._schemaForCSS(database, table)

        if options.get('match', False):
            matchParams = css.MatchTableParams(options['dirTable1'],
                                               options['dirColName1'],
                                               options['dirTable2'],
                                               options['dirColName2'],
                                               options['flagColName'])
            self._log.info('Creating table CSS info for match table')
            self.css.createMatchTable(database, table, schema, matchParams)
        else:
            if 'dirTable' in options:
                # partitioned table
                pParams = css.PartTableParams(
                    options['dirDb'], options['dirTable'],
                    options['dirColName'], options['latColName'],
                    options['lonColName'], options['overlap'], True,
                    options['subChunks'])
                sParams = css.ScanTableParams(options['lockInMem'],
                                              options['scanRating'])
            else:
                pParams = css.PartTableParams()
                sParams = css.ScanTableParams()
            self.css.createTable(database, table, schema, pParams, sParams)

        # save chunk mapping too
        self._log.info('Saving updated chunk map to CSS')
        self.chunkMap.save()
Ejemplo n.º 3
0
 def setUp(self):
     self.dbStriping = css.StripingParams(10, 10, 0, 0.0)