def baseInit(loop, node_type): """Intitialize application and return app object""" log.info("Application baseInit") app = Application(loop=loop) # set a bunch of global state node_id = createNodeId(node_type) app["id"] = node_id app["node_state"] = "INITIALIZING" app["node_type"] = node_type node_port = config.get(node_type + "_port") app["node_port"] = config.get(node_type + "_port") log.info(f"baseInit - node_id: {node_id} node_port: {node_port}") app["node_number"] = -1 app["node_count"] = -1 app["start_time"] = int(time.time()) # seconds after epoch app['register_time'] = 0 bucket_name = config.get("bucket_name") if bucket_name: log.info(f"using bucket: {bucket_name}") else: log.info("no default bucket defined") app["bucket_name"] = bucket_name app["sn_urls"] = {} app["dn_urls"] = {} counter = {} counter["GET"] = 0 counter["PUT"] = 0 counter["POST"] = 0 counter["DELETE"] = 0 counter["num_tasks"] = 0 app["req_count"] = counter counter = {} counter["DEBUG"] = 0 counter["INFO"] = 0 counter["WARN"] = 0 counter["ERROR"] = 0 app["log_count"] = counter if config.get("oio_proxy"): app["oio_proxy"] = config.get("oio_proxy") if config.get("host_ip"): app["host_ip"] = config.get("host_ip") else: app["host_ip"] = "127.0.0.1" # check to see if we are running in a k8s cluster #if ospath.exists("/var/run/secrets/kubernetes.io") or True: if config.get("KUBERNETES_SERVICE_HOST"): log.info("running in kubernetes") app["is_k8s"] = True log.app = app app["loop"] = loop # save loop instance app.router.add_get('/info', info) app.router.add_get('/about', about) return app
def baseInit(loop, node_type): """Intitialize application and return app object""" log.info("Application baseInit") app = Application(loop=loop) # set a bunch of global state node_id = createNodeId(node_type) app["id"] = node_id app["node_state"] = "INITIALIZING" app["node_type"] = node_type node_port = config.get(node_type + "_port") app["node_port"] = config.get(node_type + "_port") log.info(f"baseInit - node_id: {node_id} node_port: {node_port}") app["node_number"] = -1 app["node_count"] = -1 app["start_time"] = int(time.time()) # seconds after epoch app['register_time'] = 0 bucket_name = config.get("bucket_name") if bucket_name: log.info(f"using bucket: {bucket_name}") else: log.info("no default bucket defined") app["bucket_name"] = bucket_name app["sn_urls"] = {} app["dn_urls"] = {} counter = {} counter["GET"] = 0 counter["PUT"] = 0 counter["POST"] = 0 counter["DELETE"] = 0 counter["num_tasks"] = 0 app["req_count"] = counter counter = {} counter["DEBUG"] = 0 counter["INFO"] = 0 counter["WARN"] = 0 counter["ERROR"] = 0 app["log_count"] = counter app["s3_stats"] = getInitialS3Stats() if config.get("oio_proxy"): app["oio_proxy"] = config.get("oio_proxy") if config.get("host_ip"): app["host_ip"] = config.get("host_ip") else: app["host_ip"] = "127.0.0.1" log.app = app # save session object session = get_session(loop=loop) app["session"] = session app["loop"] = loop app.router.add_get('/info', info) app.router.add_get('/about', about) return app
async def init(loop): """Intitialize application and return app object""" app = Application(loop=loop) # set a bunch of global state app["id"] = createNodeId("head") app["cluster_state"] = "INITIALIZING" app["start_time"] = int(time.time()) # seconds after epoch app["target_sn_count"] = int(config.get("target_sn_count")) app["target_dn_count"] = int(config.get("target_dn_count")) log.info("target_sn_count: {}".format(app["target_sn_count"])) log.info("target_dn_count: {}".format(app["target_dn_count"])) bucket_name = config.get("sys_bucket_name") if not bucket_name: # use a combine data/sys bucket bucket_name = config.get("bucket_name") if not bucket_name: log.error("BUCKET_NAME environment variable not set") sys.exit() log.info("using bucket: {}".format(bucket_name)) app["bucket_name"] = bucket_name app["head_host"] = config.get("head_host") app["head_port"] = config.get("head_port") nodes = [] for node_type in ("dn", "sn", "an"): target_count = getTargetNodeCount(app, node_type) for i in range(target_count): node = { "node_number": i, "node_type": node_type, "host": None, "port": None, "id": None } nodes.append(node) app["nodes"] = nodes app["node_stats"] = { } # stats retuned by node/info request. Keyed by node id app["node_ids"] = {} # dictionary to look up node by id app["s3_stats"] = getInitialS3Stats() app.router.add_get('/', info) app.router.add_get('/nodestate', nodestate) app.router.add_get('/nodestate/{nodetype}', nodestate) app.router.add_get('/nodestate/{nodetype}/{nodenumber}', nodestate) app.router.add_get('/nodeinfo', nodeinfo) app.router.add_get('/nodeinfo/{statkey}', nodeinfo) app.router.add_get('/info', info) app.router.add_post('/register', register) return app
def init(): """Intitialize application and return app object """ app = Application() # set a bunch of global state app["id"] = createNodeId("head") app["cluster_state"] = "INITIALIZING" app["start_time"] = int(time.time()) # seconds after epoch app["target_sn_count"] = int(config.get("target_sn_count")) app["target_dn_count"] = int(config.get("target_dn_count")) log.info("target_sn_count: {}".format(app["target_sn_count"])) log.info("target_dn_count: {}".format(app["target_dn_count"])) bucket_name = config.get("bucket_name") if bucket_name: log.info("using bucket: {}".format(bucket_name)) app["bucket_name"] = bucket_name else: log.info("No default bucket name is set") app["head_host"] = config.get("head_host") app["head_port"] = config.get("head_port") nodes = [] for node_type in ("dn", "sn"): target_count = getTargetNodeCount(app, node_type) for i in range(target_count): node = { "node_number": i, "node_type": node_type, "host": None, "port": None, "id": None } nodes.append(node) app["nodes"] = nodes app["node_stats"] = { } # stats retuned by node/info request. Keyed by node id app["node_ids"] = {} # dictionary to look up node by id app.router.add_get('/', info) app.router.add_get('/nodestate', nodestate) app.router.add_get('/nodestate/{nodetype}', nodestate) app.router.add_get('/nodestate/{nodetype}/{nodenumber}', nodestate) app.router.add_get('/nodeinfo', nodeinfo) app.router.add_get('/nodeinfo/{statkey}', nodeinfo) app.router.add_get('/info', info) app.router.add_post('/register', register) return app
def baseInit(loop, node_type): """Intitialize application and return app object""" log.info("Application baseInit") app = Application(loop=loop) # set a bunch of global state app["id"] = createNodeId(node_type) app["node_state"] = "INITIALIZING" app["node_type"] = node_type app["node_port"] = config.get(node_type + "_port") app["node_number"] = -1 app["node_count"] = -1 app["start_time"] = int(time.time()) # seconds after epoch app['register_time'] = 0 bucket_name = config.get("bucket_name") if not bucket_name: log.error("BUCKET_NAME environment variable not set") sys.exit() log.info("using bucket: {}".format(bucket_name)) app["bucket_name"] = bucket_name app["sn_urls"] = {} app["dn_urls"] = {} counter = {} counter["GET"] = 0 counter["PUT"] = 0 counter["POST"] = 0 counter["DELETE"] = 0 counter["num_tasks"] = 0 app["req_count"] = counter counter = {} counter["DEBUG"] = 0 counter["INFO"] = 0 counter["WARN"] = 0 counter["ERROR"] = 0 app["log_count"] = counter app["s3_stats"] = getInitialS3Stats() log.app = app # save session object session = get_session(loop=loop) app["session"] = session app["loop"] = loop app.router.add_get('/info', info) app.router.add_get('/about', about) return app