Code

update job queue synchronization
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 11 Jul 2008 13:00:22 +0000 (13:00 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 11 Jul 2008 13:00:22 +0000 (13:00 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11609 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/server/events/databases.pm

index 50709127a1de039652cfa991bdf44108bcfffc14..d73b3c7630b1b65a00ccb0a060de25ce07bba640 100755 (executable)
@@ -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/<target>KNOWN_SERVER<\/target>/<target>$act_target_address<\/target>/g;
-#            $act_update_msg =~ s/<source>MY_LOCAL_ADDRESS<\/source>/<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' ";
index bc23786d8a24f956455beefb7652a6b4cafc2675..22144aee9fbf6d25dba2f304bf1acf87ba5fd307 100644 (file)
@@ -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 = "<xml><header>answer</header><source>$target</source><target>$source</target><answer1>$res</answer1><session_id>$session_id</session_id></xml>";
     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<\/forward_to_gosa><\/xml>/;
     }