Changeset 65

Show
Ignore:
Timestamp:
08/12/04 22:01:22 (4 years ago)
Author:
whitaker
Message:

-- don't try to replicate more copies than we have hosts, regardless of

what the mindevcount is. avoids a ton of cpu waste.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/devnotes/sql-data-simple.txt

    r14 r65  
    1 INSERT INTO host SET hostid=1, status='alive', hostname='localhost, hostip='127.0.0.1', remoteroot='/var/mogilefs'; 
     1INSERT INTO host SET hostid=1, status='alive', hostname='localhost', hostip='127.0.0.1', remoteroot='/var/mogilefs'; 
    22 
    33INSERT INTO device SET devid=1, hostid=1, status='alive'; 
  • trunk/server/mogilefsd

    r62 r65  
    538538        my $dbh = get_dbh() or return 0; 
    539539 
     540        Mgd::check_host_cache(); 
     541        my $host_ct = keys %Mgd::cache_host; 
     542 
    540543        # find the classes for each domainid (including domains without explict classes) 
    541544        my %min; # dmid -> classid -> mindevcount 
     
    548551            # classid may be NULL (undef), in which case there are no classes defined 
    549552            # and we don't note the mindevcount (yet) 
    550             $min{$dmid}{$classid} = int($mct) if defined $classid; 
     553            $min{$dmid}{$classid} = int($host_ct < $mct ? $host_ct : $mct) if defined $classid; 
    551554        } 
    552555 
     
    555558            # each domain's classid=0, if not defined, has an implied mindevcount of 2, 
    556559            # which most people will probably use. 
    557             $min{$dmid}{0} = 2 unless exists $min{$dmid}{0}; 
     560            $min{$dmid}{0} = $host_ct < 2 ? $host_ct : 2 unless exists $min{$dmid}{0}; 
    558561 
    559562            # iterate through each class, including the implicit class 0