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

Diff of /nfo/perl/libs/Data/Transfer/Sync/Core.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by jonen, Tue May 11 20:03:48 2004 UTC revision 1.13 by joko, Sat Jun 19 16:53:38 2004 UTC
# Line 8  Line 8 
8  ##  ##
9  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
10  ##    $Log$  ##    $Log$
11    ##    Revision 1.13  2004/06/19 16:53:38  joko
12    ##    fix: handle local checksum only if database is configured with "hasLocalChecksum"
13    ##
14    ##    Revision 1.12  2004/06/19 01:45:08  joko
15    ##    introduced "local checksum"-mechanism
16    ##    moved _dumpCompact to ::Compare::Checksum
17    ##
18  ##    Revision 1.11  2004/05/11 20:03:48  jonen  ##    Revision 1.11  2004/05/11 20:03:48  jonen
19  ##    bugfix[joko] related to Attribute Map  ##    bugfix[joko] related to Attribute Map
20  ##  ##
# Line 218  sub _run { Line 225  sub _run {
225    
226      $tc->{total}++;      $tc->{total}++;
227    
228  #print "========================  iter", "\n";      #print "=" x 80, "\n";
229    
230      # clone object (in case we have to modify it here)      # clone object (in case we have to modify it here)
231      # TODO:      # TODO:
# Line 308  sub _run { Line 315  sub _run {
315        print "n" if $self->{verbose};        print "n" if $self->{verbose};
316      }      }
317    
 #print "checksum", "\n";  
       
     #print Dumper($self);  
       
