Changeset 16565
- Timestamp:
- Feb 21, 2008, 1:20:39 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Nebulous-Server/Build.PL (modified) (1 diff)
-
Nebulous-Server/Changes (modified) (1 diff)
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (5 diffs)
-
Nebulous/Build.PL (modified) (1 diff)
-
Nebulous/Changes (modified) (1 diff)
-
Nebulous/lib/Nebulous/Server.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Build.PL
r16264 r16565 84 84 'DBD::mysql' => '3.0007', 85 85 'DBI' => '1.53', 86 'Digest::SHA1' => 0, 86 87 'File::ExtAttr' => '1.03', 88 'File::Path' => '1.08', 89 'File::Spec' => 0, 87 90 'File::Spec::Functions' => 0, 88 91 'Log::Log4perl' => '0.48', -
trunk/Nebulous-Server/Changes
r16354 r16565 2 2 3 3 0.07 4 - add support for storing instances in multi-tier 'hashed' directories 4 5 - pickup test DB settings from the env. 5 6 - add neb-ls -l|-1 option -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r16354 r16565 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.5 2 2008-02-07 22:18:51jhoblitt Exp $3 # $Id: Server.pm,v 1.53 2008-02-21 23:20:39 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 13 13 14 14 use DBI; 15 use Digest::SHA1 qw( sha1_hex ); 15 16 use File::ExtAttr qw( setfattr ); 17 use File::Path; 18 use File::Spec; 16 19 use Log::Log4perl; 17 20 use Nebulous::Server::Config; … … 23 26 24 27 __PACKAGE__->mk_accessors(qw( log sql config )); 28 29 use constant SUBPATH_DEPTH => 3; 25 30 26 31 sub new { … … 1229 1234 my $log = $self->log; 1230 1235 my $sql = $self->sql; 1231 my $db =$self->db; 1232 1233 my ($storage_filename); 1234 my ($uri); 1235 eval { 1236 $storage_filename = $self->_generate_storage_filename($key, $ins_id); 1237 # XXX put a hook for directory hashing here 1238 $uri = URI::file->new("$vol_path/$storage_filename"); 1236 my $db = $self->db; 1237 1238 my $uri; 1239 eval { 1240 my $storage_path = $self->_generate_storage_path($key, $vol_path); 1241 my $storage_filename = $self->_generate_storage_filename($key, $ins_id); 1242 unless (-d $storage_path) { 1243 mkpath($storage_path) 1244 or die "can't create storage path: $storage_path"; 1245 } 1246 my $fqpn = File::Spec->catfile($storage_path, $storage_filename); 1247 $uri = URI::file->new($fqpn); 1239 1248 $log->debug("generated uri $uri"); 1240 1249 $self->_create_empty_file($uri->file); … … 1291 1300 1292 1301 1302 sub _generate_storage_path 1303 { 1304 my $self = shift; 1305 1306 my ($key, $vol_path) = @_; 1307 1308 # taken and modified from Cache::File::cache_file_path() 1309 # Copyright (C) 2003-2006 Chris Leishman. All Rights Reserved. 1310 my $shakey = sha1_hex($key); 1311 my (@path) = unpack('A2' x SUBPATH_DEPTH, $shakey); 1312 1313 return File::Spec->catdir($vol_path, @path); 1314 } 1315 1316 1293 1317 sub DESTROY 1294 1318 { -
trunk/Nebulous/Build.PL
r16264 r16565 84 84 'DBD::mysql' => '3.0007', 85 85 'DBI' => '1.53', 86 'Digest::SHA1' => 0, 86 87 'File::ExtAttr' => '1.03', 88 'File::Path' => '1.08', 89 'File::Spec' => 0, 87 90 'File::Spec::Functions' => 0, 88 91 'Log::Log4perl' => '0.48', -
trunk/Nebulous/Changes
r16354 r16565 2 2 3 3 0.07 4 - add support for storing instances in multi-tier 'hashed' directories 4 5 - pickup test DB settings from the env. 5 6 - add neb-ls -l|-1 option -
trunk/Nebulous/lib/Nebulous/Server.pm
r16354 r16565 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.5 2 2008-02-07 22:18:51jhoblitt Exp $3 # $Id: Server.pm,v 1.53 2008-02-21 23:20:39 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 13 13 14 14 use DBI; 15 use Digest::SHA1 qw( sha1_hex ); 15 16 use File::ExtAttr qw( setfattr ); 17 use File::Path; 18 use File::Spec; 16 19 use Log::Log4perl; 17 20 use Nebulous::Server::Config; … … 23 26 24 27 __PACKAGE__->mk_accessors(qw( log sql config )); 28 29 use constant SUBPATH_DEPTH => 3; 25 30 26 31 sub new { … … 1229 1234 my $log = $self->log; 1230 1235 my $sql = $self->sql; 1231 my $db =$self->db; 1232 1233 my ($storage_filename); 1234 my ($uri); 1235 eval { 1236 $storage_filename = $self->_generate_storage_filename($key, $ins_id); 1237 # XXX put a hook for directory hashing here 1238 $uri = URI::file->new("$vol_path/$storage_filename"); 1236 my $db = $self->db; 1237 1238 my $uri; 1239 eval { 1240 my $storage_path = $self->_generate_storage_path($key, $vol_path); 1241 my $storage_filename = $self->_generate_storage_filename($key, $ins_id); 1242 unless (-d $storage_path) { 1243 mkpath($storage_path) 1244 or die "can't create storage path: $storage_path"; 1245 } 1246 my $fqpn = File::Spec->catfile($storage_path, $storage_filename); 1247 $uri = URI::file->new($fqpn); 1239 1248 $log->debug("generated uri $uri"); 1240 1249 $self->_create_empty_file($uri->file); … … 1291 1300 1292 1301 1302 sub _generate_storage_path 1303 { 1304 my $self = shift; 1305 1306 my ($key, $vol_path) = @_; 1307 1308 # taken and modified from Cache::File::cache_file_path() 1309 # Copyright (C) 2003-2006 Chris Leishman. All Rights Reserved. 1310 my $shakey = sha1_hex($key); 1311 my (@path) = unpack('A2' x SUBPATH_DEPTH, $shakey); 1312 1313 return File::Spec->catdir($vol_path, @path); 1314 } 1315 1316 1293 1317 sub DESTROY 1294 1318 {
Note:
See TracChangeset
for help on using the changeset viewer.
