You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Prakrati Agrawal <Pr...@mu-sigma.com> on 2012/06/05 12:37:42 UTC

How to include two nodes in Java code using Hector

Dear all

I am using a two node Cassandra cluster. How do I code in Java using Hector to get data from both the nodes. Please help

Thanks and Regards

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com


________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

Re: How to include two nodes in Java code using Hector

Posted by aaron morton <aa...@thelastpickle.com>.
The client does not have to know where the data is, thats what the cluster works out see http://www.datastax.com/docs/1.0/cluster_architecture/about_client_requests

> Now I have decommissioned a node but now I don't know how to recommission it .Please help me
http://www.datastax.com/docs/1.0/operations/cluster_management

Cheers

-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com

On 6/06/2012, at 6:12 PM, Prakrati Agrawal wrote:

> Thank you for the reply.
> Now I have decommissioned a node but now I don't know how to recommission it .Please help me
> 
> Thanks and Regards
> 
> Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com
> 
> -----Original Message-----
> From: Roshni Rajagopal [mailto:Roshni.Rajagopal@wal-mart.com]
> Sent: Wednesday, June 06, 2012 11:42 AM
> To: user@cassandra.apache.org
> Subject: Re: How to include two nodes in Java code using Hector
> 
> 
> 
> In Hector when you create a cluster using the API, you specify an IP address & cluster name. Thereafter internally which node serves the request or how many nodes need to be contacted to read/write data depends on the cluster configuration i.e. Whats your replication strategy, factor, consistency levels for the col family , how many nodes are there in the ring etc. So you don't individually need to connect to each node via Hector client. Once you connect to the cluster & keyspace, via any IP add of any node in the cluster, when you make Hector calls to read/write data, it would automatically figure out the node level details and carry out the task. You won't get 50% of the data, you will get all data.
> 
> 
> Also when you remove a node, your data will be unavailable ONLY if you don't have it available in some other node as a replica..
> 
> 
> Regards,
> 
> 
> From: Prakrati Agrawal <Pr...@mu-sigma.com>>
> Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
> Date: Tue, 5 Jun 2012 20:05:21 -0700
> To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
> Subject: RE: How to include two nodes in Java code using Hector
> 
> But the data is distributed on the nodes ( meaning 50% of data is on one node and 50% of data is on another node) so I need to specify the node ip address somewhere in the code. But where do I specify that is what I am clueless about. Please help me
> 
> Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com
> 
> From: Harshvardhan Ojha [mailto:Harshvardhan.Ojha@makemytrip.com]
> Sent: Tuesday, June 05, 2012 5:51 PM
> To: user@cassandra.apache.org<ma...@cassandra.apache.org>
> Subject: RE: How to include two nodes in Java code using Hector
> 
> Use Consistency Level =2.
> 
> Regards
> Harsh
> 
> From: Prakrati Agrawal [mailto:Prakrati.Agrawal@mu-sigma.com]
> Sent: Tuesday, June 05, 2012 4:08 PM
> To: user@cassandra.apache.org<ma...@cassandra.apache.org>
> Subject: How to include two nodes in Java code using Hector
> 
> Dear all
> 
> I am using a two node Cassandra cluster. How do I code in Java using Hector to get data from both the nodes. Please help
> 
> Thanks and Regards
> 
> Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com<http://www.mu-sigma.com>
> 
> 
> ________________________________
> This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.
> 
> Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.
> 
> ________________________________
> This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.
> 
> Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.
> 
> This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***
> 
> This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.
> 
> Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.


RE: How to include two nodes in Java code using Hector

Posted by Prakrati Agrawal <Pr...@mu-sigma.com>.
Thank you for the reply.
Now I have decommissioned a node but now I don't know how to recommission it .Please help me

Thanks and Regards

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com

-----Original Message-----
From: Roshni Rajagopal [mailto:Roshni.Rajagopal@wal-mart.com]
Sent: Wednesday, June 06, 2012 11:42 AM
To: user@cassandra.apache.org
Subject: Re: How to include two nodes in Java code using Hector



In Hector when you create a cluster using the API, you specify an IP address & cluster name. Thereafter internally which node serves the request or how many nodes need to be contacted to read/write data depends on the cluster configuration i.e. Whats your replication strategy, factor, consistency levels for the col family , how many nodes are there in the ring etc. So you don't individually need to connect to each node via Hector client. Once you connect to the cluster & keyspace, via any IP add of any node in the cluster, when you make Hector calls to read/write data, it would automatically figure out the node level details and carry out the task. You won't get 50% of the data, you will get all data.


