Move CopyCat log to $KARAF_DATA/raft

Change-Id: I97f4766279f875c15c818d4b7f0b168e06e85ac1
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
index 192e084..9187ead 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/DatabaseManager.java
@@ -82,8 +82,7 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected DatabaseProtocolService copycatMessagingProtocol;
 
-    // FIXME: point to appropriate path
-    public static final String LOG_FILE_PREFIX = "/tmp/onos-copy-cat-log_";
+    public static final String LOG_FILE_PREFIX = "raft/onos-copy-cat-log_";
 
     // Current working dir seems to be /opt/onos/apache-karaf-3.0.2
     // TODO: Set the path to /opt/onos/config
@@ -126,6 +125,10 @@
     @Activate
     public void activate() throws InterruptedException, ExecutionException {
 
+        // KARAF_DATA
+        //  http://karaf.apache.org/manual/latest/users-guide/start-stop.html
+        final String dataDir = System.getProperty("karaf.data", "./data");
+
         // load tablet configuration
         File file = new File(CONFIG_DIR, initialMemberConfig);
         log.info("Loading config: {}", file.getAbsolutePath());
@@ -179,7 +182,7 @@
 
             DatabaseStateMachine stateMachine = new DatabaseStateMachine();
             stateMachine.addEventListener(expirationTracker);
-            Log consensusLog = new MapDBLog(LOG_FILE_PREFIX + localNode.id(),
+            Log consensusLog = new MapDBLog(dataDir + "/" + LOG_FILE_PREFIX + localNode.id(),
                     ClusterMessagingProtocol.DB_SERIALIZER);
 
             CopycatConfig ccConfig = new CopycatConfig();
diff --git a/tools/test/bin/onos-install b/tools/test/bin/onos-install
index b3f84e4..c13b8b9 100755
--- a/tools/test/bin/onos-install
+++ b/tools/test/bin/onos-install
@@ -35,6 +35,10 @@
     mkdir $ONOS_INSTALL_DIR/var
     mkdir $ONOS_INSTALL_DIR/config
 
+    # create dir for Raft log
+    # TODO: use $KARAF_DATA
+    mkdir -p -- $ONOS_INSTALL_DIR/$KARAF_DIST/data/raft
+
     # Install the upstart configuration file and setup options for debugging
     [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf
     echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options
diff --git a/tools/test/bin/onos-remove-raft-logs b/tools/test/bin/onos-remove-raft-logs
index 9797016..1f1e5c6 100755
--- a/tools/test/bin/onos-remove-raft-logs
+++ b/tools/test/bin/onos-remove-raft-logs
@@ -10,4 +10,5 @@
 
 onos-service --cell stop
 
-for node in $nodes; do onos-ssh $node "rm -v /tmp/onos-copy-cat-log_*"; done
+# TODO: use $KARAF_DATA
+for node in $nodes; do onos-ssh $node "rm -v -- $ONOS_INSTALL_DIR/$KARAF_DIST/data/raft/onos-copy-cat-log_*"; done