Changeset 41172 for trunk/Nebulous/bin
- Timestamp:
- Nov 27, 2019, 12:04:14 PM (7 years ago)
- Location:
- trunk/Nebulous/bin
- Files:
-
- 10 edited
-
neb-cat (modified) (3 diffs)
-
neb-cp (modified) (2 diffs)
-
neb-cull (modified) (3 diffs)
-
neb-insert (modified) (1 diff)
-
neb-ls (modified) (5 diffs)
-
neb-migrate (modified) (1 diff)
-
neb-repair (modified) (7 diffs)
-
neb-replicate (modified) (2 diffs)
-
neb-shift (modified) (1 diff)
-
neb-stat (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/bin/neb-cat
r13080 r41172 18 18 use constant CHUNK_SIZE => 1024; 19 19 20 my ($server );20 my ($server, $help); 21 21 22 22 $server = $ENV{'NEB_SERVER'} unless $server; … … 24 24 GetOptions( 25 25 'server|s=s' => \$server, 26 'help|h' => \$help, 26 27 ) || pod2usage( 2 ); 27 28 28 pod2usage( -msg => "Required options: --server <key...>", -exitval => 2 ) 29 unless defined $server; 29 # explicitly defined -h / --help: 30 if ($help) { pod2usage( -verbose => 1 ); } 31 32 pod2usage( -msg => "Required options: --server <key...>", -exitval => 2 ) unless defined $server; 30 33 31 34 my $neb = Nebulous::Client->new( … … 95 98 =over 4 96 99 97 =item *--server|-s <URL>100 =item --server|-s <URL> 98 101 99 102 URL of the Nebulous server to connect to. -
trunk/Nebulous/bin/neb-cp
r16182 r41172 16 16 use Pod::Usage qw( pod2usage ); 17 17 18 my ($volume, $server );18 my ($volume, $server, $help); 19 19 20 20 $server = $ENV{'NEB_SERVER'} unless $server; … … 23 23 'volume=s' => \$volume, 24 24 'server|s=s' => \$server, 25 'help|h' => \$help, 25 26 ) || pod2usage( 2 ); 27 28 # explicitly defined -h / --help: 29 if ($help) { pod2usage( -verbose => 1 ); } 26 30 27 31 my $src = shift; -
trunk/Nebulous/bin/neb-cull
r30236 r41172 17 17 18 18 my ($min_copies, $server, $volume, $one_only); 19 my ($soft_volume );19 my ($soft_volume, $help); 20 20 $server = $ENV{'NEB_SERVER'} unless $server; 21 21 … … 26 26 'one_only|o' => \$one_only, 27 27 'soft_volume' => \$soft_volume, 28 'help|h' => \$help, 28 29 ) || pod2usage( 2 ); 30 31 # explicitly defined -h / --help: 32 if ($help) { pod2usage( -verbose => 1 ); } 29 33 30 34 my $key = shift; … … 59 63 # print "@cull_args\n"; 60 64 61 62 65 if ($one_only) { 63 66 my $status = $neb->there_can_be_only_one(@cull_args); 67 if (not defined $status) { 68 die "not enough instances of Nebulous key: $key"; 69 } 64 70 if ($status == 0) { 65 71 die "not enough instances of Nebulous key: $key"; -
trunk/Nebulous/bin/neb-insert
r25939 r41172 95 95 =head1 SYNOPSIS 96 96 97 neb-insert --server <neb-server><neb-key> <local-file> [--copies <n>] [--destroy]97 neb-insert [--server <neb-server>] <neb-key> <local-file> [--copies <n>] [--destroy] 98 98 99 99 #=head1 DESCRIPTION -
trunk/Nebulous/bin/neb-ls
r28581 r41172 19 19 $ls, 20 20 $column, 21 $help 21 22 ); 22 23 23 24 $server = $ENV{'NEB_SERVER'} unless $server; 24 25 25 26 26 GetOptions( … … 29 29 'l' => \$ls, 30 30 'column|c' => \$column, 31 'help|h' => \$help, 31 32 ) || pod2usage( 2 ); 33 34 # explicitly defined -h / --help: 35 if ($help) { pod2usage( -verbose => 1 ); } 32 36 33 37 # twiddle column so that it does it by default. … … 35 39 $column = not $column; 36 40 41 if ($ls) { $path = 1; } 42 37 43 my $pattern = shift; 38 44 39 45 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 40 pod2usage( -msg => "Required options: --server", -exitval => 2 ) 41 unless $server; 46 pod2usage( -msg => "Required options: --server", -exitval => 2 ) unless $server; 42 47 43 48 my $neb = Nebulous::Client->new( … … 96 101 =head1 SYNOPSIS 97 102 98 neb-ls [--server <URL>] [-c] [-p] <pattern>103 neb-ls [--server <URL>] [-c] [-p] [-l] <pattern> 99 104 100 105 =head1 DESCRIPTION 101 106 102 107 This program list Nebulous keys matched by C<<pattern>>. Call it with no 103 arguments is equivalent to searching with the pattern C<neb://>. SQL like108 arguments is equivalent to searching with the pattern C<neb://>. SQL-like 104 109 wildcards are supported to select out certain files. 105 110 … … 108 113 =over 4 109 114 110 =item *--path|-p115 =item --path|-p 111 116 112 117 Find the disk files corresponding to the keys found. 113 118 114 =item *--column|-c119 =item --column|-c 115 120 116 121 Disable column formatting, and output results one to a line. 117 122 123 =item --l|-l 124 125 Give disk file information using ls (implies -p). 126 118 127 Optional 119 128 120 =item *--server|-s <URL>129 =item --server|-s <URL> 121 130 122 131 URL of the Nebulous server to connect to. -
trunk/Nebulous/bin/neb-migrate
r28446 r41172 23 23 24 24 $server = $ENV{'NEB_SERVER'} unless $server; 25 26 die "this tool is probably too inefficient unless used very carefully"; 25 27 26 28 GetOptions( -
trunk/Nebulous/bin/neb-repair
r39926 r41172 45 45 ); 46 46 47 die "can't connect edto Nebulous Server: $server"47 die "can't connect to Nebulous Server: $server" 48 48 unless defined $neb; 49 49 50 50 my $stat = $neb->stat($key); 51 51 die "nebulous key: $key not found" unless $stat; 52 52 53 my $instances = $neb->find_instances($key, 'any'); 53 54 die "no instances found" unless $instances; … … 71 72 72 73 for (my $i = 0; $i <= $#files; $i++) { 74 # count existing files and get the MD5 sums 73 75 if (-e $files[$i]) { 74 76 $existance[$i] = 1; … … 89 91 push @{ $md5sum_valid{$md5sums[$i]} }, $files[$i]; 90 92 $last_f = $files[$i]; 91 } 92 else { 93 } else { 93 94 $existance[$i] = 0; 94 95 $md5sums[$i] = 'NON-EXISTANT'; … … 98 99 } 99 100 101 # check number of copies and number of unique MD5 sum values 100 102 my $N_mds = scalar(keys(%md5sum_uniq)); 101 103 my $N_files = scalar(@files); 104 105 # seems like we should not call neb-replicate until *after* we have 106 # removed 0-byte copies 102 107 if ($N_files < $user_copies) { 103 108 print "Insufficient copies ($N_files) of $key, replicating!\n"; 104 109 system("neb-replicate $key"); 105 110 } 111 106 112 if ($N_mds == 1) { 107 113 print "Nebulous key $key is consistent.\n"; 108 } 109 else { 114 } else { 110 115 my $valid_sum = ''; 111 116 my $valid_file = ''; 112 117 my $m; 113 118 foreach $m (keys %md5sum_valid) { 114 if (($m ne 'd41d8cd98f00b204e9800998ecf8427e') &&($m ne 'NON-EXISTANT')) {119 if (($m ne 'd41d8cd98f00b204e9800998ecf8427e') && ($m ne 'NON-EXISTANT')) { 115 120 if ($valid_sum ne '') { 116 121 die "Too many acceptable files for key $key\n"; … … 122 127 if ($valid_sum eq '') { 123 128 die "No acceptable file for key $key\n"; 124 } 125 else { 129 } else { 126 130 print "Repairing instances\n"; 127 131 foreach $m (keys %md5sum_valid) { … … 130 134 print "\tcp $valid_file $f\n"; 131 135 system("cp $valid_file $f"); 136 137 # if we failed to make a copy, the target ($f) could be inaccessible 132 138 if ($? >> 8 != 0) { 133 139 if ($existance[0] == 1) { 134 # We can fix this with culls and replications. 140 141 # The target is a valid file 0-byte file 142 # but we cannot replace it with the 143 # correct file. We can fix this with 144 # culls and replications. 145 135 146 print "Attempting to fix this.\n"; 136 147 print("neb-replicate $key\n"); 137 148 system("neb-replicate $key"); 138 149 if ($? >> 8 == 0) { 150 # if the neb-replicate succeeded, remove the bad copy with neb-cull 139 151 my $bad_volume = (split /\//, $f)[2]; 140 152 print("neb-cull --volume $bad_volume $key\n"); 141 153 system("neb-cull --volume $bad_volume $key"); 142 } 143 else { 154 } else { 144 155 die "Failed to copy file $valid_file to $f, and subsequent replication also failed!\n"; 145 156 } 146 } 147 else { 157 } else { 148 158 die "Failed to copy file $valid_file to $f!\n"; 149 159 } … … 187 197 =head1 DESCRIPTION 188 198 189 This program repairs instances and corrects instance counts for a nebulous key. 199 This program repairs instances and corrects instance counts for a nebulous key: 200 201 If some of the existing instances have the MD5 sum corresponding to a 202 0-byte file, but the rest have the same, non-zero byte md5sum, then 203 replace the 0-byte files with the non-zero byte version. 204 205 At the end, if the number of instances is less than the value of 206 user.copies, then additional copies are generated. 190 207 191 208 =head1 OPTIONS -
trunk/Nebulous/bin/neb-replicate
r29476 r41172 42 42 ); 43 43 44 # Nebulous::Client programs can use this to set the log level: 45 # $neb->set_log_level ('DEBUG'); 46 44 47 die "can't connected to Nebulous Server: $server" 45 48 unless defined $neb; … … 50 53 for (my $i = 0; $i < $copies; $i++) { 51 54 if (defined $volume) { 55 # this is coded so that all copies end up on the specified volume which seems wrong 52 56 $neb->replicate($key, $volume) 53 57 or die "failed to replicate Nebulous key: $key"; -
trunk/Nebulous/bin/neb-shift
r31964 r41172 17 17 18 18 my ($volume, $server); 19 20 die "this tool may fail since find_instances will return an instance which is not on the hard volume"; 19 21 20 22 $server = $ENV{'NEB_SERVER'} unless $server; -
trunk/Nebulous/bin/neb-stat
r32045 r41172 19 19 use URI; 20 20 21 my ($validate,$server,$nouris );21 my ($validate,$server,$nouris,$help); 22 22 23 23 $server = $ENV{'NEB_SERVER'} unless $server; 24 24 25 25 GetOptions( 26 'server|s=s' => \$server, 27 'validate|v' => \$validate, 28 'files' => \$nouris, 26 'server|s=s' => \$server, 27 'validate|v' => \$validate, 28 'files|f' => \$nouris, 29 'help|h' => \$help, 29 30 ) || pod2usage( 2 ); 30 31 32 # explicitly defined -h / --help: 33 if ($help) { pod2usage( -verbose => 1 ); } 34 31 35 my $key = shift; 32 36 33 37 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 34 pod2usage( -msg => "Required options: --server", -exitval => 2 ) 35 unless $server; 36 pod2usage( -msg => "missing key", exitval => 2 ) 37 unless defined $key; 38 pod2usage( -msg => "Required options: --server", -exitval => 2 ) unless $server; 39 pod2usage( -msg => "missing key", exitval => 2 ) unless defined $key; 38 40 39 41 my $neb = Nebulous::Client->new( … … 52 54 eval { 53 55 $user_copies = $neb->getxattr($key, "user.copies"); 56 die ("user.copies not found") unless $user_copies; 54 57 }; 55 unless(defined($user_copies) ) {58 unless(defined($user_copies) and $user_copies ne "") { 56 59 $user_copies = 1; 57 60 } … … 74 77 $md5sum_uniq{$md5sums[$i]} = 1; 75 78 close($fh); 76 } 77 else { 79 } else { 78 80 $existance[$i] = 0; 79 81 $md5sums[$i] = 'NON-EXISTANT'; 80 82 $md5sum_uniq{$md5sums[$i]} = 1; 81 83 } 84 82 85 if (defined($nouris)) { 83 86 $validation[$i] = sprintf("% 3d %32s %s", … … 85 88 $md5sums[$i], 86 89 $files[$i]); 87 } 88 else { 90 } else { 89 91 $validation[$i] = sprintf("% 3d %32s %s", 90 92 $existance[$i], … … 112 114 "instance location:\n", " " x 4, 113 115 join("\n" . " " x 4, @validation), "\n"; 116 } else { 117 118 if (defined($nouris)) { 119 my @files = map {URI->new($_)->file if $_} @$instances; 120 121 print 122 "object id: ", @$stat[0], "\n", 123 "key: ", @$stat[1], "\n", 124 "read lock: ", @$stat[2], "\n", 125 "write lock: ", @$stat[3], "\n", 126 "epoch: ", @$stat[4], "\n", 127 "mtime: ", @$stat[5], "\n", 128 "available instances: ", @$stat[6], "\n", 129 "requested instances: ", $user_copies, "\n", 130 "total instances: ", @$stat[7], "\n", 131 132 "instance location:\n", " " x 4, 133 join("\n" . " " x 4, @files), "\n"; 134 } else { 135 print 136 "object id: ", @$stat[0], "\n", 137 "key: ", @$stat[1], "\n", 138 "read lock: ", @$stat[2], "\n", 139 "write lock: ", @$stat[3], "\n", 140 "epoch: ", @$stat[4], "\n", 141 "mtime: ", @$stat[5], "\n", 142 "available instances: ", @$stat[6], "\n", 143 "requested instances: ", $user_copies, "\n", 144 "total instances: ", @$stat[7], "\n", 145 146 "instance location:\n", " " x 4, 147 join("\n" . " " x 4, @$instances), "\n"; 148 } 149 114 150 } 115 else {116 print117 "object id: ", @$stat[0], "\n",118 "key: ", @$stat[1], "\n",119 "read lock: ", @$stat[2], "\n",120 "write lock: ", @$stat[3], "\n",121 "epoch: ", @$stat[4], "\n",122 "mtime: ", @$stat[5], "\n",123 "available instances: ", @$stat[6], "\n",124 "requested instances: ", $user_copies, "\n",125 "total instances: ", @$stat[7], "\n",126 127 "instance location:\n", " " x 4,128 join("\n" . " " x 4, @$instances), "\n";129 }130 151 131 152 … … 150 171 =over 4 151 172 152 =item *--server|-s <URL>173 =item --server|-s <URL> 153 174 154 175 URL of the Nebulous server to connect to. … … 156 177 Optional if the appropriate environment variable is set. 157 178 158 =item *--validate|-v179 =item --validate|-v 159 180 160 181 Optional - prints out additional information including md5sum. 161 182 162 =item *--files183 =item --files 163 184 164 185 Optional - prints out disk files instead of uris during validate stage. … … 174 195 =over 4 175 196 176 =item *C<NEB_SERVER>197 =item C<NEB_SERVER> 177 198 178 199 Equivalent to --server|-s
Note:
See TracChangeset
for help on using the changeset viewer.
