Author: jbellis Date: Mon Aug 22 20:55:40 2011 New Revision: 1160429 URL: http://svn.apache.org/viewvc?rev=1160429&view=rev Log: Add "install" command to cassandra.bat patch by Ben Coverston; reviewed by jbellis for CASSANDRA-292
Modified: cassandra/trunk/CHANGES.txt cassandra/trunk/bin/cassandra.bat cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java Modified: cassandra/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1160429&r1=1160428&r2=1160429&view=diff ============================================================================== --- cassandra/trunk/CHANGES.txt (original) +++ cassandra/trunk/CHANGES.txt Mon Aug 22 20:55:40 2011 @@ -38,6 +38,8 @@ * Stop reading from sstables once we know we have the most recent columns, for query-by-name requests (CASSANDRA-2498) * Add query-by-column mode to stress.java (CASSANDRA-3064) + * Add "install" command to cassandra.bat (CASSANDRA-292) + 0.8.5 * fix NPE when encryption_options is unspecified (CASSANDRA-3007) Modified: cassandra/trunk/bin/cassandra.bat URL: http://svn.apache.org/viewvc/cassandra/trunk/bin/cassandra.bat?rev=1160429&r1=1160428&r2=1160429&view=diff ============================================================================== --- cassandra/trunk/bin/cassandra.bat (original) +++ cassandra/trunk/bin/cassandra.bat Mon Aug 22 20:55:40 2011 @@ -14,16 +14,18 @@ @REM See the License for the specific language governing permissions and @REM limitations under the License. -@echo off -if "%OS%" == "Windows_NT" setlocal +set ARG=%1 +set INSTALL="INSTALL" + +pushd %~dp0.. +if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%CD% +popd -if NOT DEFINED CASSANDRA_HOME set CASSANDRA_HOME=%~dp0.. if NOT DEFINED CASSANDRA_MAIN set CASSANDRA_MAIN=org.apache.cassandra.thrift.CassandraDaemon if NOT DEFINED JAVA_HOME goto err REM ***** JAVA options ***** -set JAVA_OPTS=^ - -ea^ +set JAVA_OPTS=-ea^ -javaagent:"%CASSANDRA_HOME%\lib\jamm-0.2.2.jar"^ -Xms1G^ -Xmx1G^ @@ -58,13 +60,46 @@ goto :eof REM Include the build\classes\main directory so it works in development set CASSANDRA_CLASSPATH=%CLASSPATH%;"%CASSANDRA_HOME%\build\classes\main";"%CASSANDRA_HOME%\build\classes\thrift" set CASSANDRA_PARAMS=-Dcassandra -Dcassandra-foreground=yes +if /i "%ARG%" == "INSTALL" goto installService goto runDaemon + :runDaemon echo Starting Cassandra Server "%JAVA_HOME%\bin\java" %JAVA_OPTS% %CASSANDRA_PARAMS% -cp %CASSANDRA_CLASSPATH% "%CASSANDRA_MAIN%" goto finally +:installService +set SERVICE_JVM="cassandra" +rem location of Prunsrv +set PATH_PRUNSRV=%CASSANDRA_HOME%\bin\daemon\ +set PR_LOGPATH=%PATH_PRUNSRV% + +rem fix up java ops replace ' -' with ' ;-' +set JAVA_OPTS_DELM=%JAVA_OPTS: -=;-% + +rem Allow prunsrv to be overridden +if "%PRUNSRV%" == "" set PRUNSRV=%PATH_PRUNSRV%prunsrv + +rem Install the service +echo trying to delete service if it has been created already +%PRUNSRV% //DS//%SERVICE_JVM% +echo Installing %SERVICE_JVM% +%PRUNSRV% //IS//%SERVICE_JVM% + +echo Setting the parameters for %SERVICE_JVM% +rem set PR_CLASSPATH=%CASSANDRA_CLASSPATH% +%PRUNSRV% //US//%SERVICE_JVM% ^ + --Jvm=auto --StdOutput auto --StdError auto ^ + --Classpath=%CASSANDRA_CLASSPATH% ^ + --StartMode=jvm --StartClass=%CASSANDRA_MAIN% --StartMethod=main ^ + --StopMode=jvm --StopClass=%CASSANDRA_MAIN% --StopMethod=stop ^ + ++JvmOptions=%JAVA_OPTS_DELM% ++JvmOptions=-DCassandra ^ + --PidFile pid.txt + +echo Installation of %SERVICE_JVM% is complete +goto finally + :err echo JAVA_HOME environment variable must be set! pause Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java?rev=1160429&r1=1160428&r2=1160429&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java Mon Aug 22 20:55:40 2011 @@ -53,6 +53,7 @@ import org.apache.thrift.transport.TTran public class CassandraDaemon extends org.apache.cassandra.service.AbstractCassandraDaemon { + protected static CassandraDaemon instance; private static Logger logger = LoggerFactory.getLogger(CassandraDaemon.class); private final static String SYNC = "sync"; private final static String ASYNC = "async"; @@ -86,9 +87,16 @@ public class CassandraDaemon extends org } } + public static void stop(String[] args) + { + instance.stopServer(); + instance.deactivate(); + } + public static void main(String[] args) { - new CassandraDaemon().activate(); + instance = new CassandraDaemon(); + instance.activate(); } /**