def main(): """ <Purpose> The main function that calls the process_nodes_and_change_state() function in the node_transition_lib passing in the process and error functions. <Arguments> None <Exceptions> None <Side Effects> None """ # Open and read the resource file that is necessary for twopercent vessels. # This will determine how the vessels will be split and how much resource # will be allocated to each vessel. twopercent_resource_fd = file(RESOURCES_TEMPLATE_FILE_PATH) twopercent_resourcetemplate = twopercent_resource_fd.read() twopercent_resource_fd.close() # We are going to transition all the nodes that are in the canonical state # to the twopercent state. We are going to do this in three different # state. First we are going to transition all the canonical state nodes # to the movingto_twopercent state with a no-op function. The reason for # this is, so if anything goes wrong, we can revert back. # In the second step we are going to attempt to move all the nodes in the # movingto_twopercent state to the twopercent state. The way to do this, is # we are going to split the vessels by giving each vessel the resources # that are described in the resource template. # Next we are going to try to transition all the nodes in the # movingto_twopercent state to the canonical state. Any nodes that failed # to go to the twopercent are still stuck in the movingto_twopercent state, # and we want to move them back to the canonical state. # Variables that determine weather to mark a node inactive or not. mark_node_inactive = False mark_node_active = True state_function_arg_tuplelist = [ ("canonical", "movingto_twopercent", node_transition_lib.noop, node_transition_lib.noop, mark_node_inactive), ("movingto_twopercent", "twopercent", node_transition_lib.split_vessels, node_transition_lib.noop, mark_node_active, twopercent_resourcetemplate), ("movingto_twopercent", "canonical", node_transition_lib.combine_vessels, node_transition_lib.noop, mark_node_inactive) ] sleeptime = 10 process_name = "canonical_to_twopercent" parallel_instances = 10 #call process_nodes_and_change_state() to start the node state transition node_transition_lib.process_nodes_and_change_state( state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)
def main(): """ <Purpose> The main function that calls the process_nodes_and_change_state() function in the node_transition_lib passing in the process and error functions. <Arguments> None <Exceptions> None <Side Effects> None """ # Mark the node as active. mark_node_active = True state_function_arg_tuplelist = [ ("twopercent", "twopercent", node_transition_lib.update_database, node_transition_lib.noop, mark_node_active, node_transition_lib.update_database_node)] sleeptime = 10 process_name = "twopercent_to_twopercent" parallel_instances = 10 #call process_nodes_and_change_state() to start the node state transition node_transition_lib.process_nodes_and_change_state(state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)
def main(): """ <Purpose> The main function that calls the process_nodes_and_change_state() function in the node_transition_lib passing in the process and error functions. <Arguments> None <Exceptions> None <Side Effects> None """ # Mark the node as active. mark_node_active = True state_function_arg_tuplelist = [ ("twopercent", "twopercent", node_transition_lib.update_database, node_transition_lib.noop, mark_node_active, node_transition_lib.update_database_node) ] sleeptime = 10 process_name = "twopercent_to_twopercent" parallel_instances = 10 #call process_nodes_and_change_state() to start the node state transition node_transition_lib.process_nodes_and_change_state( state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)
def main(): """ <Purpose> The main function that calls the process_nodes_and_change_state() function in the node_transition_lib passing in the process and error functions. <Arguments> None <Exceptions> None <Side Effects> None """ state_function_arg_tuplelist = [ ("acceptdonation", "canonical", node_transition_lib.noop, node_transition_lib.noop, False) ] sleeptime = 10 process_name = "donation_to_canonical" parallel_instances = 10 #call process_nodes_and_change_state() to start the node state transition node_transition_lib.process_nodes_and_change_state( state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)
def main(): """ <Purpose> The main function that calls the process_nodes_and_change_state() function in the node_transition_lib passing in the process and error functions. <Arguments> None <Exceptions> None <Side Effects> None """ # Open and read the resource file that is necessary for twopercent vessels. # This will determine how the vessels will be split and how much resource # will be allocated to each vessel. twopercent_resource_fd = file(RESOURCES_TEMPLATE_FILE_PATH) twopercent_resourcetemplate = twopercent_resource_fd.read() twopercent_resource_fd.close() # We are going to transition all the nodes that are in the canonical state # to the twopercent state. We are going to do this in three different # state. First we are going to transition all the canonical state nodes # to the movingto_twopercent state with a no-op function. The reason for # this is, so if anything goes wrong, we can revert back. # In the second step we are going to attempt to move all the nodes in the # movingto_twopercent state to the twopercent state. The way to do this, is # we are going to split the vessels by giving each vessel the resources # that are described in the resource template. # Next we are going to try to transition all the nodes in the # movingto_twopercent state to the canonical state. Any nodes that failed # to go to the twopercent are still stuck in the movingto_twopercent state, # and we want to move them back to the canonical state. # Variables that determine weather to mark a node inactive or not. mark_node_inactive = False mark_node_active = True state_function_arg_tuplelist = [ ("canonical", "movingto_twopercent", node_transition_lib.noop, node_transition_lib.noop, mark_node_inactive), ("movingto_twopercent", "twopercent", node_transition_lib.split_vessels, node_transition_lib.noop, mark_node_active, twopercent_resourcetemplate), ("movingto_twopercent", "canonical", node_transition_lib.combine_vessels, node_transition_lib.noop, mark_node_inactive)] sleeptime = 10 process_name = "canonical_to_twopercent" parallel_instances = 10 #call process_nodes_and_change_state() to start the node state transition node_transition_lib.process_nodes_and_change_state(state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)
def main(): """ <Purpose> The main function that calls the process_nodes_and_change_state() function in the node_transition_lib passing in the process and error functions. <Arguments> None <Exceptions> None <Side Effects> None """ state_function_arg_tuplelist = [("acceptdonation", "canonical", node_transition_lib.noop, node_transition_lib.noop, False)] sleeptime = 10 process_name = "donation_to_canonical" parallel_instances = 10 #call process_nodes_and_change_state() to start the node state transition node_transition_lib.process_nodes_and_change_state(state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)
def main(): """ <Purpose> This is the main launching point for this script. We are going to call the node_transition_lib and start the process of moving from onepercentmanyevents state to the canonical state through an intermediate state the moving_to_canonical state. This wasy if anything fails, we can go back to the onepercent state. <Arguments> None. <Exceptions> None <Side Effects> A lot of nodes are altered. <Return> None. """ # Open and read the resource file that is necessary for onepercentmanyevents onepercentmanyevents_resource_fd = file(RESOURCES_TEMPLATE_FILE_PATH) onepercentmanyevents_resourcetemplate = onepercentmanyevents_resource_fd.read( ) onepercentmanyevents_resource_fd.close() # Create a list that is used to call node_transition_lib. # The list will have a list of three tuples. The first # tuple will transition all the onepercentmanyevents state # to the moving_to_canonical state. This will use noop functions. # We will not actually perform any actions. Next we will transition # all the moving_to_canonical state nodes to the canonical state by # performing a join operation on all the vessels, to combine all the # vessels on one node into one giant node that it was before it got # split. # In the next phase we will transition all the moving_to_canonical # state nodes into the onepercentmanyevents state. This is for the # case where we might have failed to combine the vessels and move # to canonical state, so we want to restore them back to the # onepercent state. # We are not going to mark any of the nodes active in the database, # as we are joining the vessels back together. mark_nodes_inactive = False state_function_arg_tuplelist = [ ("onepercentmanyevents", "movingto_canonical", node_transition_lib.noop, node_transition_lib.noop, mark_nodes_inactive), ("movingto_canonical", "canonical", node_transition_lib.combine_vessels, node_transition_lib.noop, mark_nodes_inactive), ("movingto_canonical", "onepercentmanyevents_state", node_transition_lib.split_vessels, node_transition_lib.noop, mark_nodes_inactive, onepercentmanyevents_resourcetemplate) ] # Some constant variables we will use to call node_transition_lib. sleeptime = 10 process_name = "onepercentmanyevents_to_canonical" parallel_instances = 10 # Call the process_node_and_change_state() function to attempt to # transition all the nodes from onepercentmanyevents to canonical. node_transition_lib.process_nodes_and_change_state( state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)
def main(): """ <Purpose> This is the main launching point for this script. We are going to call the node_transition_lib and start the process of moving from onepercentmanyevents state to the canonical state through an intermediate state the moving_to_canonical state. This wasy if anything fails, we can go back to the onepercent state. <Arguments> None. <Exceptions> None <Side Effects> A lot of nodes are altered. <Return> None. """ # Open and read the resource file that is necessary for onepercentmanyevents onepercentmanyevents_resource_fd = file(RESOURCES_TEMPLATE_FILE_PATH) onepercentmanyevents_resourcetemplate = onepercentmanyevents_resource_fd.read() onepercentmanyevents_resource_fd.close() # Create a list that is used to call node_transition_lib. # The list will have a list of three tuples. The first # tuple will transition all the onepercentmanyevents state # to the moving_to_canonical state. This will use noop functions. # We will not actually perform any actions. Next we will transition # all the moving_to_canonical state nodes to the canonical state by # performing a join operation on all the vessels, to combine all the # vessels on one node into one giant node that it was before it got # split. # In the next phase we will transition all the moving_to_canonical # state nodes into the onepercentmanyevents state. This is for the # case where we might have failed to combine the vessels and move # to canonical state, so we want to restore them back to the # onepercent state. # We are not going to mark any of the nodes active in the database, # as we are joining the vessels back together. mark_nodes_inactive=False state_function_arg_tuplelist = [ ("onepercentmanyevents", "movingto_canonical", node_transition_lib.noop, node_transition_lib.noop, mark_nodes_inactive), ("movingto_canonical", "canonical", node_transition_lib.combine_vessels, node_transition_lib.noop, mark_nodes_inactive), ("movingto_canonical", "onepercentmanyevents_state", node_transition_lib.split_vessels, node_transition_lib.noop, mark_nodes_inactive, onepercentmanyevents_resourcetemplate)] # Some constant variables we will use to call node_transition_lib. sleeptime = 10 process_name = "onepercentmanyevents_to_canonical" parallel_instances = 10 # Call the process_node_and_change_state() function to attempt to # transition all the nodes from onepercentmanyevents to canonical. node_transition_lib.process_nodes_and_change_state(state_function_arg_tuplelist, process_name, sleeptime, parallel_instances)