I found hector is not a good design. 1. We cannot create multiple threads (each thread have a connection to cassandra server) to one cassandra server. As we known, usually, cassandra client should be multiple-threads to achieve good throughput.
2. The implementation is too fat. 3. Introduce traditional RDBMS habit into Cassandra is not a good idea. On Wed, Apr 21, 2010 at 1:25 AM, Ran Tavory <ran...@gmail.com> wrote: > great, I'm happy you found hector useful and reused it in your client. > > > On Tue, Apr 20, 2010 at 5:11 PM, Dop Sun <su...@dopsun.com> wrote: > >> Hi, >> >> >> >> I have downloaded hector-0.6.0-10.jar. As you mentioned, it has good >> implementation for the connection pooling, JMX counters. >> >> >> >> What I’m doing is: using Hector to create the Cassandra client (be >> specific: borrow_client(url, port)). And my understanding is: in this way, >> the Jassandra will enjoy the client pool and JMX counter. >> >> >> >> http://code.google.com/p/jassandra/issues/detail?id=17 >> >> >> >> Please feel free to let me know if you have any suggestions. >> >> >> >> The new build 1.0.0 build 3(http://code.google.com/p/jassandra/) created. >> From Jassandra client side, no API changes. >> >> >> >> Cheers~~~ >> >> Dop >> >> >> >> *From:* Ran Tavory [mailto:ran...@gmail.com] >> *Sent:* Tuesday, April 20, 2010 1:36 AM >> *To:* user@cassandra.apache.org >> *Subject:* Re: Cassandra Java Client >> >> >> >> Hi Dop, you may want to look at hector as a low level cassandra client on >> which you build jassandra, adding hibernate style magic etc like other ppl >> have done with ORM layers on top of it. >> >> Hector's main features include extensive jmx counters, failover and >> connection pooling. >> >> It's available for all recent versions, including 0.5.0, 0.5.1, 0.6.0 and >> 0.6.1 >> >> On Mon, Apr 19, 2010 at 5:58 PM, Dop Sun <su...@dopsun.com> wrote: >> >> Well, there are couple of points while Jassandra is created: >> >> 1. First of all, I want to create something like that is because I come >> from >> JDBC background, and familiar with Hibernate API. The ICriteria (which is >> created for querying) is inspired by the Criteria API from hibernate. >> >> Actually, maybe because of this background, it cost me a lot efforts try >> to >> understand Cassandra in the beginning and Thrift API also takes time to >> use. >> >> 2. The Jassandra creates a layer, which removes the direct link to >> underlying Thrift API (including the exceptions, ConsistencyLevel >> enumeration etc) >> >> High light this point because I believe the client of the Jassandra will >> benefit for the implementation changes in future, for example, if the >> Cassandra provides better Thrift API to selecting the columns for a list >> of >> keys, SCFs, or deprecating some structures, exceptions, the client may not >> be changed. Of cause, if Jassandra failed to approve itself, this is >> actually not the advantage. :) >> >> 3. The Jassandra is designed to be an JDBC like API, no less, no more. It >> strives to use the best API to do the quering (with token, key, SCF/ CF), >> doing the CRUD, but no more than that. For example, it does not cover any >> API like object mapping. But it should cover all the API functionalities >> Thrift provided. >> >> These 3 points, are different from Hector (I should be honest that I have >> not tried to use it before, the feeling of difference are coming from the >> sample code Hector provided). >> >> So, the API Jassandra abstracted was something like this: >> >> IConnection connection = DriverManager.getConnection( >> "thrift://localhost:9160", info); >> try { >> // 2. Get a KeySpace by name >> IKeySpace keySpace = connection.getKeySpace("Keyspace1"); >> >> // 3. Get a ColumnFamily by name >> IColumnFamily cf = keySpace.getColumnFamily("Standard2"); >> >> // 4. Insert like this >> long now = System.currentTimeMillis(); >> ByteArray nameFirst = ByteArray.ofASCII("first"); >> ByteArray nameLast = ByteArray.ofASCII("last"); >> ByteArray nameAge = ByteArray.ofASCII("age"); >> ByteArray valueLast = ByteArray.ofUTF8("Smith"); >> IColumn colFirst = new Column(nameFirst, ByteArray.ofUTF8("John"), >> now); >> cf.insert(userName, colFirst); >> >> IColumn colLast = new Column(nameLast, valueLast, now); >> cf.insert(userName, colLast); >> >> IColumn colAge = new Column(nameAge, ByteArray.ofLong(42), now); >> cf.insert(userName, colAge); >> >> // 5. Select like this >> ICriteria criteria = cf.createCriteria(); >> criteria.keyList(Lists.newArrayList(userName)) >> .columnRange(nameAge, nameLast, 10); >> Map<String, List<IColumn>> map = criteria.select(); >> List<IColumn> list = map.get(userName); >> Assert.assertEquals(3, list.size()); >> Assert.assertEquals(valueLast, list.get(2).getValue()); >> >> // 6. Delete like this >> cf.delete(userName, colFirst); >> map = criteria.select(); >> Assert.assertEquals(2, map.get(userName).size()); >> >> // 7. Get count like this >> criteria = cf.createCriteria(); >> criteria.keyList(Lists.newArrayList(userName)); >> int count = criteria.count(); >> Assert.assertEquals(2, count); >> } finally { >> // 8. Don't forget to close the connection. >> connection.close(); >> >> } >> } >> >> -----Original Message----- >> From: Jonathan Ellis [mailto:jbel...@gmail.com] >> Sent: Monday, April 19, 2010 10:35 PM >> To: user@cassandra.apache.org >> >> Subject: Re: Cassandra Java Client >> >> How is Jassandra different from http://github.com/rantav/hector ? >> >> On Mon, Apr 19, 2010 at 9:21 AM, Dop Sun <su...@dopsun.com> wrote: >> > May I take this chance to share this link here: >> > >> > http://code.google.com/p/jassandra/ >> > >> > >> > >> > It currently based with Cassandra 0.6 Thrift APIs. >> > >> > >> > >> > The class ThriftCriteria and ThriftColumnFamily has direct use of Thrift >> > API. Also, the site itself has test code, which is actually works on >> > Jassandra abstraction. >> > >> > >> > >> > Dop >> > >> > >> > >> > From: Nirmala Agadgar [mailto:nirmala...@gmail.com] >> > Sent: Friday, April 16, 2010 5:56 PM >> > To: user@cassandra.apache.org >> > Subject: Cassandra Java Client >> > >> > >> > >> > Hi, >> > >> > Can anyone tell how to implement Client that can insert data into >> cassandra >> > in Java. Any Code or guidelines would be helpful. >> > >> > - >> > Nirmala >> > >> >> >> > >