You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Siddharth Verma <ve...@snapdeal.com> on 2016/08/29 22:32:31 UTC

Output of "select token from system.local where key = 'local' "

Hi,
Could someone help me understand the output of the following command
select token from system.local where key = 'local';
I guess, it shows a set of tokens,
How to interpret the primary token range owned by that particular node.

Sample output
{'-1035756551821816651', '-108957861241888777', '-1161596540795301922',
'-1276292043371991260', '-1293596438649823880', '-1330135818805258847',
'-136426632202581848', '-1409818867186360151', '-1533033009849766669',
'-1564907174894655878', '-1584647395198498348', '-1702206275259837746',
'-1721442595839036207', '-1805584913850385618', '-1864431424606939975',
'-1873848383432337211', '-1892654073052562380', '-2186290790906441332',
'-2186765238750288172', '-2197833544080563919', '-2312633922078117403',
'-2321320265233112691', '-2335956594377837445', '-2424911379303247410',
'-2532940572807108582', '-2572328989390771083', '-2612671610689977935',
'-2657900505769917971', '-2668909558831926811', '-279614115829924150',
'-2839022628456081845', '-2846881115962038911', '-2958124669955869073',
'-2992921216980560418', '-3678390348748264779', '-3684161849039614282',
'-3741232934292837535', '-3750954137388291628', '-3850140265242652809',
'-390010538110574579', '-4006306392709442561', '-4116783191966874716',
'-4316647765096897458', '-4356479172530739420', '-4372885117468910019',
'-4430889521235204154', '-4437658536127203648', '-4449209854113393087',
'-4543800863152083575', '-464297196288632984', '-4675074910073273256',
'-472580274354546852', '-4803278065373034864', '-4891618505890184648',
'-5091755919537009887', '-5151733595633610320', '-5268682788952206789',
'-5271711096972641214', '-5287499067302592080', '-5446718207129372966',
'-5489806965344233323', '-5490969110222376134', '-5510190605911483781',
'-5669108101279850080', '-5686191990261733236', '-5689717024133766607',
'-5691837460073026784', '-5746782609172300685', '-5768034391503746031',
'-577475144444747349', '-5875011074928680620', '-6071594375278915419',
'-6307700444039401317', '-6321240651038322332', '-6348627710614231587',
'-6361547358222908818', '-6376152739505164772', '-6471829637466047434',
'-6502967463429252258', '-6576959520352130505', '-6585378589663405235',
'-6621564305305055308', '-674159849250112581', '-6822398617376794170',
'-68803457508331064', '-6891828170629316670', '-6937113203723614760',
'-7004485253683484902', '-7255858186450616047', '-7351191457877543012',
'-7371417393033639437', '-7375915128210118147', '-7404208421239468681',
'-7423157133479664610', '-7571238711655130339', '-7700969462542547675',
'-773578924173999990', '-7852790646279178741', '-7882833842177674281',
'-7921706136406335031', '-7933429097890809487', '-7947983739628530349',
'-7948911196844668395', '-8037977208125589093', '-8097363893556012177',
'-825973782834131237', '-8261844733517170405', '-8434459356828346480',
'-8680582999674568959', '-871968420768755006', '-8777679998035197588',
'-8782836903565526640', '-8783714708689576666', '-8849823838450650295',
'-8966883282909722537', '-9091305238842852755', '-9151804468236791735',
'-9158270917401751838', '-9199054268853034612', '-919907064118614842',
'-9204547573912250796', '-951679945181697829', '1050816873688171372',
'1082619590543587528', '1316647095040185085', '1350651239261814856',
'1365355242516180612', '1504521861455250655', '1553118105533398541',
'1687906499655724513', '170156827106725047', '1841283172375517094',
'1934120555771435337', '1950218111279487888', '1951000088547509323',
'1958397784843795789', '199907967323860791', '2093879466073397262',
'2223181706166154558', '2346060431217227894', '2364536724234068419',
'2382591925891908896', '2429124684884597938', '244430838142896474',
'244925668410340093', '2485346011674373180', '2626282359632995454',
'2693462343040966729', '2718655143471808670', '2765243990793471492',
'2789661355953551747', '2792656114228506892', '2875065064454847186',
'2877658606936819232', '3115127498698455075', '3171221149125308871',
'3204314794520771859', '3225785212981795464', '328177243900091789',
'3344530729414517347', '3345238149336998459', '3502198757183164466',
'351101769587756802', '3588504874207249607', '3606382180043621196',
'3687903264019113607', '3808573696234663432', '3826930999611830586',
'3937594202513320004', '3991573227385747358', '4049586397706206888',
'4113277683763393618', '4133779736724357706', '436041502200834273',
'4409977876499706529', '4501676578785778929', '4542194500781241332',
'457304378229441003', '4625447288380261317', '4635627349070688401',
'4653117816344136666', '4684783897201143715', '4718159652990403843',
'4774133625331605257', '4830998188269931348', '4910055390341907857',
'4998500558397491684', '5023943523343001536', '505744292693224967',
'5162320571738032500', '5277396368371480274', '5346830336223723812',
'5360976982928138315', '5415193046016833300', '5420351854649967783',
'551728115923760971', '5611031614377902472', '564955142261319773',
'5741673630415265730', '5765467955391572803', '5777120745629762657',
'5911733864168126799', '5963370543879046708', '601095846312433394',
'6025232037324913724', '6124999964281122209', '6130180990267145790',
'614044759087911080', '615625082046151174', '6204536250349648494',
'6254832987275160383', '6299420497233402212', '6330219643037606275',
'6332166655931126455', '649843146990783793', '6546360696742228459',
'6667173768996479693', '6681703316740595756', '6700409845144118031',
'6768174919292984477', '6993240335038495953', '699592662848728421',
'7067614760768641586', '7464549774220819665', '7470203399706056435',
'7517126645125886173', '75179143059671689', '7532146377366822000',
'7668359789169421370', '7693365598138379140', '7693612576353655751',
'771781371808055068', '773878061649801356', '7949652196530716229',
'8101045330184519696', '8131531126072838629', '8140361357245000979',
'8302292937826438542', '8422369105285792829', '8449836158927214743',
'8499955449276612349', '850192426321138914', '8605431687486711156',
'8678800982435339567', '8687105151647096442', '8776316423500407040',
'8953364009441747611', '8979834615817990709', '8984590311736053933',
'9069513190093258312', '9080235839310378242', '9098260908744107307',
'9102600462020381711', '938833944614881458', '987385371860069729',
'990370821724370771'}


