AC-Yenta
view release on metacpan or search on metacpan
lib/AC/Yenta.pm view on Meta::CPAN
New nodes can be added or removed on the fly with no configuration.
=head2 Kibitzing
Each yenta kibitzes (gossips) with the other yentas in the network
to exchange status information, distribute key-value data, and
detect and correct inconsistent data.
=head2 Eventual Consistency
Key-value data is versioned with timestamps. By default, newest wins.
Maps can be configured to keep and return multiple versions and client
code can use other conflict resolution mechanisms.
Lost, missing or otherwise inconsistent data is detected
by kibitzing merkle tree hash values.
=head2 Topological awareness
Yentas can take network topology into account when tranferring
data around to minimize long-distance transfers. You will need to
lib/AC/Yenta.pm view on Meta::CPAN
Yentas can take advantage of multiple network interfaces with
different IP addresses (eg. a private internal network + a public network),
or multiple addresses (eg. a private addresses and a public address)
and various NAT configurations.
You will need to write a custom C<MySelf> class and C<my_network_info>
function.
=head2 Network Information
By default, yentas obtain their primary IP address by calling
C<gethostbyname( hostname() )>. If this either does not work on your
systems, or isn't the value you want to use,
you will need to write a custom C<MySelf> class and C<my_network_info>
function.
=head1 CONFIG FILE
various parameters need to be specified in a config file.
lib/AC/Yenta/Customize.pm view on Meta::CPAN
#
# $Id$
package AC::Yenta::Customize;
use strict;
sub customize {
my $class = shift;
my $implby = shift;
(my $default = $class) =~ s/(.*)::([^:]+)$/$1::Default::$2/;
# load user's implemantation + default
for my $p ($implby, $default){
eval "require $p" if $p;
die $@ if $@;
}
# import/export
no strict;
no warnings;
for my $f ( @{$class . '::CUSTOM'} ){
*{$class . '::' . $f} = ($implby && $implby->can($f)) || $default->can($f);
}
}
1;
lib/AC/Yenta/Default/MySelf.pm view on Meta::CPAN
# -*- perl -*-
# Copyright (c) 2010 AdCopy
# Author: Jeff Weisberg
# Created: 2010-Jan-18 18:10 (EST)
# Function: info about myself - default implementation
#
# $Id$
package AC::Yenta::Default::MySelf;
use AC::Yenta::Config;
use AC::Yenta::Debug;
use Sys::Hostname;
use Socket;
use strict;
lib/AC/Yenta/Default/MySelf.pm view on Meta::CPAN
sub my_server_id {
return $SERVERID;
}
sub my_network_info {
return [ { ipa => $MYIP } ];
}
sub my_datacenter {
return 'default';
}
1;
lib/AC/Yenta/MySelf.pm view on Meta::CPAN
emacs /myperldir/Local/Yenta/MySelf.pm
copy. paste. edit.
use lib '/myperldir';
my $y = AC::Yenta::D->new(
class_myself => 'Local::Yenta::MySelf',
);
=head1 DESCRIPTION
provide functions to override default behavior. you may define
any or all of the following functions.
=head2 my_server_id
return a unique identity for this yenta instance. typically,
something similar to the server hostname.
sub my_server_id {
return 'yenta@' . hostname();
}
lib/AC/Yenta/Store/Map.pm view on Meta::CPAN
$BACKEND{$name} = $impl;
}
sub new {
my $class = shift;
my $name = shift;
my $bkend = shift;
my $conf = shift;
unless( $bkend ){
# from extension, or default
my($ext) = $conf->{dbfile} =~ /\.(.+)$/;
$bkend = $ext if $BACKEND{$ext};
}
my $c = $BACKEND{$bkend || $DEFAULT};
unless( $c ){
problem("invalid storage backend: $bkend - ignoring map");
return ;
}
lib/AC/Yenta/Store/SQLite.pm view on Meta::CPAN
map text not null,
sub text not null,
key text not null,
value text,
unique(map,sub,key)
);
create index if not exists ykvidx on ykv(map, sub, key);
pragma synchronous = 1; -- default is full(2)
pragma cache_size = 100000; -- default is 2000
vacuum;
analyze;
END
;
1;
( run in 0.268 second using v1.01-cache-2.11-cpan-0a6323c29d9 )