view release on metacpan or search on metacpan
lib/AC/Yenta/Client.pm view on Meta::CPAN
# one or more of:
# new( host, port )
# new( servers => [ { host, port }, ... ] )
# new( server_file )
sub new {
my $class = shift;
my $me = bless {
debug => sub{ },
host => 'localhost',
proto => AC::DC::Protocol->new(),
copies => 1,
@_,
}, $class;
$me->{server_file} ||= $me->{altfile}; # compat
die "servers or server_file?\n" unless $me->{servers} || $me->{server_file};
lib/AC/Yenta/Crypto.pm view on Meta::CPAN
use strict;
require 'AC/protobuf/auth.pl';
my $ALGORITHM = 'x-acy-aes-1';
sub new {
my $class = shift;
my $secret = shift;
return bless {
secret => $secret,
}, $class;
}
sub encrypt {
my $me = shift;
my $buf = shift;
my $seqno = int( time() * 1_000_000 );
my $nonce = random_text(48);
lib/AC/Yenta/D.pm view on Meta::CPAN
use strict;
sub new {
my $class = shift;
my %p = @_;
AC::Yenta::MySelf->customize( $p{class_myself} );
# ...
return bless \$class, $class;
}
sub daemon {
my $me = shift;
my $cfile = shift;
my $opt = shift; # foreground, debugall, persistent_id, argv
die "no config file specified\n" unless $cfile;
# configure
lib/AC/Yenta/Direct.pm view on Meta::CPAN
sub new {
my $class = shift;
my $map = shift;
my $file = shift;
my $db = AC::Yenta::Store::Map->new( $map, undef, { dbfile => $file, readonly => 1 } );
return unless $db;
return bless { db => $db }, $class;
}
sub get {
my $me = shift;
my $key = shift;
my $db = $me->{db};
return $db->get($key);
}
lib/AC/Yenta/Status.pm view on Meta::CPAN
use Socket;
require 'AC/protobuf/yenta_status.pl';
use strict;
my $KEEPDOWN = 1800; # keep data about down servers for how long?
my $KEEPLOST = 600; # keep data about servers we have not heard about for how long?
my $SAVEMAX = 1800; # do not save if older than
my $PORT;
our $DATA = bless {
allpeer => {}, # yenta_status
sceptical => {},
mappeer => {}, # {map} => { id => id }
peermap => {}, # {id} => @map
datacenter => {}, # {dc} => { id => id }
peertype => {}, # {ss} => { id => id }
};
sub init {
my $port = shift;
lib/AC/Yenta/Store/AE.pm view on Meta::CPAN
AC::DC::Sched->new(
info => 'anti-entropy',
freq => 60,
func => \&AC::Yenta::Store::AE::periodic,
);
sub new {
my $class = shift;
my $me = bless {
badnode => [ {version => 0, shard => 0, level => 0} ],
cache => {},
kvneed => [],
kvneedorig => [],
kvfetching => 0,
missing => 0,
}, $class;
debug("new ae");
$me->_pick_map() || return;
lib/AC/Yenta/Store/BDBI.pm view on Meta::CPAN
-Filename => $file,
-Env => $env,
-Flags => DB_CREATE,
);
problem("cannot open db file $file") unless $db;
# web server will need access
chmod 0666, $file;
return bless {
dir => $dir,
file => $file,
db => $db,
hasenv => ($env ? 1 : 0),
}, $class;
}
sub get {
my $me = shift;
my $map = shift;
lib/AC/Yenta/Store/Distrib.pm view on Meta::CPAN
my $class = shift;
my $req = shift;
my $cont = shift;
return if $req->{hop} >= $MAXHOP;
return if $req->{expire} < $^T;
my $sender = $req->{sender};
my $sendat = AC::Yenta::Status->peer($sender);
my $me = bless {
info => "$req->{datum}{map}/$req->{datum}{key}/$req->{datum}{version}",
map => $req->{datum}{map},
req => $req,
content => $cont,
# we tune the distribution algorithm based on where it came from:
faraway => (my_datacenter() ne $sendat->{datacenter}),
farseen => 0,
nearseen => 0,
farsend => [],
lib/AC/Yenta/Store/File.pm view on Meta::CPAN
use AC::Yenta::Debug 'store_file';
use File::Path;
use strict;
sub new {
my $class = shift;
my $name = shift;
my $conf = shift;
return bless {
name => $name,
conf => $conf,
}, $class;
}
sub get {
my $me = shift;
my $name = shift;
my $cf = $me->{conf};
lib/AC/Yenta/Store/LevelDB.pm view on Meta::CPAN
debug("opening LevelDB file=$file");
my $db = $OPEN{$file} || Tie::LevelDB::DB->new( $file );
$OPEN{$file} = $db;
problem("cannot open db file $file") unless $db;
# web server will need access
chmod 0777, $file;
return bless {
file => $file,
db => $db,
}, $class;
}
sub get {
my $me = shift;
my $map = shift;
my $sub = shift;
my $key = shift;
lib/AC/Yenta/Store/Map.pm view on Meta::CPAN
unless( $c ){
problem("invalid storage backend: $bkend - ignoring map");
return ;
}
debug("configuring map $name with $c");
my $db = $c->new( $name, $conf );
my $fs = AC::Yenta::Store::File->new( $name, $conf );
my $me = bless {
name => $name,
conf => $conf,
db => $db,
fs => $fs,
merkle_height => 16,
vers_cache => AC::Cache->new( $CACHESIZE ),
}, $class;
$me->merkle_init();
lib/AC/Yenta/Store/SQLite.pm view on Meta::CPAN
my $db = DBI->connect( $dsn, '', '', {
AutoCommit => 1,
RaiseError => 1,
} );
problem("cannot open sqlite file $file") unless $db;
_init( $db );
return bless {
file => $file,
db => $db,
}, $class;
}
sub get {
my $me = shift;
my $map = shift;
my $sub = shift;
my $key = shift;
lib/AC/Yenta/Store/Tokyo.pm view on Meta::CPAN
my $flags = $conf->{readonly} ? ($db->OREADER | $db->ONOLCK) : ($db->OWRITER | $db->OCREAT);
if(!$db->open($file, $flags)){
#my $ecode = $db->ecode();
#printf STDERR ("open error: %s\n", $db->errmsg($ecode));
problem("cannot open db file $file");
}
# web server will need access
chmod 0666, $file;
return bless {
file => $file,
db => $db,
}, $class;
}
sub get {
my $me = shift;
my $map = shift;
my $sub = shift;
my $key = shift;