IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13047


Ignore:
Timestamp:
Apr 26, 2007, 1:47:05 PM (19 years ago)
Author:
jhoblitt
Message:

add Nebulous::Server->find_keys()

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Changes

    r13046 r13047  
    22
    330.05
     4    - add Nebulous::Server->find_keys()
    45    - add neb-touch
    56    - add neb-df
  • trunk/Nebulous-Server/MANIFEST

    r13046 r13047  
    8484t/10_server_is_valid_volume_name.t
    8585t/11_server_is_valid_class_id.t
     86t/12_server_find_objects.t
    8687t/50_client_new.t
    8788t/51_client_create.t
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r12966 r13047  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.24 2007-04-23 23:31:32 jhoblitt Exp $
     3# $Id: Server.pm,v 1.25 2007-04-26 23:45:03 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    567567
    568568
     569sub find_objects {
     570    my $self = shift;
     571
     572    my ( $pattern ) = validate_pos( @_,
     573        {
     574            type        => SCALAR,
     575            optional    => 1,
     576        },
     577    );
     578
     579    my $log = $self->log;
     580    my $sql = $self->sql;
     581    my $db  =$self->db;
     582
     583    $log->debug( "entered - @_" );
     584
     585    my $query;
     586
     587    eval {
     588        $query = $db->prepare_cached( $sql->find_objects );
     589        $query->execute( $pattern );
     590    };
     591    $log->logdie( "database error: $@" ) if $@;
     592
     593    my @keys;
     594
     595    while ( my $row = $query->fetchrow_hashref ) {
     596        my $key = $row->{ 'ext_id' };
     597        push @keys, $key if $key;
     598    }
     599
     600    $log->debug( "no keys found" ) unless ( scalar @keys );
     601
     602    $log->debug( "leaving" );
     603
     604    return \@keys;
     605}
     606
     607
    569608sub find_instances {
    570609    my $self = shift;
     
    744783    my $query;
    745784    eval {
     785        # ask the db to generate the table of mounted Nebulous volume
     786        $query = $db->prepare_cached("call getmountedvol()");
     787        $query->execute();
     788
    746789        # TODO cache this?
    747790        my $rows;
     
    759802        }
    760803
    761         $volume = $query->fetchrow_hashref->{ 'mountpoint' };
     804        $volume = $query->fetchrow_hashref->{ 'volume' };
    762805
    763806        $query->finish;
     
    769812        $log->logdie( "database error: $@" ) if $@;
    770813    }
     814
     815    $log->logdie( "failed to find a suitable volume" ) unless defined $volume;
    771816
    772817    $log->debug( "leaving" );
  • trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm

    r13041 r13047  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: SQL.pm,v 1.26 2007-04-26 20:27:33 jhoblitt Exp $
     3# $Id: SQL.pm,v 1.27 2007-04-26 23:45:03 jhoblitt Exp $
    44
    55package Nebulous::Server::SQL;
     
    116116    get_storage_volume_byname   => qq{
    117117        SELECT
    118             mountpoint,
     118            path as volume,
    119119            total - used as free
    120         FROM volume
    121         JOIN mount      -- join limits us to currently mounted volumes
    122             ON volume.path = mount.mountpoint
     120        FROM mountedvol
    123121        WHERE
    124122            used / total < ?
     
    129127    get_storage_volume          => qq{
    130128        SELECT
    131             mountpoint,
     129            path as volume,
    132130            total - used as free
    133         FROM volume
    134         JOIN mount      -- join limits us to currently mounted volumes
    135             ON volume.path = mount.mountpoint
     131        FROM mountedvol
    136132        WHERE
    137133            used / total < ?
     
    152148        FROM volume
    153149        WHERE name = ?
     150    },
     151    find_objects => qq{
     152        SELECT *
     153        FROM storage_object
     154        WHERE ext_id REGEXP ?
    154155    },
    155156);
     
    315316    ) ENGINE=MEMORY;
    316317
    317     -- iterator over the volume table finding the coresponding entry in the
     318    -- iterate over the volume table finding the coresponding entry in the
    318319    -- mount table and inserting union of the volume & mount row into the
    319320    -- mountedvol table
  • trunk/Nebulous/Changes

    r13046 r13047  
    22
    330.05
     4    - add Nebulous::Server->find_keys()
    45    - add neb-touch
    56    - add neb-df
  • trunk/Nebulous/MANIFEST

    r13046 r13047  
    8484t/10_server_is_valid_volume_name.t
    8585t/11_server_is_valid_class_id.t
     86t/12_server_find_objects.t
    8687t/50_client_new.t
    8788t/51_client_create.t
  • trunk/Nebulous/lib/Nebulous/Server.pm

    r12966 r13047  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.24 2007-04-23 23:31:32 jhoblitt Exp $
     3# $Id: Server.pm,v 1.25 2007-04-26 23:45:03 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    567567
    568568
     569sub find_objects {
     570    my $self = shift;
     571
     572    my ( $pattern ) = validate_pos( @_,
     573        {
     574            type        => SCALAR,
     575            optional    => 1,
     576        },
     577    );
     578
     579    my $log = $self->log;
     580    my $sql = $self->sql;
     581    my $db  =$self->db;
     582
     583    $log->debug( "entered - @_" );
     584
     585    my $query;
     586
     587    eval {
     588        $query = $db->prepare_cached( $sql->find_objects );
     589        $query->execute( $pattern );
     590    };
     591    $log->logdie( "database error: $@" ) if $@;
     592
     593    my @keys;
     594
     595    while ( my $row = $query->fetchrow_hashref ) {
     596        my $key = $row->{ 'ext_id' };
     597        push @keys, $key if $key;
     598    }
     599
     600    $log->debug( "no keys found" ) unless ( scalar @keys );
     601
     602    $log->debug( "leaving" );
     603
     604    return \@keys;
     605}
     606
     607
    569608sub find_instances {
    570609    my $self = shift;
     
    744783    my $query;
    745784    eval {
     785        # ask the db to generate the table of mounted Nebulous volume
     786        $query = $db->prepare_cached("call getmountedvol()");
     787        $query->execute();
     788
    746789        # TODO cache this?
    747790        my $rows;
     
    759802        }
    760803
    761         $volume = $query->fetchrow_hashref->{ 'mountpoint' };
     804        $volume = $query->fetchrow_hashref->{ 'volume' };
    762805
    763806        $query->finish;
     
    769812        $log->logdie( "database error: $@" ) if $@;
    770813    }
     814
     815    $log->logdie( "failed to find a suitable volume" ) unless defined $volume;
    771816
    772817    $log->debug( "leaving" );
  • trunk/Nebulous/lib/Nebulous/Server/SQL.pm

    r13041 r13047  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: SQL.pm,v 1.26 2007-04-26 20:27:33 jhoblitt Exp $
     3# $Id: SQL.pm,v 1.27 2007-04-26 23:45:03 jhoblitt Exp $
    44
    55package Nebulous::Server::SQL;
     
    116116    get_storage_volume_byname   => qq{
    117117        SELECT
    118             mountpoint,
     118            path as volume,
    119119            total - used as free
    120         FROM volume
    121         JOIN mount      -- join limits us to currently mounted volumes
    122             ON volume.path = mount.mountpoint
     120        FROM mountedvol
    123121        WHERE
    124122            used / total < ?
     
    129127    get_storage_volume          => qq{
    130128        SELECT
    131             mountpoint,
     129            path as volume,
    132130            total - used as free
    133         FROM volume
    134         JOIN mount      -- join limits us to currently mounted volumes
    135             ON volume.path = mount.mountpoint
     131        FROM mountedvol
    136132        WHERE
    137133            used / total < ?
     
    152148        FROM volume
    153149        WHERE name = ?
     150    },
     151    find_objects => qq{
     152        SELECT *
     153        FROM storage_object
     154        WHERE ext_id REGEXP ?
    154155    },
    155156);
     
    315316    ) ENGINE=MEMORY;
    316317
    317     -- iterator over the volume table finding the coresponding entry in the
     318    -- iterate over the volume table finding the coresponding entry in the
    318319    -- mount table and inserting union of the volume & mount row into the
    319320    -- mountedvol table
  • trunk/Nebulous/nebclient/nebulous.wsdl

    r4645 r13047  
    6060    </message>
    6161
     62    <message name="find_ObjectsRequest">
     63        <part name="pattern" type="xsd:string" />
     64    </message>
     65    <message name="find_ObjectsResponse">
     66        <!-- fixme -->
     67        <part name="result" type="tns:ArrayOfString" />
     68    </message>
     69
    6270    <message name="find_instancesRequest">
    6371        <part name="key" type="xsd:string" />
     
    114122            -->
    115123        </operation>
     124        <operation name="find_objects">
     125            <input  message="tns:find_objectsRequest" />
     126            <output message="tns:find_objectsResponse" />
     127            <!--
     128                <fault name="" message="" />
     129            -->
     130        </operation>
    116131        <operation name="find_instances">
    117132            <input  message="tns:find_instancesRequest" />
     
    175190        <operation name="unlock_object">
    176191            <soap:operation soapAction="urn:Nebulous/Server/SOAP#unlock_object" />
     192            <input>
     193                <soap:body use="encoded" namespace="urn:Nebulous/Server/SOAP"
     194                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
     195            </input>
     196            <output>
     197                <soap:body use="encoded" namespace="urn:Nebulous/Server/SOAP"
     198                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
     199            </output>
     200        </operation>
     201        <operation name="find_objects">
     202            <soap:operation soapAction="urn:Nebulous/Server/SOAP#find_objects" />
    177203            <input>
    178204                <soap:body use="encoded" namespace="urn:Nebulous/Server/SOAP"
Note: See TracChangeset for help on using the changeset viewer.