You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by sam_ <am...@yahoo.com> on 2011/04/14 19:59:48 UTC
Starting the Cassandra server from Java (without command line)
Hello there,
To start the Cassandra server we can use the following command in command
prompt:
cassandra -f
I am wondering if it is possible to directly start the server inside a Java
program using thrift API or a lower level class inside Cassandra
implementation.
The purpose of this is to be able to run JUnit tests that need to start
Cassandra server in SetUp(), without the need to create a process and run
"cassandra" from command line.
Thanks,
Sam
--
View this message in context: http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Starting-the-Cassandra-server-from-Java-without-command-line-tp6273826p6273826.html
Sent from the cassandra-user@incubator.apache.org mailing list archive at Nabble.com.
Re: Starting the Cassandra server from Java (without command line)
Posted by sam_ <am...@yahoo.com>.
@Naren Thanks for the reply.
I noticed that EmbeddedCassandraService is now part of the Cassandra
distribution. The source code is changed compared to what Ran had posted at
http://prettyprint.me/2010/02/14/running-cassandra-as-an-embedded-service/
I tried to use EmbeddedCassandraService with this code:
@BeforeClass
public static void startServer() {
// C:\cassandra is where cassandra is installed
System.setProperty("storage-config", "C:\\cassandra\\conf\\");
cassandra = new EmbeddedCassandraService();
cassandra.start();
}
But I got the following error:
java.lang.ExceptionInInitializerError
at
org.apache.cassandra.service.EmbeddedCassandraService.start(EmbeddedCassandraService.java:58)
...
...
Caused by: java.lang.RuntimeException: Couldn't figure out log4j
configuration.
at
org.apache.cassandra.service.AbstractCassandraDaemon.<clinit>(AbstractCassandraDaemon.java:74)
...
I guess I am not setting the right properties?
Any help is appreciated.
Thanks,
Sam
--
View this message in context: http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Starting-the-Cassandra-server-from-Java-without-command-line-tp6273826p6278552.html
Sent from the cassandra-user@incubator.apache.org mailing list archive at Nabble.com.
Re: Starting the Cassandra server from Java (without command line)
Posted by Narendra Sharma <na...@gmail.com>.
The write up is a year old but still will give you fair idea of how to do.
http://prettyprint.me/2010/02/14/running-cassandra-as-an-embedded-service/
<http://prettyprint.me/2010/02/14/running-cassandra-as-an-embedded-service/>
Thanks,
Naren
On Thu, Apr 14, 2011 at 10:59 AM, sam_ <am...@yahoo.com> wrote:
> Hello there,
>
> To start the Cassandra server we can use the following command in command
> prompt:
> cassandra -f
>
> I am wondering if it is possible to directly start the server inside a Java
> program using thrift API or a lower level class inside Cassandra
> implementation.
>
> The purpose of this is to be able to run JUnit tests that need to start
> Cassandra server in SetUp(), without the need to create a process and run
> "cassandra" from command line.
>
> Thanks,
> Sam
>
> --
> View this message in context:
> http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Starting-the-Cassandra-server-from-Java-without-command-line-tp6273826p6273826.html
> Sent from the cassandra-user@incubator.apache.org mailing list archive at
> Nabble.com.
>
--
Narendra Sharma
Solution Architect
*http://www.persistentsys.com*
*http://narendrasharma.blogspot.com/*
Re: Starting the Cassandra server from Java (without command line)
Posted by sam_ <am...@yahoo.com>.
@Jason Thanks, I found the Pelops EmbeddedCassandraServer implementation and
am giving it a try.
--
View this message in context: http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Starting-the-Cassandra-server-from-Java-without-command-line-tp6273826p6278564.html
Sent from the cassandra-user@incubator.apache.org mailing list archive at Nabble.com.
Re: Starting the Cassandra server from Java (without command line)
Posted by Jason Pell <ja...@gmail.com>.
You can make use of embedded Cassandra server. Both Hector and Pelops have classes that you can use in your own unit tests, the Pelops one is quite good.
Sent from my iPhone
On Apr 15, 2011, at 3:59, sam_ <am...@yahoo.com> wrote:
> Hello there,
>
> To start the Cassandra server we can use the following command in command
> prompt:
> cassandra -f
>
> I am wondering if it is possible to directly start the server inside a Java
> program using thrift API or a lower level class inside Cassandra
> implementation.
>
> The purpose of this is to be able to run JUnit tests that need to start
> Cassandra server in SetUp(), without the need to create a process and run
> "cassandra" from command line.
>
> Thanks,
> Sam
>
> --
> View this message in context: http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Starting-the-Cassandra-server-from-Java-without-command-line-tp6273826p6273826.html
> Sent from the cassandra-user@incubator.apache.org mailing list archive at Nabble.com.