Changeset 17815 for trunk/Nebulous-Server
- Timestamp:
- May 27, 2008, 11:59:53 AM (18 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 5 edited
-
Build.PL (modified) (1 diff)
-
Changes (modified) (1 diff)
-
MANIFEST (modified) (1 diff)
-
bin/neb-admin (modified) (9 diffs)
-
lib/Nebulous/Server/SQL.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Build.PL
r17072 r17815 38 38 script_files => [qw( 39 39 bin/neb-addvol 40 bin/neb-admin 40 41 bin/neb-fsck 41 42 bin/neb-initdb -
trunk/Nebulous-Server/Changes
r17761 r17815 2 2 3 3 0.12 4 - add neb-admin util 4 5 - fix Nebulous::Server::setxattr_object() so that creating a new xattr with 5 6 the "replace" flag works -
trunk/Nebulous-Server/MANIFEST
r17077 r17815 8 8 Todo 9 9 bin/neb-addvol 10 bin/neb-admin 10 11 bin/neb-fsck 11 12 bin/neb-initdb -
trunk/Nebulous-Server/bin/neb-admin
r17771 r17815 3 3 # Copyright (C) 2005-2008 Joshua Hoblitt 4 4 # 5 # $Id: neb-admin,v 1. 1 2008-05-22 04:08:29jhoblitt Exp $5 # $Id: neb-admin,v 1.2 2008-05-27 21:59:53 jhoblitt Exp $ 6 6 7 7 use strict; … … 19 19 use Pod::Usage qw( pod2usage ); 20 20 21 my ($db, $dbuser, $dbpass, $server );21 my ($db, $dbuser, $dbpass, $server, $limit); 22 22 23 23 $db = $ENV{'NEB_DB'} unless $db; … … 31 31 'pass=s' => \$dbpass, 32 32 'server|s=s' => \$server, 33 'limit|l=i' => \$limit, 33 34 ) || pod2usage( 2 ); 34 35 … … 38 39 pod2usage( -msg => "Required options: --db --user --pass", -exitval => 2 ) 39 40 unless $db && $dbuser && $dbpass; 41 42 # set default limit to 5 43 $limit ||= 5; 40 44 41 45 my $neb = Nebulous::Client->new( … … 60 64 61 65 # so_id, ext_id, instances, available_instances, need_recovery, recoverable 62 my $query = $dbh->prepare( $sql->find_objects_with_unavailable_instances ); 66 my $query = $dbh->prepare( $sql->find_objects_with_unavailable_instances 67 . " LIMIT $limit" ); 63 68 $query->execute; 64 69 … … 68 73 } 69 74 $query->finish; 75 76 print "replciate MULTI\n\n"; 70 77 71 78 foreach my $obj (@rows) { … … 75 82 my $key = $obj->{ext_id}; 76 83 my $has = $obj->{instances}; 84 my $vol_name = $obj->{volume_name}; 77 85 my $available = $obj->{available_instances} || 0; 78 86 my $need_recovery = $obj->{need_recovery}; … … 84 92 # objects with only a single instance that are offline are unrecoverable so 85 93 # we don't need to handle that special case 86 next unless $need_recovery;94 # next unless $need_recovery; 87 95 unless ($recoverable) { 88 96 warn "so_id: $so_id key: \'$key\' ", … … 96 104 next unless $need; 97 105 98 for (; $need > 0; $need--) { 99 warn "so_id: $so_id key: \'$key\' ", 100 "has $available available instances, target $copies -- replicating" 101 or warn "so_id: $so_id key: \'$key\' replication failed"; 102 103 $need++; 106 my %md = ( 107 key => $key, 108 need_copies => $need, 109 volume_name => $vol_name, 110 ); 111 112 print_metadata("replicate", \%md); 113 print "\n"; 114 } 115 116 sub print_metadata 117 { 118 my ($name, $pairs) = @_; 119 120 print "$name METADATA\n"; 121 122 # format from formatMetadataItem() in pzMetadataConfig.c 123 foreach my $key (keys %$pairs) { 124 my $value = $pairs->{$key}; 125 if (looks_like_number($value)) { 126 printf(" " . "%-15s %-8s %-15s\n", $key, "S32", $value); 127 } else { 128 printf(" " . "%-15s %-8s %-15s\n", $key, "STR", $value); 129 } 104 130 } 131 132 print "END\n"; 133 } 134 135 # looks_like_number() was stolen from Scalar::Util 136 # 137 # Copyright (c) 1997-2006 Graham Barr <gbarr@pobox.com>. All rights reserved. 138 # This program is free software; you can redistribute it and/or modify it 139 # under the same terms as Perl itself. 140 141 sub looks_like_number { 142 local $_ = shift; 143 144 # checks from perlfaq4 145 return 0 if !defined($_) or ref($_); 146 return 1 if (/^[+-]?\d+$/); # is a +/- integer 147 return 1 if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); # a C float 148 return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i); 149 150 0; 105 151 } 106 152 -
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r17772 r17815 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1.5 1 2008-05-22 04:10:01jhoblitt Exp $3 # $Id: SQL.pm,v 1.52 2008-05-27 21:59:53 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 249 249 ext_id, 250 250 count(ins_id) as instances, 251 volume.name as volume_name, 251 252 count(mountedvol.vol_id) as available_instances, 252 253 count(mountedvol.vol_id) > 0 as recoverable, … … 255 256 JOIN instance 256 257 USING(so_id) 258 JOIN volume 259 USING(vol_id) 257 260 LEFT JOIN storage_object_xattr 258 261 ON storage_object.so_id = storage_object_xattr.so_id
Note:
See TracChangeset
for help on using the changeset viewer.
