[prev in list] [next in list] [prev in thread] [next in thread] 

List:       intermezzo-cvs
Subject:    CVS: intermezzo/lento/Lento Bootstrap.pm,1.66,1.67 Client.pm,1.10,1.11 Fileset.pm,1.22,1.23 Fsetdb.p
From:       Phil Schwan <pschwan () users ! sourceforge ! net>
Date:       2001-10-16 17:11:10
[Download RAW message or body]

Update of /cvsroot/intermezzo/intermezzo/lento/Lento
In directory usw-pr-cvs1:/tmp/cvs-serv6183/lento/Lento

Modified Files:
	Bootstrap.pm Client.pm Fileset.pm Fsetdb.pm KML.pm 
	Replicator.pm Server.pm 
Log Message:
I want to know why there are _any_ cvs error paths that don't leave the commit
message in the temp file.  I'd also like to know why our masquerading timeout
is so short.

Summary:
- Extended the last_rcvd record to include a 16-byte UUID and a 32-bit ctime
- Removed the replicator.db
- Extended the SysId RPC to include a UUID and protocol version
- Updated the tests to provide those UUIDs in the config files

Capital letters mean important:
IF YOU UPGRADE ANY NODES IN YOUR CLUSTER TO CVS HEAD, YOU MUST UPGRADE THEM 
ALL.  ZERO BACKWARDS COMPATIBILITY.  OTHERWISE IT WILL FAIL ON STARTUP AND YOUR
HOUSE WILL CATCH ON FIRE.

- presto24/journal.c: added some missing EXITs; we don't write the last
  backfetched ctime here, but added some comments so that future last_rcvd
  revisions don't forget about it

- lento: added the first $::PROTOCOL_VERSION

- Lento/Bootstrap.pm: check for the now-mandatory UUID in the SysId file
- Lento/Client.pm: UUID-related functions
- Lento/Fileset.pm: added tiny bits of kernel_reint and kml_truncate
infrastructure; updated the Client call
- Lento/Fsetdb.pm: more kernel_reint/kml_trunc flag goop
- Lento/KML.pm: s/%d/%s/ fixups for quads
- Lento/Replicator.pm: removed all traces of the replicatordb; added UUID and
last_backfetched_ctime to the last_rcvd structure
- Lento/Server.pm: added UUID and PROTOCOL_VERSION to the SysId packet
- Lento/InterMezzo/ReqHandler.pm: SysId handler stuff; explode if we get an old
SysId packet, or one with an unregonized protocol version
- tests/common.sh: added UUID to sysid_add, client_add, and server_add functions
- tests/iface_setup.sh: create faux UUIDs for server and clients


Index: Bootstrap.pm
===================================================================
RCS file: /cvsroot/intermezzo/intermezzo/lento/Lento/Bootstrap.pm,v
retrieving revision 1.66
retrieving revision 1.67
diff -U2 -r1.66 -r1.67
--- Bootstrap.pm	2001/08/07 02:26:04	1.66
+++ Bootstrap.pm	2001/10/16 17:11:08	1.67
@@ -196,4 +196,5 @@
 
     $::mysysid = $::prefix.$buf->{name};
+    $::myuuid = $buf->{uuid};
     $prestodev = $buf->{psdev}; 
     $::mysysip = $buf->{bindaddr};
@@ -201,4 +202,9 @@
     $prestodev = "/dev/intermezzo0" unless $prestodev;
     $::mysysip = "" unless $::mysysip;
