Skip to content

Commit

Permalink
NFThinCassandraDaemon should work with JSVC like Cassandra does
Browse files Browse the repository at this point in the history
  • Loading branch information
codyaray committed May 7, 2012
1 parent bf03ae9 commit a2e36f9
Showing 1 changed file with 34 additions and 4 deletions.
@@ -1,5 +1,7 @@
package com.netflix.priam.cassandra;

import java.io.IOException;

import org.apache.cassandra.thrift.CassandraDaemon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -10,7 +12,36 @@ public class NFThinCassandraDaemon extends CassandraDaemon
{
private static final Logger logger = LoggerFactory.getLogger(NFThinCassandraDaemon.class);

/**
* Initialize the Cassandra Daemon based on the given command-line
* arguments. This is the normal {@code java} entry point.
*
* @param args the arguments passed on the command-line
*/
public static void main(String[] args)
{
NFThinCassandraDaemon daemon = new NFThinCassandraDaemon();
daemon.setPriamProperties();
daemon.activate();
}

/**
* Initialize the Cassandra Daemon based on the given <a
* href="http://commons.apache.org/daemon/jsvc.html">Commons
* Daemon</a>-specific arguments. To clarify, this is a hook for
* JSVC and serves as a second entry point.
*
* @param args the arguments passed in from JSVC
* @throws IOException
*/
@Override
public void init(String[] args) throws IOException
{
setPriamProperties();
super.init(args);
}

private void setPriamProperties()
{
String token = null;
String seeds = null;
Expand All @@ -27,7 +58,7 @@ public static void main(String[] args)
{
logger.error("Failed to obtain a token from a pre-defined list, we can not start!", e);
}

if (token != null && seeds != null)
break;
// sleep for 5 sec and try again.
Expand All @@ -40,11 +71,10 @@ public static void main(String[] args)
// do nothing.
}
}

System.setProperty("cassandra.initial_token", token);

if (isReplace)
System.setProperty("cassandra.replace_token", token);

new CassandraDaemon().activate();
}
}

0 comments on commit a2e36f9

Please sign in to comment.