Re: how to verify the cached elements in each of partitions

2016-08-16 Thread Alexey Goncharuk
Hi,

If I understand correctly, you want to reduce the total number of
partitions for your cache to 2. Is there any reason you want to do this? It
is impossible to change the number of partitions without the full cluster
restart, so if at some point in time you want to add more nodes to your
cluster, it will be impossible unless you change your configuration and
restart all the nodes.

If this is really what you want, you need to override method "int
partitions()" and return 2 from it (otherwise, as Vladislav mentioned, you
will still have 1024 partitions).
To check that your affinity function works, you can use
ignite.affinity(String cacheName) interface.

2016-08-16 14:48 GMT+03:00 Vladislav Pyatkov :

> Hi,
>
> At first. This method (public int partition(final Object key)) returns
> partition number by key, if you have 1024 partitions it must will be
> returned number between 0 and 1023. Look at the implementation for
> RendezvousAffinityFunction[1].
>
> If you want to understand how partitions distributed by nodes, you can use
> the code snippet:
>
>
> // Getting affinity for person cache.
> Affinity affinity = ignite().affinity(cacheName);
>
> // Building a list of all partitions numbers.
> List rndParts = new ArrayList<>(10);
>
> for (int i = 0; i < affinity.partitions(); i++)
>   rndParts.add(i);
>
> // Getting partition to node mapping.
> Map partPerNodes = affinity.mapPartitionsToNodes(
> rndParts);
>
>
> Amount of entry on node or on partition you can see in 
> cache.localSizeLong(CachePeekMode.ALL)
> and cache.localSizeLong(1, CachePeekMode.ALL) respectively.
>
> [1] org.apache.ignite.cache.affinity.rendezvous.
> RendezvousAffinityFunction#partition
>
> On Tue, Aug 16, 2016 at 7:00 AM, minisoft_rm 
> wrote:
>
>> Hi Experts, i implemented the customised partition thing like below:
>> [
>> public class MattRendezvousAffinityFunction extends
>> RendezvousAffinityFunction
>> {
>>
>> ..
>> public int partition(final Object key){
>>.
>>//return 0 or 1 because I launch two nodes
>> }
>>
>> }
>> ]
>>
>> I feel I already touch the most important part.. now I know the default
>> partitions is 1024.
>> after launched two ignite server node jvms, I expected to see items goto
>> each of partitions in nodes
>>
>> but how to check this thing? (I feel all the items goto the first started
>> node)
>>
>> the "cache -scan" can not show things within one partition... right?
>>
>>
>>
>>
>> --
>> View this message in context: http://apache-ignite-users.705
>> 18.x6.nabble.com/how-to-verify-the-cached-elements-in-each-
>> of-partitions-tp7085.html
>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Vladislav Pyatkov
>


how to verify the cached elements in each of partitions

2016-08-15 Thread minisoft_rm
Hi Experts, i implemented the customised partition thing like below:
[
public class MattRendezvousAffinityFunction extends
RendezvousAffinityFunction
{

..
public int partition(final Object key){
   .
   //return 0 or 1 because I launch two nodes
}

}
]

I feel I already touch the most important part.. now I know the default
partitions is 1024. 
after launched two ignite server node jvms, I expected to see items goto
each of partitions in nodes
 
but how to check this thing? (I feel all the items goto the first started
node)

the "cache -scan" can not show things within one partition... right?




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/how-to-verify-the-cached-elements-in-each-of-partitions-tp7085.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.