Yuta HIGUCHI
Committed by Gerrit Code Review

Move CopyCat log to $KARAF_DATA/raft

Change-Id: I97f4766279f875c15c818d4b7f0b168e06e85ac1
......@@ -82,8 +82,7 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
@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 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
@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 @@ public class DatabaseManager implements DatabaseService, DatabaseAdminService {
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();
......
......@@ -35,6 +35,10 @@ ssh $remote "
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
......
......@@ -10,4 +10,5 @@ nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
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
......