From b8ffeb310daed11ceceb744d1b9c5999c1a32883 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Fri, 11 Jul 2008 13:00:22 +0000 Subject: [PATCH] update job queue synchronization git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11609 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 30 +++++++++------------------- gosa-si/server/events/databases.pm | 32 ++++++++++++++++++------------ 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 50709127a..d73b3c763 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -255,7 +255,7 @@ my $max_children = 2; "domain" => [\$server_domain, ""], "key" => [\$ServerPackages_key, "none"], "key-lifetime" => [\$foreign_servers_register_delay, 120], - "job-synchronization" => [\$job_synchronization, "true"], + "job-synchronization-enabled" => [\$job_synchronization, "true"], "synchronization-loop" => [\$modified_jobs_loop_delay, 5], } ); @@ -1470,12 +1470,13 @@ sub session_start { $kernel->sig(USR2 => "recreate_packages_db"); $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay); $kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay); - $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay); + $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay); $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay); + } @@ -1506,26 +1507,13 @@ sub watch_for_modified_jobs { # if db contains no jobs which should be update, do nothing if (keys %$res != 0) { - # make out of the db result a gosa-si message - my $update_msg = &db_res2si_msg ($res, "foreign_job_updates", "KNOWN_SERVER", "MY_LOCAL_ADDRESS"); + if ($job_synchronization eq "true") { + # make out of the db result a gosa-si message + my $update_msg = &db_res2si_msg ($res, "foreign_job_updates", "KNOWN_SERVER", "MY_LOCAL_ADDRESS"); - # update all other SI-server - &inform_all_other_si_server($update_msg); - -# # determine all other si-server a foreign_job_updates message should be send -# my $sql_statement= "SELECT * FROM $known_server_tn"; -# my $res = $known_server_db->select_dbentry( $sql_statement ); -# while( my ($hit_num, $hit) = each %$res ) { -# my $act_update_msg = $update_msg; -# my $act_target_address = $hit->{hostname}; -# my $act_target_key = $hit->{hostkey}; -# my ($act_target_ip, $act_target_port) = split(/:/, $act_target_address); -# my $act_source_address = &get_local_ip_for_remote_ip($act_target_ip).":$act_target_port"; -# -# $act_update_msg =~ s/KNOWN_SERVER<\/target>/$act_target_address<\/target>/g; -# $act_update_msg =~ s/MY_LOCAL_ADDRESS<\/source>/$act_source_address<\/source>/g; -# &send_msg_to_target($act_update_msg, $act_target_address, $act_target_key, "foreign_job_updates" , "J"); -# } + # update all other SI-server + &inform_all_other_si_server($update_msg); + } # set jobs all jobs to modified = 0, wait until the next modification for updates of other si-server $sql_statement = "UPDATE $job_queue_tn SET modified='0' "; diff --git a/gosa-si/server/events/databases.pm b/gosa-si/server/events/databases.pm index bc23786d8..22144aee9 100644 --- a/gosa-si/server/events/databases.pm +++ b/gosa-si/server/events/databases.pm @@ -128,25 +128,31 @@ sub delete_jobdb_entry { my $source = @{$msg_hash->{'source'}}[0]; # prepare query sql statement - my $table= $main::job_queue_tn; my $where= &get_where_statement($msg, $msg_hash); - my $sql_statement = "DELETE FROM $table $where"; - &main::daemon_log("$session_id DEBUG: $sql_statement",7); - # execute db query - my $db_res = $main::job_db->del_dbentry($sql_statement); - - my $res; - if( $db_res > 0 ) { - $res = 0 ; - } else { - $res = 1; - } + #my $sql_statement = "DELETE FROM $main::job_queue_tn $where"; + #&main::daemon_log("$session_id DEBUG: $sql_statement",7); + # execute db query + #my $db_res = $main::job_db->del_dbentry($sql_statement); + # + #my $res; + #if( $db_res > 0 ) { + # $res = 0 ; + #} else { + # $res = 1; + #} + + # set job to status 'done', job will be deleted automatically + my $sql_statement = "UPDATE $main::job_queue_tn ". + "SET status='done', modified='1' ". + "$where"; + &main::daemon_log("$session_id DEBUG: $sql_statement", 7); + my $res = $main::job_db->update_dbentry( $sql_statement ); + # prepare xml answer my $out_xml = "
answer
$target$source$res$session_id
"; my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; if (defined $forward_to_gosa) { - #&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); $out_xml =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; } -- 2.30.2