[Bps-public-commit] r12381 - in Prophet/branches/luid: lib/Prophet

sartak at bestpractical.com sartak at bestpractical.com
Fri May 16 07:32:43 EDT 2008


Author: sartak
Date: Fri May 16 07:32:41 2008
New Revision: 12381

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

Log:
 r55976 at onn:  sartak | 2008-05-16 07:32:22 -0400
 Implement luid mapping using the external metadata directory


Modified: Prophet/branches/luid/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/branches/luid/lib/Prophet/Replica.pm	(original)
+++ Prophet/branches/luid/lib/Prophet/Replica.pm	Fri May 16 07:32:41 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