/[Sack]/trunk/lib/Sack/Server.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Sack/Server.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 191 by dpavlin, Sun Nov 8 13:44:10 2009 UTC revision 192 by dpavlin, Sun Nov 8 14:12:38 2009 UTC
# Line 70  sub to_all { Line 70  sub to_all {
70          }          }
71  }  }
72    
73    my @shard_paths;
74    
75  while (1) {  while (1) {
76          for my $sock ($sel->can_read(1)) {          for my $sock ($sel->can_read(1)) {
77                  if ($sock == $lsn) {                  if ($sock == $lsn) {
# Line 88  while (1) { Line 90  while (1) {
90                                  $sock->close;                                  $sock->close;
91                          } else {                          } else {
92                                  warn "<<<< ", dump($data), $/;                                  warn "<<<< ", dump($data), $/;
93                                  if ( $data->{repl} ) {                                  if ( my $repl = $data->{repl} ) {
94                                          my $response = { repl => $$ };                                          my $response = { repl_pid => $$ };
95                                          if ( $data->{repl} =~ m/ping/ ) {                                          if ( $repl =~ m/ping/ ) {
96                                                  to_all { ping => 1 };                                                  to_all { ping => 1 };
97                                          } elsif ( $data->{repl} =~ m/info/ ) {                                          } elsif ( $repl =~ m/info/ ) {
98                                                  $response->{info} = $info;                                                  $response->{info} = $info;
99                                            } elsif ( $repl =~ m{load\s*(\S+)?} ) {
100                                                    my $name = $1 || 'shard';
101                                                    @shard_paths = glob "/tmp/sack/$name/*";
102                                                    warn "loading shards ", dump( @shard_paths );
103                                                    to_all { load => $name };
104                                          } else {                                          } else {
105                                                  $response->{error}->{unknown} = $data;                                                  $response->{error}->{unknown} = $data;
106                                          }                                          }
# Line 102  while (1) { Line 109  while (1) {
109                                          my $port = $data->{port};                                          my $port = $data->{port};
110                                          info $port => 'ping', $port;                                          info $port => 'ping', $port;
111                                          $session->{port}->{ $data->{port} } = $sock;                                          $session->{port}->{ $data->{port} } = $sock;
112                                    } elsif ( $data->{load} eq 'shard' ) {
113                                            if ( my $path = shift @shard_paths ) {
114                                                    warn "retrieve $path ", -s $path;
115                                                    my $shard = Storable::retrieve $path;
116                                                    warn ">>>> [", $data->{port}, "] sending shard $path\n";
117                                                    Storable::store_fd( { path => $path, shard => $shard }, $sock );
118                                            } else {
119                                                    warn "no more shards for [", $data->{port}, "]\n";
120                                            }
121                                    } else {
122                                            warn "UNKNOWN ",dump($data);
123                                  }                                  }
124                          }                          }
125                  }                  }

Legend:
Removed from v.191  
changed lines
  Added in v.192

  ViewVC Help
Powered by ViewVC 1.1.26