| | 1034 | |
|---|
| | 1035 | # now we want to do the "new" replication stats |
|---|
| | 1036 | my $db_time = $dbh->selectrow_array('SELECT UNIX_TIMESTAMP()'); |
|---|
| | 1037 | $stats = $dbh->selectall_arrayref('SELECT nexttry, COUNT(*) FROM file_to_replicate GROUP BY 1'); |
|---|
| | 1038 | foreach my $stat (@$stats) { |
|---|
| | 1039 | if ($stat->[0] < 1000) { |
|---|
| | 1040 | # anything under 1000 is a specific state, so let's define those. here's the list |
|---|
| | 1041 | # of short names to describe them. |
|---|
| | 1042 | my $name = { |
|---|
| | 1043 | 0 => 'newfile', # new files that need to be replicated |
|---|
| | 1044 | 1 => 'redo', # files that need to go through replication again |
|---|
| | 1045 | }->{$stat->[0]} || "unknown"; |
|---|
| | 1046 | |
|---|
| | 1047 | # now put it in the output hashref. note that we do += because we might |
|---|
| | 1048 | # have more than one group of unknowns. |
|---|
| | 1049 | $ret->{"to_replicate_$name"} += $stat->[1]; |
|---|
| | 1050 | |
|---|
| | 1051 | } elsif ($stat->[0] == MogileFS::Worker::Replicate::end_of_time()) { |
|---|
| | 1052 | $ret->{"to_replicate_manually"} = $stat->[1]; |
|---|
| | 1053 | |
|---|
| | 1054 | } elsif ($stat->[0] < $db_time) { |
|---|
| | 1055 | $ret->{"to_replicate_overdue"} += $stat->[1]; |
|---|
| | 1056 | |
|---|
| | 1057 | } else { |
|---|
| | 1058 | $ret->{"to_replicate_deferred"} += $stat->[1]; |
|---|
| | 1059 | } |
|---|
| | 1060 | } |
|---|