def getClusterInfo(runner, available_hosts, clearHostCache): # raise execption when failed to connect response = runner.call_proc('@SystemInformation', [VOLT.FastSerializer.VOLTTYPE_STRING], ['OVERVIEW'], True, None, True) if response.response.status != 1: return None; if clearHostCache: available_hosts[:] = [] # Convert @SystemInformation results to objects. hosts = Hosts(runner.abort) for tuple in response.table(0).tuples(): hosts.update(tuple[0], tuple[1], tuple[2]) for hostId, hostInfo in hosts.hosts_by_id.items(): if hostInfo.hostname not in available_hosts: available_hosts.append(hostInfo.hostname + ":" + str(hostInfo.clientport)) # get current version and root directory from an arbitrary node host = hosts.hosts_by_id.itervalues().next() # ClusterId in @SystemInformation is added in v7.2, so must check the version of target cluster to make it work properly. version = host.version versionStr = version.split('.') majorVersion = int(versionStr[0]) minorVersion = int(versionStr[1]) if majorVersion < RELEASE_MAJOR_VERSION or (majorVersion == RELEASE_MAJOR_VERSION and minorVersion < RELEASE_MINOR_VERSION): runner.abort("Only v7.2 or higher version of VoltDB supports this command. Target cluster running on v" + version + ".") clusterId = host.clusterid fullClusterSize = int(host.fullclustersize) uptime = host.uptime response = runner.call_proc('@SystemInformation', [VOLT.FastSerializer.VOLTTYPE_STRING], ['DEPLOYMENT'], True, None, True) for tuple in response.table(0).tuples(): if tuple[0] == 'kfactor': kfactor = tuple[1] break cluster = Cluster(int(clusterId), version, int(kfactor), int(fullClusterSize), uptime) for hostId, hostInfo in hosts.hosts_by_id.items(): cluster.add_member(hostId, hostInfo.hostname) # number of live clients connect to the cluster try: response = checkstats.get_stats(runner, "LIVECLIENTS") except StatisticsProcedureException as e: runner.info(e.message) sys.exit(e.exitCode) liveclients = 0 for tuple in response.table(0).tuples(): isAdmin = tuple[5] # exclude admin connections if isAdmin != 1: liveclients += 1 cluster.update_live_clients(liveclients) if runner.opts.dr: # Do we have any ongoing DR conversation? try: response = checkstats.get_stats(runner, "DRROLE") except StatisticsProcedureException as e: runner.info(e.message) sys.exit(e.exitCode) for tuple in response.table(0).tuples(): role = tuple[0] status = tuple[1] remote_cluster_id = tuple[2] if (remote_cluster_id != -1): cluster.add_remote_cluster(remote_cluster_id, status, role) try: response = checkstats.get_stats(runner, "DRPRODUCER") except StatisticsProcedureException as e: runner.info(e.message) sys.exit(e.exitCode) for tuple in response.table(0).tuples(): host_name = tuple[2] remote_cluster_id = tuple[4] last_queued_drid = tuple[10] last_queued_ts = tuple[12] last_acked_ts = tuple[13] if last_queued_drid == -1: delay = 0 else: delay = (last_queued_ts - last_acked_ts).total_seconds() cluster.get_remote_cluster(remote_cluster_id).update_producer_latency(host_name, remote_cluster_id, delay) # Find remote topology through drconsumer stats try: response = checkstats.get_stats(runner, "DRCONSUMER") except StatisticsProcedureException as e: runner.info(e.message) sys.exit(e.exitCode) for tuple in response.table(1).tuples(): remote_cluster_id = tuple[4] covering_host = tuple[7] last_applied_ts = tuple[9] if covering_host != '': cluster.get_remote_cluster(remote_cluster_id).add_remote_member(covering_host) return cluster
def getClusterInfo(runner): response = runner.call_proc('@SystemInformation', [VOLT.FastSerializer.VOLTTYPE_STRING], ['OVERVIEW']) # Convert @SystemInformation results to objects. hosts = Hosts(runner.abort) for tuple in response.table(0).tuples(): hosts.update(tuple[0], tuple[1], tuple[2]) # get current version and root directory from an arbitrary node host = hosts.hosts_by_id.itervalues().next() clusterId = host.clusterid fullClusterSize = int(host.fullclustersize) version = host.version uptime = host.uptime response = runner.call_proc('@SystemInformation', [VOLT.FastSerializer.VOLTTYPE_STRING], ['DEPLOYMENT']) for tuple in response.table(0).tuples(): if tuple[0] == 'kfactor': kfactor = tuple[1] break cluster = Cluster(int(clusterId), version, int(kfactor), int(fullClusterSize), uptime) for hostId, hostInfo in hosts.hosts_by_id.items(): cluster.add_member(hostId, hostInfo.hostname) # number of live clients connect to the cluster response = checkstats.get_stats(runner, "LIVECLIENTS") liveclients = 0 for tuple in response.table(0).tuples(): isAdmin = tuple[5] # exclude admin connections if isAdmin != 1: liveclients += 1 cluster.update_live_clients(liveclients) if runner.opts.dr: # Do we have any ongoing DR conversation? response = checkstats.get_stats(runner, "DRROLE") for tuple in response.table(0).tuples(): role = tuple[0] status = tuple[1] remote_cluster_id = tuple[2] if (remote_cluster_id != -1): cluster.add_remote_cluster(remote_cluster_id, status, role) response = checkstats.get_stats(runner, "DRPRODUCER") for tuple in response.table(0).tuples(): host_name = tuple[2] remote_cluster_id = tuple[4] last_queued_drid = tuple[10] last_queued_ts = tuple[12] last_acked_ts = tuple[13] if last_queued_drid == -1: delay = 0 else: delay = (last_queued_ts - last_acked_ts).total_seconds() cluster.get_remote_cluster( remote_cluster_id).update_producer_latency( host_name, remote_cluster_id, delay) # Find remote topology through drconsumer stats response = checkstats.get_stats(runner, "DRCONSUMER") for tuple in response.table(1).tuples(): remote_cluster_id = tuple[4] covering_host = tuple[7] last_applied_ts = tuple[9] if covering_host != '': cluster.get_remote_cluster( remote_cluster_id).add_remote_member(covering_host) return cluster