def isShardRegistered(dbHost=None, configHost=getConfigHost(), block=False): """ Check if given mongo db host is registered as a shard """ functionName = isShardRegistered.__name__ helpers.entrylog(log, functionName, locals()) if dbHost == None: dbHost = getCollector() helpers.exitlog(log, functionName) return Server.isShardRegistered( dbHost=helpers.toControlPlaneNodeName(dbHost), configHost=helpers.toControlPlaneNodeName(configHost), block=block)
def registerShard( mongod=config.getNodeName(), mongos=getConfigHost(), timeout=TIMEOUT): """ Function to register a database server as a shard in the database cluster """ functionName = registerShard.__name__ helpers.entrylog(log, functionName, locals()) mongod = helpers.toControlPlaneNodeName(mongod) mongos = helpers.toControlPlaneNodeName(mongos) Server.registerShard(dbHost=mongod, configHost=mongos, timeout=timeout) helpers.exitlog(log, functionName)
def setBalancerState(state): """ Function to turn on/off data balancer """ Server.setBalancerState(state=state, configHost=helpers.toControlPlaneNodeName( getConfigHost()))
def startShardServer(configHost=getConfigHost(), timeout=TIMEOUT): """ Function to start a database config server on the node """ return Server.startShardServer( logPath=os.path.join(config.getLogDir(), "mongos.log"), configHost=helpers.toControlPlaneNodeName(configHost), timeout=timeout)
def isDBRunning(host='localhost', port=DATABASE_SERVER_PORT): """ Check if a database server is running on a given host and port """ #In case of a single node experiment /etc/hosts does not get populated if host == config.getNodeName(): host = 'localhost' return Server.isDBRunning(host=helpers.toControlPlaneNodeName(host), port=port)
def moveChunk(host, collector=None, collectionname=COLLECTION_NAME): """ Shard, split and move a given collection to the corresponding collector """ functionName = moveChunk.__name__ helpers.entrylog(log, functionName, locals()) if collector == None: collector = host Server.moveChunk(db=DB_NAME, collection=collectionname, host=host, collector=helpers.toControlPlaneNodeName(collector), configHost=helpers.toControlPlaneNodeName( getConfigHost())) helpers.exitlog(log, functionName)
def loadActualDataFromDeter(self, projectName, expName): print "Loading experiment data..." print "Project Name: %s, Experiment Name: %s" % (projectName, expName) experimentConfigFile = helpers.getExperimentConfigFile(projectName, expName) experimentConfig = yaml.load(open(experimentConfigFile, 'r')) dbdl = experimentConfig['dbdl'] data = getData( 'iso_server_agent', # dbHost=getDBConfigHost(project=projectName, experiment=expName), dbHost=helpers.toControlPlaneNodeName(dbdl['configHost']), # dbPort=27017 dbPort=dbdl['configPort'] ) data = [d for d in data if d.get("statsType") == "iso_stats"] # print "ACTUAL RESULTS FROM MONGO:" # print repr(data) return data
def loadActualDataFromDeter(self, projectName, expName): print "Loading experiment data..." print "Project Name: %s, Experiment Name: %s" % (projectName, expName) experimentConfigFile = helpers.getExperimentConfigFile( projectName, expName) experimentConfig = yaml.load(open(experimentConfigFile, 'r')) dbdl = experimentConfig['dbdl'] data = getData( 'iso_server_agent', # dbHost=getDBConfigHost(project=projectName, experiment=expName), dbHost=helpers.toControlPlaneNodeName(dbdl['configHost']), # dbPort=27017 dbPort=dbdl['configPort']) data = [d for d in data if d.get("statsType") == "iso_stats"] # print "ACTUAL RESULTS FROM MONGO:" # print repr(data) return data
def getConnection(host=None, port=DATABASE_SERVER_PORT, block=True, timeout=TIMEOUT): """ Function to get connection to a database server """ functionName = getConnection.__name__ helpers.entrylog(log, functionName, locals()) if host == None: host = getCollector() #In case of a single node experiment /etc/hosts does not get populated if host == config.getNodeName(): host = 'localhost' helpers.exitlog(log, functionName) return Connection.getConnection(host=helpers.toControlPlaneNodeName(host), port=port, block=block, timeout=timeout)
def isConfigHost(): configHost = getConfigHost() return (config.getNodeName() == configHost or helpers.toControlPlaneNodeName(config.getNodeName()) == configHost)