예제 #1
0
    def establishConnection(self, config, args, channel):
        ## ----------------------------------------------
        ## Connect to MongoDB
        ## ----------------------------------------------
        hostname = config.get(configutil.SECT_MONGODB, 'host')
        port = config.getint(configutil.SECT_MONGODB, 'port')
        assert hostname
        assert port
        try:
            conn = mongokit.Connection(host=hostname, port=port)
        except:
            LOG.error("Failed to connect to MongoDB at %s:%s" % (hostname, port))
            raise
        ## Register our objects with MongoKit
        conn.register([ catalog.Collection, workload.Session ])

        ## Make sure that the databases that we need are there
        db_names = conn.database_names()
        for key in [ 'dataset_db', ]: # FIXME 'workload_db' ]:
            if not config.has_option(configutil.SECT_MONGODB, key):
                raise Exception("Missing the configuration option '%s.%s'" % (configutil.SECT_MONGODB, key))
            elif not config.get(configutil.SECT_MONGODB, key):
                raise Exception("Empty configuration option '%s.%s'" % (configutil.SECT_MONGODB, key))
        ## FOR
        
        metadata_db = conn[config.get(configutil.SECT_MONGODB, 'metadata_db')]
        dataset_db = conn[config.get(configutil.SECT_MONGODB, 'dataset_db')]
        
        designer = Designer(config, metadata_db, dataset_db, channel)
        designer.setOptionsFromArguments(args)
        
        return designer
    ## DEF
    
## CLASS
예제 #2
0
파일: d4.py 프로젝트: greinerb/mongodb-d4
            if LOG.isEnabledFor(logging.DEBUG):
                LOG.warn("Dropping %s.%s", metadata_db.name, col_name)
            metadata_db.drop_collection(col_name)
        ## FOR

        for col_name in dataset_db.collection_names():
            if col_name.startswith("system"): continue
            if LOG.isEnabledFor(logging.DEBUG):
                LOG.warn("Dropping %s.%s" % (dataset_db.name, col_name))
            dataset_db.drop_collection(col_name)
        ## FOR
    ## IF

    # This designer is only used for input processing
    designer = Designer(config, metadata_db, dataset_db)
    designer.setOptionsFromArguments(args)

    if args['init_design']:
        designer.load(False, None, True)
        exit("Initial Design done")
    ## IF
    if args['input_design']:
        # evaluate the input design and then quit
        ds = Deserializer()
        ds.loadDesignFile(args['input_design'])
        replay_design = ds.Deserialize()
        LOG.info("Read in design\n%s", replay_design)
        designer.load(True, replay_design)
        exit("Design evaluation done")
    ## IF
예제 #3
0
파일: d4.py 프로젝트: cmu-db/mongodb-d4
            if LOG.isEnabledFor(logging.DEBUG):
                LOG.warn("Dropping %s.%s", metadata_db.name, col_name)
            metadata_db.drop_collection(col_name)
        ## FOR

        for col_name in dataset_db.collection_names():
            if col_name.startswith("system"): continue
            if LOG.isEnabledFor(logging.DEBUG):
                LOG.warn("Dropping %s.%s" % (dataset_db.name, col_name))
            dataset_db.drop_collection(col_name)
        ## FOR
    ## IF
    
    # This designer is only used for input processing
    designer = Designer(config, metadata_db, dataset_db)
    designer.setOptionsFromArguments(args)
    
    if args['init_design']:
        designer.load(False, None, True)
        exit("Initial Design done")
    ## IF
    if args['input_design']:
        # evaluate the input design and then quit
        ds = Deserializer()
        ds.loadDesignFile(args['input_design'])
        replay_design = ds.Deserialize()
        LOG.info("Read in design\n%s", replay_design)
        designer.load(True, replay_design)
        exit("Design evaluation done")
    ## IF