You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Peter Harrison <ch...@gmail.com> on 2010/09/07 20:58:18 UTC

Re: connect to cassandra using java

On Wed, Sep 8, 2010 at 3:20 AM, Asif Jan <as...@gmail.com> wrote:
>
>
> Hi
> I need to use the low level java API in order to test bulk ingestion to
> cassandra. I have already looked at the code in contrib/bmt_example and
> contrib/client_only.
> When I try and run the following code, I get following exception ; using
> cassandra-cli I am able to see the "Keyspace1' and column family 'Standard1'
> .

On the server you need to load the schema from the yaml. To do this you will
need to use jconsole to connect and run the schema load method. You only
need to do this once on a single node.

I have written some code to load and drop keyspaces and column families
for hector; but I'm not quite happy with it yet. This will enable you
to do everything
programatically.

Re: connect to cassandra using java

Posted by Asif Jan <as...@gmail.com>.
Thanks

once I am using cli script, it is able to connect to the local server  
and see all keyspaces etc. Do I still need to load schemas when using  
the same local server ?

Asif
On Sep 7, 2010, at 8:58 PM, Peter Harrison wrote:

> On Wed, Sep 8, 2010 at 3:20 AM, Asif Jan <as...@gmail.com> wrote:
>>
>>
>> Hi
>> I need to use the low level java API in order to test bulk  
>> ingestion to
>> cassandra. I have already looked at the code in contrib/bmt_example  
>> and
>> contrib/client_only.
>> When I try and run the following code, I get following exception ;  
>> using
>> cassandra-cli I am able to see the "Keyspace1' and column family  
>> 'Standard1'
>> .
>
> On the server you need to load the schema from the yaml. To do this  
> you will
> need to use jconsole to connect and run the schema load method. You  
> only
> need to do this once on a single node.
>
> I have written some code to load and drop keyspaces and column  
> families
> for hector; but I'm not quite happy with it yet. This will enable you
> to do everything
> programatically.


Re: connect to cassandra using java

Posted by Asif Jan <as...@gmail.com>.
On Sep 7, 2010, at 8:58 PM, Peter Harrison wrote:

> On Wed, Sep 8, 2010 at 3:20 AM, Asif Jan <as...@gmail.com> wrote:
>>
>>
>> Hi
>> I need to use the low level java API in order to test bulk  
>> ingestion to
>> cassandra. I have already looked at the code in contrib/bmt_example  
>> and
>> contrib/client_only.
>> When I try and run the following code, I get following exception ;  
>> using
>> cassandra-cli I am able to see the "Keyspace1' and column family  
>> 'Standard1'
>> .
>
> On the server you need to load the schema from the yaml. To do this  
> you will
> need to use jconsole to connect and run the schema load method. You  
> only
> need to do this once on a single node.

using jconsole to load schemas results in the following exception  
being generated.

Uncaught exception in thread Thread[MIGRATION-STAGE:1,5,main]
java.util.concurrent.ExecutionException:  
org.apache.cassandra.config.ConfigurationException: Cannot load from  
XML on top of pre-existing schemas.
	at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
	at java.util.concurrent.FutureTask.get(FutureTask.java:83)
	at  
org 
.apache 
.cassandra 
.concurrent 
.DebuggableThreadPoolExecutor 
.afterExecute(DebuggableThreadPoolExecutor.java:87)
	at java.util.concurrent.ThreadPoolExecutor 
$Worker.runTask(ThreadPoolExecutor.java:888)
	at java.util.concurrent.ThreadPoolExecutor 
$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:637)
Caused by: org.apache.cassandra.config.ConfigurationException: Cannot  
load from XML on top of pre-existing schemas.
	at org.apache.cassandra.service.StorageService 
$5.call(StorageService.java:1678)
	at org.apache.cassandra.service.StorageService 
$5.call(StorageService.java:1673)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor 
$Worker.runTask(ThreadPoolExecutor.java:886)



I understand from FAQ

http://wiki.apache.org/cassandra/FAQ#no_keyspaces

that keyspaces are not loaded by default. What could explain that I am  
able to see the kepspaces via CLI and not able to see when connecting  
to same cassandra instance via java.


Thanks a lot





>
> I have written some code to load and drop keyspaces and column  
> families
> for hector; but I'm not quite happy with it yet. This will enable you
> to do everything
> programatically.