Also when you remove a node, your data will be unavailable ONLY if you don't have it available in some other node as a replica..


Regards,


From: Prakrati Agrawal <Pr...@mu-sigma.com>>
Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Date: Tue, 5 Jun 2012 20:05:21 -0700
To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Subject: RE: How to include two nodes in Java code using Hector

But the data is distributed on the nodes ( meaning 50% of data is on one node and 50% of data is on another node) so I need to specify the node ip address somewhere in the code. But where do I specify that is what I am clueless about. Please help me

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com

From: Harshvardhan Ojha [mailto:Harshvardhan.Ojha@makemytrip.com]
Sent: Tuesday, June 05, 2012 5:51 PM
To: user@cassandra.apache.org<ma...@cassandra.apache.org>
Subject: RE: How to include two nodes in Java code using Hector

Use Consistency Level =2.

Regards
Harsh

From: Prakrati Agrawal [mailto:Prakrati.Agrawal@mu-sigma.com]
Sent: Tuesday, June 05, 2012 4:08 PM
To: user@cassandra.apache.org<ma...@cassandra.apache.org>
Subject: How to include two nodes in Java code using Hector

Dear all

I am using a two node Cassandra cluster. How do I code in Java using Hector to get data from both the nodes. Please help

Thanks and Regards

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com<http://www.mu-sigma.com>


________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***

 This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

Re: How to include two nodes in Java code using Hector

Posted by samal <sa...@gmail.com>.
I don't use hector, don't know much about internals, this may help

