Return-Path: Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: (qmail 97552 invoked from network); 17 Mar 2010 16:24:44 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Mar 2010 16:24:44 -0000 Received: (qmail 67288 invoked by uid 500); 17 Mar 2010 16:24:43 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 67271 invoked by uid 500); 17 Mar 2010 16:24:43 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 67263 invoked by uid 99); 17 Mar 2010 16:24:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Mar 2010 16:24:43 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bburruss@real.com designates 207.188.23.4 as permitted sender) Received: from [207.188.23.4] (HELO kal-el.real.com) (207.188.23.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Mar 2010 16:24:36 +0000 Received: from seacas02.corp.real.com ([::ffff:192.168.139.57]) (TLS: TLSv1/SSLv3,128bits,AES128-SHA) by kal-el.real.com with esmtp; Wed, 17 Mar 2010 09:24:14 -0700 id 00080007.4BA1022E.00006E71 Received: from [172.21.131.225] (192.168.198.6) by seacas02.corp.real.com (192.168.139.57) with Microsoft SMTP Server id 8.2.176.0; Wed, 17 Mar 2010 09:24:13 -0700 Message-ID: <4BA1022F.9050701@real.com> Date: Wed, 17 Mar 2010 09:24:15 -0700 From: "B. Todd Burruss" User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: "user@cassandra.apache.org" Subject: Re: Dividing the client load between machines in Cassandra References: <991ae7f81003161430r705a00fu85949dd1dd327f6@mail.gmail.com> <4B9FFE45.4040709@real.com> <991ae7f81003161532i4913e247h742140aca95a5673@mail.gmail.com> In-Reply-To: <991ae7f81003161532i4913e247h742140aca95a5673@mail.gmail.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Old-Return-Path: bburruss@real.com X-Virus-Checked: Checked by ClamAV on apache.org below is the commented out code i once used. i think it is from the 0.5 days, so it might not even work now. not sure. the bootstrapHostArr is simply a list of host information used to bootstrap the process. connectToHost is a method used to generate a Cassandra.Client object. there is sample code on cassandra wiki for doing this. good luck! // can't use this on cassandra because the tokens returned are for the "internal cassandra server comm", not the thrift IPs // String hostList = null; // for ( HostInfo hi : bootstrapHostArr ) { // Cassandra.Client client = null; // try { // client = connectToHost( hi.getHostName(), hi.getPort() ); // hostList = client.get_string_property( "token map" ); // break; // } // catch ( TTransportException e ) { // logger.error( "cannot connect to bootstrap node - will try another if available : " + hi.getNameAndPort() ); // } // catch ( TException e ) { // logger.error( "cannot retrieve host list from node - will try another if available : " + hi.getNameAndPort() ); // } // finally { // if ( null != client ) { // disconnectFromCluster( client ); // } // } // } // // if ( null != hostList ) { // ArrayList newArr; // try { // JSONObject jsonObj = new JSONObject( hostList ); // String[] ringArr = JSONObject.getNames( jsonObj ); // newArr = new ArrayList( ringArr.length ); // // for ( int i=0;i < ringArr.length;i++ ) { // String hostName = jsonObj.getString( ringArr[i] ); // if ( !hostIgnoreSet.contains(hostName) ) { // newArr.add( hostName ); // } // } // } // catch ( JSONException e ) { // throw new ClusterRuntimeException( "Could not parse JSON returned from Cassandra - don't know what to do? ARRRRGGGG" ); // } Sonny Heer wrote: > Is there some example code on how to do this? > > On Tue, Mar 16, 2010 at 3:07 PM, Jonathan Ellis wrote: > >> token map is an internal representation, so returning the internal IPs >> is correct, even though this makes it slightly more difficult to use >> for thrift clients. >> >> On Tue, Mar 16, 2010 at 4:55 PM, B. Todd Burruss wrote: >> >>> if you choose #3 - get_string_property("token map") - keep in mind that the >>> IPs returned from this call are the IPs used for "ListenAddress" param in >>> storage-conf.xml. In my case we have two NICs and I set this to be an IP >>> that is only for "node to node" communication. The "ThriftAddress" param is >>> the one i really want. maybe this has been changed, "fixed" ;), haven't >>> tested in a while. >>> >>> Jonathan Ellis wrote: >>> >>>> http://wiki.apache.org/cassandra/FAQ#node_clients_connect_to >>>> >>>> On Tue, Mar 16, 2010 at 4:30 PM, Sonny Heer wrote: >>>> >>>> >>>>> How can I accomplish this? >>>>> >>>>> The way I'm doing it now it is creating a TSocket connection using a >>>>> static IP of one of the boxes on Cassandra: >>>>> TTransport tr = new TSocket(host, port.intValue()); >>>>> TProtocol proto = new TBinaryProtocol(tr); >>>>> Cassandra.Client client = new Cassandra.Client(proto); >>>>> tr.open(); >>>>> >>>>> With a larger cluster I would imagine there is another preferred >>>>> solution with no single point of failure (e.g. that one box goes >>>>> down). >>>>> >>>>> >>>>>