def writePopulationToDatabase(self): # Uncommenting these lines allows testing when there is no web server. #Log.debug("PopulationClass.writePopulationToDatabase entered") statements = LinkedList() # Acquire the lock to copy the recentPopulationNumbers dictionary, # and then release it. try: self.popLock.lock() mostRecentPopulationNumbers = self.recentPopulationNumbers self.recentPopulationNumbers = {} finally: self.popLock.unlock() #Log.debug("PopulationClass.writePopulationToDatabase: " + str(len(mostRecentPopulationNumbers)) + " elements") # Iterate over the recent population changes elements. # If the instanceOid already exists in allPopulationNumbers and # the population is zero, remove the row and remove the element # of allPopulationNumbers; otherwise, create the update statement. # If it's not in allPopulationNumbers, create the insert statement. for accountId, (population, instanceOid) in mostRecentPopulationNumbers.items(): if accountId in self.allPopulationNumbers: if (population == 0): statements.add( "DELETE FROM populations WHERE account_id = " + str(accountId) + ";") del self.allPopulationNumbers[accountId] else: statements.add("UPDATE populations SET population = " + str(population) + " WHERE instance_id = " + str(instanceOid) + ";") else: statements.add( "INSERT INTO populations (account_id, instance_id, population) VALUES (" + str(accountId) + "," + str(instanceOid) + "," + str(population) + ");") self.allPopulationNumbers[accountId] = (population, instanceOid) # If there is nothing to do, return if statements.size() == 0: return else: Engine.getDatabase().executeBatch(statements) if (Log.loggingDebug): batch = "" for i in range(statements.size() - 1): batch += "\n" + statements.get(i) Log.debug( "PopulationClass.writePopulationFields: ran SQL statements " + batch)
def writePopulationToDatabase(self): # Uncommenting these lines allows testing when there is no web server. #Log.debug("PopulationClass.writePopulationToDatabase entered") statements = LinkedList() # Acquire the lock to copy the recentPopulationNumbers dictionary, # and then release it. try: self.popLock.lock() mostRecentPopulationNumbers = self.recentPopulationNumbers self.recentPopulationNumbers = {} finally: self.popLock.unlock() #Log.debug("PopulationClass.writePopulationToDatabase: " + str(len(mostRecentPopulationNumbers)) + " elements") # Iterate over the recent population changes elements. # If the instanceOid already exists in allPopulationNumbers and # the population is zero, remove the row and remove the element # of allPopulationNumbers; otherwise, create the update statement. # If it's not in allPopulationNumbers, create the insert statement. for accountId, (population, instanceOid) in mostRecentPopulationNumbers.items(): if accountId in self.allPopulationNumbers: if (population == 0): statements.add("DELETE FROM populations WHERE account_id = " + str(accountId) + ";") del self.allPopulationNumbers[accountId] else: statements.add("UPDATE populations SET population = " + str(population) + " WHERE instance_id = " + str(instanceOid) + ";") else: statements.add("INSERT INTO populations (account_id, instance_id, population) VALUES (" + str(accountId) + "," + str(instanceOid) + "," + str(population) + ");") self.allPopulationNumbers[accountId] = (population, instanceOid) # If there is nothing to do, return if statements.size() == 0: return else: Engine.getDatabase().executeBatch(statements) if (Log.loggingDebug): batch = "" for i in range(statements.size() - 1): batch += "\n" + statements.get(i) Log.debug("PopulationClass.writePopulationFields: ran SQL statements " + batch)
# readability and configuration. print "\nCleaning up unecessary configurations" print "-------------------------------------------------" index = 0; servers = deletions.getForeignServers() while index < servers.size(): deleteServer(servers.get(index)) index += 1 index = 0; apps = deletions.getApplications() while index < apps.size(): deleteApplication(apps.get(index)) index += 1 index = 0; clusters = deletions.getClusteredForeignServers() while index < clusters.size(): deleteClusteredServer(clusters.get(index)) index += 1 if save == "true": AdminConfig.save() else: print "Trial Mode Enabled - No Changes Were Persisted"