/[cvs]/nfo/perl/libs/Data/Storage/Container.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Container.pm

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

revision 1.1 by joko, Fri Nov 29 04:54:54 2002 UTC revision 1.4 by jonen, Wed Dec 4 07:38:07 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.4  2002/12/04 07:38:07  jonen
7    #  + deep copy
8    #
9    #  Revision 1.3  2002/12/01 22:18:28  joko
10    #  - no interactive implicit deploy
11    #  + only test integrity if storage available
12    #
13    #  Revision 1.2  2002/12/01 07:08:35  joko
14    #  + needs to "use Data::Storage;"
15    #
16  #  Revision 1.1  2002/11/29 04:54:54  joko  #  Revision 1.1  2002/11/29 04:54:54  joko
17  #  + initial check-in  #  + initial check-in
18  #  #
# Line 23  my $logger = Log::Dispatch::Config->inst Line 33  my $logger = Log::Dispatch::Config->inst
33    
34  use libp qw( deep_copy );  use libp qw( deep_copy );
35  use Data::Dumper;  use Data::Dumper;
36    use Data::Storage;
37    #use Data::Storage::Locator;
38    
39  sub new {  sub new {
40    my $invocant = shift;    my $invocant = shift;
# Line 83  sub initLocator { Line 94  sub initLocator {
94    $cfg_locator->{name} = $name;    $cfg_locator->{name} = $name;
95        
96    # merge in specific settings    # merge in specific settings
97    foreach (keys %$db_config) {    my $specific = deep_copy($db_config);
98      $cfg_locator->{$_} = $db_config->{$_};    foreach (keys %$specific) {
99        $cfg_locator->{$_} = $specific->{$_};
100    }    }
101        
102    # HACK: transfer dsn from main to dbi settings    # HACK: transfer dsn from main to dbi settings
# Line 129  sub initStorage { Line 141  sub initStorage {
141    
142    # should we test availability of the storage before using it?    # should we test availability of the storage before using it?
143    if ($locator->{test_availability}) {    if ($locator->{test_availability}) {
144        $locator->{status}->{availability} = $storage->testAvailability();
145      if ( !$storage->testAvailability() ) {      if ( !$storage->testAvailability() ) {
146        $logger->error( "$log_prefix is not available" );        $logger->error( "$log_prefix: testAvailability failed" );
       return;  
147      }      }
148    }    }
149                        
150    # should we test integrity of the storage before using it?    # should we test integrity of the storage before using it?
151    if ($locator->{test_integrity}) {    if ($locator->{status}->{availability} && $locator->{test_integrity}) {
152      #return unless $storage->testIntegrity();      #return unless $storage->testIntegrity();
153      $locator->{status}->{integrity} = $storage->testIntegrity();      $locator->{status}->{integrity} = $storage->testIntegrity();
154      # actions if integrity fails      # actions if integrity fails
155      if (!$locator->{status}->{integrity}) {      if (!$locator->{status}->{integrity}) {
156        $logger->error( "testIntegrity failed on $log_prefix" );        $logger->error( "$log_prefix: testIntegrity failed" );
       print "Try a $locator->{name}.deploySchema()? (y/n) ";  
       my $res = <STDIN>;  
       if ($res =~ m/y/i) {  
         $storage->deploySchema();  
       }  
157      }      }
158    }    }
159    
# Line 155  sub initStorage { Line 162  sub initStorage {
162    # don't connect right here, do an implicit connect on (later) usage    # don't connect right here, do an implicit connect on (later) usage
163    # maybe set ->{meta}->{connectmethod} = "connect" here    # maybe set ->{meta}->{connectmethod} = "connect" here
164    #return unless $storage->connect();    #return unless $storage->connect();
165    $storage->connect();    $storage->connect() if $locator->{status}->{integrity};
166    
167    # should we check emptyness?    # should we check emptyness?
168    if ( $locator->{test_emptyness} && $locator->{status}->{integrity} ) {    if ($locator->{status}->{availability} && $locator->{test_emptyness}) {
169        #print "test empty", "\n";
170      if ( !@{$storage->getChildNodes()} ) {      if ( !@{$storage->getChildNodes()} ) {
171        $locator->{status}->{empty} = 1;        $locator->{status}->{empty} = 1;
172        $logger->warning( "$log_prefix is empty");        $logger->warning( "$log_prefix: Storage is empty.");
173        #return;        #return;
174      }      }
175    }    }
176    
177    # expand logging?    # expand logging?
178    if ( $locator->{logger} && $locator->{status}->{integrity} ) {    if ( $locator->{status}->{integrity} && $locator->{logger} ) {
179      # expand logging (to Tangram-Database)      # expand logging (to Tangram-Database)
180      # TODO:      # TODO:
181      # - move configuration data from this code to db_config somehow      # - move configuration data from this code to db_config somehow
# Line 184  sub initStorage { Line 192  sub initStorage {
192    }    }
193    
194    #$self->{storage}->{$name} = $storage;    #$self->{storage}->{$name} = $storage;
195      #print "add storage: $name", "\n";
196    $self->addStorage($name, $storage);    $self->addStorage($name, $storage);
197    
198    return 1;    return 1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

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