Thanks,
Siddharth Verma

Re: Output of "select token from system.local where key = 'local' "

Posted by Alexander DEJANOVSKI <ad...@gmail.com>.
To be thorough, token ranges do not overlap per DC. Ranges in different DCs
do overlap as the token distribution is different.

Le mer. 31 août 2016 10:51, Moshe Levy <lg...@nemesis.co.il> a écrit :

>
>
>  .
> P
>
> On Wednesday, 31 August 2016, Alexander DEJANOVSKI <ad...@gmail.com>
> wrote:
>
>> Hi Siddharth,
>>
>> yes, we are sure token ranges will never overlap (I think the start token
>> in describering output is excluded and the end token included).
>>
>> You can get per host information in the Datastax Java driver using :
>>
>> Set<TokenRange> rangesForKeyspace =  cluster.getMetadata()
>> .getTokenRanges(keyspaceName, host);
>> Bye,
>>
>> Alex
>>
>> Le mar. 30 août 2016 à 10:04, Siddharth Verma <
>> verma.siddharth@snapdeal.com> a écrit :
>>
>>> Hi ,
>>> Can we be sure that, token ranges in nodetool describering will be non
>>> overlapping?
>>>
>>> Thanks
>>> Siddharth Verma
>>>
>>

Re: Output of "select token from system.local where key = 'local' "

Posted by Moshe Levy <lg...@nemesis.co.il>.
 .
P
On Wednesday, 31 August 2016, Alexander DEJANOVSKI <ad...@gmail.com>
wrote:

> Hi Siddharth,
>
> yes, we are sure token ranges will never overlap (I think the start token
> in describering output is excluded and the end token included).
>
> You can get per host information in the Datastax Java driver using :
>
> Set<TokenRange> rangesForKeyspace =  cluster.getMetadata().getTokenRanges(
> keyspaceName, host);
> Bye,
>
> Alex
>
> Le mar. 30 août 2016 à 10:04, Siddharth Verma <
> verma.siddharth@snapdeal.com
> <javascript:_e(%7B%7D,'cvml','verma.siddharth@snapdeal.com');>> a écrit :
>
>> Hi ,
>> Can we be sure that, token ranges in nodetool describering will be non
>> overlapping?
>>
>> Thanks
>> Siddharth Verma
>>
>

Re: Output of "select token from system.local where key = 'local' "

Posted by Alexander DEJANOVSKI <ad...@gmail.com>.
Hi Siddharth,

yes, we are sure token ranges will never overlap (I think the start token
in describering output is excluded and the end token included).

You can get per host information in the Datastax Java driver using :

Set<TokenRange> rangesForKeyspace =  cluster.getMetadata().getTokenRanges(
keyspaceName, host);
Bye,

Alex

Le mar. 30 août 2016 à 10:04, Siddharth Verma <ve...@snapdeal.com>
a écrit :

> Hi ,
> Can we be sure that, token ranges in nodetool describering will be non
> overlapping?
>
> Thanks
> Siddharth Verma
>

Re: Output of "select token from system.local where key = 'local' "

Posted by Siddharth Verma <ve...@snapdeal.com>.
Hi ,
Can we be sure that, token ranges in nodetool describering will be non
overlapping?

Thanks
Siddharth Verma

Re: Output of "select token from system.local where key = 'local' "

Posted by Siddharth Verma <ve...@snapdeal.com>.
Hi Alex,
Thanks for your reply.
I saw describering yesterday, but didn't know "the first endpoint being the
primary". Thanks for that.
Is there anyway to get the same information in application?
If there isn't any way to get the same information at application layer, I
would be using this as a backup.

Siddharth Verma

Re: Output of "select token from system.local where key = 'local' "

Posted by Alexander DEJANOVSKI <ad...@gmail.com>.
Hi Siddarth,

I would recommend running "nodetool describering keyspace_name" as its
output is much simpler to reason about :

Schema Version:9a091b4e-3712-3149-b187-d2b09250a19b

TokenRange:

TokenRange(start_token:1943978523300203561, end_token:2137919499801737315,
endpoints:[127.0.0.3, 127.0.0.6, 127.0.0.7, 127.0.0.2, 127.0.0.5,
127.0.0.1], rpc_endpoints:[127.0.0.3, 127.0.0.6, 127.0.0.7, 127.0.0.2,
127.0.0.5, 127.0.0.1], endpoint_details:[EndpointDetails(host:127.0.0.3,
datacenter:dc1, rack:r1), EndpointDetails(host:127.0.0.6, datacenter:dc2,
rack:r1), EndpointDetails(host:127.0.0.7, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.2, datacenter:dc1, rack:r1),
EndpointDetails(host:127.0.0.5, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.1, datacenter:dc1, rack:r1)])

TokenRange(start_token:6451470843510300950, end_token:7799236518897713874,
endpoints:[127.0.0.6, 127.0.0.4, 127.0.0.1, 127.0.0.3, 127.0.0.5,
127.0.0.2], rpc_endpoints:[127.0.0.6, 127.0.0.4, 127.0.0.1, 127.0.0.3,
127.0.0.5, 127.0.0.2], endpoint_details:[EndpointDetails(host:127.0.0.6,
datacenter:dc2, rack:r1), EndpointDetails(host:127.0.0.4, datacenter:dc2,
rack:r1), EndpointDetails(host:127.0.0.1, datacenter:dc1, rack:r1),
EndpointDetails(host:127.0.0.3, datacenter:dc1, rack:r1),
EndpointDetails(host:127.0.0.5, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.2, datacenter:dc1, rack:r1)])

