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