/[cvs]/nfo/perl/libs/Data/Transfer/Task.pm
ViewVC logotype

Annotation of /nfo/perl/libs/Data/Transfer/Task.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Thu Oct 17 00:10:43 2002 UTC (21 years, 8 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +6 -3 lines
+ bugfix: constructor argument logging

1 cvsjoko 1.1 #################################
2     #
3 joko 1.2 # $Id: Task.pm,v 1.1 2002/10/10 03:44:21 cvsjoko Exp $
4     #
5     # $Log: Task.pm,v $
6     # Revision 1.1 2002/10/10 03:44:21 cvsjoko
7     # + new
8 cvsjoko 1.1 #
9     #
10     #################################
11    
12     package Data::Transfer::Task;
13    
14     use strict;
15     use warnings;
16    
17     use misc::HashExt;
18     use Data::Transfer::SyncStep;
19    
20     # get logger instance
21     my $logger = Log::Dispatch::Config->instance;
22    
23     sub new {
24     my $invocant = shift;
25     my $class = ref($invocant) || $invocant;
26     my $self = { @_ };
27 joko 1.2 $logger->debug( __PACKAGE__ . "->new( @_ )" );
28 cvsjoko 1.1 return bless $self, $class;
29     }
30    
31    
32     sub run {
33    
34     my $self = shift;
35    
36     my $storage_left = $self->{storages}->{L};
37     my $storage_right = $self->{storages}->{R};
38     my $tasks = $self->{steps};
39     my $tasklist = $self->{steplist};
40    
41     # create synchronization object
42     $logger->notice("Starting synchronization (push) between \"Object Store (dbi:" . $storage_left->getDbName() . ")\" and \"Relational Database (dbi:" . $storage_right->getDbName() . ")\"");
43     my $syncStep = Data::Transfer::SyncStep->new( L => $storage_left, R => $storage_right );
44    
45     my $stats_sum = SummableHash->new;
46     foreach my $taskKey (@{$tasklist}) {
47     my $task = $tasks->{$taskKey};
48     my $taskname = $taskKey;
49     if ($task->{name}) { $taskname = $task->{name}; }
50     #print "-" x 60, "\n";
51     #sysevent( { usermsg => $task->{caption}, level => LEVEL_NOTIFY }, $taskEvent );
52     $logger->info($task->{caption});
53    
54     #syncSet2Table( $satellite->{mapping}->$taskname );
55     # execute synchronization step (ObjectSet -> Table)
56    
57     #$syncStep->syncSet2Table( $satellite->{mapping}->$taskname );
58    
59     if ($task->{coderef}) {
60     $task->{coderef}( $syncStep );
61     } else {
62     my $stats_ref = $syncStep->syncSet2Table( $self->{mapping}->$taskname );
63     $stats_sum += $stats_ref;
64     }
65    
66     }
67    
68     # uses overloading via "misc::HashExt" here to transparently stringify hash with statistic-counts
69     $logger->notice("stats: $stats_sum");
70    
71     }
72    
73     1;

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed