Beispiel #1
0

            elif api == 'id_list': ## this for debugging purposes
                userid = message['userid']
                itemid = message['itemid']
                timestamp = message['timestamp']
                domainid = message['domainid']

                additional_filter = {'domainid': domainid}

                if config_global.SAVE_RANDOM_RECOMMENDER in backends:
                    fb = Random_Recommender()
                    fb.set_recommendables(itemid, additional_filter)

                if config_global.SAVE_HADOOP_SINK in backends:
                    hS = HadoopSink(append=True)
                    rating = 1
                    hS.save_mode2(userid, itemid, domainid, timestamp)

                if config_global.SAVE_USER_STATS in backends:
                    us = UserStats('userid', 'itemid')
                    us.save(userid, itemid)

                    #save sync
        else:
            body_message = {'message': message,
                            'api': api,
                            'backends': backends}

            body_message = pickle.dumps(body_message)
	
	""" select as much ids as you want then enque this as a replay job. 
	Each worker will then fetch the task from the queue and request to 
	the Request handler then """
	
	""" grab the messages and send them as a post to the contest request handler """
	
	
	db=_mysql.connect(host="localhost",user="******",
				  passwd=config_local.mysql_password,db="contest")
	
	SAVE_ITEM_BY_USER = False
	SAVE_DIMENSION_LIST = False
	SAVE_DISTRIBUTED_COUNTER = False
	SAVE_HADOOP_SINK = False
	hS = HadoopSink()
	
	#db.query("""SELECT * FROM contest.contest_messages c LIMIT 0,1000""")
	#db.query("""SELECT id, type, timestamp, json, response_time, response_id FROM contest.contest_messages c \
	#WHERE type = 'impression' AND id > 1500004 LIMIT 5""")
	db.query("""SELECT id, type, timestamp, json, response_time, response_id FROM contest.contest_messages c \
	WHERE ( type = 'impression' ) AND id > 1000000 LIMIT 10 """)
	r=db.use_result()
	
	""" what happens if there is a timestamp collison? It doesn't matter if we don't try to count with the timestamp
	""" 
	
	replay_time = time2.time()
	
	result = r.fetch_row()