+
+    if (!defined($::myuuid)) {
+        print("The ID file ($idfile) now requires a UUID of the form \
aabbccdd-eeff-gghh-iijj-kkllmmnnoo.\n"); +        die("Please add one to your config \
file.\n"); +    }
 
     if (! -c $prestodev ) {

Index: Client.pm
===================================================================
RCS file: /cvsroot/intermezzo/intermezzo/lento/Lento/Client.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -U2 -r1.10 -r1.11
--- Client.pm	2001/07/30 02:41:02	1.10
+++ Client.pm	2001/10/16 17:11:08	1.11
@@ -1,7 +1,8 @@
 package Lento::Client;
 use strict;
+use UUID;
 use Lento::List;
 
-sub new ($$$) {
+sub new ($$) {
     my $class = shift;
     my $self = {};
@@ -18,8 +19,23 @@
 }
 
+sub uuid ($;$) {
+    my $self = shift;
+    my $new = shift;
+
+    if (defined($new)) {
+        if (length($new) != 36) {
+            LOG(">>> Warning: UUID ($new) is not 36 bytes\n");
+        }
+        $self->{uuid} = $new;
+    }
+    return $self->{uuid};
+}
+
 sub printme ($) {
     my $self = shift;
+    my $uuid;
+    UUID::unparse($self->{uuid}, $uuid);
 
-    my $msg = "[Client ID: $self->{sysid}, replicating fsets: [ ";
+    my $msg = "[Client ID: $self->{sysid}, uuid: $uuid, replicating fsets: [ ";
     foreach my $v (@{$self->{repfsets}}) {
 	    $msg .= "$v ";

Index: Fileset.pm
===================================================================
RCS file: /cvsroot/intermezzo/intermezzo/lento/Lento/Fileset.pm,v
retrieving revision 1.22
retrieving revision 1.23
diff -U2 -r1.22 -r1.23
--- Fileset.pm	2001/10/11 18:20:48	1.22
+++ Fileset.pm	2001/10/16 17:11:08	1.23
@@ -94,7 +94,9 @@
     $self->{fetch_on_demand}= shift;
     $self->{data_on_demand} = shift;
+    $self->{kernel_reint} = shift;
     $self->{steal_permit}= shift;
     $self->{jclose_on_write}= shift;
     $self->{fetchtype}= shift;
+    $self->{kml_truncate} = shift;
     my $replicators = shift;
 
@@ -187,5 +189,5 @@
 	        $self->{presto_read_only}= 0;
 	    }
-	
+
 	    # add replicators with KML offset 0
 	    foreach my $repid (@{$replicators}) {
@@ -199,5 +201,5 @@
 		        LOG(">>     Creating client object ($repid) for " .
 		            "replication of fileset $self->{name}\n");
-		        $client = new Lento::Client($repid, undef);
+		        $client = new Lento::Client($repid);
 		        $::clientdb->add($client);
 	        }

Index: Fsetdb.pm
===================================================================
RCS file: /cvsroot/intermezzo/intermezzo/lento/Lento/Fsetdb.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- Fsetdb.pm	2001/09/20 18:21:49	1.7
+++ Fsetdb.pm	2001/10/16 17:11:08	1.8
@@ -62,6 +62,10 @@
         if ($entry->{kernel_reint}) {
             $entry->{kernel_reint} = 1;
+
+            LOG(">>>   - kernel reintegration enabled for fileset $fsetname\n");
         } else {
             $entry->{kernel_reint} = 0;
+
+            LOG(">>>   - kernel reintegration disabled for fileset $fsetname\n");
         }
 
@@ -102,6 +106,9 @@
         if ($entry->{fetch_on_demand}) {
             die "Fetch-on-demand is unfinished.  Do not enable it.\n";
+        }
+        if ($entry->{kml_truncate}) {
+            LOG(">>> KML truncation enabled, at $entry->{kml_truncate} bytes\n");
         }
-        my $fset = Lento::Fileset->new($fsetname, 
+        my $fset = Lento::Fileset->new($fsetname,
                                      $entry->{servername},
                                      $entry->{mount_point},
@@ -109,7 +116,9 @@
                                      $entry->{fetch_on_demand},
                                      $entry->{data_on_demand},
+                                     $entry->{kernel_reint},
                                      $entry->{steal_permit},
                                      $entry->{jclose_on_write},
                                      $entry->{fetchtype},
+                                       $entry->{kml_truncate},
                                      $entry->{replicator});
         die "Error in initializing fileset $fsetname\n" unless $fset;

Index: KML.pm
===================================================================
RCS file: /cvsroot/intermezzo/intermezzo/lento/Lento/KML.pm,v
retrieving revision 1.71
retrieving revision 1.72
diff -U2 -r1.71 -r1.72
--- KML.pm	2001/10/06 00:13:30	1.71
+++ KML.pm	2001/10/16 17:11:08	1.72
@@ -126,5 +126,5 @@
         $count++;
     
-        $result .= sprintf "Record $count size: $size, offset $kml_offset,  (total \
kml length %d)\n", $kml->last_offset(); +        $result .= sprintf "Record $count \
size: $size, offset $kml_offset,  (total kml length %s)\n", $kml->last_offset();  
         if (defined $rec) {
@@ -424,5 +424,5 @@
     $kml->last_offset($::psdev->get_kml_size($kml->{fset}->mtpt()));
     
-    DEBUG("send_KML: last_offset %d\n%s\n", 
+    DEBUG("send_KML: last_offset %s\n%s\n", 
             $kml->last_offset(), $replicator->printme());
     

Index: Replicator.pm
===================================================================
RCS file: /cvsroot/intermezzo/intermezzo/lento/Lento/Replicator.pm,v
retrieving revision 1.58
retrieving revision 1.59
diff -U2 -r1.58 -r1.59
--- Replicator.pm	2001/10/12 20:16:22	1.58
+++ Replicator.pm	2001/10/16 17:11:08	1.59
@@ -12,5 +12,4 @@
 use POE;
 use POSIX;
-use DB_File;
 use File::stat;
 use Lento::EventSupport;
@@ -41,8 +40,4 @@
 =pod
 
-$ReplicatorDB_tied is a hash of ties to an anonymous hashes stored in DB files.
-    The key in the anonymous hash is the binary string "sysid\0fsetname".  The
-    values are a frozen copy of fields  slot_offset & state.
-    
     An important function is the last_rcvd method which returns the
     last_rcvd record numbers and offsets, both the local and remote ones,
@@ -50,7 +45,4 @@
 
 =cut
-    
-my %ReplicatorDB_tied = ();     # becomes a hash of the hashes for disk files
-my %ReplicatorDB_handle= ();    # hash of handles to open databases
 
 # XXX set $D to n or I depending on the host
@@ -87,43 +79,52 @@
     
     bless $self, $class;
+    return $self;
+}
+
+sub init ($$) {
+    my $self = shift;
+    $self->{uuid} = shift;
+
     # if this guy is new assign a slot_offset to it
-    my $data = $self->load_from_db();
-    
-    if (! defined  $data ) {
-        my $st = stat $self->{last_rcvd_file} || 
+    if ($self->get_slot_offset() < 0) {
+        my $st = stat $self->{last_rcvd_file} ||
             die "No last received file for $self->{fsetname}";
-        # the size of an expect structure is 32 + 64 + 32 + 64 bits = 24 bytes
-        $self->{slot_offset} = $st->size;
-        
+        # the size of a last_rcvd structure is 128 + 32 + 64 + 32 + 64 + 32 bits
+        # = 44 bytes, but the slot_offset starts after the 16-byte UUID
+        $self->{slot_offset} = $st->size() + 16;
+
         # put stuff there to fill the slot
         # XXX I to be replaced with $D$D$D$D
-        DEBUG "extending $self->{last_rcvd_file} from $self->{slot_offset} to \
                $self->{slot_offset} + 24\n";
-        my $buf = pack("IIIIII", 0, 0, 0, 0, 0, 0);
-        sysopen FH, "$self->{last_rcvd_file}", O_RDWR | O_APPEND | O_SYNC
-            or die "Cannot open $self->{last_rcvd_file} ($!)";
-        die "write error ($!)" unless defined syswrite FH, $buf, 24;
-        close FH;
-        $self->save_to_db();
-        $self->test_db();
-        $ReplicatorDB_handle{$self->{fsetname}}->sync();
-        $self->test_db();
+        DEBUG("extending $self->{last_rcvd_file} from " . $st->size() . " to " .
+              $self->{slot_offset} + 28 . "\n");
+        my $tmp;
+        if (UUID::parse($self->{uuid}, $tmp) == -1) {
+            confess "Unable to parse UUID ($self->{uuid})";
+        }
+        my $buf = pack("a16IIIIIII", $tmp, 0, 0, 0, 0, 0, 0, 0);
+        my $fh = new IO::File;
+        if (!$fh->open("$self->{last_rcvd_file}", O_RDWR | O_APPEND | O_SYNC)) {
+            die "Cannot open $self->{last_rcvd_file}: $!";
+        }
+        if (!defined($fh->syswrite($buf, 44))) {
+            die "write error ($!)";
+        }
+        $fh->close();
     } else {
         DEBUG "slot_offset= $self->{slot_offset}";
         DEBUG "state= $self->{state}\n";
     }
-    LOG(">>     New replicator: peer %s fset %s, slot offset %s\n", 
+    LOG(">>     New replicator: peer %s fset %s, slot offset %s\n",
         $self->{sysid}, $self->{fsetname}, $self->{slot_offset});
-    
+
     # and into the hashes
     $ReplicatorDB->{$self->{sysid}}->{$self->{fsetname}} = $self;
-    
-    $self->test_db();
-    
+
     # next KML offset to send to peer (this system's numbering)
-    $self->{next_to_send} = 0; 
-    
+    $self->{next_to_send} = 0;
+
     # XXX hack, should be established by ReplicatorStatus calls
     $self->online(1);
-    
+
     # This is needed since the lento might have crashed in the middle
     # of a send_KML the last time around and this erroneous state will get
@@ -131,5 +132,6 @@
     $self->morepending(0);
     $self->clear_send_session();
-    return $self;
+
+    return;
 }
 
@@ -150,84 +152,104 @@
     return $str;
 }
-
 
-sub load_from_db () {
+sub get_kml_size () {
     my $self = shift;
-    $self->initialize_tie() 
-        unless defined $ReplicatorDB_tied{$self->{fsetname}};
-    my $data = $ReplicatorDB_tied{$self->{fsetname}}->{$self->{sysid} . "\0" . \
                $self->{fsetname}};
-    
-    DEBUG("READING $self->{sysid}, $self->{fsetname} from replicator db\n");
-    if (defined $data) {
-        $self->{slot_offset}
-            = unpack "n", $data;
-        DEBUG("---- DATA: $self->{slot_offset}\n");
+    my $mtpt = shift;
+
+    if (!defined($mtpt)) {
+        $mtpt = $self->{fileset}->mtpt();
     }
-    
-    DEBUG "kml size".$::psdev->get_kml_size($self->{fileset}->mtpt())."\n" 
-        if defined $::fsetdb;
-    
-    return $data;
+
+    return $::psdev->get_kml_size($mtpt);
 }
 
-sub test_db () {
+sub get_slot_offset ($) {
     my $self = shift;
-    my $data = $ReplicatorDB_tied{$self->{fsetname}}->{$self->{sysid} . "\0" . \
                $self->{fsetname}};
-    confess "GRR: data still not defined\n" unless defined $data;
-}
 
+    # Walk the last_rcvd file looking for this UUID
+    my $fh = new IO::File;
+    if (!$fh->open($self->{last_rcvd_file})) {
+        die("Unable to open last_rcvd file ($self->{last_rcvd_file}): $!\n");
+    }
 
-sub save_to_db () {
-    my $self = shift;
-    $self->initialize_tie() unless defined $ReplicatorDB_tied{$self->{fsetname}};
-    die "No db\n" unless defined $ReplicatorDB_tied{$self->{fsetname}} and
-        defined $ReplicatorDB_handle{$self->{fsetname}};
-    die unless defined  $self->{slot_offset};
-    my $data = pack("n", $self->{slot_offset});
-    $ReplicatorDB_tied{$self->{fsetname}}->{
-                       $self->{sysid} . "\0" . $self->{fsetname}} = $data;
-}
+    DEBUG("Looking for UUID $self->{uuid} in last_rcvd\n");
 
-sub initialize_tie {
-    my $self=shift;
-    my $replicator_db_file = $self->{journal_path} . "db/replicators.db";
-    $ReplicatorDB_handle{$self->{fsetname}}= 
-        tie (%{$ReplicatorDB_tied{$self->{fsetname}}}, 'DB_File', 
-            $replicator_db_file, O_CREAT|O_RDWR, 0700, $DB_HASH) 
-        or die "Cannot open replicator database - $replicator_db_file. ($!)\n";
-}
+    my ($buf, $rc);
+    my $offset = 0;
+    while (($rc = $fh->sysread($buf, 44)) == 44) {
+        my $tmp;
+        UUID::unparse(substr($buf, 0, 16), $tmp);
+        if ($tmp eq $self->{uuid}) {
+            $self->{slot_offset} = $offset + 16;
+            return 0;
+        }
+        $offset += 44;
+    }
+    $fh->close();
 
-sub sync_replicator_db {
-    my $fsetname;
-    foreach $fsetname (keys %ReplicatorDB_handle) {
-        $ReplicatorDB_handle{$fsetname}->sync();
+    if ($rc != 44) {
+        # Couldn't find the UUID.  What a tragedy.
+        return -1;
     }
 }
 
+sub do_last_rcvd ($$) {
+    my $file = shift;
+    my $offset = shift;
+    my $fh = new IO::File;
+    my $count;
+    my $buf;
+
+    # Sometimes under high loads the os might return an error (EAGAIN?)
+    for ($count = 0; $count < $Lento::Replicator::RETRY; $count++) {
+        if ($fh->open($file)) {
+            last;
+        }
+    }
+    if ($count == $Lento::Replicator::RETRY) {
+        confess("Cannot open $file ($!)");
+    }
+
+    DEBUG("do_last_rcvd: offset = $offset\n");
+    if (!defined($fh->sysseek($offset, SEEK_SET))) {
+        die "sysseek failed: $!";
+    }
+    if ($fh->sysread($buf, 28) != 28) {
+        confess("last_rcvd read failed: $!\n");
+    }
+    my ($last_remote_recno,
+        $last_remote_offset_low, $last_remote_offset_high,
+        $last_local_recno,
+        $last_local_offset_low, $last_local_offset_high,
+        $last_backfetched_ctime) = unpack("IIIIIII", $buf);
+    $fh->close();
+
+    DEBUG("last_remote_recno: $last_remote_recno\n");
+    DEBUG("last_remote_offset_low: $last_remote_offset_low\n");
+    DEBUG("last_remote_offset_high: $last_remote_offset_high\n");
+    DEBUG("last_local_recno: $last_local_recno\n");
+    DEBUG("last_local_offset_low: $last_local_offset_low\n");
+    DEBUG("last_local_offset_high: $last_local_offset_high\n");
+    DEBUG("last_backfetched_ctime: $last_backfetched_ctime\n");
+
+    return ($last_remote_recno,
+            $last_remote_offset_low, $last_remote_offset_high,
+            $last_local_recno,
+            $last_local_offset_low, $last_local_offset_high,
+            $last_backfetched_ctime);
+}
+
 # This function now returns quads for offsets. -SHP
 sub last_rcvd {
     my $self = shift;
-    my $buf;
-    my $count=0;
-    
-    # Sometimes under high loads the os might return an error (EAGAIN?)
-    for ($count=0;$count < $Lento::Replicator::RETRY;$count++) {
-        sysopen(FH, "$self->{last_rcvd_file}", O_RDONLY) && last;
-    };
-    
-    confess "Cannot open $self->{last_rcvd_file} ($!)" 
-        if ($count == $Lento::Replicator::RETRY);
-    
-    sysseek(FH, $self->{slot_offset}, SEEK_SET);
-    sysread(FH, $buf, 24);
-    close FH;
 
     # note that disk order is little endian.
-    ($self->{last_remote_recno}, $self->{last_remote_offset_low}, 
-     $self->{last_remote_offset_high}, 
-     $self->{last_local_recno}, $self->{last_local_offset_low}, 
-     $self->{last_local_offset_high}) = 
-         unpack "IIIIII", $buf;
-    
+    ($self->{last_remote_recno}, $self->{last_remote_offset_low},
+     $self->{last_remote_offset_high},
+     $self->{last_local_recno}, $self->{last_local_offset_low},
+     $self->{last_local_offset_high},
+     $self->{last_backfetched_ctime}) =
+       do_last_rcvd($self->{last_rcvd_file}, $self->{slot_offset});
+
     $self->{last_remote_recno}=0 unless defined $self->{last_remote_recno};
     $self->{last_remote_offset_low}=0 unless defined \
$self->{last_remote_offset_low}; @@ -236,4 +258,5 @@
     $self->{last_local_offset_low}=0 unless defined $self->{last_local_offset_low};
     $self->{last_remote_offset_high}=0 unless defined $self->{last_remote_offset};
+    $self->{last_backfetched_ctime} = 0 unless \
defined($self->{last_backfetched_Ctime});  
     # Convert to quads...note reordering of parameters to high:low SHP
@@ -246,6 +269,7 @@
 
     return ($self->{last_remote_recno}, $self->{last_remote_offset},
-            $self->{last_local_recno}, $self->{last_local_offset});
-}    
+            $self->{last_local_recno}, $self->{last_local_offset},
+            $self->{last_backfetched_ctime});
+}
 
 # last_remote_offset is a quad
@@ -255,38 +279,45 @@
     die "offset must be passed in" unless defined $last_remote_offset;
 
-    my ($remote_recno,$remote_offset,$local_recno,$local_offset)=
-        $self->last_rcvd();
+    my ($remote_recno, $remote_offset, $local_recno, $local_offset,
+        $last_backfetched_ctime) = $self->last_rcvd();
 
     #replace old remote offset values with new ones
     $self->write_last_rcvd($remote_recno, $last_remote_offset,
-                           $local_recno, $local_offset);
+                           $local_recno, $local_offset, $last_backfetched_ctime);
 }
 
 # offsets are quads...
-sub sync_last_rcvd {
-    my ($self,$last_remote_recno,$last_remote_offset) = @_;
-    
+sub sync_last_rcvd ($$$;$) {
+    my ($self, $last_remote_recno, $last_remote_offset,
+        $last_backfetched_ctime) = @_;
+
+    if (!defined($last_backfetched_ctime)) {
+        $last_backfetched_ctime = $self->{last_backfetched_ctime};
+    }
+
     die "recno  not defined" unless defined $last_remote_recno;
     die "offset not defined" unless defined $last_remote_offset;
     
     my $last_local_recno=$::psdev->get_last_recno($self->{fileset}->mtpt());
-    my $last_local_offset=$::psdev->get_kml_size($self->{fileset}->mtpt());
+    my $last_local_offset=$self->get_kml_size();
     
     DEBUG $self->printme();
-    DEBUG "syncing last rcvd sequence with $last_remote_recno,".
-        " $last_remote_offset, $last_local_recno, $last_local_offset\n";
+    DEBUG("syncing last rcvd sequence with $last_remote_recno," .
+          " $last_remote_offset, $last_local_recno, $last_local_offset, " .
+          "$last_backfetched_ctime\n");
     
     $self->write_last_rcvd($last_remote_recno, $last_remote_offset,
-                           $last_local_recno, $last_local_offset);
+                           $last_local_recno, $last_local_offset,
+                           $last_backfetched_ctime);
 }
 
 
 # note that this function now operates with quad offsets.
-sub write_last_rcvd ($$$$$$) {
+sub write_last_rcvd ($$$$$$$) {
     my ($self, $last_remote_recno, $last_remote_offset, $last_local_recno,
-        $last_local_offset)=@_;
-    
-    DEBUG("Writing last_rcvd for \n".$self->printme().
-        "with $last_remote_recno, $last_remote_offset, \
$last_local_recno,$last_local_offset"); +        $last_local_offset, \
$last_backfetched_ctime) = @_; +
+    DEBUG("Writing last_rcvd for \n".$self->printme() .
+          "with $last_remote_recno, $last_remote_offset, \
$last_local_recno,$last_local_offset");  
     die "no remote recno"  if !(defined $last_remote_recno);
@@ -294,4 +325,5 @@
     die "no local recno"   if !(defined $last_local_recno);
     die "no local offset"  if !(defined $last_local_offset);
+    die "no last ctime"    if !(defined $last_backfetched_ctime);
 
     my ($rr,$ro,$lr,$lo) = $self->last_rcvd();
@@ -307,14 +339,22 @@
     
     # note reordering of high/low parameters for writing to disk
-    my $buf= pack("IIIIII",$last_remote_recno, $last_remote_offset_low, 
+    my $buf= pack("IIIIIII", $last_remote_recno,
+                  $last_remote_offset_low,
                   $last_remote_offset_high,
-                  $last_local_recno, $last_local_offset_low, 
-                  $last_local_offset_high);
-    
-    sysopen(FH, "$self->{last_rcvd_file}", O_RDWR | O_SYNC) 
-        or die "Cannot open $self->{last_rcvd_file}";
-    sysseek(FH, $self->{slot_offset}, SEEK_SET);
-    die "write error ($!)" unless defined syswrite FH, $buf, 24;
-    close FH;
+                  $last_local_recno, $last_local_offset_low,
+                  $last_local_offset_high,
+                  $last_backfetched_ctime);
+
+    my $fh = new IO::File;
+    if (!$fh->open("$self->{last_rcvd_file}", O_RDWR | O_SYNC)) {
+        die "Cannot open $self->{last_rcvd_file}: $!";
+    }
+    if (!$fh->sysseek($self->{slot_offset}, SEEK_SET)) {
+        die "Cannot seek to $self->{slot_offset} in $self->{last_rcvd_file}: $!";
+    }
+    if (!defined($fh->syswrite($buf, 28))) {
+        die "write error ($!)";
+    }
+    $fh->close();
 }
 
@@ -328,5 +368,5 @@
         return $ReplicatorDB->{$sysid}->{$fsetname};
     }
-    undef;
+    return undef;
 }
 
@@ -440,8 +480,8 @@
     die "No incr passed" unless defined $val;
     $self->{next_to_send} += $val;
-    DEBUG "Setting next_to_send to $self->{next_to_send}\n";
+    DEBUG "Setting next_to_send to $self->{next_to_send} ($val incr)\n";
     
     # quadint...
-    my $kmlsize=$::psdev->get_kml_size($self->{fileset}->mtpt());
+    my $kmlsize = $self->get_kml_size();
 
     if ($self->{next_to_send} > $kmlsize) {
@@ -449,5 +489,5 @@
             "adjusting offsets\n";
         # be paranoid kml sizes may change!
-        $kmlsize=$self->{next_to_send}=$::psdev->get_kml_size($self->{fileset}->mtpt());
 +        $kmlsize = $self->{next_to_send} = $self->get_kml_size();
     }
     
@@ -475,5 +515,5 @@
     confess "no next_to_send" unless defined $self->{next_to_send};
     
-    my $kmlsize=$::psdev->get_kml_size($self->{fileset}->mtpt());
+    my $kmlsize = $self->get_kml_size();
 
     DEBUG "kml size $kmlsize\n";
@@ -495,5 +535,5 @@
             "adjusting offsets\n";
         # be paranoid...kml sizes may change so redo the ioctl
-        $self->{next_to_send}=$::psdev->get_kml_size($self->{fileset}->mtpt());
+        $self->{next_to_send} = $self->get_kml_size();
     }
     
@@ -513,5 +553,5 @@
 
     die "repinfo from an older lento is not supported\n"
-        if (length($repinfo) < 32);
+        if (length($repinfo) < 36);
     
     # our status of the fileset - important at reconnect time
@@ -520,5 +560,5 @@
     my ($r_kmlsize_h, $r_kmlsize_l, $r_remote_recno, $r_remote_offset_h, 
         $r_remote_offset_l, $r_local_recno, $r_local_offset_h, 
-        $r_local_offset_l) = unpack("NNNNNNNN", $repinfo);
+        $r_local_offset_l, $r_last_ctime) = unpack("NNNNNNNNN", $repinfo);
 
     # convert to quads...
@@ -531,5 +571,5 @@
     
     DEBUG("repinfo= $r_kmlsize, $r_remote_recno, $r_remote_offset,". 
-      " $r_local_recno, $r_local_offset\n");
+          " $r_local_recno, $r_local_offset, $r_last_ctime\n");
     
     my ($local_last_state, $local_kmlgrowth, $remote_kmlgrowth)=
@@ -558,6 +598,7 @@
         # sense is when the remote was reformatted, but things may change with
         # snapshots...
-        $replicator->write_last_rcvd
-            ($r_local_recno,$r_local_offset,$r_remote_recno,$r_remote_offset);
+        $replicator->write_last_rcvd($r_local_recno, $r_local_offset,
+                                     $r_remote_recno, $r_remote_offset,
+                                     $r_last_ctime);
         my ($last_state,$local_kmlgrowth,$remote_kmlgrowth) =
             $replicator->compute_kmlgrowth($r_kmlsize,
@@ -616,6 +657,6 @@
     my $replicator=shift;
     my ($last_remote_recno,$last_remote_offset,$last_local_recno,
-        $last_local_offset) = $replicator->last_rcvd();
-    my $local_kmlsize=$::psdev->get_kml_size($replicator->{fileset}->{mtpt});
+        $last_local_offset, $last_backfetched_ctime) = $replicator->last_rcvd();
+    my $local_kmlsize = $replicator->get_kml_size();
 
     my ($lks_h,$lks_l) = $local_kmlsize->toArray();
@@ -626,6 +667,7 @@
     # we go to native quads. Also note that this is different from 
     # disk where we keep stuff in little endian form.
-    my $status = pack("NNNNNNNN", $lks_h, $lks_l, $last_remote_recno, 
-                $lro_h, $lro_l, $last_local_recno, $llo_h, $llo_l);
+    my $status = pack("NNNNNNNNN", $lks_h, $lks_l, $last_remote_recno,
+                      $lro_h, $lro_l, $last_local_recno, $llo_h, $llo_l,
+                      $last_backfetched_ctime);
 
     return $status;
@@ -657,5 +699,5 @@
     my ($remote_recno,$remote_offset,$local_recno,$local_offset)=
         $self->last_rcvd();
-    my $local_kmlsize=$::psdev->get_kml_size($fset->mtpt());
+    my $local_kmlsize = $self->get_kml_size();
 
     DEBUG "rrr $r_remote_recno: rro $r_remote_offset: rlr $r_local_recno: rlo \
$r_local_offset\n";

Index: Server.pm
===================================================================
RCS file: /cvsroot/intermezzo/intermezzo/lento/Lento/Server.pm,v
retrieving revision 1.83
retrieving revision 1.84
diff -U2 -r1.83 -r1.84
--- Server.pm	2001/10/04 16:21:45	1.83
+++ Server.pm	2001/10/16 17:11:08	1.84
@@ -176,5 +176,6 @@
                         ($_[SESSION]); 
                 $server->{connection_obj}->sendpacket
-                        ('REQ', ['SysId', $::mysysid]);
+                        ('REQ', ['SysId', $::mysysid, $::PROTOCOL_VERSION,
+                                 $::myuuid]);
             }
        },
@@ -183,4 +184,14 @@
             my $packet = $_[ARG0];
             my $result = shift @{$packet->[PKT_PARMS]};
+            my $remote_uuid = shift @{$packet->[PKT_PARMS]};
+
+            # Tell the replicators the remote UUID
+            $server->{replist}->iterate
+              (
+               sub {
+                   my $replicator = shift;
+                   my $uuid = shift;
+                   $replicator->init($uuid);
+               }, $remote_uuid);
 
             $server->{connection_obj}->remove_from_monitor_list($_[SESSION]); 


_______________________________________________
intermezzo-commit mailing list
intermezzo-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/intermezzo-commit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic