Changeset 13251 for trunk/Nebulous/lib
- Timestamp:
- May 4, 2007, 1:36:46 PM (19 years ago)
- Location:
- trunk/Nebulous/lib/Nebulous
- Files:
-
- 2 edited
-
Server.pm (modified) (3 diffs)
-
Server/SQL.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/lib/Nebulous/Server.pm
r13244 r13251 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.3 7 2007-05-04 20:46:29jhoblitt Exp $3 # $Id: Server.pm,v 1.38 2007-05-04 23:36:46 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 930 930 my $query; 931 931 eval { 932 {933 # ask the db to generate the table of mounted Nebulous volume934 my $query = $db->prepare_cached("call getmountedvol()");935 $query->execute();936 }937 938 $log->debug("generated mountedvol table");939 940 932 if ($vol_name) { 941 933 $query = $db->prepare_cached( $sql->get_object_instances_by_vol_name ); … … 1114 1106 my ($vol_id, $vol_path); 1115 1107 eval { 1116 {1117 # ask the db to generate the table of mounted Nebulous volume1118 my $query = $db->prepare_cached("call getmountedvol()");1119 $query->execute();1120 }1121 1122 1108 # TODO cache this? 1123 1109 my $query; -
trunk/Nebulous/lib/Nebulous/Server/SQL.pm
r13245 r13251 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: SQL.pm,v 1. 39 2007-05-04 21:20:43jhoblitt Exp $3 # $Id: SQL.pm,v 1.40 2007-05-04 23:36:46 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server::SQL; … … 274 274 DROP TABLE IF EXISTS class; 275 275 DROP TABLE IF EXISTS log; 276 DROP TABLE IF EXISTS mountedvol; 276 277 DROP PROCEDURE IF EXISTS getmountedvol; 277 278 SET FOREIGN_KEY_CHECKS=1 … … 386 387 ### 387 388 389 CREATE TABLE mountedvol( 390 mountpoint VARCHAR(255) NOT NULL, 391 total BIGINT NOT NULL, 392 used BIGINT NOT NULL, 393 vol_id INT NOT NULL, 394 name VARCHAR(255) NOT NULL, 395 path VARCHAR(255) NOT NULL, 396 allocate BOOLEAN DEFAULT FALSE, 397 available BOOLEAN DEFAULT FALSE, 398 KEY(vol_id), 399 KEY(allocate), 400 KEY(available) 401 ) ENGINE=innodb; 402 403 ### 404 388 405 CREATE PROCEDURE getmountedvol() DETERMINISTIC 389 406 BEGIN … … 401 418 SELECT @@session.tx_isolation INTO trans_level; 402 419 403 -- set trans level 420 -- set trans level to repeatable-read so the volume table does not change 421 -- out from under our cursor 404 422 SET @@session.tx_isolation = 'REPEATABLE-READ'; 405 406 -- create a temp table to hold the merged results of the volume & mount407 -- tables. One would hope the that the transaction isolation level will408 -- stop one session from stomping on another sessions version of this409 -- table.410 411 DROP TABLE IF EXISTS mountedvol;412 CREATE TEMPORARY TABLE mountedvol(413 mountpoint VARCHAR(255) NOT NULL,414 total BIGINT NOT NULL,415 used BIGINT NOT NULL,416 vol_id INT NOT NULL,417 name VARCHAR(255) NOT NULL,418 path VARCHAR(255) NOT NULL,419 allocate BOOLEAN DEFAULT FALSE,420 available BOOLEAN DEFAULT FALSE,421 KEY(vol_id),422 KEY(allocate),423 KEY(available)424 ) ENGINE=MEMORY;425 423 426 424 -- iterate over the volume table finding the coresponding entry in the 427 425 -- mount table and inserting union of the volume & mount row into the 428 426 -- mountedvol table 429 430 427 OPEN cur1; 428 429 DELETE FROM mountedvol; 431 430 432 431 myloop: LOOP … … 446 445 -- restore the original transaction level 447 446 SET @@session.tx_isolation = trans_level; 447 448 COMMIT; 448 449 END
Note:
See TracChangeset
for help on using the changeset viewer.
