[Fawkes Git] branch/fzwilling/robot-memory: robot-memory: proper first setup of local mongod with oplog

Frederik Zwilling zwilling at kbsg.rwth-aachen.de
Thu Oct 13 13:22:46 CEST 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, fzwilling/robot-memory has been updated
        to  7c6cda7df994d2355c46debc88d29b906cf3f99d (commit)
      from  e1e2264aa7bfe8ac10bf83dfc7e6eacd9bdd3431 (commit)

http://git.fawkesrobotics.org/fawkes.git/fzwilling/robot-memory

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit 7c6cda7df994d2355c46debc88d29b906cf3f99d
Author:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
AuthorDate: Thu Oct 13 13:21:38 2016 +0200
Commit:     Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
CommitDate: Thu Oct 13 13:22:40 2016 +0200

    robot-memory: proper first setup of local mongod with oplog

http://git.fawkesrobotics.org/fawkes.git/commit/7c6cda7
http://trac.fawkesrobotics.org/changeset/7c6cda7

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/plugins/robot-memory/robot_memory_setup.cpp |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* 7c6cda7df994d2355c46debc88d29b906cf3f99d - - - - - - - - - -
Author:  Frederik Zwilling <zwilling at kbsg.rwth-aachen.de>
Date:    Thu Oct 13 13:21:38 2016 +0200
Subject: robot-memory: proper first setup of local mongod with oplog

 src/plugins/robot-memory/robot_memory_setup.cpp |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/robot-memory/robot_memory_setup.cpp b/src/plugins/robot-memory/robot_memory_setup.cpp
index 9f1d077..db73a54 100644
--- a/src/plugins/robot-memory/robot_memory_setup.cpp
+++ b/src/plugins/robot-memory/robot_memory_setup.cpp
@@ -48,11 +48,12 @@ void RobotMemorySetup::setup_mongods()
   //start local mongod if necessary
   unsigned int local_port = config->get_uint("plugins/robot-memory/setup/local/port");
   std::string local_db_name = config->get_string("plugins/robot-memory/database");
+  std::string local_repl_name = config->get_string("plugins/robot-memory/setup/local/replica-set-name");
   std::string local_port_str = std::to_string(local_port);
   const char *local_argv[] = {"mongod", "--port", local_port_str.c_str(),
-      "--replSet", "local", NULL}; //'local' replica set to enable the oplog
+      "--replSet", local_repl_name.c_str(), NULL}; //local replica set just to enable the oplog
   start_mongo_process("mongod-local", local_port, local_argv);
-  std::string local_config = "{_id: 'local', members:[{_id:1,host:'localhost:" + local_port_str + "'}]}";
+  std::string local_config = "{_id: '" + local_repl_name + "', members:[{_id:1,host:'localhost:" + local_port_str + "'}]}";
   run_mongo_command(local_port, std::string("{replSetInitiate:" + local_config + "}"), "already initialized");
   //wait for initialization
   usleep(1000000);
@@ -101,15 +102,16 @@ void RobotMemorySetup::setup_mongods()
 
   //configure mongos (add parts of the sharded cluster)
   mongo::BSONObj current_shards =  run_mongo_command(mongos_port, std::string("{listShards:1}"));
-  if(current_shards.getField("shards").Array().size() == 0)
+  if(current_shards.getField("shards").Array().size() < 2)
   {
-    run_mongo_command(mongos_port, std::string("{addShard: 'localhost:" + local_port_str + "'}"), "host already used");
+    run_mongo_command(mongos_port, std::string("{addShard: '" + local_repl_name +
+      "/localhost:" + local_port_str + "'}"), "host already used");
     run_mongo_command(mongos_port, std::string("{addShard: '" + distributed_replset +
       "/localhost:" + distributed_port_str + "'}"), "host already used");
   }
   //define which db is in which shard
   run_mongo_command(mongos_port, std::string("{movePrimary: '" + distributed_replset + "', to: '" + distributed_replset + "'}"), "it is already the primary");
-  run_mongo_command(mongos_port, std::string("{movePrimary: '" + local_db_name + "', to: 'shard0000'}"), "it is already the primary");
+  run_mongo_command(mongos_port, std::string("{movePrimary: '" + local_db_name + "', to: '" + local_repl_name + "'}"), "it is already the primary");
 }
 
 /**




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list