Changeset 24625
- Timestamp:
- Jun 29, 2009, 1:54:25 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous-Server/bin/neb-admin (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/bin/neb-admin
r23932 r24625 91 91 { 92 92 # so_id, ext_id, instances, available_instances, need_recovery, recoverable 93 $dbh->do("CREATE TEMPORARY TABLE mymountedvol LIKE mountedvol"); 94 $dbh->do("INSERT INTO mymountedvol SELECT * FROM mountedvol"); 95 $dbh->do("CREATE TEMPORARY TABLE myvolume LIKE volume"); 96 $dbh->do("INSERT INTO myvolume SELECT * FROM volume"); 93 # XXX don't remove the temp table code -- testing w/o it 94 # $dbh->do("CREATE TEMPORARY TABLE mymountedvol LIKE mountedvol"); 95 # $dbh->do("INSERT INTO mymountedvol SELECT * FROM mountedvol"); 97 96 98 97 if (not defined $so_id_start) { $so_id_start = 0; } … … 102 101 # XXX check if so_id_start is beyond MAX(so_id): if so, exit with exit status 10 103 102 { 104 my $query = $dbh->prepare("SELECT MAX(so_id) from storage_object");105 $query->execute;103 my $query = $dbh->prepare("SELECT MAX(so_id) from storage_object"); 104 $query->execute; 106 105 my $answer = $query->fetchrow_arrayref; 107 106 my $max_so_id = $$answer[0]; 108 $query->finish;109 110 if ($so_id_start > $max_so_id) {111 print STDERR "at end of so_id range, reset please\n";112 exit 10;113 }114 } 115 107 $query->finish; 108 109 if ($so_id_start > $max_so_id) { 110 print STDERR "at end of so_id range, reset please\n"; 111 exit 10; 112 } 113 } 114 116 115 my $query = $dbh->prepare( 117 " SELECT 118 storage_object.so_id, 119 ext_id, 120 count(ins_id) as instances, 121 myvolume.name as volume_name, 122 myvolume.host as volume_host, 123 count(mymountedvol.vol_id) as available_instances, 124 count(mymountedvol.vol_id) > 0 as recoverable, 125 storage_object_xattr.value as copies 126 FROM storage_object 127 JOIN instance 128 USING(so_id) 129 JOIN myvolume 130 USING(vol_id) 131 LEFT JOIN storage_object_xattr 132 ON storage_object.so_id = storage_object_xattr.so_id 133 JOIN mymountedvol 134 USING(vol_id) 135 WHERE mymountedvol.available = 1 136 AND storage_object_xattr.name = 'user.copies' 137 AND storage_object.so_id >= $so_id_start 138 AND storage_object.so_id < $so_id_end 139 GROUP BY so_id 140 HAVING available_instances < instances OR instances < copies 141 LIMIT $limit" 116 " 117 SELECT 118 so.so_id, 119 so.ext_id, 120 count(ins_id) as instances, 121 mv.name as volume_name, 122 mv.host as volume_host, 123 count(mv.vol_id) as available_instances, 124 count(mv.vol_id) > 0 as recoverable, 125 xattr.value as copies 126 FROM storage_object AS so 127 JOIN storage_object_xattr AS xattr 128 ON so.so_id = xattr.so_id 129 AND xattr.name = 'user.copies' 130 JOIN instance AS i 131 ON so.so_id = i.so_id 132 JOIN mountedvol AS mv 133 USING(vol_id) 134 WHERE 135 mv.available = 1 136 AND so.so_id >= $so_id_start 137 AND so.so_id < $so_id_end 138 GROUP BY so_id 139 ORDER BY so_id DESC 140 HAVING available_instances < instances OR instances < copies 141 LIMIT $limit" 142 142 ); 143 143 $query->execute; 144 144 145 $dbh->do("DROP TABLE IF EXISTS mymountedvol");145 # $dbh->do("DROP TABLE IF EXISTS mymountedvol"); 146 146 147 147 my @rows; … … 174 174 # if the copies xattr is unset and the object has 2 or more instances, we 175 175 # will assume a target of 2 copies 176 177 # XXX change this: there should be no default value or we will178 # have a race condition. user.copies should never get set by179 # any client until AFTER a file is no longer in use.176 177 # XXX change this: there should be no default value or we will 178 # have a race condition. user.copies should never get set by 179 # any client until AFTER a file is no longer in use. 180 180 my $copies = $obj->{copies} || 2; 181 181 … … 207 207 # use a different exit status if we hit the limit (likely more files pending) 208 208 if ($Npending == $limit) { 209 exit 1;209 exit 1; 210 210 } 211 211 exit 0; … … 225 225 226 226 $dbh->do("DROP TABLE IF EXISTS mymountedvol"); 227 $dbh->do("DROP TABLE IF EXISTS myvolume"); 227 228 228 229 my @rows;
Note:
See TracChangeset
for help on using the changeset viewer.
