def _get_cluster_row_and_node_row(interaction_pool): """ use node_id as shard id """ log = logging.getLogger("_get_cluster_row_and_shard_id") query = """select %s from nimbusio_central.cluster where name = %%s""" % (\ ",".join(cluster_row_template._fields), ) async_result = interaction_pool.run(interaction=query, interaction_args=[ _cluster_name, ], pool=_central_pool_name) result_list = async_result.get() if len(result_list) == 0: error_message = "Unable to identify cluster {0}".format(_cluster_name) log.error(error_message) raise WebWriterError(error_message) result = result_list[0] cluster_row = cluster_row_template(id=result["id"], name=result["name"], node_count=result["node_count"], replication_level=\ result["replication_level"]) query = """select %s from nimbusio_central.node where cluster_id = %%s order by node_number_in_cluster""" % (",".join( node_row_template._fields), ) async_result = interaction_pool.run(interaction=query, interaction_args=[ cluster_row.id, ], pool=_central_pool_name) result_list = async_result.get() for row in result_list: node_row = node_row_template(id=row["id"], node_number_in_cluster=\ row["node_number_in_cluster"], name=row["name"], hostname=row["hostname"], offline=row["offline"]) if node_row.name == _local_node_name: return cluster_row, node_row # if we make it here, this cluster is misconfigured error_message = "node name {0} is not in node cluster {1}".format( _local_node_name, _cluster_name) log.error(error_message) raise WebWriterError(error_message)
def _get_cluster_row_and_node_row(interaction_pool): """ use node_id as shard id """ log = logging.getLogger("_get_cluster_row_and_shard_id") query = """select %s from nimbusio_central.cluster where name = %%s""" % (\ ",".join(cluster_row_template._fields), ) async_result = interaction_pool.run(interaction=query, interaction_args=[_cluster_name, ], pool=_central_pool_name) result_list = async_result.get() if len(result_list) == 0: error_message = "Unable to identify cluster {0}".format(_cluster_name) log.error(error_message) raise WebWriterError(error_message) result = result_list[0] cluster_row = cluster_row_template(id=result["id"], name=result["name"], node_count=result["node_count"], replication_level=\ result["replication_level"]) query = """select %s from nimbusio_central.node where cluster_id = %%s order by node_number_in_cluster""" % ( ",".join(node_row_template._fields), ) async_result = interaction_pool.run(interaction=query, interaction_args=[cluster_row.id, ], pool=_central_pool_name) result_list = async_result.get() for row in result_list: node_row = node_row_template(id=row["id"], node_number_in_cluster=\ row["node_number_in_cluster"], name=row["name"], hostname=row["hostname"], offline=row["offline"]) if node_row.name == _local_node_name: return cluster_row, node_row # if we make it here, this cluster is misconfigured error_message = "node name {0} is not in node cluster {1}".format( _local_node_name, _cluster_name) log.error(error_message) raise WebWriterError(error_message)
def _get_cluster_row(interaction_pool): """ use node_id as shard id """ log = logging.getLogger("_get_cluster_row_and_shard_id") query = """select %s from nimbusio_central.cluster where name = %%s""" % (\ ",".join(cluster_row_template._fields), ) async_result = \ interaction_pool.run(interaction=query, interaction_args=[_cluster_name, ], pool=_central_pool_name) result_list = async_result.get() if len(result_list) == 0: error_message = "Unable to identify cluster {0}".format(_cluster_name) log.error(error_message) raise WebPublicReaderError(error_message) result = result_list[0] return cluster_row_template(id=result["id"], name=result["name"], node_count=result["node_count"], replication_level=result["replication_level"])