You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by James Dodson <ji...@gmail.com> on 2018/10/05 18:30:43 UTC

Affinity quesions

If I have something like:
class HouseKey {

    @QuerySqlField(index = true)
    Long id

    @AffinityKeyMapped
    @QuerySqlField
    Short ownerId
}

and

class CarKey {

    @QuerySqlField(index = true)
    Long id

    @AffinityKeyMapped
    @QuerySqlField
    Short ownerId

}

and define my caches like

cacheConfiguration.setIndexedTypes(HouseKey, House)

cacheConfiguration.setIndexedTypes(CarKey, Car)

is that enough to ensure new Cars and Houses are stored on the same
nodes if their ownerIds are the same?

Or do I need to create an Owner class with ownerId field and store it first?

Re: Affinity quesions

Posted by Pavel Vinokurov <vi...@gmail.com>.
James,

Please pay attention to the following query configuration method
Query#setLocal(true). It allows to return records located on only local
node.
Following code block iterates through cache entries located on each server
node:

ignite.compute(ignite.cluster().forServers()).broadcast(new IgniteRunnable() {
    @Override public void run() {
        Ignite local = Ignition.localIgnite();

        System.out.println("Ignite node:"+local.cluster().localNode().id());

        IgniteCache cache = local.cache("cache");

        QueryCursor query = cache.query(new ScanQuery().setLocal(true));

        Iterator it = query.iterator();
        while (it.hasNext()){
            //iterate through local entities
        }
    }
});


пт, 5 окт. 2018 г. в 22:45, James Dodson <ji...@gmail.com>:

> Thanks Val.
> Is there a way I can verify this behavior - a way to query one node in
> particular to see what data is on each node?
>
> On Fri, Oct 5, 2018 at 2:04 PM vkulichenko <va...@gmail.com>
> wrote:
>
>> James,
>>
>> That would be enough - everything with the same affinity key will be
>> stored
>> on the same node. That's assuming, of course, that both caches have equal
>> affinity configuration (same affinity function, same number of partitions,
>> etc.).
>>
>> -Val
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>

-- 

Regards

Pavel Vinokurov

Re: Affinity quesions

Posted by James Dodson <ji...@gmail.com>.
Thanks Val.
Is there a way I can verify this behavior - a way to query one node in
particular to see what data is on each node?

On Fri, Oct 5, 2018 at 2:04 PM vkulichenko <va...@gmail.com>
wrote:

> James,
>
> That would be enough - everything with the same affinity key will be stored
> on the same node. That's assuming, of course, that both caches have equal
> affinity configuration (same affinity function, same number of partitions,
> etc.).
>
> -Val
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Affinity quesions

Posted by vkulichenko <va...@gmail.com>.
James,

That would be enough - everything with the same affinity key will be stored
on the same node. That's assuming, of course, that both caches have equal
affinity configuration (same affinity function, same number of partitions,
etc.).

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/