Skip to content
This repository

SolandraDaemon (Working Version) #135

Merged
merged 1 commit into from almost 3 years ago

2 participants

Levmatta Jake Luciani
Levmatta

This class was made to conform with the CassandraDaemon Interface, so I can use Solandra in production (I use Ubuntu) using the Apache Cassandra PPA.
To do that I do:

git clone git://github.com/tjake/Solandra.git
mkdir tmp
mkdir tmp/bin
cp /usr/sbin/cassandra tmp/bin/cassandra
cd Solandra
ant
ant -Dcassandra=/root/tmp/ cassandra-dist
cd ../tmp
cp conf/* /etc/cassandra/
\# Verify if override
cp -i lib/* /usr/share/cassandra/lib/
cp bin/solandra /usr/sbin/solandra

After that I edited the /etc/init.d/cassandra script to point to solandra.SolandraDaemon

Personally I believe this is all very simple, and valid to run solandra as a daemon and with the correct structure on Ubuntu.

Jake Luciani tjake merged commit 82038f8 into from
Jake Luciani
Owner

Looks good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 30, 2011
Levmatta levmatta-umanni SolandraDaemon (Working Version) fe05be7
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 107 additions and 0 deletions. Show diff stats Hide diff stats

  1. +107 0 src/solandra/SolandraDaemon.java
107 src/solandra/SolandraDaemon.java
... ... @@ -0,0 +1,107 @@
  1 +/**
  2 + * Licensed to the Apache Software Foundation (ASF) under one
  3 + * or more contributor license agreements. See the NOTICE file
  4 + * distributed with this work for additional information
  5 + * regarding copyright ownership. The ASF licenses this file
  6 + * to you under the Apache License, Version 2.0 (the
  7 + * "License"); you may not use this file except in compliance
  8 + * with the License. You may obtain a copy of the License at
  9 + *
  10 + * http://www.apache.org/licenses/LICENSE-2.0
  11 + *
  12 + * Unless required by applicable law or agreed to in writing, software
  13 + * distributed under the License is distributed on an "AS IS" BASIS,
  14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15 + * See the License for the specific language governing permissions and
  16 + * limitations under the License.
  17 + */
  18 +package solandra;
  19 +
  20 +import lucandra.CassandraUtils;
  21 +import java.io.IOException;
  22 +import org.apache.cassandra.service.CassandraDaemon;
  23 +
  24 +/**
  25 + * This class supports two methods for creating a Cassandra node daemon,
  26 + * invoking the class's main method, and using the jsvc wrapper from
  27 + * commons-daemon, (for more information on using this class with the
  28 + * jsvc wrapper, see the
  29 + * <a href="http://commons.apache.org/daemon/jsvc.html">Commons Daemon</a>
  30 + * documentation).
  31 + */
  32 +public class SolandraDaemon implements CassandraDaemon {
  33 +
  34 + /**
  35 + * Initialize the Cassandra Daemon based on the given <a
  36 + * href="http://commons.apache.org/daemon/jsvc.html">Commons
  37 + * Daemon</a>-specific arguments. To clarify, this is a hook for JSVC.
  38 + *
  39 + * @param arguments
  40 + * the arguments passed in from JSVC
  41 + * @throws IOException
  42 + */
  43 + public void init(String[] arguments) throws IOException {
  44 + // Nothing
  45 + }
  46 +
  47 + /**
  48 + * Start the Cassandra Daemon, assuming that it has already been
  49 + * initialized, via either {@link #init(String[])} or
  50 + * {@link #load(String[])}.
  51 + *
  52 + * @throws IOException
  53 + */
  54 + public void start() throws IOException {
  55 + startRPCServer();
  56 + }
  57 +
  58 + /**
  59 + * Stop the daemon, ideally in an idempotent manner.
  60 + */
  61 + public void stop() {
  62 + stopRPCServer();
  63 + }
  64 +
  65 + /**
  66 + * Clean up all resources obtained during the lifetime of the daemon. Just
  67 + * to clarify, this is a hook for JSVC.
  68 + */
  69 + public void destroy() {
  70 + // Nothing
  71 + }
  72 +
  73 + @SuppressWarnings("CallToThreadDumpStack")
  74 + public void startRPCServer() {
  75 + String context = System.getProperty("solandra.context", "/solandra");
  76 + try {
  77 + CassandraUtils.startupServer();
  78 +
  79 + JettySolandraRunner jetty = new JettySolandraRunner(context, CassandraUtils.port, CassandraUtils.webHost);
  80 + jetty.start(false);
  81 + } catch (Exception ex) {
  82 + ex.printStackTrace();
  83 + }
  84 + }
  85 +
  86 + public void stopRPCServer() {
  87 + CassandraUtils.stopServer();
  88 + }
  89 +
  90 + public boolean isRPCServerRunning() {
  91 + return true;
  92 + }
  93 +
  94 + /**
  95 + * A convenience method to initialize and start the daemon in one shot.
  96 + */
  97 + public void activate() {
  98 + startRPCServer();
  99 + }
  100 +
  101 + /**
  102 + * A convenience method to stop and destroy the daemon in one shot.
  103 + */
  104 + public void deactivate() {
  105 + stopRPCServer();
  106 + }
  107 +}

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.