MCPcopy
hub / github.com/rueckstiess/mtools / discover

Method discover

mtools/mlaunch/mlaunch.py:1206–1368  ·  view source on GitHub ↗

Fetch state for each processes. Build the self.cluster_tree, self.cluster_tags, self.cluster_running data structures, needed for sub-commands start, stop, list.

(self)

Source from the content-addressed store, hash-verified

1204 # MLaunchTool() object
1205
1206 def discover(self):
1207 """
1208 Fetch state for each processes.
1209
1210 Build the self.cluster_tree, self.cluster_tags, self.cluster_running
1211 data structures, needed for sub-commands start, stop, list.
1212 """
1213 # need self.args['command'] so fail if it's not available
1214 if (not self.args or 'command' not in self.args or not
1215 self.args['command']):
1216 return
1217
1218 # load .mlaunch_startup file for start, stop, list, use current
1219 # parameters for init
1220 if self.args['command'] == 'init':
1221 self.loaded_args = self.args
1222 self.loaded_unknown_args = self.unknown_args
1223 else:
1224 if not self._load_parameters():
1225 startup_file = os.path.join(self.dir, ".mlaunch_startup")
1226 raise SystemExit("Can't read %s, use 'mlaunch init ...' first."
1227 % startup_file)
1228
1229 self.ssl_pymongo_options = self._get_ssl_pymongo_options(self.loaded_args)
1230 self.tls_pymongo_options = self._get_tls_pymongo_options(self.loaded_args)
1231
1232 # reset cluster_* variables
1233 self.cluster_tree = {}
1234 self.cluster_tags = defaultdict(list)
1235 self.cluster_running = {}
1236
1237 # get shard names
1238 shard_names = self._get_shard_names(self.loaded_args)
1239
1240 # some shortcut variables
1241 is_sharded = ('sharded' in self.loaded_args and
1242 self.loaded_args['sharded'] is not None)
1243 is_replicaset = ('replicaset' in self.loaded_args and
1244 self.loaded_args['replicaset'])
1245 is_single = 'single' in self.loaded_args and self.loaded_args['single']
1246 has_arbiter = ('arbiter' in self.loaded_args and
1247 self.loaded_args['arbiter'])
1248
1249 # determine number of nodes to inspect
1250 if is_sharded:
1251 num_config = self.loaded_args['config']
1252 # at least one temp. mongos for adding shards, will be
1253 # killed later on
1254 num_mongos = max(1, self.loaded_args['mongos'])
1255 num_shards = len(shard_names)
1256 else:
1257 num_shards = 1
1258 num_config = 0
1259 num_mongos = 0
1260
1261 num_nodes_per_shard = self.loaded_args['nodes'] if is_replicaset else 1
1262 if has_arbiter:
1263 num_nodes_per_shard += 1

Callers 7

initMethod · 0.95
startMethod · 0.95
listMethod · 0.95
killMethod · 0.95
_construct_cmdlinesMethod · 0.95
teardown_methodMethod · 0.80
test_kill_partialMethod · 0.80

Calls 7

_load_parametersMethod · 0.95
_get_shard_namesMethod · 0.95
is_runningMethod · 0.95
clientMethod · 0.95
commandMethod · 0.80

Tested by 2

teardown_methodMethod · 0.64
test_kill_partialMethod · 0.64