IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2007, 10:45:08 AM (19 years ago)
Author:
jhoblitt
Message:

change API to generally return true URIs instead of file paths
add support for some what intelligent volume allocations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm

    r12007 r12961  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: SQL.pm,v 1.23 2007-02-23 01:23:45 jhoblitt Exp $
     3# $Id: SQL.pm,v 1.24 2007-04-23 20:45:08 jhoblitt Exp $
    44
    55package Nebulous::Server::SQL;
     
    115115    },
    116116    get_storage_volume_byname   => qq{
    117         SELECT uri FROM volume WHERE name = ? ORDER BY rand() LIMIT 1
     117        SELECT
     118            mountpoint,
     119            total - used as free
     120        FROM volume
     121        JOIN mount      -- join limits us to currently mounted volumes
     122            ON volume.path = mount.mountpoint
     123        WHERE
     124            used / total < ?
     125            AND name = ?
     126        ORDER BY free DESC
     127        LIMIT 1
    118128    },
    119129    get_storage_volume          => qq{
    120         SELECT uri FROM volume ORDER BY rand() LIMIT 1
     130        SELECT
     131            mountpoint,
     132            total - used as free
     133        FROM volume
     134        JOIN mount      -- join limits us to currently mounted volumes
     135            ON volume.path = mount.mountpoint
     136        WHERE
     137            used / total < ?
     138        ORDER BY free DESC
     139        LIMIT 1
    121140    },
    122141    new_volume          => qq{
    123         INSERT INTO volume (name, uri)
     142        INSERT INTO volume (name, path)
    124143        VALUES (?, ?)
    125144    },
     
    130149    },
    131150    get_volume_by_name => qq{
    132         SELECT vol_id, name, uri
     151        SELECT vol_id, name, path
    133152        FROM volume
    134153        WHERE name = ?
     
    156175DROP TABLE IF EXISTS lock_record;
    157176DROP TABLE IF EXISTS volume;
     177DROP TABLE IF EXISTS mount;
    158178DROP TABLE IF EXISTS class;
    159179DROP TABLE IF EXISTS log
Note: See TracChangeset for help on using the changeset viewer.