318      # determine status of entry by synchronization method      # determine status of entry by synchronization method
319      if ( lc $self->{options}->{metadata}->{syncMethod} eq 'checksum' ) {      if ( lc $self->{options}->{metadata}->{syncMethod} eq 'checksum' ) {
320      #if ( $statOK && (lc $self->{args}->{method} eq 'checksum') ) {      #if ( $statOK && (lc $self->{args}->{method} eq 'checksum') ) {
321      #if ( !$self->{node}->{status}->{new} && (lc $self->{args}->{method} eq 'checksum') ) {      #if ( !$self->{node}->{status}->{new} && (lc $self->{args}->{method} eq 'checksum') ) {
322                
323        # new 2004-06-17: calculate local checksum of source node
324        # new 2004-06-19: ... only if requested
325        if ($self->{options}->{source}->{storage}->{handle}->{locator}->{hasLocalChecksum}) {
326          $self->handleLocalChecksum('source');
327        }
328        
329      # calculate checksum of source node      # calculate checksum of source node
330        #$self->_calcChecksum('source');        #$self->_calcChecksum('source');
331        if (!$self->_readChecksum('source')) {        if (!$self->readChecksum('source')) {
332          $logger->warning( __PACKAGE__ . "->_run: Could not find \"source\" entry with ident=\"$self->{node}->{source}->{ident}\"" );          $logger->warning( __PACKAGE__ . "->_run: Could not find \"source\" entry with ident=\"$self->{node}->{source}->{ident}\"" );
333          $tc->{skip}++;          $tc->{skip}++;
334          print "s" if $self->{verbose};          print "s" if $self->{verbose};
# Line 327  sub _run { Line 336  sub _run {
336        }        }
337                
338        # get checksum from synchronization target        # get checksum from synchronization target
339        $self->_readChecksum('target');        $self->readChecksum('target');
340        #if (!$self->_readChecksum('target')) {        #if (!$self->readChecksum('target')) {
341        #  $logger->critical( __PACKAGE__ . "->_readChecksum: Could not find \"target\" entry with ident=\"$self->{node}->{source}->{ident}\"" );        #  $logger->critical( __PACKAGE__ . "->readChecksum: Could not find \"target\" entry with ident=\"$self->{node}->{source}->{ident}\"" );
342        #  next;        #  next;
343        #}        #}
344        
# Line 346  sub _run { Line 355  sub _run {
355        # trace        # trace
356          #print Dumper($self->{node});          #print Dumper($self->{node});
357          #exit;          #exit;
358            #print "LOCAL: ", $self->{node}->{source}->{checksum_local_storage}, " <-> ", $self->{node}->{source}->{checksum_local_calculated}, "\n";
359            #print "REMOTE: ", $self->{node}->{source}->{checksum}, " <-> ", $self->{node}->{target}->{checksum}, "\n";
360    
361          # calculate new/dirty status
362        $self->{node}->{status}->{new} = !$self->{node}->{target}->{checksum};        $self->{node}->{status}->{new} = !$self->{node}->{target}->{checksum};
363        if (!$self->{node}->{status}->{new}) {        if (!$self->{node}->{status}->{new}) {
364          $self->{node}->{status}->{dirty} =          $self->{node}->{status}->{dirty} =
# Line 356  sub _run { Line 368  sub _run {
368            $self->{args}->{force};            $self->{args}->{force};
369        }        }
370    
371          # new 2004-06-17: also check if local checksum is inconsistent
372          # new 2004-06-19: ... only if requested
373          if ($self->{options}->{source}->{storage}->{handle}->{locator}->{hasLocalChecksum} and
374            ($self->{node}->{source}->{checksum_local_storage} ne $self->{node}->{source}->{checksum_local_calculated}) ) {
375            $self->{node}->{status}->{dirty_local} = 1;
376            $self->{node}->{status}->{dirty} = 1;
377          }
378    
379      } else {      } else {
380        $logger->warning( __PACKAGE__ . "->_run: Synchronization method '$self->{options}->{metadata}->{syncMethod}' is not implemented" );        $logger->warning( __PACKAGE__ . "->_run: Synchronization method '$self->{options}->{metadata}->{syncMethod}' is not implemented" );
381        $tc->{skip}++;        $tc->{skip}++;
# Line 363  sub _run { Line 383  sub _run {
383        next;        next;
384      }      }
385    
386        # new 2004-06-17: also update local checksum
387        if ($self->{node}->{status}->{dirty_local}) {
388          $tc->{locally_modified}++;
389          print "[lm]" if $self->{verbose};
390          $self->_doModify_LocalChecksum('source');
391        }
392    
393      # first reaction on entry-status: continue with next entry if the current is already "in sync"      # first reaction on entry-status: continue with next entry if the current is already "in sync"
394      if (!$self->{node}->{status}->{new} && !$self->{node}->{status}->{dirty}) {      if (!$self->{node}->{status}->{new} && !$self->{node}->{status}->{dirty}) {
395        $tc->{in_sync}++;        $tc->{in_sync}++;
# Line 407  sub _run { Line 434  sub _run {
434        # asymmetry: refetch node from target to re-calculate new ident and checksum (TODO: is IdentAuthority of relevance here?)        # asymmetry: refetch node from target to re-calculate new ident and checksum (TODO: is IdentAuthority of relevance here?)
435        #print Dumper($self->{node});        #print Dumper($self->{node});
436        $self->_statloadNode('target', $self->{node}->{target}->{ident}, 1);        $self->_statloadNode('target', $self->{node}->{target}->{ident}, 1);
437        $self->_readChecksum('target');        $self->readChecksum('target');
438    
439      } elsif ($self->{node}->{status}->{dirty}) {      } elsif ($self->{node}->{status}->{dirty}) {
440        $tc->{attempt_modify}++;        $tc->{attempt_modify}++;
441        # asymmetry: get ident before updating (TODO: is IdentAuthority of relevance here?)        # asymmetry: get ident before updating (TODO: is IdentAuthority of relevance here?)
442        $self->{node}->{target}->{ident} = $self->{node}->{map}->{$self->{meta}->{target}->{IdentProvider}->{arg}};        $self->{node}->{target}->{ident} = $self->{node}->{map}->{$self->{meta}->{target}->{IdentProvider}->{arg}};
443        $self->_doTransferToTarget('update');        $self->_doTransferToTarget('update');
444        $self->_readChecksum('target');        $self->readChecksum('target');
445      }      }
446    
447      if ($self->{node}->{status}->{ok}) {      if ($self->{node}->{status}->{ok}) {
# Line 442  sub _run { Line 469  sub _run {
469        #exit;        #exit;
470        $self->_doModifySource_IdentChecksum($self->{node}->{target}->{ident});        $self->_doModifySource_IdentChecksum($self->{node}->{target}->{ident});
471      }      }
472        
473      #print "UNLOAD", "\n";      #print "UNLOAD", "\n";
474      #$self->{meta}->{source}->{storage}->unload( $self->{node}->{source}->{payload} );      #$self->{meta}->{source}->{storage}->unload( $self->{node}->{source}->{payload} );
475    
# Line 469  sub _run { Line 496  sub _run {
496  }  }
497    
498    
 # refactor this as some core-function to do a generic dump resolving data-encapsulations of e.g. Set::Object  
 sub _dumpCompact {  
   my $self = shift;  
   
   #my $vars = \@_;  
   my @data = ();  
   
   my $count = 0;  
   foreach (@_) {  
     my $item = {};  
     foreach my $key (keys %$_) {  
       my $val = $_->{$key};  
   
 #print Dumper($val);  
   
       if (ref $val eq 'Set::Object') {  
         #print "========================= SET", "\n";  
 #print Dumper($val);  
         #print Dumper($val->members());  
         #$val = $val->members();  
         #$vars->[$count]->{$key} = $val->members() if $val->can("members");  
         #$item->{$key} = $val->members() if $val->can("members");  
         $item->{$key} = $val->members();  
         #print Dumper($vars->[$count]->{$key});  
   
       } else {  
         $item->{$key} = $val;  
       }  
   
     }  
     push @data, $item;  
     $count++;  
   }  
   
 #print "Dump:", Dumper(@data), "\n";  
   
   $Data::Dumper::Indent = 0;  
   my $result = Dumper(@data);  
   $Data::Dumper::Indent = 2;  
   return $result;  
     
 }  
   
   
   
