@@ -2724,41 +2724,6 @@ static vine_result_code_t start_one_task(struct vine_manager *q, struct vine_wor
27242724 return result ;
27252725}
27262726
2727- /*
2728- Start one task on a given worker by specializing the task to the worker,
2729- sending the appropriate input files, and then sending the details of the task.
2730- Note that the "infile" and "outfile" components of the task refer to
2731- files that have already been uploaded into the worker's cache by the manager.
2732- */
2733-
2734- static vine_result_code_t start_group_task (
2735- struct vine_manager * q , struct vine_worker_info * w , struct vine_task * t , struct list * l )
2736- {
2737- vine_result_code_t result = 0 ;
2738- struct vine_task * lt ;
2739- LIST_ITERATE (l , lt )
2740- {
2741- struct rmsummary * limits = vine_manager_choose_resources_for_task (q , w , t );
2742- char * command_line ;
2743-
2744- if (q -> monitor_mode && !t -> needs_library ) {
2745- command_line = vine_monitor_wrap (q , w , t , limits );
2746- } else {
2747- command_line = xxstrdup (t -> command_line );
2748- }
2749- result = vine_manager_put_task (q , w , lt , command_line , limits , 0 );
2750- free (command_line );
2751- if (result == VINE_SUCCESS ) {
2752- t -> current_resource_box = limits ;
2753- rmsummary_merge_override_basic (t -> resources_allocated , limits );
2754- debug (D_VINE , "%s (%s) busy on group '%s'" , w -> hostname , w -> addrport , t -> command_line );
2755- } else {
2756- rmsummary_delete (limits );
2757- }
2758- }
2759- return result ;
2760- }
2761-
27622727static void count_worker_resources (struct vine_manager * q , struct vine_worker_info * w )
27632728{
27642729 w -> resources -> cores .inuse = 0 ;
@@ -2865,6 +2830,7 @@ assignment and the new task state.
28652830
28662831static vine_result_code_t commit_task_to_worker (struct vine_manager * q , struct vine_worker_info * w , struct vine_task * t )
28672832{
2833+ <<<<<<< HEAD
28682834 vine_result_code_t result = VINE_SUCCESS ;
28692835
28702836 /* Kill unused libraries on this worker to reclaim resources. */
@@ -2894,31 +2860,52 @@ static vine_result_code_t commit_task_to_worker(struct vine_manager *q, struct v
28942860
28952861 t -> time_when_commit_start = timestamp_get ();
28962862 vine_result_code_t result ;
2863+ = == == ==
2864+ vine_result_code_t result = 0 ;
2865+ >>>>>>> 5 ab8af678 (add worker code )
28972866 struct list * l = 0 ;
2898- if (t -> group_id ) {
2899- l = hash_table_lookup (q -> task_group_table , t -> group_id );
2900- }
2901- if (l && list_size (l ) > 1 ) {
2902- result = start_group_task (q , w , t , l );
2903- } else {
2867+ l = hash_table_lookup (q -> task_group_table , t -> group_id );
2868+ int counter = 0 ;
2869+ do {
2870+ /* Kill empty libraries to reclaim resources. Match the assumption of
2871+ * @vine.schedule.c:check_worker_have_enough_resources() */
2872+ kill_empty_libraries_on_worker (q , w , t );
2873+ t -> hostname = xxstrdup (w -> hostname );
2874+ t -> addrport = xxstrdup (w -> addrport );
2875+
2876+ t -> time_when_commit_start = timestamp_get ();
29042877 result = start_one_task (q , w , t );
2905- }
2906- t -> time_when_commit_end = timestamp_get ();
2878+ t -> time_when_commit_end = timestamp_get ();
2879+
2880+ itable_insert (w -> current_tasks , t -> task_id , t );
2881+ t -> worker = w ;
2882+
2883+ /* Increment the function count if this is a function task.
2884+ * If the manager fails to send this function task to the worker however,
2885+ * then the count will be decremented properly in @handle_failure() below. */
2886+ if (t -> needs_library ) {
2887+ t -> library_task = find_library_on_worker_for_task (w , t -> needs_library );
2888+ t -> library_task -> function_slots_inuse ++ ;
2889+ vine_txn_log_write_library_update (q , w , t -> task_id , VINE_LIBRARY_SENT );
2890+ }
29072891
2908- itable_insert (w -> current_tasks , t -> task_id , t );
2909- t -> worker = w ;
2892+ change_task_state (q , t , VINE_TASK_RUNNING );
29102893
2911- change_task_state (q , t , VINE_TASK_RUNNING );
2894+ t -> try_count += 1 ;
2895+ q -> stats -> tasks_dispatched += 1 ;
29122896
2913- t -> try_count += 1 ;
2914- q -> stats -> tasks_dispatched += 1 ;
2897+ count_worker_resources (q , w );
29152898
2916- count_worker_resources (q , w );
2899+ if (result != VINE_SUCCESS ) {
2900+ debug (D_VINE , "Failed to send task %d to worker %s (%s)." , t -> task_id , w -> hostname , w -> addrport );
2901+ handle_failure (q , w , t , result );
2902+ }
29172903
2918- if (result != VINE_SUCCESS ) {
2919- debug (D_VINE , "Failed to send task %d to worker %s (%s)." , t -> task_id , w -> hostname , w -> addrport );
2920- handle_failure (q , w , t , result );
2921- }
2904+ counter ++ ;
2905+
2906+ } while ((t = list_next_item (l )));
2907+
2908+ debug (D_VINE , "Sent batch of %d tasks to worker %s" , counter , w -> hostname );
29222909
29232910 return result ;
29242911}
0 commit comments