コード例 #1
0
ファイル: gcollect.py プロジェクト: sivang/relaxession
	def __init__(self, database_uri=None, dbname=None):
		'''
		Create a Server object, initiate connection and set up the databse URI 
		(Not particulary in that order :-)
		Oh and also sync up the views from the on disk storage onto CouchDB
		so we can use them for our maintainance operations.
		'''
		self.logger = configuration.get_logger(logging_instance=conflictlogging,
							system_name='dbmaintainer')
		configuration.info(self.logger)
		self.logger.info('Database maintainer starting.')
		if not database_uri:
			database_uri = "http://127.0.0.1:5984"
		if not dbname:
			dbname = 'session_store'
		self.dbname = dbname
		self.db_uri = database_uri
		self.dbserver = Server(self.db_uri)
		loader = FileSystemDocsLoader('/root/relaxession/_design/')
		try:
			self.db = self.dbserver.get_or_create_db(self.dbname)
			loader.sync(self.db, verbose=True)
		except Exception as e:
			self.logger.info('Init error: %s' % e)
			sys.exit(1)
		self.db.res.put('/_revs_limit',str(configuration.REVS_LIMIT))
コード例 #2
0
ファイル: connmanager.py プロジェクト: sivang/relaxession
 def __init__(self, hosts, database_name="session_store"):
     self.logger = configuration.get_logger(logging_instance=connlogging, system_name="connmanager")
     configuration.info(self.logger)
     self.database_name = database_name
     self.hosts = hosts
     self.online = []
     self.ip = self.get_ip_address()
     self.logger.info("= ConnectionManager instantiated =")
     self.logger.info("My IP -> %s" % self.ip)
     self.logger.info("Targets: %s" % self.hosts)
     # Create an instance to the local server
     self.dbserver = Server()
     self.node_probe = None  # reference for the NodeProbe object