diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index c9cbfa3ad914dc5e27d0e074e5dce46e4846f66b..d73b3c7630b1b65a00ccb0a060de25ce07bba640 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_ip, $gosa_port, $gosa_timeout,
$foreign_server_string, $server_domain, $ServerPackages_key, $foreign_servers_register_delay,
- $wake_on_lan_passwd,
+ $wake_on_lan_passwd, $job_synchronization, $modified_jobs_loop_delay,
);
# additional variable which should be globaly accessable
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
"plainname DEFAULT 'none'",
+ "siserver DEFAULT 'none'",
+ "modified DEFAULT '0'",
);
# holds all other gosa-si-server
"domain" => [\$server_domain, ""],
"key" => [\$ServerPackages_key, "none"],
"key-lifetime" => [\$foreign_servers_register_delay, 120],
+ "job-synchronization-enabled" => [\$job_synchronization, "true"],
+ "synchronization-loop" => [\$modified_jobs_loop_delay, 5],
}
);
if ($done) {
# if a job or a gosa message comes from a foreign server, fake module to GosaPackages
# so gosa-si-server knows how to process this kind of messages
- if ($header =~ /^gosa_/ || $header =~ /job_/) {
+ if ($header =~ /^gosa_/ || $header =~ /^job_/) {
$module = "GosaPackages";
}
$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_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);
+
}
sub watch_for_done_jobs {
my ($kernel,$heap) = @_[KERNEL, HEAP];
- my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE status='done'";
+ my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE ((status='done') AND (modified='0'))";
my $res = $job_db->select_dbentry( $sql_statement );
while( my ($id, $hit) = each %{$res} ) {
}
+# if a job got an update or was modified anyway, send to all other si-server an update message
+# of this jobs
+sub watch_for_modified_jobs {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE ((siserver='localhost') AND (modified='1'))";
+ my $res = $job_db->select_dbentry( $sql_statement );
+
+ # if db contains no jobs which should be update, do nothing
+ if (keys %$res != 0) {
+
+ 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);
+ }
+
+ # 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' ";
+ $res = $job_db->update_dbentry($sql_statement);
+ }
+
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
+}
+
+
sub watch_for_new_jobs {
if($watch_for_new_jobs_in_progress == 0) {
$watch_for_new_jobs_in_progress = 1;
my ($kernel,$heap) = @_[KERNEL, HEAP];
- # check gosa job queue for jobs with executable timestamp
+ # check gosa job quaeue for jobs with executable timestamp
my $timestamp = &get_time();
my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER)) < $timestamp ORDER BY timestamp";
my $res = $job_db->exec_statement( $sql_statement );
}
+
sub watch_for_new_messages {
my ($kernel,$heap) = @_[KERNEL, HEAP];
my @coll_user_msg; # collection list of outgoing messages
watch_for_delivery_messages => \&watch_for_delivery_messages,
watch_for_done_messages => \&watch_for_done_messages,
watch_for_new_jobs => \&watch_for_new_jobs,
+ watch_for_modified_jobs => \&watch_for_modified_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
watch_for_old_known_clients => \&watch_for_old_known_clients,
create_packages_list_db => \&run_create_packages_list_db,