70 |
type request_result = |
type request_result = |
71 |
| File_possible (* we asked, but didn't know *) |
| File_possible (* we asked, but didn't know *) |
72 |
| File_not_found (* we asked, the file is not there *) |
| File_not_found (* we asked, the file is not there *) |
73 |
| File_expected (* we asked, because it was announced *) |
(* | File_expected we asked, because it was announced *) |
74 |
| File_new_source (* we never asked, but we should *) |
| File_new_source (* we never asked, but we should *) |
75 |
| File_found (* the file was found *) |
| File_found (* the file was found *) |
76 |
| File_chunk (* the file has chunks we want *) |
| File_chunk (* the file has chunks we want *) |
77 |
| File_upload (* we uploaded from this client *) |
| File_upload (* we uploaded from this client *) |
78 |
| File_unknown (* We don't know anything *) |
(* | File_unknown We don't know anything *) |
79 |
|
|
|
let initial_new_source_score = 10 (* before the first request *) |
|
|
let new_source_score = 1 (* after the first request *) |
|
80 |
let not_found_score = -5 |
let not_found_score = -5 |
81 |
let possible_score = -3 |
let possible_score = -3 |
82 |
let expected_score = 0 |
let new_source_score = 1 (* after the first request *) |
83 |
let found_score = 3 |
let found_score = 3 |
84 |
let chunk_score = 5 |
let chunk_score = 5 |
85 |
let upload_score = 7 |
let upload_score = 7 |
86 |
|
let initial_new_source_score = 10 (* before the first request *) |
87 |
|
|
88 |
let outside_queue = -1 |
let outside_queue = -1 |
89 |
let new_sources_queue = 0 |
let new_sources_queue = 0 |
341 |
else |
else |
342 |
find_throttled_queue (queue + 1) |
find_throttled_queue (queue + 1) |
343 |
|
|
344 |
|
let get_throttle_delay m q throttled = |
345 |
|
if throttled then |
346 |
|
(max 0 |
347 |
|
(queue_period.(q) |
348 |
|
- (file_priority (m.manager_file ())) |
349 |
|
+ Queue.length m.manager_sources.(connected_sources_queue)) |
350 |
|
) |
351 |
|
else 0 |
352 |
|
|
353 |
(* |
(* |
354 |
* determine the number of (throttled) ready sources for a manager queue |
* determine the number of (throttled) ready sources for a manager queue |
355 |
*) |
*) |
356 |
let count_file_ready_sources m q throttled = |
let count_file_ready_sources m q throttled = |
357 |
let ready_count = ref 0 in |
let ready_count = ref 0 in |
358 |
let throttle_delay = |
let throttle_delay = get_throttle_delay m q throttled in |
|
if throttled then |
|
|
(max 0 (queue_period.(q) - |
|
|
(file_priority (m.manager_file ())) + |
|
|
Queue.length m.manager_sources.(connected_sources_queue))) |
|
|
else |
|
|
0 |
|
|
in |
|
359 |
Queue.iter |
Queue.iter |
360 |
(fun ( time, s ) -> |
(fun ( time, s ) -> |
361 |
if time + !!min_reask_delay + throttle_delay < last_time () then |
if time + !!min_reask_delay + throttle_delay < last_time () then |
457 |
let pos_to_string v = |
let pos_to_string v = |
458 |
(if v > 0 then string_of_int(v) else "-") |
(if v > 0 then string_of_int(v) else "-") |
459 |
in |
in |
460 |
let html_tr_one () = Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>" in |
|
461 |
let html_tr_two () = Printf.bprintf buf "\\<tr class=\\\"dl-2\\\"\\>" in |
html_mods_cntr_init(); |
462 |
|
let mycntr = ref 1 in |
463 |
|
|
464 |
|
let html_tr () = begin |
465 |
|
mycntr := html_mods_cntr(); |
466 |
|
Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (!mycntr) |
467 |
|
end |
468 |
|
in |
469 |
|
let html_tr_same () = Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (!mycntr) in |
470 |
|
|
471 |
(* Header *) |
(* Header *) |
472 |
if output_type = HTML then |
if output_type = HTML then |
473 |
begin |
begin |
474 |
|
|
475 |
|
let header = Printf.sprintf "File sources per manager queue (%d)" (List.length !file_sources_managers) in |
476 |
|
|
477 |
Printf.bprintf buf "\\<div class=results\\>"; |
Printf.bprintf buf "\\<div class=results\\>"; |
478 |
html_mods_table_header buf "sourcesTable" "sources" []; |
html_mods_table_header buf "sourcesTable" "sources" []; |
479 |
Printf.bprintf buf "\\<tr\\>"; |
Printf.bprintf buf "\\<tr\\>"; |
480 |
html_mods_td buf [ |
html_mods_td buf [ |
481 |
("", "srh", "Statistics on sources "); |
("", "srh", "Statistics on sources "); |
482 |
("", "srh", "@ " ^(Date.time_to_string_short timer)); |
("", "srh", "@ " ^(Date.time_to_string_short timer)); |
483 |
("", "srh", "File sources per manager queue"); ]; |
("", "srh", header); ]; |
484 |
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\n"; |
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\n"; |
485 |
|
|
486 |
html_mods_table_header buf "sourcesTable" "sources" [ |
html_mods_table_header buf "sourcesTable" "sources" [ |
487 |
( "0", "srh", "Filename", "Name" ); |
( "0", "srh br", "New sources", Printf.sprintf "New(%d)" new_sources_queue ); |
488 |
( "0", "srh", "New sources", "New" ); |
( "0", "srh br", "Good sources", Printf.sprintf "Good(%d)" good_sources_queue ); |
489 |
( "0", "srh", "Good sources", "Good" ); |
( "0", "srh br", "Ready saved sources", Printf.sprintf "Ready(%d)" ready_saved_sources_queue); |
490 |
( "0", "srh", "Ready sources", "Ready" ); |
( "0", "srh br", "Waiting saved sources", Printf.sprintf "Wait(%d)" waiting_saved_sources_queue); |
491 |
( "0", "srh", "Waiting sources", "Wait" ); |
( "0", "srh br", "Old sources 1", Printf.sprintf "Old1(%d)" old_sources1_queue ); |
492 |
( "0", "srh", "Old sources 1", "Old1" ); |
( "0", "srh br", "Old sources 2", Printf.sprintf "Old2(%d)" old_sources2_queue ); |
493 |
( "0", "srh", "Old sources 2", "Old2" ); |
( "0", "srh br", "Old sources 3", Printf.sprintf "Old3(%d)" old_sources3_queue ); |
494 |
( "0", "srh", "Old sources 3", "Old3" ); |
( "0", "srh br", "Do not try sources", Printf.sprintf "nTry(%d)" do_not_try_queue ); |
495 |
( "0", "srh", "Number of retries", "N..try" ); |
( "0", "srh br", "Connected sources", Printf.sprintf "Conn(%d)" connected_sources_queue ); |
496 |
( "0", "srh", "Connected sources", "Conn..ed" ); |
( "0", "srh br", "Connecting sources", Printf.sprintf "Cing(%d)" connecting_sources_queue ); |
497 |
( "0", "srh", "Connecting sources", "Conn..ing" ); |
( "0", "srh br", "Busy sources", Printf.sprintf "Busy(%d)" busy_sources_queue ); |
498 |
( "0", "srh", "Busy sources", "Busy" ); |
( "0", "srh br", "Total sources", "All" ); |
499 |
( "0", "srh", "Total sources", "Total" ) ]; |
( "0", "srh br", "Filename", "Name" ); ]; |
500 |
end |
end |
501 |
else |
else |
502 |
begin |
begin |
503 |
Printf.bprintf buf "Statistics on sources: time %d\n" (last_time ()); |
Printf.bprintf buf "Statistics on sources: time %d\n" (last_time ()); |
504 |
|
Printf.bprintf buf "File sources per manager queue(%d):\n" (List.length !file_sources_managers); |
505 |
Printf.bprintf buf "File sources per manager queue:\n"; |
Printf.bprintf buf "new good redy wait old1 old2 old3 ntry conn cing busy all\n"; |
|
Printf.bprintf buf "new good rdy wait old1 old2 old3 ntry conn cing busy all\n"; |
|
506 |
(* "9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999" |
(* "9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999" |
507 |
11*5 chars |
11*5 chars |
508 |
one row each: all,indirect,ready*) |
one row each: all,indirect,ready*) |
545 |
let q = m.manager_sources.(i) in |
let q = m.manager_sources.(i) in |
546 |
if output_type = HTML then |
if output_type = HTML then |
547 |
slist := !slist @ [ |
slist := !slist @ [ |
548 |
("", "sr", (pos_to_string (Queue.length q))); ] |
("", "sr ar br", (pos_to_string (Queue.length q))); ] |
549 |
else |
else |
550 |
Printf.bprintf buf "%4d " (Queue.length q); |
Printf.bprintf buf "%4d " (Queue.length q); |
551 |
|
|
572 |
if output_type = HTML then |
if output_type = HTML then |
573 |
begin |
begin |
574 |
sreadylist := !sreadylist @ [ |
sreadylist := !sreadylist @ [ |
575 |
("", "sr", (pos_to_string (Queue.length q))); ] ; |
("", "sr ar br", (pos_to_string (Queue.length q))); ] ; |
576 |
streadylist := !streadylist @ [ |
streadylist := !streadylist @ [ |
577 |
("", "sr", (pos_to_string (count_file_ready_sources m i true))); ] ; |
("", "sr ar br", (pos_to_string (count_file_ready_sources m i true))); ] ; |
578 |
sindirectlist := !sindirectlist @ [ |
sindirectlist := !sindirectlist @ [ |
579 |
("", "sr", (pos_to_string !nindirect)); ] ; |
("", "sr ar br", (pos_to_string !nindirect)); ] ; |
580 |
sinvalidlist := !sinvalidlist @ [ |
sinvalidlist := !sinvalidlist @ [ |
581 |
("", "sr", (pos_to_string !ninvalid)); ] ; |
("", "sr ar br", (pos_to_string !ninvalid)); ] ; |
582 |
end |
end |
583 |
else |
else |
584 |
begin |
begin |
601 |
|
|
602 |
if output_type = HTML then |
if output_type = HTML then |
603 |
begin |
begin |
604 |
html_tr_one (); |
html_tr (); |
605 |
html_mods_td buf ([ |
html_mods_td buf ( |
606 |
("Filename", "sr", (shorten name !!max_name_len)); ] |
!slist |
607 |
@ !slist @ |
@ [ ("", "sr ar br", Printf.sprintf "%d" m.manager_all_sources); ] |
608 |
[ ("", "sr", Printf.sprintf "%d" m.manager_all_sources); ]); |
@ [ ("Filename", "sr", (shorten name !!max_name_len)); ] ); |
609 |
|
|
610 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
611 |
|
|
612 |
html_tr_two (); |
html_tr_same (); |
613 |
html_mods_td buf ([ |
html_mods_td buf ( |
614 |
("", "sr", ((Printf.sprintf "ready with %d active" |
!sreadylist |
615 |
m.manager_active_sources) ^ ( |
@ [ ("", "sr ar br", Printf.sprintf "%d" !anready); ] |
616 |
if file_state (m.manager_file ()) = FileDownloading && need_new_sources m then |
@ [ ("", "sr", ((Printf.sprintf "ready with %d active" m.manager_active_sources) |
617 |
|
^ (if file_state (m.manager_file ()) = FileDownloading |
618 |
|
&& need_new_sources m then |
619 |
begin |
begin |
620 |
incr naneed; |
incr naneed; |
621 |
" and needs sources" |
" and needs sources" |
622 |
end |
end |
623 |
else |
else "") |
624 |
"" |
)); |
625 |
))); ] |
] |
626 |
@ !sreadylist @ |
); |
|
[ ("", "sr", Printf.sprintf "%d" !anready); ]); |
|
627 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
628 |
|
|
629 |
html_tr_two (); |
html_tr_same (); |
630 |
html_mods_td buf ([ |
|
631 |
("", "sr", "throttled ready"); ] |
html_mods_td buf ( |
632 |
@ !streadylist @ |
!streadylist |
633 |
[ ("", "sr", Printf.sprintf "%d" !antready); ]); |
@ [ ("", "sr ar br", Printf.sprintf "%d" !antready); ] |
634 |
|
@ [("", "sr", "throttled ready"); ] |
635 |
|
); |
636 |
|
|
637 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
638 |
|
|
639 |
(if !anindirect <> 0 then |
(if !anindirect <> 0 then |
640 |
begin |
begin |
641 |
html_tr_two (); |
html_tr_same (); |
642 |
html_mods_td buf ([ |
html_mods_td buf ( |
643 |
("", "sr", "indirect"); ] |
!sindirectlist |
644 |
@ !sindirectlist @ |
@ [ ("", "sr ar br", Printf.sprintf "%d" !anindirect); ] |
645 |
[ ("", "sr", Printf.sprintf "%d" !anindirect); ]); |
@ [ ("", "sr", "indirect"); ] |
646 |
|
); |
647 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
648 |
end |
end |
649 |
); |
); |
650 |
|
|
651 |
(if !aninvalid <> 0 then |
(if !aninvalid <> 0 then |
652 |
begin |
begin |
653 |
html_tr_two (); |
html_tr_same (); |
654 |
html_mods_td buf ([ |
html_mods_td buf ( |
655 |
("", "sr", "invalid"); ] |
!sinvalidlist |
656 |
@ !sinvalidlist @ |
@ [ ("", "sr ar br", Printf.sprintf "%d" !aninvalid); ] |
657 |
[ ("", "sr", Printf.sprintf "%d" !aninvalid); ]); |
@ [ ("", "sr", "invalid"); ] |
658 |
|
); |
659 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
660 |
end |
end |
661 |
); |
); |
687 |
|
|
688 |
if output_type = HTML then |
if output_type = HTML then |
689 |
begin |
begin |
690 |
html_tr_one (); |
html_tr (); |
691 |
html_mods_td buf |
|
692 |
[ |
html_mods_td buf [ |
693 |
("", "sr", name); |
("", "sr ar br", "-"); ("", "sr ar br", ""); ("", "sr ar br", ""); |
694 |
("", "sr", ""); ("", "sr", ""); ("", "sr", ""); |
("", "sr ar br", ""); ("", "sr ar br", ""); ("", "sr ar br", ""); |
695 |
("", "sr", ""); ("", "sr", ""); ("", "sr", ""); |
("", "sr ar br", ""); ("", "sr ar br", ""); ("", "sr ar br", ""); |
696 |
("", "sr", ""); ("", "sr", ""); ("", "sr", ""); |
("", "sr ar br", ""); ("", "sr ar br", ""); ("", "sr ar br", ""); |
697 |
("", "sr", ""); ("", "sr", ""); ("", "sr", ""); |
("", "sr br", (shorten name !!max_name_len)); |
698 |
]; |
]; |
699 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
700 |
end |
end |
711 |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
712 |
|
|
713 |
html_mods_table_header buf "sourcesTable" "sources" [ |
html_mods_table_header buf "sourcesTable" "sources" [ |
|
( "0", "srh", "Type", "Type" ); |
|
714 |
( "0", "srh", "New sources", "New" ); |
( "0", "srh", "New sources", "New" ); |
715 |
( "0", "srh", "Good sources", "Good" ); |
( "0", "srh", "Good sources", "Good" ); |
716 |
( "0", "srh", "Ready sources", "Ready" ); |
( "0", "srh", "Ready sources", "Ready" ); |
718 |
( "0", "srh", "Old sources 1", "Old1" ); |
( "0", "srh", "Old sources 1", "Old1" ); |
719 |
( "0", "srh", "Old sources 2", "Old2" ); |
( "0", "srh", "Old sources 2", "Old2" ); |
720 |
( "0", "srh", "Old sources 3", "Old3" ); |
( "0", "srh", "Old sources 3", "Old3" ); |
721 |
( "0", "srh", "Number of retries", "N..try" ); |
( "0", "srh", "Do not try", "nTry" ); |
722 |
( "0", "srh", "Connected sources", "Conn..ed" ); |
( "0", "srh", "Connected sources", "Conn" ); |
723 |
( "0", "srh", "Connecting sources", "Conn..ing" ); |
( "0", "srh", "Connecting sources", "Cing" ); |
724 |
( "0", "srh", "Busy sources", "Busy" ); |
( "0", "srh", "Busy sources", "Busy" ); |
725 |
( "0", "srh", "Total sources", "Total" ) ]; |
( "0", "srh", "Total sources", "All" ); |
726 |
|
( "0", "srh", "Type", "Type" ); ]; |
727 |
|
|
728 |
end |
end |
729 |
else |
else |
730 |
Printf.bprintf buf "new good rdy wait old1 old2 old3 ntry conn cing busy all\n"; |
Printf.bprintf buf "new good redy wait old1 old2 old3 ntry conn cing busy all\n"; |
731 |
|
|
732 |
let slist = ref [] in |
let slist = ref [] in |
733 |
let sreadylist = ref [] in |
let sreadylist = ref [] in |
749 |
if output_type = HTML then |
if output_type = HTML then |
750 |
begin |
begin |
751 |
slist := !slist @ [ |
slist := !slist @ [ |
752 |
("", "sr", (pos_to_string nsources_per_queue.(i))); ] ; |
("", "sr ar", (pos_to_string nsources_per_queue.(i))); ] ; |
753 |
sreadylist := !sreadylist @ [ |
sreadylist := !sreadylist @ [ |
754 |
("", "sr", (pos_to_string nready_per_queue.(i))); ] ; |
("", "sr ar", (pos_to_string nready_per_queue.(i))); ] ; |
755 |
anready := !anready + nready_per_queue.(i); |
anready := !anready + nready_per_queue.(i); |
756 |
streadylist := !streadylist @ [ |
streadylist := !streadylist @ [ |
757 |
("", "sr", (pos_to_string (count_ready_sources i true))); ] ; |
("", "sr ar", (pos_to_string (count_ready_sources i true))); ] ; |
758 |
antready := !antready + (count_ready_sources i true); |
antready := !antready + (count_ready_sources i true); |
759 |
sindirectlist := !sindirectlist @ [ |
sindirectlist := !sindirectlist @ [ |
760 |
("", "sr", (pos_to_string nindirect_per_queue.(i))); ] ; |
("", "sr ar", (pos_to_string nindirect_per_queue.(i))); ] ; |
761 |
anindirect := !anindirect + nindirect_per_queue.(i); |
anindirect := !anindirect + nindirect_per_queue.(i); |
762 |
sinvalidlist := !sinvalidlist @ [ |
sinvalidlist := !sinvalidlist @ [ |
763 |
("", "sr", (pos_to_string ninvalid_per_queue.(i))); ] ; |
("", "sr ar", (pos_to_string ninvalid_per_queue.(i))); ] ; |
764 |
aninvalid := !aninvalid + ninvalid_per_queue.(i); |
aninvalid := !aninvalid + ninvalid_per_queue.(i); |
765 |
speriodlist := !speriodlist @ [ |
speriodlist := !speriodlist @ [ |
766 |
("", "sr", (pos_to_string queue_period.(i))); ] ; |
("", "sr ar", (pos_to_string queue_period.(i))); ] ; |
767 |
end |
end |
768 |
else |
else |
769 |
begin |
begin |
779 |
speriod := Printf.sprintf "%s%4d " !speriod queue_period.(i); |
speriod := Printf.sprintf "%s%4d " !speriod queue_period.(i); |
780 |
end; |
end; |
781 |
done; (* end Queues *) |
done; (* end Queues *) |
782 |
|
|
783 |
let nsources = ref 0 in |
let nsources = ref 0 in |
784 |
HS.iter (fun _ -> incr nsources) sources_by_uid; |
let nroq = ref 0 in |
785 |
|
HS.iter (fun s -> |
786 |
|
incr nsources; |
787 |
|
List.iter (fun r -> |
788 |
|
if r.request_queue = outside_queue then |
789 |
|
incr nroq; |
790 |
|
) s.source_files; |
791 |
|
) sources_by_uid; |
792 |
|
|
793 |
if output_type = HTML then |
if output_type = HTML then |
794 |
begin |
begin |
795 |
html_tr_one (); |
html_tr(); |
796 |
html_mods_td buf ([ |
html_mods_td buf ( |
797 |
("", "sr", Printf.sprintf "all source managers (%d by UID)" !nsources); ] |
!slist |
798 |
@ !slist @ |
@ [ ("", "sr ar", Printf.sprintf "%d" !nall); ] |
799 |
[ ("", "sr", Printf.sprintf "%d" !nall); ]); |
@ [("", "sr", Printf.sprintf "all source managers (%d by UID) (%d ROQ)" !nsources !nroq);] |
800 |
|
); |
801 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
802 |
|
|
803 |
html_tr_two (); |
html_tr (); |
804 |
html_mods_td buf ([ |
html_mods_td buf ( |
805 |
("", "sr", Printf.sprintf "ready with %d active and %i need sources" !naact !naneed); ] |
!sreadylist |
806 |
@ !sreadylist @ |
@ [ ("", "sr ar", Printf.sprintf "%d" !anready); ] |
807 |
[ ("", "sr", Printf.sprintf "%d" !anready); ]); |
@ [ ("", "sr", Printf.sprintf "ready with %d active and %i need sources" !naact !naneed); ] |
808 |
|
); |
809 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
810 |
|
|
811 |
html_tr_two (); |
html_tr(); |
812 |
html_mods_td buf ([ |
html_mods_td buf ( |
813 |
("", "sr", "throttled ready"); ] |
!streadylist |
814 |
@ !streadylist @ |
@ [ ("", "sr ar", Printf.sprintf "%d" !antready); ] |
815 |
[ ("", "sr", Printf.sprintf "%d" !antready); ]); |
@ [ ("", "sr", "throttled ready"); ] |
816 |
|
); |
817 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
818 |
|
|
819 |
(if !anindirect <> 0 then |
(if !anindirect <> 0 then |
820 |
begin |
begin |
821 |
html_tr_two (); |
html_tr (); |
822 |
html_mods_td buf ([ |
html_mods_td buf ( |
823 |
("", "sr", "indirect"); ] |
!sindirectlist |
824 |
@ !sindirectlist @ |
@ [ ("", "sr ar", Printf.sprintf "%d" !anindirect); ] |
825 |
[ ("", "sr", Printf.sprintf "%d" !anindirect); ]); |
@ [ ("", "sr", "indirect"); ] |
826 |
|
); |
827 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
828 |
end |
end |
829 |
); |
); |
830 |
|
|
831 |
(if !aninvalid <> 0 then |
(if !aninvalid <> 0 then |
832 |
begin |
begin |
833 |
html_tr_two (); |
html_tr (); |
834 |
html_mods_td buf ([ |
html_mods_td buf ( |
835 |
("", "sr", "invalid"); ] |
!sinvalidlist |
836 |
@ !sinvalidlist @ |
@ [ ("", "sr ar", Printf.sprintf "%d" !aninvalid); ] |
837 |
[ ("", "sr", Printf.sprintf "%d" !aninvalid); ]); |
@ [ ("", "sr", "invalid"); ] |
838 |
|
); |
839 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
840 |
end |
end |
841 |
); |
); |
842 |
|
|
843 |
html_tr_two (); |
html_tr (); |
844 |
html_mods_td buf ([ |
html_mods_td buf ( |
845 |
("", "sr", "period"); ] |
!speriodlist |
846 |
@ !speriodlist @ |
@ [ ("", "sr", "") ] |
847 |
[ ("", "sr", "") ]); |
@ [("", "sr", "period"); ] |
848 |
|
); |
849 |
Printf.bprintf buf "\\</tr\\>\n"; |
Printf.bprintf buf "\\</tr\\>\n"; |
850 |
|
|
851 |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
852 |
end |
end |
853 |
else |
else |
854 |
begin |
begin |
855 |
Printf.bprintf buf "%4d all source managers %d by UID\n" !nall !nsources; |
Printf.bprintf buf "%4d all source managers (%d by UID) (%d ROQ)\n" !nall !nsources !nroq; |
856 |
Printf.bprintf buf "%s%4d ready %d active %i need sources\n" !sready !anready !naact !naneed; |
Printf.bprintf buf "%s%4d ready %d active %i need sources\n" !sready !anready !naact !naneed; |
857 |
Printf.bprintf buf "%s%4d throttled ready\n" !stready !antready; |
Printf.bprintf buf "%s%4d throttled ready\n" !stready !antready; |
858 |
if !anindirect <> 0 then |
if !anindirect <> 0 then |
932 |
else |
else |
933 |
good_sources_queue |
good_sources_queue |
934 |
else |
else |
935 |
if r.request_score = found_score then |
if r.request_score >= new_source_score then |
|
(* found but, but obviously no chunk! *) |
|
936 |
old_sources1_queue |
old_sources1_queue |
937 |
else |
else |
938 |
old_sources2_queue |
old_sources2_queue |
959 |
m.manager_all_sources <- m.manager_all_sources + 1; |
m.manager_all_sources <- m.manager_all_sources + 1; |
960 |
r.request_queue <- queue |
r.request_queue <- queue |
961 |
|
|
|
|
|
962 |
(*************************************************************************) |
(*************************************************************************) |
963 |
(* *) |
(* *) |
964 |
(* iter_all_sources *) |
(* iter_all_sources *) |
1286 |
source_num = n; |
source_num = n; |
1287 |
source_files = []; |
source_files = []; |
1288 |
} in |
} in |
1289 |
|
|
1290 |
|
|
1291 |
HS.add sources_by_uid s; |
HS.add sources_by_uid s; |
1292 |
H.add sources_by_num s; |
H.add sources_by_num s; |
1293 |
s |
s |
1319 |
let find_request s file = |
let find_request s file = |
1320 |
iter_has_request s.source_files file |
iter_has_request s.source_files file |
1321 |
|
|
|
|
|
1322 |
(*************************************************************************) |
(*************************************************************************) |
1323 |
(* *) |
(* *) |
1324 |
(* find_request_result *) |
(* find_request_result *) |
1328 |
let find_request_result s file = |
let find_request_result s file = |
1329 |
let r = find_request s file in |
let r = find_request s file in |
1330 |
let score = r.request_score in |
let score = r.request_score in |
1331 |
if score = initial_new_source_score then File_new_source else |
if score <= not_found_score then File_not_found else |
1332 |
if score = not_found_score then File_not_found else |
if score <= possible_score then File_possible else |
|
if score < not_found_score then File_possible else |
|
|
if score <= new_source_score then File_expected else |
|
1333 |
if score <= found_score then File_found else |
if score <= found_score then File_found else |
1334 |
if score <= chunk_score then File_chunk else |
if score <= chunk_score then File_chunk else |
1335 |
if score <= upload_score then File_upload else |
if score <= initial_new_source_score then File_new_source else |
1336 |
assert false |
assert false |
1337 |
|
|
1338 |
(*************************************************************************) |
(*************************************************************************) |
1380 |
let rec set_request_score s file score = |
let rec set_request_score s file score = |
1381 |
try |
try |
1382 |
let r = find_request s file in |
let r = find_request s file in |
1383 |
if not ( |
if (not ( |
1384 |
(* If a request has been done in the last half-hour, and the source is |
(* If a request has been done in the last half-hour, and the source is |
1385 |
announced as new, just forget it. *) |
announced as new, just forget it. : why half-hour? - trying min_reask_delay *) |
1386 |
score = initial_new_source_score && |
score = initial_new_source_score && |
1387 |
r.request_time + 1800 > last_time () |
r.request_time + !!min_reask_delay > last_time () |
1388 |
) then |
)) |
1389 |
|
(* If a file has been paused, and resumed, it is flagged outside_queue / not_found_score in |
1390 |
|
clean_sources, but really should be re-added to the queues as soon as possible (while retaining |
1391 |
|
its request_time) or it is skipped for far too long (if it is even found again) - reschedule |
1392 |
|
now puts new_source_score in old1 *) |
1393 |
|
|| (score = initial_new_source_score |
1394 |
|
&& r.request_queue = outside_queue) then |
1395 |
let score = |
let score = |
1396 |
if score = initial_new_source_score then new_source_score |
if score = initial_new_source_score |
1397 |
|
then new_source_score |
1398 |
else score |
else score |
1399 |
in |
in |
1400 |
if r.request_queue < connected_sources_queue then |
if r.request_queue < connected_sources_queue then |
1432 |
| File_chunk -> chunk_score |
| File_chunk -> chunk_score |
1433 |
| File_upload -> upload_score |
| File_upload -> upload_score |
1434 |
| File_new_source -> initial_new_source_score |
| File_new_source -> initial_new_source_score |
1435 |
| File_possible -> possible_score + 1 |
| File_possible -> possible_score + 1) |
|
| _ -> assert false) |
|
1436 |
|
|
1437 |
(*************************************************************************) |
(*************************************************************************) |
1438 |
(* *) |
(* *) |
1673 |
let q = m.manager_sources.(queue) in |
let q = m.manager_sources.(queue) in |
1674 |
if Queue.length q > 0 then |
if Queue.length q > 0 then |
1675 |
let (request_time, s) = Queue.head q in |
let (request_time, s) = Queue.head q in |
1676 |
(* TODO: merge this with throttle_delay from count_file_read_sources *) |
let throttled = queue_period.(queue) > 0 && nsource > 1 in |
1677 |
let throttle_delay = |
let throttle_delay = get_throttle_delay m queue throttled in |
|
if queue_period.(queue) > 0 && nsource > 1 then |
|
|
(max 0 (queue_period.(queue) - |
|
|
file_priority (m.manager_file ()) + |
|
|
Queue.length m.manager_sources.(connected_sources_queue) ) |
|
|
) |
|
|
else |
|
|
0 |
|
|
in |
|
1678 |
if request_time + !!min_reask_delay + throttle_delay < last_time () then |
if request_time + !!min_reask_delay + throttle_delay < last_time () then |
1679 |
begin |
begin |
1680 |
if !verbose_sources > 1 then |
if !verbose_sources > 1 then |
1807 |
let f = m.manager_file () in |
let f = m.manager_file () in |
1808 |
if file_state f = FileDownloading then |
if file_state f = FileDownloading then |
1809 |
begin |
begin |
1810 |
let q = m.manager_sources.(do_not_try_queue) in |
let remove_old q t = begin |
|
if Queue.length q > 0 then |
|
|
let (request_time, s) = Queue.head q in |
|
|
if request_time + 14400 < last_time () then |
|
|
remove_from_queue s (find_request s m); |
|
|
let q = m.manager_sources.(old_sources3_queue) in |
|
1811 |
if Queue.length q > 0 then |
if Queue.length q > 0 then |
1812 |
let (request_time, s) = Queue.head q in |
let (request_time, s) = Queue.head q in |
1813 |
if request_time + 2400 < last_time () then |
if request_time + t < last_time () then |
1814 |
remove_from_queue s (find_request s m); |
remove_from_queue s (find_request s m); |
1815 |
let q = m.manager_sources.(old_sources2_queue) in |
end in |
1816 |
if Queue.length q > 0 then |
remove_old m.manager_sources.(do_not_try_queue) 14400; |
1817 |
let (request_time, s) = Queue.head q in |
remove_old m.manager_sources.(old_sources3_queue) 2400; |
1818 |
if request_time + 1200 < last_time () then |
remove_old m.manager_sources.(old_sources2_queue) 1200; |
|
remove_from_queue s (find_request s m) |
|
1819 |
end |
end |
1820 |
) !file_sources_managers; |
) !file_sources_managers; |
1821 |
(* more power to the "runaway" (most overloaded) file, pick extra sources *) |
(* more power to the "runaway" (most overloaded) file, pick extra sources *) |
1922 |
|
|
1923 |
(*************************************************************************) |
(*************************************************************************) |
1924 |
(* *) |
(* *) |
1925 |
|
(* clean_sources helper *) |
1926 |
|
(* *) |
1927 |
|
(*************************************************************************) |
1928 |
|
let put_all_outside_queue m q queue = |
1929 |
|
let _, s = Queue.take q in |
1930 |
|
m.manager_all_sources <- m.manager_all_sources - 1; |
1931 |
|
if active_queue queue then |
1932 |
|
m.manager_active_sources <- m.manager_active_sources - 1; |
1933 |
|
List.iter |
1934 |
|
(fun r -> |
1935 |
|
if r.request_file == m then |
1936 |
|
begin |
1937 |
|
r.request_queue <- outside_queue; |
1938 |
|
set_score_part r not_found_score |
1939 |
|
end |
1940 |
|
) s.source_files |
1941 |
|
|
1942 |
|
(*************************************************************************) |
1943 |
|
(* *) |
1944 |
(* clean_sources *) |
(* clean_sources *) |
1945 |
(* *) |
(* *) |
1946 |
(*************************************************************************) |
(*************************************************************************) |
1960 |
&& queue <> good_sources_queue |
&& queue <> good_sources_queue |
1961 |
then |
then |
1962 |
begin |
begin |
1963 |
let _, s = Queue.take q in |
put_all_outside_queue m q queue; |
|
m.manager_all_sources <- m.manager_all_sources - 1; |
|
|
if active_queue queue then |
|
|
m.manager_active_sources <- m.manager_active_sources - 1; |
|
|
List.iter |
|
|
(fun r -> |
|
|
if r.request_file == m then |
|
|
begin |
|
|
r.request_queue <- outside_queue; |
|
|
set_score_part r not_found_score |
|
|
end |
|
|
) s.source_files; |
|
1964 |
iter (nsources-1) q queue |
iter (nsources-1) q queue |
1965 |
end |
end |
1966 |
else |
else |
1967 |
if queue = old_sources1_queue then |
let do_iter q = iter nsources m.manager_sources.(q) q in |
1968 |
iter nsources m.manager_sources.(do_not_try_queue) (do_not_try_queue) |
|
1969 |
else |
if queue = old_sources1_queue then do_iter do_not_try_queue else |
1970 |
if queue = do_not_try_queue then |
if queue = do_not_try_queue then do_iter new_sources_queue else |
1971 |
iter nsources m.manager_sources.(new_sources_queue) (new_sources_queue) |
if queue = new_sources_queue then do_iter waiting_saved_sources_queue else |
1972 |
else |
if queue > good_sources_queue then do_iter (queue-1) |
1973 |
if queue = new_sources_queue then |
|
|
iter nsources m.manager_sources.(waiting_saved_sources_queue) (waiting_saved_sources_queue) |
|
|
else |
|
|
if queue > good_sources_queue then |
|
|
iter nsources m.manager_sources.(queue-1) (queue-1) |
|
1974 |
in |
in |
1975 |
iter (nsources - max_sources_per_file) (m.manager_sources.(old_sources3_queue)) old_sources3_queue |
iter (nsources - max_sources_per_file) (m.manager_sources.(old_sources3_queue)) old_sources3_queue |
1976 |
|
|
1978 |
let rec iter q queue = |
let rec iter q queue = |
1979 |
if Queue.length q > 0 then |
if Queue.length q > 0 then |
1980 |
begin |
begin |
1981 |
let _, s = Queue.take q in |
put_all_outside_queue m q queue; |
|
m.manager_all_sources <- m.manager_all_sources - 1; |
|
|
if active_queue queue then |
|
|
m.manager_active_sources <- m.manager_active_sources - 1; |
|
|
List.iter |
|
|
(fun r -> |
|
|
if r.request_file == m then |
|
|
begin |
|
|
r.request_queue <- outside_queue; |
|
|
set_score_part r not_found_score |
|
|
end |
|
|
) s.source_files; |
|
1982 |
iter q queue |
iter q queue |
1983 |
end |
end |
1984 |
else |
else |
2087 |
in |
in |
2088 |
iter max_sources false; |
iter max_sources false; |
2089 |
if !verbose_sources > 1 then |
if !verbose_sources > 1 then |
2090 |
lprintf " done\n"; |
lprintf " done connect_sources\n"; |
2091 |
with Exit -> () |
with Exit -> () |
2092 |
|
|
2093 |
|
|
2161 |
done |
done |
2162 |
) !file_sources_managers; |
) !file_sources_managers; |
2163 |
|
|
2164 |
Printf.bprintf buf "\nFor all managers:\n"; |
Printf.bprintf buf "\nFor all managers (%d):\n" (List.length !file_sources_managers); |
2165 |
for i = 0 to nqueues - 1 do |
for i = 0 to nqueues - 1 do |
2166 |
Printf.bprintf buf " Queue[%s]: %d entries (%d ready)\n" |
Printf.bprintf buf " Queue[%s]: %d entries (%d ready)\n" |
2167 |
queue_name.(i) nsources_per_queue.(i) nready_per_queue.(i); |
queue_name.(i) nsources_per_queue.(i) nready_per_queue.(i); |