incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre <e-mailadr...@hotmail.com>
Subject RE: Getting Cassandra 0.7 beta2 to work - creating keyspaces
Date Sun, 10 Oct 2010 22:00:16 GMT
That's it. Now I can actually have a play with it.

Thanks Nicolas

 

From: Nicolas Mathieu [mailto:nico008@gmail.com] 
Sent: 10 October 2010 22:29
To: user@cassandra.apache.org
Subject: Re: Getting Cassandra 0.7 beta2 to work - creating keyspaces

 

Since 0.7 beta 2 or something, locators have differents names.
In conf/cassandra.yaml :
Out of the box, Cassandra provides 
#     * org.apache.cassandra.locator.SimpleStrategy 
#     * org.apache.cassandra.locator.NetworkTopologyStrategy
#     * org.apache.cassandra.locator.OldNetworkTopologyStrategy

Good luck

Nico008

On 10/10/2010 20:38, Andre wrote: 

Yeah that certainly seems to be the way forward, thanks.

Made adjustments but I'm still coming up short, the set strategy class
method has no javadoc and I'm getting a 

InvalidRequestException(why:org.apache.cassandra.locator.RackUnawareStrategy
) 

 

Am I doing this right, in the old config xml file you specified the full
path to the class, has that changed too?

 

public static void main(String[] args) throws InvalidRequestException,
TException {

            TFramedTransport transport = new TFramedTransport(new
TSocket("localhost", 9160));

            Cassandra.Client client = new Cassandra.Client(new
TBinaryProtocol(transport));

            transport.open();

 

            KsDef ks = new KsDef();

            CfDef cf = new CfDef();

            cf.setColumn_type("Standard");

            cf.setName("Standard1");

            cf.setKeyspace("Keyspace1");

            List<CfDef> cl = new ArrayList<CfDef>();

            cl.add(cf);

            ks.setReplication_factor(1);

 
ks.setStrategy_class("org.apache.cassandra.locator.RackUnawareStrategy");

            ks.setName("Keyspace1");

            ks.setCf_defs(cl);

            client.system_add_keyspace(ks);

 

      }

 

From: Nicolas Mathieu [mailto:nico008@gmail.com] 
Sent: 10 October 2010 18:35
To: user@cassandra.apache.org
Subject: Re: Getting Cassandra 0.7 beta2 to work - creating keyspaces

 

Try this :
TFramedTranspor transport = new TFramedTransport(new TSocket(host, port));
Cassandra.Client cassandraConn = new Cassandra.Client(new
TBinaryProtocol(transport));
transport.open();

It is now Framed transport ;-)

Hope that helps

Nico008

On 10/10/2010 18:40, Andre wrote: 

Hi everyone.

I'm having a bit of a problem getting started with 0.7

I had 0.6.4 working and I want to start checking out 0.7, I can't figure out
how to create keyspaces to even get started.

Can anyone also give me a little info on secondary index's, their purpose
and use

 

The following is the java code I was using 

public class Client {

      private static TTransport tr = null;

      private static Cassandra.Client client = null;

      public static Client Cassandra = new Client();

 

      public Client() {

            setupConnection();

      }

 

      private static void setupConnection() {

            try {

                  tr = new TSocket("localhost", 9160);

                  TProtocol proto = new TBinaryProtocol(tr);

                  client = new Cassandra.Client(proto);

                  tr.open();

            } catch (TException ex) {

                  Logger.getLogger(Client.class.getName()).log(Level.ALL,
null, ex);

            }

      }

      public static void main(String[] args) throws InvalidRequestException,
TException {

            KsDef ks = new KsDef();

            CfDef cf = new CfDef();

            cf.setColumn_type("Standard");

            cf.setName("Standard1");

            cf.setKeyspace("Keyspace1");

            List<CfDef> cl = new ArrayList<CfDef>();

            cl.add(cf);

            ks.setReplication_factor(1);

 
ks.setStrategy_class("org.apache.cassandra.locator.RackUnawareStrategy");

            ks.setName("Keyspace1");

            ks.setCf_defs(cl);

            Client.Cassandra.client.system_add_keyspace(ks);

 

      }

 

}

 

But of course it throws an exception:

 

Exception in thread "main" org.apache.thrift.transport.TTransportException

      at
org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:
132)

      at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)

      at
org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:369)

      at
org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:295)

      at
org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.
java:202)

      at
org.apache.cassandra.thrift.Cassandra$Client.recv_system_add_keyspace(Cassan
dra.java:1454)

      at
org.apache.cassandra.thrift.Cassandra$Client.system_add_keyspace(Cassandra.j
ava:1439)

      at org.shotaz.Cassandra.Client.main(Client.java:58)

 

I've seen http://wiki.apache.org/cassandra/LiveSchemaUpdates  and
http://wiki.apache.org/cassandra/API (CFdef and KSDef section)

But I still can't suss it any help/pointers would be much appreciated.

P.S I also used Hector with 0.6.4 so examples using either thrift or Hector
should get me going.

 

thanks

 

 


Mime
View raw message