Hello,

Please refer to the corresponding documentation section
https://apacheignite.readme.io/docs/affinity-collocation

In short, for your case, just introduce a key class for ClassC like this:

public class ClassCKey {
    private int id;

    // ClassB ID which will be used for affinity.
    @AffinityKeyMapped
    private int idB;
    ...
}


In such a config, ClassB will be a root entity and ClassC will be colocated
with it by means of field idB.

Kind regards,
Alex


25 апр. 2017 г. 12:02 AM пользователь "blasteralfred [via Apache Ignite
Users]" <[email protected]> написал:

Hi,

I have 3 java classes ClassA, ClassB, ClassC.

ClassA{
        int idA;
        String stringA;
        public ClassA(){}
        public ClassA(int idA,String stringA){
                this.idA=idA;
                this.stringA=stringA;
        }
        public int getidA(){
                return idA;
        }
        public String getstringA(){
                return stringA;
        }
}

ClassB{
        int idB;
        String stringB;
        public ClassB(){}
        public ClassB(int idB,String stringB){
                this.idB=idB;
                this.stringB=stringB;
        }
        public int getidB(){
                return idB;
        }
        public String getstringB(){
                return stringB;
        }
}

ClassC{
        int idC,idB;
        String stringC;
        public ClassC(){}
        public ClassB(int idB,int idC,String stringC){
                this.idC=idC;
                this.stringC=stringC;
        }
        public int getidC(){
                return idC;
        }
        public String getstringC(){
                return stringC;
        }
}

I want ClassA in replicated mode and B & C in partitioned mode. ClassC is
related to ClassB. The id of ClassB is present in ClassC (acting like a
foreign key). Say, I have 3 nodes, 30 ClassA objects, 30 ClassB objects and
30 ClassC objects. They are distributed in nodes like below;

Node 1 => ClassA->30, ClassB->10,ClassC->8
Node 2 => ClassA->30, ClassB->5,ClassC->3
Node 3 => ClassA->30, ClassB->15,ClassC->19

Objects of ClassC related to ClassB should present in same node. I know
that there is some mechanism AffinityKey, but I don't know how to implement
this. Could somebody tell me how to do this?

Thanks in advance..

------------------------------
If you reply to this email, your message will be added to the discussion
below:
http://apache-ignite-users.70518.x6.nabble.com/How-to-create
-class-affinity-tp12211.html
To start a new topic under Apache Ignite Users, email
[email protected]
To unsubscribe from Apache Ignite Users, click here
<http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=YWxleGFuZGVyLmZlZG90b2ZmQGdtYWlsLmNvbXwxfC0xMzYxNTU0NTg=>
.
NAML
<http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/How-to-create-class-affinity-tp12211p12214.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to