*  Cluster cluster = HFactory.getOrCreateCluster("
TestCluster","host1:9160,host2:9160,host3:9160")*

If you have 2 node cluster with RF=2, your data will be present in both
node. And if consistency level 2 is used both node must be UP to read and
write.

It doesn't matter which node you connect, if your data is present in
cluster it will be read directly or through coordinator node.

Read hector doc-
http://hector-client.github.com/hector/build/html/documentation.html

/Samal

On Wed, Jun 6, 2012 at 8:35 AM, Prakrati Agrawal <
Prakrati.Agrawal@mu-sigma.com> wrote:

>  But the data is distributed on the nodes ( meaning 50% of data is on one
> node and 50% of data is on another node) so I need to specify the node ip
> address somewhere in the code. But where do I specify that is what I am
> clueless about. Please help me****
>
> ** **
>
> Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 |
> www.mu-sigma.com ****
>
> ** **
>
> *From:* Harshvardhan Ojha [mailto:Harshvardhan.Ojha@makemytrip.com]
> *Sent:* Tuesday, June 05, 2012 5:51 PM
> *To:* user@cassandra.apache.org
> *Subject:* RE: How to include two nodes in Java code using Hector****
>
> ** **
>
> Use Consistency Level =2.****
>
> ** **
>
> Regards****
>
> Harsh****
>
> ** **
>
> *From:* Prakrati Agrawal [mailto:Prakrati.Agrawal@mu-sigma.com]
> *Sent:* Tuesday, June 05, 2012 4:08 PM
> *To:* user@cassandra.apache.org
> *Subject:* How to include two nodes in Java code using Hector****
>
> ** **
>
> Dear all****
>
> ** **
>
> I am using a two node Cassandra cluster. How do I code in Java using
> Hector to get data from both the nodes. Please help****
>
> ** **
>
> Thanks and Regards****
>
> ** **
>
> Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 |
> www.mu-sigma.com ****
>
> ** **
>
> ** **
>  ------------------------------
>
> This email message may contain proprietary, private and confidential
> information. The information transmitted is intended only for the person(s)
> or entities to which it is addressed. Any review, retransmission,
> dissemination or other use of, or taking of any action in reliance upon,
> this information by persons or entities other than the intended recipient
> is prohibited and may be illegal. If you received this in error, please
> contact the sender and delete the message from your system.
>
> Mu Sigma takes all reasonable steps to ensure that its electronic
> communications are free from viruses. However, given Internet
> accessibility, the Company cannot accept liability for any virus introduced
> by this e-mail or any attachment and you are advised to use up-to-date
> virus checking software.****
>
> ------------------------------
> This email message may contain proprietary, private and confidential
> information. The information transmitted is intended only for the person(s)
> or entities to which it is addressed. Any review, retransmission,
> dissemination or other use of, or taking of any action in reliance upon,
> this information by persons or entities other than the intended recipient
> is prohibited and may be illegal. If you received this in error, please
> contact the sender and delete the message from your system.
>
> Mu Sigma takes all reasonable steps to ensure that its electronic
> communications are free from viruses. However, given Internet
> accessibility, the Company cannot accept liability for any virus introduced
> by this e-mail or any attachment and you are advised to use up-to-date
> virus checking software.
>

Re: How to include two nodes in Java code using Hector

Posted by Roshni Rajagopal <Ro...@wal-mart.com>.

In Hector when you create a cluster using the API, you specify an IP address & cluster name. Thereafter internally which node serves the request or how many nodes need to be contacted to read/write data depends on the cluster configuration i.e. Whats your replication strategy, factor, consistency levels for the col family , how many nodes are there in the ring etc. So you don't individually need to connect to each node via Hector client. Once you connect to the cluster & keyspace, via any IP add of any node in the cluster, when you make Hector calls to read/write data, it would automatically figure out the node level details and carry out the task. You won't get 50% of the data, you will get all data.


Also when you remove a node, your data will be unavailable ONLY if you don't have it available in some other node as a replica..


Regards,


From: Prakrati Agrawal <Pr...@mu-sigma.com>>
Reply-To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Date: Tue, 5 Jun 2012 20:05:21 -0700
To: "user@cassandra.apache.org<ma...@cassandra.apache.org>" <us...@cassandra.apache.org>>
Subject: RE: How to include two nodes in Java code using Hector

But the data is distributed on the nodes ( meaning 50% of data is on one node and 50% of data is on another node) so I need to specify the node ip address somewhere in the code. But where do I specify that is what I am clueless about. Please help me

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com

From: Harshvardhan Ojha [mailto:Harshvardhan.Ojha@makemytrip.com]
Sent: Tuesday, June 05, 2012 5:51 PM
To: user@cassandra.apache.org<ma...@cassandra.apache.org>
Subject: RE: How to include two nodes in Java code using Hector

Use Consistency Level =2.

Regards
Harsh

From: Prakrati Agrawal [mailto:Prakrati.Agrawal@mu-sigma.com]
Sent: Tuesday, June 05, 2012 4:08 PM
To: user@cassandra.apache.org<ma...@cassandra.apache.org>
Subject: How to include two nodes in Java code using Hector

Dear all

I am using a two node Cassandra cluster. How do I code in Java using Hector to get data from both the nodes. Please help

Thanks and Regards

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com<http://www.mu-sigma.com>


________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***

RE: How to include two nodes in Java code using Hector

Posted by Prakrati Agrawal <Pr...@mu-sigma.com>.
But the data is distributed on the nodes ( meaning 50% of data is on one node and 50% of data is on another node) so I need to specify the node ip address somewhere in the code. But where do I specify that is what I am clueless about. Please help me

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com

From: Harshvardhan Ojha [mailto:Harshvardhan.Ojha@makemytrip.com]
Sent: Tuesday, June 05, 2012 5:51 PM
To: user@cassandra.apache.org
Subject: RE: How to include two nodes in Java code using Hector

Use Consistency Level =2.

Regards
Harsh

From: Prakrati Agrawal [mailto:Prakrati.Agrawal@mu-sigma.com]
Sent: Tuesday, June 05, 2012 4:08 PM
To: user@cassandra.apache.org
Subject: How to include two nodes in Java code using Hector

Dear all

I am using a two node Cassandra cluster. How do I code in Java using Hector to get data from both the nodes. Please help

Thanks and Regards

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com<http://www.mu-sigma.com>


________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.

RE: How to include two nodes in Java code using Hector

Posted by Harshvardhan Ojha <Ha...@makemytrip.com>.
Use Consistency Level =2.

Regards
Harsh

From: Prakrati Agrawal [mailto:Prakrati.Agrawal@mu-sigma.com]
Sent: Tuesday, June 05, 2012 4:08 PM
To: user@cassandra.apache.org
Subject: How to include two nodes in Java code using Hector

Dear all

I am using a two node Cassandra cluster. How do I code in Java using Hector to get data from both the nodes. Please help

Thanks and Regards

Prakrati Agrawal | Developer - Big Data(I&D)| 9731648376 | www.mu-sigma.com<http://www.mu-sigma.com>


________________________________
This email message may contain proprietary, private and confidential information. The information transmitted is intended only for the person(s) or entities to which it is addressed. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited and may be illegal. If you received this in error, please contact the sender and delete the message from your system.

Mu Sigma takes all reasonable steps to ensure that its electronic communications are free from viruses. However, given Internet accessibility, the Company cannot accept liability for any virus introduced by this e-mail or any attachment and you are advised to use up-to-date virus checking software.