Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AB7B89C61 for ; Mon, 13 Feb 2012 20:25:24 +0000 (UTC) Received: (qmail 59129 invoked by uid 500); 13 Feb 2012 20:25:24 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 59009 invoked by uid 500); 13 Feb 2012 20:25:23 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 58863 invoked by uid 99); 13 Feb 2012 20:25:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2012 20:25:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2012 20:25:20 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id BD6071B4828 for ; Mon, 13 Feb 2012 20:24:59 +0000 (UTC) Date: Mon, 13 Feb 2012 20:24:59 +0000 (UTC) From: "Peter Schuller (Commented) (JIRA)" To: commits@cassandra.apache.org Message-ID: <1096112828.33264.1329164699777.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <2103209779.25767.1319739752526.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CASSANDRA-3412) make nodetool ring ownership smarter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CASSANDRA-3412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13207169#comment-13207169 ] Peter Schuller commented on CASSANDRA-3412: ------------------------------------------- Our internal tool (external, in python, based on describe_ring) simply uses {{describe_ring}} and looks at each range and their responsible nodes and just adds them all up. The ownership we report for a node is the total amount of ringspace (regardless of primary/secondary/dc/etc concerns) that the node has, compared to the overall total. It ends up giving you the real number while completely blackboxing "why" we got there - whether it be due to rack awareness (CASSANDRA-3810) or DC:s. FWIW, here is the code for that. It's not self-contained and won't run, but it's an FYI. The topology_xref is just post-processing the describe ring results to yield the map of range -> nodes_responsible. {code} def cmd_effective_ownership(opts, args): """ Print effective ownership of nodes in a cluster. Effective ownership means the actual amount of the ring for which it has data, whether or not it is because it is the primary or secondary (etc) owner of the ring segment. This is essentially the ownership you would want "nodetool ring" to print but doesn't. """ if not args and not opts.all: return node_ranges, range_nodes = topology_xref(describe_ring(*((opts,) + split_hostport(seed(opts, 'localhost') if opts.all else args[0])))) if opts.all: args = node_ranges.keys() # acrobatics to handle wrap-around max_token = 0 min_token = 2**127 for r in range_nodes.keys(): if r[0] < min_token: min_token = r[0] if r[1] > max_token: max_token = r[1] def ownership(start_token, end_token): start_token, end_token = int(start_token), int(end_token) if end_token < start_token: # wrap-around return end_token + (2**127 - start_token) else: return end_token - start_token toprint = [] # list of (owned, ranges), later to be sorted for node in (hostnames.normalize_hostname(arg) for arg in args): if not node in node_ranges: raise cmdline.UserError('node %s not in ring' % (node,)) ranges = node_ranges[node] owned = reduce(lambda a, b: a + b, [ownership(r[0], r[1]) for r in ranges], 0) toprint.append((owned, node, ranges)) toprint = sorted(toprint, reverse=True) for owned, node, ranges in toprint: print '%s %f%%' % (node, float(owned) / 2**127 * 100.0) if opts.print_ranges: for r in sorted(ranges): print ' %s - %s' % (r[0], r[1]) {code} > make nodetool ring ownership smarter > ------------------------------------ > > Key: CASSANDRA-3412 > URL: https://issues.apache.org/jira/browse/CASSANDRA-3412 > Project: Cassandra > Issue Type: Improvement > Reporter: Jackson Chung > Assignee: Vijay > Priority: Minor > > just a thought.. the ownership info currently just look at the token and calculate the % between nodes. It would be nice if it could do more, such as discriminate nodes of each DC, replica set, etc. > ticket is open for suggestion... -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira