#NEWLINE# def driver( reactor , cluster , scenario_factory , operation_factory , metric_factory , num_samples , result , output ) : #NEWLINE# #INDENT# '\n    :param reactor: Reactor to use.\n    :param BenchmarkCluster cluster: Benchmark cluster.\n    :param callable scenario_factory: A load scenario factory.\n    :param callable operation_factory: An operation factory.\n    :param callable metric_factory: A metric factory.\n    :param int num_samples: Number of samples to take.\n    :param result: A dictionary which will be updated with values to\n        create a JSON result.\n    :param output: A callable to receive the JSON structure, for\n        printing or storage.\n    ' #NEWLINE# control_service = cluster . get_control_service ( reactor ) #NEWLINE# d = gather_deferreds ( [ control_service . version ( ) , control_service . list_nodes ( ) , control_service . list_containers_configuration ( ) , control_service . list_datasets_configuration ( ) ] ) #NEWLINE# def add_control_service( characteristics , result ) : #NEWLINE# #INDENT# version = characteristics [ 0 ] #NEWLINE# node_count = len ( characteristics [ 1 ] ) #NEWLINE# container_count = len ( characteristics [ 2 ] ) #NEWLINE# dataset_count = len ( characteristics [ 3 ] . datasets ) #NEWLINE# result [ 'control_service' ] = dict ( host = cluster . control_node_address ( ) . compressed , flocker_version = version [ 'flocker' ] , node_count = node_count , container_count = container_count , dataset_count = dataset_count ) #NEWLINE# #UNINDENT# d . addCallback ( add_control_service , result ) #NEWLINE# def run_benchmark( ignored ) : #NEWLINE# #INDENT# return benchmark ( scenario_factory ( reactor , cluster ) , operation_factory ( reactor , cluster ) , metric_factory ( reactor , cluster ) , num_samples ) #NEWLINE# #UNINDENT# d . addCallback ( control_service ) #NEWLINE# def add_samples( outputs , result ) : #NEWLINE# #INDENT# ( samples , scenario_metrics ) = outputs #NEWLINE# result [ 'samples' ] = samples #NEWLINE# if scenario_metrics : #NEWLINE# #INDENT# result [ 'scenario' ] [ 'metrics' ] = scenario_metrics #NEWLINE# #UNINDENT# return result #NEWLINE# #UNINDENT# d . addCallback ( add_samples , result ) #NEWLINE# d . addCallback ( output ) #NEWLINE# return d