@@ -236,11 +236,10 @@ def init_from_parsed_args(self, parsed_args):
236
236
self .tmaster_stats_port = parsed_args .tmaster_stats_port
237
237
self .heron_internals_config_file = parsed_args .heron_internals_config_file
238
238
self .override_config_file = parsed_args .override_config_file
239
- self .component_ram_map = \
240
- map (lambda x : {x .split (':' )[0 ]:
241
- int (x .split (':' )[1 ])}, parsed_args .component_ram_map .split (',' ))
242
- self .component_ram_map = \
243
- functools .reduce (lambda x , y : dict (x .items () + y .items ()), self .component_ram_map )
239
+ self .component_ram_map = [{x .split (':' )[0 ]:int (x .split (':' )[1 ])}
240
+ for x in parsed_args .component_ram_map .split (',' )]
241
+ self .component_ram_map = functools .reduce (lambda x , y : dict (list (x .items ()) + list (y .items ())),
242
+ self .component_ram_map )
244
243
245
244
# component_jvm_opts_in_base64 itself is a base64-encoding-json-map, which is appended with
246
245
# " at the start and end. It also escapes "=" to "&equals" due to aurora limitation
@@ -256,7 +255,7 @@ def init_from_parsed_args(self, parsed_args):
256
255
base64 .b64decode (parsed_args .component_jvm_opts .
257
256
lstrip ('"' ).rstrip ('"' ).replace ('(61)' , '=' ).replace ('=' , '=' ))
258
257
if component_jvm_opts_in_json != "" :
259
- for (k , v ) in json .loads (component_jvm_opts_in_json ).items ():
258
+ for (k , v ) in list ( json .loads (component_jvm_opts_in_json ).items () ):
260
259
# In json, the component name and JVM options are still in base64 encoding
261
260
self .component_jvm_opts [base64 .b64decode (k )] = base64 .b64decode (v )
262
261
@@ -366,7 +365,7 @@ def parse_args(args):
366
365
parser .add_argument ("--is-stateful" , required = True )
367
366
parser .add_argument ("--checkpoint-manager-classpath" , required = True )
368
367
parser .add_argument ("--checkpoint-manager-port" , required = True )
369
- parser .add_argument ("--checkpoint-manager-ram" , type = long , required = True )
368
+ parser .add_argument ("--checkpoint-manager-ram" , type = int , required = True )
370
369
parser .add_argument ("--stateful-config-file" , required = True )
371
370
parser .add_argument ("--health-manager-mode" , required = True )
372
371
parser .add_argument ("--health-manager-classpath" , required = True )
@@ -793,7 +792,7 @@ def _get_streaming_processes(self):
793
792
'--zkhostportlist=%s' % self .state_manager_connection ,
794
793
'--zkroot=%s' % self .state_manager_root ,
795
794
'--stmgr_id=%s' % self .stmgr_ids [self .shard ],
796
- '--instance_ids=%s' % ',' .join (map ( lambda x : x [0 ], instance_info ) ),
795
+ '--instance_ids=%s' % ',' .join ([ x [0 ] for x in instance_info ] ),
797
796
'--myhost=%s' % self .master_host ,
798
797
'--data_port=%s' % str (self .master_port ),
799
798
'--local_data_port=%s' % str (self .tmaster_controller_port ),
@@ -958,8 +957,8 @@ def _run_blocking_process(self, cmd, is_shell=False):
958
957
def _kill_processes (self , commands ):
959
958
# remove the command from processes_to_monitor and kill the process
960
959
with self .process_lock :
961
- for command_name , command in commands .items ():
962
- for process_info in self .processes_to_monitor .values ():
960
+ for command_name , command in list ( commands .items () ):
961
+ for process_info in list ( self .processes_to_monitor .values () ):
963
962
if process_info .name == command_name :
964
963
del self .processes_to_monitor [process_info .pid ]
965
964
Log .info ("Killing %s process with pid %d: %s" %
@@ -978,7 +977,7 @@ def _start_processes(self, commands):
978
977
Log .info ("Start processes" )
979
978
processes_to_monitor = {}
980
979
# First start all the processes
981
- for (name , command ) in commands .items ():
980
+ for (name , command ) in list ( commands .items () ):
982
981
p = self ._run_process (name , command )
983
982
processes_to_monitor [p .pid ] = ProcessInfo (p , name , command )
984
983
@@ -999,7 +998,7 @@ def start_process_monitor(self):
999
998
(pid , status ) = os .wait ()
1000
999
1001
1000
with self .process_lock :
1002
- if pid in self .processes_to_monitor .keys ():
1001
+ if pid in list ( self .processes_to_monitor .keys () ):
1003
1002
old_process_info = self .processes_to_monitor [pid ]
1004
1003
name = old_process_info .name
1005
1004
command = old_process_info .command
@@ -1061,19 +1060,19 @@ def get_command_changes(self, current_commands, updated_commands):
1061
1060
1062
1061
# if the current command has a matching command in the updated commands we keep it
1063
1062
# otherwise we kill it
1064
- for current_name , current_command in current_commands .items ():
1063
+ for current_name , current_command in list ( current_commands .items () ):
1065
1064
# We don't restart tmaster since it watches the packing plan and updates itself. The stream
1066
1065
# manager is restarted just to reset state, but we could update it to do so without a restart
1067
- if current_name in updated_commands .keys () and \
1066
+ if current_name in list ( updated_commands .keys () ) and \
1068
1067
current_command == updated_commands [current_name ] and \
1069
1068
not current_name .startswith ('stmgr-' ):
1070
1069
commands_to_keep [current_name ] = current_command
1071
1070
else :
1072
1071
commands_to_kill [current_name ] = current_command
1073
1072
1074
1073
# updated commands not in the keep list need to be started
1075
- for updated_name , updated_command in updated_commands .items ():
1076
- if updated_name not in commands_to_keep .keys ():
1074
+ for updated_name , updated_command in list ( updated_commands .items () ):
1075
+ if updated_name not in list ( commands_to_keep .keys () ):
1077
1076
commands_to_start [updated_name ] = updated_command
1078
1077
1079
1078
return commands_to_kill , commands_to_keep , commands_to_start
@@ -1083,8 +1082,8 @@ def launch(self):
1083
1082
Then starts new ones required and kills old ones no longer required.
1084
1083
'''
1085
1084
with self .process_lock :
1086
- current_commands = dict (map ((lambda process : (process .name , process .command )),
1087
- self .processes_to_monitor .values ()))
1085
+ current_commands = dict (list ( map ((lambda process : (process .name , process .command )),
1086
+ list ( self .processes_to_monitor .values ()) )))
1088
1087
updated_commands = self .get_commands_to_run ()
1089
1088
1090
1089
# get the commands to kill, keep and start
@@ -1176,7 +1175,7 @@ def cleanup():
1176
1175
Log .info ('Executor terminated; exiting all process in executor.' )
1177
1176
1178
1177
# Kill child processes first and wait for log collection to finish
1179
- for pid in executor .processes_to_monitor .keys ():
1178
+ for pid in list ( executor .processes_to_monitor .keys () ):
1180
1179
os .kill (pid , signal .SIGTERM )
1181
1180
time .sleep (5 )
1182
1181
@@ -1192,7 +1191,7 @@ def cleanup():
1192
1191
sid = os .getsid (pid )
1193
1192
1194
1193
# POSIX prohibits the change of the process group ID of a session leader
1195
- if pid <> sid :
1194
+ if pid != sid :
1196
1195
Log .info ('Set up process group; executor becomes leader' )
1197
1196
os .setpgrp () # create new process group, become its leader
1198
1197
0 commit comments