TokenRange(start_token:-2494488779943368698,
end_token:-2344803022847488784, endpoints:[127.0.0.1, 127.0.0.4, 127.0.0.6,
127.0.0.5, 127.0.0.3, 127.0.0.2], rpc_endpoints:[127.0.0.1, 127.0.0.4,
127.0.0.6, 127.0.0.5, 127.0.0.3, 127.0.0.2],
endpoint_details:[EndpointDetails(host:127.0.0.1, datacenter:dc1, rack:r1),
EndpointDetails(host:127.0.0.4, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.6, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.5, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.3, datacenter:dc1, rack:r1),
EndpointDetails(host:127.0.0.2, datacenter:dc1, rack:r1)])

TokenRange(start_token:-3354341409828719744,
end_token:-3001704612215276412, endpoints:[127.0.0.7, 127.0.0.1, 127.0.0.4,
127.0.0.6, 127.0.0.3, 127.0.0.2], rpc_endpoints:[127.0.0.7, 127.0.0.1,
127.0.0.4, 127.0.0.6, 127.0.0.3, 127.0.0.2],
endpoint_details:[EndpointDetails(host:127.0.0.7, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.1, datacenter:dc1, rack:r1),
EndpointDetails(host:127.0.0.4, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.6, datacenter:dc2, rack:r1),
EndpointDetails(host:127.0.0.3, datacenter:dc1, rack:r1),
EndpointDetails(host:127.0.0.2, datacenter:dc1, rack:r1)])


It will give you the start and end token of each range (vnode) and the list
of the replicas for each (the first endpoint being the primary).

Hope this helps you figuring out your token distribution.

Alex

Le mar. 30 août 2016 à 09:11, Siddharth Verma <ve...@snapdeal.com>
a écrit :

> Hi,
> I saw that in cassandra-driver-core,(3.1.0) Metadata.TokenMap has
> primaryToTokens which has the value for ALL the nodes.
> I tried to find (primary)range ownership for nodes in one DC.
> And executed the following in debug mode in IDE.
>
> TreeMap<Long,Host> primaryTokenMap = new TreeMap<>();
> for(Host host :
> main.cluster.getMetadata().tokenMap.primaryToTokens.keySet()){
>     if(!host.getDatacenter().equals("dc2"))
>         continue;
>     for(Token token :
> main.cluster.getMetadata().tokenMap.primaryToTokens.get(host)){
>         primaryTokenMap.put((Long) token.getValue(),host);
>
>     }
> }
> primaryTokenMap //this printed the map in evaluate code fragment window
>
> dc2 has 3 nodes, RF is 3
> Sample entries :
> 244925668410340093 -> /10.0.3.79:9042
> 291047688656337660 -> /10.0.3.217:9042
> 317775761591844910 -> /10.0.3.135:9042
> 328177243900091789 -> /10.0.3.79:9042
> 329239043633655596 -> /10.0.3.135:9042
> ....
>
> Can I safely assume
> Token
> Range
> Host
> 244925668410340093 to 291047688656337660 -1 belongs to 10.0.3.79:9042
> 291047688656337660 to 317775761591844910 -1 belongs to 10.0.3.135:9042
> 317775761591844910 to 328177243900091789 -1 belongs to 10.0.3.135:9042
> And so on.
>
> Is the above assumption ABSOLUTELY correct?
> (Kindly suggest changes/errors, if any)
>
> Any help would be great.
> Thanks and Regards,
> Siddharth Verma
>

Re: Output of "select token from system.local where key = 'local' "

Posted by Siddharth Verma <ve...@snapdeal.com>.
Hi,
I saw that in cassandra-driver-core,(3.1.0) Metadata.TokenMap has
primaryToTokens which has the value for ALL the nodes.
I tried to find (primary)range ownership for nodes in one DC.
And executed the following in debug mode in IDE.

TreeMap<Long,Host> primaryTokenMap = new TreeMap<>();
for(Host host :
main.cluster.getMetadata().tokenMap.primaryToTokens.keySet()){
    if(!host.getDatacenter().equals("dc2"))
        continue;
    for(Token token :
main.cluster.getMetadata().tokenMap.primaryToTokens.get(host)){
        primaryTokenMap.put((Long) token.getValue(),host);

    }
}
primaryTokenMap //this printed the map in evaluate code fragment window

dc2 has 3 nodes, RF is 3
Sample entries :
244925668410340093 -> /10.0.3.79:9042
291047688656337660 -> /10.0.3.217:9042
317775761591844910 -> /10.0.3.135:9042
328177243900091789 -> /10.0.3.79:9042
329239043633655596 -> /10.0.3.135:9042
....

Can I safely assume
Token
Range
Host
244925668410340093 to 291047688656337660 -1 belongs to 10.0.3.79:9042
291047688656337660 to 317775761591844910 -1 belongs to 10.0.3.135:9042
317775761591844910 to 328177243900091789 -1 belongs to 10.0.3.135:9042
And so on.

Is the above assumption ABSOLUTELY correct?
(Kindly suggest changes/errors, if any)

Any help would be great.
Thanks and Regards,
Siddharth Verma

Re: Output of "select token from system.local where key = 'local' "

Posted by Siddharth Verma <ve...@snapdeal.com>.
Hi Eric,
Thanks for your reply.
I know about V nodes, and token ownership.
If I want to find the token range, how do i do that from this data?
For eg, the 1st entry is -1035756551821816651. which range is it, i.e. is
this the start/end, and how to find the other extremity of this range.

Thanks,
Siddharth Verma

Re: Output of "select token from system.local where key = 'local' "

Posted by Eric Zietlow <er...@datastax.com>.
Siddharth,

This is the tokens assigned to your local node.  It looks from this that
you have 256 vnodes set.  The system.local only stored information on the
local node.

Thanks,

Eric Zietlow

On Mon, Aug 29, 2016 at 5:32 PM, Siddharth Verma <
verma.siddharth@snapdeal.com> wrote:

