Changeset 680

Show
Ignore:
Timestamp:
01/08/07 19:55:33 (3 years ago)
Author:
hachi
Message:

r23534@lj: lj | 2007-01-05 16:42:00 -0800
Docs for the IOStatWatcher object.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/server/lib/MogileFS/IOStatWatcher.pm

    r496 r680  
    55use IO::Socket::INET; 
    66 
     7=head1 Methods 
     8 
     9=head2 $iow = MogileFS::IOStatWatcher->new() 
     10 
     11Returns a new IOStatWatcher object. 
     12 
     13=cut 
     14 
    715sub new { 
    816    my ($class) = @_; 
    9     return bless {}, $class; 
     17    my $self = bless {}, $class; 
     18    $self->on_stats; # set an empty handler. 
     19    return $self; 
    1020} 
     21 
     22=head2 $iow->set_hosts( host1 [, host2 [, ...] ] ) 
     23 
     24Sets the list of hosts to connect to for collecting IOStat information. This call can block if you 
     25pass it hostnames instead of ip addresses. 
     26 
     27Upon successfull connection, the on_stats callback will be called each time the statistics are 
     28collected. Error states (failed connections, etc.) will trigger retries on 60 second intervals, and 
     29disconnects will trigger an immediate reconnect. 
     30 
     31=cut 
    1132 
    1233sub set_hosts { 
     
    2142    $self->{hosts} = $new_hosts; 
    2243} 
     44 
     45=head2 $iow->on_stats( coderef ) 
     46 
     47Sets the coderef called for the C<on_stats> callback. 
     48 
     49=cut 
     50 
     51sub on_stats { 
     52    my ($self, $cb) = @_; 
     53 
     54    unless (ref $cb eq 'CODE') { 
     55        $cb = sub {}; 
     56    } 
     57 
     58    $self->{on_stats} = $cb; 
     59} 
     60 
     61=head1 Callbacks 
     62 
     63=head2 on_stats->( host, stats ) 
     64 
     65Called each time device use statistics are collected. The C<host> argument is the value passed in to the 
     66C<set_hosts> method. The C<stats> object is a hashref of mogile device names and utilization percentages. 
     67 
     68=cut 
     69 
     70# Everything beyond here is internal. 
    2371 
    2472sub got_stats { 
     
    3987} 
    4088 
    41 sub on_stats { 
    42     my ($self, $cb) = @_; 
    43     $self->{on_stats} = $cb; 
    44 } 
    45  
     89# Support class that does the communication with individual hosts. 
    4690package MogileFS::IOStatWatch::Client; 
    4791