def __init__(self): self.opentsdb_handler = bdwatchdog.OpenTSDBServer() self.couchdb_handler = couchdb.CouchDBServer() self.containerRebalancer = containerReBalancer.ContainerRebalancer() self.applicationReBalancer = applicationReBalancer.ApplicationRebalancer( ) self.userReBalancer = userReBalancer.UserRebalancer() self.debug = True self.config = {}
def beat(self): # Serverless Containers from src.StateDatabase import couchdb as couchDB from src.MyUtils import MyUtils as MyUtils self.logger.info("Starting heartbeat of " + self.SERVICE_NAME) db_handler = couchDB.CouchDBServer() while True: try: MyUtils.beat(db_handler, self.SERVICE_NAME) time.sleep(10) except ValueError: # Service not found: # - maybe it doesn't exist at all, register it # - it may have been deleted while the daemon was running, re-register it register_service(db_handler, self.SERVICE_NAME) except requests.ConnectionError: # Error connecting to the Couchdb database, ignore as it may be temporary pass
def report(self): db = couchDB.CouchDBServer(couchdb_url="couchdb") orchestrator_hostname = "orchestrator" self.__REST_SERVICES__.append( (orchestrator_hostname, orchestrator_hostname, "5000")) while True: dead, alive = self.__sort_services_dead_and_alive( db.get_services(), self.__REST_SERVICES__, self.__MAX_TIME_ALLOWED__) print("AT: " + str(time.strftime("%D %H:%M:%S", time.localtime()))) print("") print("!---- ALIVE ------!") alive_services = { "Atops": list(), "Turbostats": list(), "Node-Rescalers": list(), "Others": list() } for a in alive: alive_services[self.__classify_service(a)].append(a) self.__print_services(alive_services) print("") print("!---- DEAD -------!") dead_services = { "Atops": list(), "Turbostats": list(), "Node-Rescalers": list(), "Others": list() } for d in dead: dead_services[self.__classify_service(d)].append(d) self.__print_services(dead_services) print("") time.sleep(self.__POLLING_TIME__)
type="service", heartbeat="", config=dict(ACTIVE=False, DEBUG=True)) sanity_checker = dict(name="sanity_checker", type="service", heartbeat="", config=dict(DELAY=30, DEBUG=True)) rebalancer = dict(name="rebalancer", type="service", heartbeat="", config=dict(DEBUG=True)) if __name__ == "__main__": initializer_utils = couchdb_utils.CouchDBUtils() handler = couchDB.CouchDBServer() database = "services" initializer_utils.remove_db(database) initializer_utils.create_db(database) if handler.database_exists("services"): print("Adding 'services' document") handler.add_service(scaler) handler.add_service(guardian) handler.add_service(database_snapshoter) handler.add_service(structures_snapshoter) handler.add_service(refeeder) handler.add_service(sanity_checker) handler.add_service(rebalancer)
def __init__(self): self.__couchdb_handler = couchdb.CouchDBServer() self.__debug = True self.__config = {}
def __init__(self): self.couchdb_handler = couchdb.CouchDBServer()
# along with ServerlessContainers. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function import requests import json import time import traceback import logging import src.StateDatabase.couchdb as couchdb import src.StateDatabase.opentsdb as opentsdb from src.MyUtils.MyUtils import MyConfig, log_error, get_service, beat, log_info, log_warning db_handler = couchdb.CouchDBServer() opentsdb_handler = opentsdb.OpenTSDBServer() CONFIG_DEFAULT_VALUES = { "POLLING_FREQUENCY": 5, "DEBUG": True, "DOCUMENTS_PERSISTED": ["limits", "structures", "users", "configs"], "ACTIVE": True } OPENTSDB_STORED_VALUES_AS_NULL = 0 SERVICE_NAME = "database_snapshoter" MAX_FAIL_NUM = 5 debug = True PERSIST_METRICS = [ "max", "min", "upper", "lower", "current", "usage", "fixed", "shares" ]
def __init__(self): self.opentsdb_handler = bdwatchdog.OpenTSDBServer() self.couchdb_handler = couchdb.CouchDBServer() self.NO_METRIC_DATA_DEFAULT_VALUE = self.opentsdb_handler.NO_METRIC_DATA_DEFAULT_VALUE
def __init__(self): self.__opentsdb_handler = opentsdb.OpenTSDBServer() self.__couchdb_handler = couchdb.CouchDBServer() self.__NO_METRIC_DATA_DEFAULT_VALUE = self.__opentsdb_handler.NO_METRIC_DATA_DEFAULT_VALUE self.__debug = True self.__config = {}
def get_db(): global COUCHDB_URL """Opens a new database connection if there is none yet for the current application context.""" if not hasattr(g, 'db_handler'): g.db_handler = couchDB.CouchDBServer(couchdb_url=COUCHDB_URL) return g.db_handler
def __init__(self): self.handler = couchDB.CouchDBServer()