> Hi,
> Could someone help me understand the output of the following command
> select token from system.local where key = 'local';
> I guess, it shows a set of tokens,
> How to interpret the primary token range owned by that particular node.
>
> Sample output
> {'-1035756551821816651', '-108957861241888777', '-1161596540795301922',
> '-1276292043371991260', '-1293596438649823880', '-1330135818805258847',
> '-136426632202581848', '-1409818867186360151', '-1533033009849766669',
> '-1564907174894655878', '-1584647395198498348', '-1702206275259837746',
> '-1721442595839036207', '-1805584913850385618', '-1864431424606939975',
> '-1873848383432337211', '-1892654073052562380', '-2186290790906441332',
> '-2186765238750288172', '-2197833544080563919', '-2312633922078117403',
> '-2321320265233112691', '-2335956594377837445', '-2424911379303247410',
> '-2532940572807108582', '-2572328989390771083', '-2612671610689977935',
> '-2657900505769917971', '-2668909558831926811', '-279614115829924150',
> '-2839022628456081845', '-2846881115962038911', '-2958124669955869073',
> '-2992921216980560418', '-3678390348748264779', '-3684161849039614282',
> '-3741232934292837535', '-3750954137388291628', '-3850140265242652809',
> '-390010538110574579', '-4006306392709442561', '-4116783191966874716',
> '-4316647765096897458', '-4356479172530739420', '-4372885117468910019',
> '-4430889521235204154', '-4437658536127203648', '-4449209854113393087',
> '-4543800863152083575', '-464297196288632984', '-4675074910073273256',
> '-472580274354546852', '-4803278065373034864', '-4891618505890184648',
> '-5091755919537009887', '-5151733595633610320', '-5268682788952206789',
> '-5271711096972641214', '-5287499067302592080', '-5446718207129372966',
> '-5489806965344233323', '-5490969110222376134', '-5510190605911483781',
> '-5669108101279850080', '-5686191990261733236', '-5689717024133766607',
> '-5691837460073026784', '-5746782609172300685', '-5768034391503746031',
> '-577475144444747349', '-5875011074928680620', '-6071594375278915419',
> '-6307700444039401317', '-6321240651038322332', '-6348627710614231587',
> '-6361547358222908818', '-6376152739505164772', '-6471829637466047434',
> '-6502967463429252258', '-6576959520352130505', '-6585378589663405235',
> '-6621564305305055308', '-674159849250112581', '-6822398617376794170',
> '-68803457508331064', '-6891828170629316670', '-6937113203723614760',
> '-7004485253683484902', '-7255858186450616047', '-7351191457877543012',
> '-7371417393033639437', '-7375915128210118147', '-7404208421239468681',
> '-7423157133479664610', '-7571238711655130339', '-7700969462542547675',
> '-773578924173999990', '-7852790646279178741', '-7882833842177674281',
> '-7921706136406335031', '-7933429097890809487', '-7947983739628530349',
> '-7948911196844668395', '-8037977208125589093', '-8097363893556012177',
> '-825973782834131237', '-8261844733517170405', '-8434459356828346480',
> '-8680582999674568959', '-871968420768755006', '-8777679998035197588',
> '-8782836903565526640', '-8783714708689576666', '-8849823838450650295',
> '-8966883282909722537', '-9091305238842852755', '-9151804468236791735',
> '-9158270917401751838', '-9199054268853034612', '-919907064118614842',
> '-9204547573912250796', '-951679945181697829', '1050816873688171372',
> '1082619590543587528', '1316647095040185085', '1350651239261814856',
> '1365355242516180612', '1504521861455250655', '1553118105533398541',
> '1687906499655724513', '170156827106725047', '1841283172375517094',
> '1934120555771435337', '1950218111279487888', '1951000088547509323',
> '1958397784843795789', '199907967323860791', '2093879466073397262',
> '2223181706166154558', '2346060431217227894', '2364536724234068419',
> '2382591925891908896', '2429124684884597938', '244430838142896474',
> '244925668410340093', '2485346011674373180', '2626282359632995454',
> '2693462343040966729', '2718655143471808670', '2765243990793471492',
> '2789661355953551747', '2792656114228506892', '2875065064454847186',
> '2877658606936819232', '3115127498698455075', '3171221149125308871',
> '3204314794520771859', '3225785212981795464', '328177243900091789',
> '3344530729414517347', '3345238149336998459', '3502198757183164466',
> '351101769587756802', '3588504874207249607', '3606382180043621196',
> '3687903264019113607', '3808573696234663432', '3826930999611830586',
> '3937594202513320004', '3991573227385747358', '4049586397706206888',
> '4113277683763393618', '4133779736724357706', '436041502200834273',
> '4409977876499706529', '4501676578785778929', '4542194500781241332',
> '457304378229441003', '4625447288380261317', '4635627349070688401',
> '4653117816344136666', '4684783897201143715', '4718159652990403843',
> '4774133625331605257', '4830998188269931348', '4910055390341907857',
> '4998500558397491684', '5023943523343001536', '505744292693224967',
> '5162320571738032500', '5277396368371480274', '5346830336223723812',
> '5360976982928138315', '5415193046016833300', '5420351854649967783',
> '551728115923760971', '5611031614377902472', '564955142261319773',
> '5741673630415265730', '5765467955391572803', '5777120745629762657',
> '5911733864168126799', '5963370543879046708', '601095846312433394',
> '6025232037324913724', '6124999964281122209', '6130180990267145790',
> '614044759087911080', '615625082046151174', '6204536250349648494',
> '6254832987275160383', '6299420497233402212', '6330219643037606275',
> '6332166655931126455', '649843146990783793', '6546360696742228459',
> '6667173768996479693', '6681703316740595756', '6700409845144118031',
> '6768174919292984477', '6993240335038495953', '699592662848728421',
> '7067614760768641586', '7464549774220819665', '7470203399706056435',
> '7517126645125886173', '75179143059671689', '7532146377366822000',
> '7668359789169421370', '7693365598138379140', '7693612576353655751',
> '771781371808055068', '773878061649801356', '7949652196530716229',
> '8101045330184519696', '8131531126072838629', '8140361357245000979',
> '8302292937826438542', '8422369105285792829', '8449836158927214743',
> '8499955449276612349', '850192426321138914', '8605431687486711156',
> '8678800982435339567', '8687105151647096442', '8776316423500407040',
> '8953364009441747611', '8979834615817990709', '8984590311736053933',
> '9069513190093258312', '9080235839310378242', '9098260908744107307',
> '9102600462020381711', '938833944614881458', '987385371860069729',
> '990370821724370771'}
>
>
> Thanks,
> Siddharth Verma
>



-- 
*Eric Zietlow*
*Solutions Architect - DataStax*