--- trunk/lib/BackupPC/SearchLib.pm 2005/08/30 22:43:01 102 +++ trunk/lib/BackupPC/SearchLib.pm 2005/09/15 13:54:29 121 @@ -175,6 +175,23 @@ return ($results, \@ret); } +sub getHyperEstraier_url($) { + my ($use_hest) = @_; + + return unless $use_hest; + + use HyperEstraier; + my ($index_path, $index_node_url); + + if ($use_hest =~ m#^http://#) { + $index_node_url = $use_hest; + } else { + $index_path = $TopDir . '/' . $index_path; + $index_path =~ s#//#/#g; + } + return ($index_path, $index_node_url); +} + sub getFilesHyperEstraier($) { my ($param) = @_; @@ -185,9 +202,19 @@ use HyperEstraier; + my ($index_path, $index_node_url) = getHyperEstraier_url($index_path); + # open the database - my $db = HyperEstraier::Database->new(); - $db->open($index_path, $HyperEstraier::ESTDBREADER); + my $db; + if ($index_path) { + $db = HyperEstraier::Database->new(); + $db->open($index_path, $HyperEstraier::ESTDBREADER); + } elsif ($index_node_url) { + $db ||= HyperEstraier::Node->new($index_node_url); + $db->set_auth('admin', 'admin'); + } else { + die "BUG: unimplemented"; + } # create a search condition object my $cond = HyperEstraier::Condition->new(); @@ -219,17 +246,32 @@ $cond->set_order( 'date NUMA' ); # get the result of search - my $result = $db->search($cond, 0); - my @res; - my $hits = $result->size; + my ($result, $hits); + + if ($index_path) { + $result = $db->search($cond, 0); + $hits = $result->size; + } elsif ($index_node_url) { + $result = $db->search($cond, 0); + $hits = $result->doc_num; + } else { + die "BUG: unimplemented"; + } # for each document in result for my $i ($offset .. ($offset + $on_page - 1)) { last if ($i >= $hits); - my $id = $result->get($i); - my $doc = $db->get_doc($id, 0); + my $doc; + if ($index_path) { + my $id = $result->get($i); + $doc = $db->get_doc($id, 0); + } elsif ($index_node_url) { + $doc = $result->get_doc($i); + } else { + die "BUG: unimplemented"; + } my $row; foreach my $c (qw/fid hname sname backupnum fiilename filepath date type size/) { @@ -241,25 +283,36 @@ return ($hits, \@res); } +sub getGzipName($$$) +{ + my ($host, $share, $backupnum) = @_; + my $ret = $Conf{GzipSchema}; + + $share =~ s/\//_/g; + $ret =~ s/\\h/$host/ge; + $ret =~ s/\\s/$share/ge; + $ret =~ s/\\n/$backupnum/ge; + + return $ret; + +} + sub getBackupsNotBurned() { my $dbh = get_dbh(); + my $sql = q{ - SELECT - backups.hostID AS hostid, - min(hosts.name) AS host, - min(shares.name) AS share, - backups.num AS backupnum, - min(backups.type) AS type, - min(backups.date) AS date, - min(backups.size) AS size - FROM files - INNER JOIN shares ON files.shareID=shares.ID - INNER JOIN hosts ON hosts.ID = shares.hostID - INNER JOIN backups ON backups.num = files.backupnum and backups.hostID = hosts.ID AND backups.shareID = shares.ID - GROUP BY - backups.hostID, backups.num, backups.shareid - ORDER BY min(backups.date) + SELECT + backups.hostID AS hostID, + hosts.name AS host, + shares.name AS share, + backups.id AS backupnum, + backups.type AS type, + backups.date AS date, + backups.size AS size + FROM backups + WHERE id not in( select id from backups,archive_backup where archive_backup.backup_id=backups.id) + ORDER BY backups.date }; my $sth = $dbh->prepare( $sql ); my @ret; @@ -268,6 +321,10 @@ while ( my $row = $sth->fetchrow_hashref() ) { $row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); $row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); + my (undef,undef,undef,undef,undef,undef,undef,$fs_size,undef,undef,undef,undef,undef) = + stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'. + getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'})); + $row->{'fs_size'} = $fs_size; push @ret, $row; } @@ -296,29 +353,52 @@ } } } + + function sumiraj() + { + var suma = 0; + for (var i = 0; i < document.forma.elements.length; i++) + { + var e = document.forma.elements[i]; + if ((e.checked || !e.checked) && e.name != \'all\') + { + if (e.checked) + { + var ret = e.name.match("fcb(.*)"); + suma += parseInt(eval("document.forma.fss"+ret[1]+".value")); + + } + } + } + document.forma.totalsize.value = suma; + return suma; + } //--> EOF3 $retHTML .= q{ -
- - - - - - - - - - - - - - + + + +
- - ShareBackup noTypedateage/dayssize/MB
- -
+ + + + + + + + + + + + }; my @color = (' bgcolor="#e0e0e0"', ''); @@ -336,9 +416,9 @@ $retHTML .= ""; $retHTML .= ''; + $backup->{'hostid'}.'_'.$backup->{'backupnum'} . + '" value="' . $backup->{'hostid'}.'_'.$backup->{'backupnum'} . + '" onClick="sumiraj();">'; $retHTML .= '' . @@ -347,12 +427,17 @@ '' . '' . '' . + '\n"; } $retHTML .= "
+ + ShareBackup noTypedateage/dayssize/MBgzip size
+ +
' . $backup->{'host'} . ':' . $backup->{'share'} . '' . epoch_to_iso( $backup->{'date'} ) . '' . $backup->{'age'} . '' . $backup->{'size'} . '' . $backup->{'fs_size'} . + '' . "
"; + $retHTML .= "total gzip size:
"; + $retHTML .= "Note:"; $retHTML .= "
"; return $retHTML;