IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20060


Ignore:
Timestamp:
Oct 10, 2008, 4:13:23 PM (18 years ago)
Author:
jhoblitt
Message:

use a temp copy of the volume table too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/bin/neb-admin

    r20031 r20060  
    33# Copyright (C) 2005-2008  Joshua Hoblitt
    44#
    5 # $Id: neb-admin,v 1.11 2008-10-09 23:41:47 jhoblitt Exp $
     5# $Id: neb-admin,v 1.12 2008-10-11 02:13:23 jhoblitt Exp $
    66
    77use strict;
     
    1313use DBI;
    1414use Nebulous::Client;
    15 use Nebulous::Server::SQL;
     15#use Nebulous::Server::SQL;
    1616use Net::Server::Daemonize qw( check_pid_file create_pid_file unlink_pid_file );
    1717use URI;
     
    6767);
    6868
    69 my $sql = Nebulous::Server::SQL->new();
     69#my $sql = Nebulous::Server::SQL->new();
    7070
    7171# so_id, ext_id, instances, available_instances, need_recovery, recoverable
     
    8080}
    8181
    82 my $query = $dbh->prepare( $sql->find_objects_with_unavailable_instances
    83         . " LIMIT $limit" );
     82{
     83    my $query = $dbh->prepare("CREATE TEMPORARY TABLE myvolume LIKE volume");
     84    $query->execute;
     85}
     86
     87{
     88    my $query = $dbh->prepare("INSERT INTO myvolume SELECT * FROM volume");
     89    $query->execute;
     90}
     91
     92my $query = $dbh->prepare(
     93"        SELECT
     94            storage_object.so_id,
     95            ext_id,
     96            count(ins_id) as instances,
     97            myvolume.name as volume_name,
     98            myvolume.host as volume_host,
     99            count(mymountedvol.vol_id) as available_instances,
     100            count(mymountedvol.vol_id) > 0 as recoverable,
     101            storage_object_xattr.value as copies
     102        FROM storage_object
     103        JOIN instance
     104            USING(so_id)
     105        JOIN myvolume
     106            USING(vol_id)
     107        LEFT JOIN storage_object_xattr
     108            ON storage_object.so_id = storage_object_xattr.so_id
     109        JOIN mymountedvol
     110            USING(vol_id)
     111        WHERE mymountedvol.available = 1
     112--        WHERE storage_object_xattr.name = 'user.copies'
     113        GROUP BY so_id
     114        HAVING available_instances < instances OR instances < copies
     115        LIMIT $limit" );
    84116$query->execute;
    85117
Note: See TracChangeset for help on using the changeset viewer.