[Bps-public-commit] r12447 - in Prophet/trunk: .

jesse at bestpractical.com jesse at bestpractical.com
Sat May 17 05:32:32 EDT 2008


Author: jesse
Date: Sat May 17 05:32:29 2008
New Revision: 12447

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/Replica.pm

Log:
 r31112 at dhcp113 (orig r12381):  sartak | 2008-05-16 20:32:41 +0900
  r55976 at onn:  sartak | 2008-05-16 07:32:22 -0400
  Implement luid mapping using the external metadata directory
 


Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica.pm	Sat May 17 05:32:29 2008
@@ -576,12 +576,28 @@
     return ++$map->{'_maximum_luid'};
 }
 
+sub _guid2luid_file { "local-id-cache" }
+
 sub _read_guid2luid_mappings {
-    Carp::confess "Someone has failed to implement a '_read_guid2luid_mappings' method for their replica type.";
+    my $self = shift;
+    my $json = $self->read_metadata_file(path => $self->_guid2luid_file)
+            || '{}';
+
+    require JSON;
+    return JSON::from_json($json, { utf8 => 1 });
 }
 
 sub _write_guid2luid_mappings {
-    Carp::confess "Someone has failed to implement a '_write_guid2luid_mappings' method for their replica type.";
+    my $self = shift;
+    my $map  = shift;
+
+    require JSON;
+    my $content = JSON::to_json($map, { canonical => 1, pretty => 0, utf8 => 1 });
+
+    $self->write_metadata_file(
+        path    => $self->_guid2luid_file,
+        content => $content,
+    );
 }
 
 sub _read_luid2guid_mappings {



More information about the Bps-public-commit mailing list