499  sub _doTransferToTarget {  sub _doTransferToTarget {
500    my $self = shift;    my $self = shift;
501    my $action = shift;    my $action = shift;
# Line 546  sub _doModifySource_IdentChecksum { Line 528  sub _doModifySource_IdentChecksum {
528    $self->_modifyNode('source', 'update', $map);    $self->_modifyNode('source', 'update', $map);
529  }  }
530    
531    sub _doModify_LocalChecksum {
532      my $self = shift;
533      my $descent = shift;
534      my $map = {
535        cs_local => $self->{node}->{$descent}->{checksum_local_calculated},
536      };
537      $self->_modifyNode($descent, 'update', $map);
538    }
539    
540  sub _prepareNode_MetaProperties {  sub _prepareNode_MetaProperties {
541    my $self = shift;    my $self = shift;
# Line 582  sub _prepareNode_MetaProperties { Line 571  sub _prepareNode_MetaProperties {
571    
572  }  }
573    
574    # TODO: load column-metadata from reversed mapping-metadata
575  sub _prepareNode_DummyIdent {  sub _prepareNode_DummyIdent {
576    my $self = shift;    my $self = shift;
577    my $descent = shift;    my $descent = shift;
578    
579      #print Dumper($self->{options});
580    $logger->info( __PACKAGE__ . "->_prepareNode_DummyIdent( descent $descent )" );    $logger->info( __PACKAGE__ . "->_prepareNode_DummyIdent( descent $descent )" );
581    
582    my $list = $self->_getNodeList($descent);    my $list = $self->_getNodeList($descent);
# Line 599  sub _prepareNode_DummyIdent { Line 590  sub _prepareNode_DummyIdent {
590      my $map = {      my $map = {
591        $self->{meta}->{$descent}->{IdentProvider}->{arg} => $ident_dummy,        $self->{meta}->{$descent}->{IdentProvider}->{arg} => $ident_dummy,
592        cs => undef,        cs => undef,
593          cs_local => undef,
594      };      };
595            
596      # diff lists and ...      # diff lists and ...
# Line 623  sub _prepareNode_DummyIdent { Line 615  sub _prepareNode_DummyIdent {
615      $i++;      $i++;
616    }    }
617    
618    #print "\n" if $self->{verbose};    print "\n" if $self->{verbose};
619        
620    if (!$i) {    if (!$i) {
621      $logger->warning( __PACKAGE__ . "->_prepareNode_DummyIdent: no nodes touched" );      $logger->warning( __PACKAGE__ . "->_prepareNode_DummyIdent: no nodes touched" );

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.13

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