[Bps-public-commit] Prophet branch, master, updated. aef857c4ccf701a1dbda0034414ac82c837adc6b

jesse jesse at bestpractical.com
Wed Apr 15 23:42:36 EDT 2009


The branch, master has been updated
       via  aef857c4ccf701a1dbda0034414ac82c837adc6b (commit)
      from  e8153cd1e567df6a4b42207b1c0459cc90388daa (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Mirror.pm    |    5 +--
 lib/Prophet/Replica/prophet_cache.pm |   49 ++++++++++++++++++++++++++++-----
 2 files changed, 43 insertions(+), 11 deletions(-)

- Log -----------------------------------------------------------------
commit aef857c4ccf701a1dbda0034414ac82c837adc6b
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Apr 16 11:42:05 2009 +0800

    relocated the resdb mirror into the resdb

diff --git a/lib/Prophet/CLI/Command/Mirror.pm b/lib/Prophet/CLI/Command/Mirror.pm
index 27cffad..976550f 100644
--- a/lib/Prophet/CLI/Command/Mirror.pm
+++ b/lib/Prophet/CLI/Command/Mirror.pm
@@ -16,8 +16,6 @@ sub run {
 
     $self->validate_args();
 
-    $self->set_arg(
-        'to' => 'prophet_cache:' . $self->app_handle->handle->url . '/remote-replica-cache/' );
 
     my $source = Prophet::Replica->get_handle(
         url        => $self->arg('from'),
@@ -28,11 +26,12 @@ sub run {
         exit 1;
     }
 
+    $self->set_arg( 'to' => 'prophet_cache:' . $source->uuid);
     my $target
         = Prophet::Replica->get_handle( url => $self->arg('to'), app_handle => $self->app_handle );
 
     $target->uuid( $source->uuid );
-    $target->resolution_db_handle->uuid( $source->resolution_db_handle->uuid );
+    $target->resdb_replica_uuid( $source->resolution_db_handle->uuid );
 
     if ( !$target->replica_exists && !$target->can_initialize ) {
         die "The target replica path you specified can't be created.\n";
diff --git a/lib/Prophet/Replica/prophet_cache.pm b/lib/Prophet/Replica/prophet_cache.pm
index c9c09bc..d54b104 100644
--- a/lib/Prophet/Replica/prophet_cache.pm
+++ b/lib/Prophet/Replica/prophet_cache.pm
@@ -25,7 +25,7 @@ has fs_root_parent => (
     lazy    => 1,
     default => sub {
         my $self = shift;
-        return $self->app_handle->handle->url =~ m{^file://(.*)/.*?$} ? $1 : undef;
+        return $self->fs_root =~ m{^(.*)/.+/?$} ? $1 : undef;
     },
 );
 
@@ -42,6 +42,16 @@ has changeset_cas => (
     },
 );
 
+has  resdb_replica_uuid  => (
+    is => 'rw',
+    lazy => 1,
+    isa => 'Str',
+    default => sub {
+            my $self = shift;
+           return  $self->_read_file( $self->resolution_db_replica_uuid_file );
+        }
+  );
+            
 has '+resolution_db_handle' => (
     isa     => 'Prophet::Replica | Undef',
     lazy    => 1,
@@ -50,10 +60,10 @@ has '+resolution_db_handle' => (
         return if $self->is_resdb ;
         my $suffix = 'remote_replica_cache';
         return Prophet::Replica->get_handle(
-            {   url        => 'prophet_cache:'.$self->app_handle->handle->resolution_db_handle->url . "/".$suffix,
+            {   url        => 'prophet_cache:'.$self->resdb_replica_uuid,
                 fs_root    => File::Spec->catdir($self->app_handle->handle->resolution_db_handle->fs_root =>  $suffix),
-                fs_root_parent    => File::Spec->catdir($self->app_handle->handle->resolution_db_handle->fs_root_parent => $suffix),
                 app_handle => $self->app_handle,
+                db_uuid => $self->app_handle->handle->resolution_db_handle->db_uuid,
                 is_resdb   => 1,
             }
         );
@@ -85,6 +95,15 @@ has changeset_index => (
     }
 
 );    
+has resolution_db_replica_uuid_file => (
+    is => 'rw',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+        File::Spec->catdir($self->replica_dir , $self->uuid, 'resolution_replica');
+    }
+
+);    
 
 use constant can_read_records    => 0;
 use constant can_read_changesets => 1;
@@ -94,11 +113,15 @@ use constant can_write_records    => 0;
 sub BUILD {
     my $self = shift;
     my $args = shift;
-    if ($self->url =~ m|^prophet_cache:file://(.*)/([AF09\-]+)/?$|i) {
-        my $root = $1;
-        my $uuid = $2;
-        $self->fs_root(File::Spec->catdir($root => 'remote-replica-cache' ));
+    warn "we're building";
+    if ($self->url =~ /^prophet_cache:(.*)$/i) {
+        my $uuid = $1;
         $self->uuid($uuid);
+        if ($self->is_resdb) {
+            $self->fs_root(File::Spec->catdir($self->app_handle->handle->resolution_db_handle->fs_root => 'remote-replica-cache' ));
+        } else {
+            $self->fs_root(File::Spec->catdir($self->app_handle->handle->fs_root => 'remote-replica-cache' ));
+        }
     }
 }
 
@@ -141,17 +164,27 @@ sub initialize {
     }
 
     $self->set_db_uuid( $self->app_handle->handle->db_uuid);
+    $self->set_resdb_replica_uuid($args{resdb_replica_uuid}) unless ($self->is_resdb);
     $self->resolution_db_handle->initialize(db_uuid => $args{resdb_uuid}, replica_uuid => $args{resdb_replica_uuid})  unless ($self->is_resdb);
     $self->after_initialize->($self);
 }
 
 
+sub set_resdb_replica_uuid {
+    my $self = shift;
+    my $id   = shift;
+    $self->_write_file(
+        path    => $self->resolution_db_replica_uuid_file ,
+        content => scalar($id)
+    );
+}
+
+
 sub replica_exists {
     my $self = shift;
     if (-e File::Spec->catdir($self->fs_root, $self->changeset_index)) { 
             return 1;
     } else {
-        warn File::Spec->catdir($self->fs_root, $self->changeset_index) ." does not exist";
         return undef;
     }
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list