initial import : implementes replication and soap service
This commit is contained in:
parent
16af0c7709
commit
24d75a9acb
|
@ -0,0 +1,18 @@
|
|||
Revision history for Perl extension Apache::Session::Memorycached.
|
||||
|
||||
1.0 Sun Oct 3 15:05:46 2004
|
||||
- original version; created by h2xs 1.22 with options
|
||||
-XAn Apache::Session::Memorycached
|
||||
|
||||
1.1 Oct 8 2004
|
||||
- Add 'timeout' session parameter
|
||||
|
||||
2.0.0 May 04 2006
|
||||
- optimize persistant connection
|
||||
- add memd.pl in scripts directory
|
||||
|
||||
2.1.0 Nov 17 2006
|
||||
- add reverse reference on principal identity
|
||||
2.2.0 Feb 09 2007
|
||||
- add two replication daemons
|
||||
- add SOAP service
|
|
@ -0,0 +1,22 @@
|
|||
Changes
|
||||
lib/Apache/Session/Lock/Memorycached.pm
|
||||
lib/Apache/Session/Memorycached.pm
|
||||
lib/Apache/Session/MemcachedClient.pm
|
||||
lib/Apache/Session/MemcachedReplicator.pm
|
||||
lib/Apache/Session/Store/Memorycached.pm
|
||||
Makefile.PL
|
||||
MANIFEST This list of files
|
||||
META.yml
|
||||
README
|
||||
scripts/memd.pl
|
||||
scripts/client_memcached.pl
|
||||
scripts/slurp_memcached.pl
|
||||
scripts/MemcachedSOAPClass.pm
|
||||
scripts/MemcachedSOAP.cgi
|
||||
scripts/statTest.pl
|
||||
scripts/getTest.pl
|
||||
scripts/setTest.pl
|
||||
|
||||
|
||||
t/1.t
|
||||
t/test-apache-session.t
|
|
@ -0,0 +1,12 @@
|
|||
# http://module-build.sourceforge.net/META-spec.html
|
||||
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
|
||||
name: Apache-Session-Memorycached
|
||||
version: 2.2.0
|
||||
version_from: lib/Apache/Session/Memorycached.pm
|
||||
installdirs: site
|
||||
requires:
|
||||
Apache::Session: 0.0
|
||||
Cache::Memcached: 1.0.12
|
||||
|
||||
distribution_type: module
|
||||
generated_by: ExtUtils::MakeMaker version 6.17
|
|
@ -0,0 +1,12 @@
|
|||
use ExtUtils::MakeMaker;
|
||||
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
|
||||
# the contents of the Makefile that is written.
|
||||
WriteMakefile(
|
||||
NAME => 'Apache::Session::Memorycached',
|
||||
VERSION_FROM => 'lib/Apache/Session/Memorycached.pm', # finds $VERSION
|
||||
PREREQ_PM => {Apache::Session=> '0.0',
|
||||
Cache::Memcached=> '1.0.12',
|
||||
}, # e.g., Module::Name => 1.1
|
||||
($] >= 5.005 ? ## Add these new keywords supported since 5.005
|
||||
(AUTHOR => 'Eric German <germanlinux@yahoo.fr>') : ()),
|
||||
);
|
|
@ -0,0 +1,75 @@
|
|||
NAME
|
||||
Apache::Session::Memorycached - An implementation of Apache::Session
|
||||
|
||||
SYNOPSIS
|
||||
use Apache::Session::Memorycached;
|
||||
|
||||
tie %session, 'Apache::Session::Memorycached', $cookie, {
|
||||
'servers' => ["10.75.1.19:11211"], #all write operations
|
||||
'local' => ["localhost:11211"], #read-only operations
|
||||
'timeout' => '300'
|
||||
};
|
||||
|
||||
tie %s, 'Apache::Session::Memorycached', undef,
|
||||
{servers => ['mymemcachedserver:port'],
|
||||
'timeout' => '300',
|
||||
'updateOnly' => 1 ,
|
||||
'principal' => uid,
|
||||
};
|
||||
|
||||
In order to optimize the network ,you can use a local memcached server.
|
||||
All read-only opération are sending fisrt at local server .If you need
|
||||
write ou rewrite data , the data is sending at the principal memcached
|
||||
sever and local cache too for synchronisation.
|
||||
|
||||
note : 'updateOnly' => 1 just realize up-date operation not init
|
||||
operation. Init operation is use in order to book and lock the number
|
||||
session but it's not available in this module
|
||||
|
||||
'principal' => uid : this parameter is use to create reverse reference
|
||||
like this : MD5_hex(uid) => id_session in memcached server . By this it usefull to retrieve id_session from principal name . And add uid_MD5 => MD5_hex(uid) in main session .
|
||||
|
||||
DESCRIPTION
|
||||
This module is an implementation of Apache::Session. It uses the
|
||||
memcached system backing store . You may specify servers (principal) and
|
||||
locals caches for locking in arguments to the constructor. See the
|
||||
example, and the documentation for Apache::Session::Store::Memorycached
|
||||
and Cache::Memcached .
|
||||
|
||||
REPLICATION
|
||||
Now Apache::Session::Memorycahed inclues replication between memecached servers
|
||||
Two new components provide a replication service .
|
||||
First package is Apache::Session::MemcachedReplicator
|
||||
Second is Apache::Session::MemcachedClient
|
||||
|
||||
It's now possible to do replication master to slave or master to master
|
||||
see man pages and scripts .
|
||||
|
||||
SOAP service
|
||||
Now Apache::Session::Memorycached inclues a SOAP service in order to set or
|
||||
get %session in any language . The SOAP service translates data in Perl hashes
|
||||
|
||||
Installation of SOAP service
|
||||
All scripts are in scripts directory
|
||||
|
||||
Put MemcachedSOAPClass.pm and MemcachedSOAP.cgi in the cgi-bin directory of your apache server with the appropriate right (x) .
|
||||
Change in MemcachedSOAP.cgi the memcached server address .
|
||||
(line 11 : $machine = 'ip.ip.ip.ip:11211'; )
|
||||
|
||||
Try the three scripts statTest.pl (first !) then getTest.pl finish with setTest.pl.
|
||||
|
||||
The lemonldap project (SSO under GPL) uses this module
|
||||
|
||||
AUTHOR
|
||||
This module was written by eric german <germanlinux@yahoo.fr>.
|
||||
|
||||
Completed by Habib ZITOUNI <zitouni.habib@gmail.com> and
|
||||
Hamza AISSAT<asthamza@hotmail.fr>
|
||||
|
||||
SOAP service is a contribution of Casimir ANTUNES .
|
||||
|
||||
SEE ALSO
|
||||
Apache::Session::DB_File, Apache::Session::Flex,
|
||||
Apache::Session::MemcachedClient,Apache::Session::MemcachedReplicator,
|
||||
Apache::Session::MySQL, Apache::Session::Postgres, Apache::Session
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
############################################################################
|
||||
#
|
||||
# Apache::Session::Lock::Memorycached
|
||||
# Copyright(c) eric german <germanlinux@yahoo.fr>
|
||||
# Distribute under the Artistic License
|
||||
#
|
||||
############################################################################
|
||||
|
||||
package Apache::Session::Lock::Memorycached;
|
||||
|
||||
use strict;
|
||||
|
||||
use vars qw($VERSION);
|
||||
|
||||
$VERSION = '1.0';
|
||||
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
||||
return bless { read => 0, write => 0, opened => 0, id => 0 }, $class;
|
||||
}
|
||||
|
||||
sub acquire_read_lock {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
return if $self->{read};
|
||||
|
||||
if (!$self->{opened}) {
|
||||
$self->{opened} = 1;
|
||||
}
|
||||
$self->{read} = 1;
|
||||
}
|
||||
|
||||
sub acquire_write_lock {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
return if $self->{write};
|
||||
|
||||
if (!$self->{opened}) {
|
||||
$self->{opened} = 1;
|
||||
}
|
||||
$self->{write} = 1;
|
||||
}
|
||||
|
||||
sub release_read_lock {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
die unless $self->{read};
|
||||
|
||||
if (!$self->{write}) {
|
||||
$self->{opened} = 0;
|
||||
}
|
||||
|
||||
$self->{read} = 0;
|
||||
}
|
||||
|
||||
sub release_write_lock {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
die unless $self->{write};
|
||||
|
||||
if ($self->{read}) {
|
||||
}
|
||||
else {
|
||||
$self->{opened} = 0;
|
||||
}
|
||||
|
||||
$self->{write} = 0;
|
||||
}
|
||||
|
||||
sub release_all_locks {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
if ($self->{opened}) {
|
||||
}
|
||||
|
||||
$self->{opened} = 0;
|
||||
$self->{read} = 0;
|
||||
$self->{write} = 0;
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
|
||||
$self->release_all_locks;
|
||||
}
|
||||
|
||||
sub clean {
|
||||
my $self = shift;
|
||||
my $dir = shift;
|
||||
my $time = shift;
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Apache::Session::Lock::File - Provides mutual exclusion using flock
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Apache::Session::Lock::File;
|
||||
|
||||
my $locker = new Apache::Session::Lock::File;
|
||||
|
||||
$locker->acquire_read_lock($ref);
|
||||
$locker->acquire_write_lock($ref);
|
||||
$locker->release_read_lock($ref);
|
||||
$locker->release_write_lock($ref);
|
||||
$locker->release_all_locks($ref);
|
||||
|
||||
$locker->clean($dir, $age);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Apache::Session::Lock::Memorycached fulfills the locking interface of
|
||||
Apache::Session. NO locking is using .
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
|
||||
none
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by eric german <germanlinux@yahoo.fr>
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<Apache::Session>
|
|
@ -0,0 +1,178 @@
|
|||
package Apache::Session::MemcachedClient;
|
||||
use Apache::Session::Memorycached;
|
||||
use Fcntl qw(:DEFAULT :flock);
|
||||
$| = 1;
|
||||
our $VERSION = '2.1.1';
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my %args = @_;
|
||||
my $self;
|
||||
$self = \%args;
|
||||
bless $self, $class;
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
||||
my $self = shift;
|
||||
my $file_input = $self->{in_file};
|
||||
my $file_output = $self->{out_file};
|
||||
my $naptime = $self->{naptime} || '1';
|
||||
my $safetime = $self->{safetime} || '900'; # 15 minutes
|
||||
|
||||
for ( ; ; ) {
|
||||
sysopen( FH, $file_input, O_RDWR | O_CREAT ) || die "$file_input $!\n";
|
||||
flock( FH, LOCK_EX );
|
||||
my @ligne = <FH>;
|
||||
seek( FH, 0, 0 );
|
||||
truncate( FH, 0 );
|
||||
close(FH);
|
||||
my @log;
|
||||
for (@ligne) {
|
||||
( my $session, my $time ) = /^(\w+)\s(\d+)/;
|
||||
### retrieve session
|
||||
my $param = $self->{localmemcached};
|
||||
my $sign = $self->{signature} || 'master';
|
||||
|
||||
my %localsession;
|
||||
my %remotesession;
|
||||
tie %localsession, 'Apache::Session::Memorycached', $session,
|
||||
$param;
|
||||
if ( !%localsession ) {
|
||||
|
||||
### error in retrieve session
|
||||
untie %localsession;
|
||||
push @log, "FATAL :$session FAILED \n";
|
||||
next;
|
||||
|
||||
}
|
||||
my %_localsession = %localsession;
|
||||
untie %localsession;
|
||||
|
||||
#######################################
|
||||
## avoid loop in master2master case ##
|
||||
#######################################
|
||||
if ( $_localsession{$sign} ) {
|
||||
### pehap already replicated
|
||||
# exept in this case
|
||||
my $time_origine = $_localsession{$sign};
|
||||
$time_origine =~ s/#.+$//;
|
||||
if ( ( time - $time_origine ) < $safetime ) {
|
||||
push @log, "INFO :$session SYN OK\n";
|
||||
next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$_localsession{$sign} = time . "#" . $time;
|
||||
|
||||
#### and send this to the other server
|
||||
my $paramdist = $self->{remotememcached};
|
||||
|
||||
##### ne marche pas $session exist ########
|
||||
my %remotesession;
|
||||
tie %remotesession, 'Apache::Session::Memorycached', $session,
|
||||
$paramdist;
|
||||
|
||||
if (%remotesession) {
|
||||
### error in retrieve remote session
|
||||
my $time_origine = $remotesession{$sign};
|
||||
$time_origine =~ s/#.+$//;
|
||||
next if ( ( time - $time_origine ) < $safetime );
|
||||
}
|
||||
|
||||
%remotesession = %_localsession;
|
||||
untie %remotesession;
|
||||
|
||||
push @log, "INFO :$session REPLICATED\n";
|
||||
|
||||
if ( $self->{safety_mode} ) {
|
||||
my %remotesession;
|
||||
### we retrieve session from the other memcached server
|
||||
my $paramdist = $self->{remotememcached};
|
||||
tie %remotesession, 'Apache::Session::Memorycached', $session,
|
||||
$paramdist;
|
||||
|
||||
my %_remotesession = %remotesession;
|
||||
untie %remotesession;
|
||||
|
||||
if ( $_remotesession{$sign} ) {
|
||||
push @log, "INFO :$session VERIFIED\n";
|
||||
}
|
||||
else {
|
||||
push @log, "FATAL :$session REPLICATION ERROR\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sysopen( FS, $file_output, O_WRONLY | O_APPEND | O_CREAT )
|
||||
|| die "$file_output $!\n";
|
||||
flock( FS, LOCK_EX );
|
||||
for (@log) {
|
||||
print FS $_;
|
||||
}
|
||||
close(FS);
|
||||
sleep $naptime;
|
||||
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Apache::Session::MemcachedClient - A component of memcached's replication
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Apache::Session::MemcachedClient ;
|
||||
my $rep = MemcachedClient->new(in_file =>"/tmp/logmem1",
|
||||
out_file =>"/tmp/log1",
|
||||
naptime => 2 ,
|
||||
localmemcached => {'servers' => ['localhost:11211'], },
|
||||
remotememcached =>{'servers' => ['localhost:11311'], },
|
||||
signature => 'master11211',
|
||||
safety_mode =>'actived' ,
|
||||
);
|
||||
$rep->run ;
|
||||
exit;
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module is an implementation of replication for memcached backend session storage . It replicates session created by Apache::Session::Memorycached between master to slave OR master to master.
|
||||
|
||||
In input , it reads a file issued from Apache::Session::MemcachedReplicator then it sends session on the other memcached server .
|
||||
|
||||
|
||||
The lemonldap project (SSO under GPL) uses this module
|
||||
|
||||
=head1 Options
|
||||
|
||||
- in_file : input file .
|
||||
- out_file : log in output file
|
||||
- naptime : time between 2 cycles (in second)
|
||||
- localmemcached : you local server
|
||||
- remotememcached : you remote server (pehap the slave)
|
||||
- signature : string used in order to avoid loops replication
|
||||
- safety_mode : thrue : read on remote server after write in order to be sure of success of replication
|
||||
|
||||
see client_memcached.pl in script directory.
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by eric german <germanlinux@yahoo.fr>.
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
|
||||
L<Apache::Session::MemcachedReplicator>,
|
||||
L<Apache::Session::Memorycached>,
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package Apache::Session::MemcachedReplicator;
|
||||
use Fcntl qw(:DEFAULT :flock) ;
|
||||
our $VERSION = '2.1.1';
|
||||
$| =1;
|
||||
|
||||
sub new {
|
||||
my $class =shift;
|
||||
my %args = @_;
|
||||
my $self;
|
||||
$self=\%args;;
|
||||
bless $self,$class;
|
||||
|
||||
}
|
||||
|
||||
sub run {
|
||||
my $self =shift;
|
||||
my $file_input = $self->{in_file} ;
|
||||
my $file_output = $self->{out_file} ;
|
||||
my $naptime= $self->{naptime}||'1';
|
||||
|
||||
|
||||
for(;;) {
|
||||
sysopen (FH,$file_input, O_RDWR|O_CREAT) ||die "$file_input $!\n";
|
||||
flock (FH,LOCK_EX);
|
||||
my @ligne = <FH> ;
|
||||
seek (FH,0,0);
|
||||
truncate (FH,0);
|
||||
close(FH) ;
|
||||
my %un_id;
|
||||
for (@ligne) {
|
||||
if (/\sset\s/ ) {
|
||||
( my $session) = /set\s(\w+)\s/ ;
|
||||
$un_id{$session} = time ;
|
||||
}
|
||||
}
|
||||
sysopen (FS,$file_output, O_WRONLY|O_APPEND|O_CREAT)||die "$file_output $!\n";
|
||||
flock (FS,LOCK_EX);
|
||||
for (keys %un_id) {
|
||||
print FS "$_ $un_id{$_}\n";
|
||||
}
|
||||
close (FS) ;
|
||||
sleep $naptime;
|
||||
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Apache::Session::MemcachedReplicator - A component of memcached's replication
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Apache::Session::MemcachedReplicator ;
|
||||
my $rep = MemcachedReplicator->new(in_file =>"/tmp/memcachedlog",
|
||||
out_file =>"/tmp/logmem",
|
||||
naptime => 2 ,
|
||||
);
|
||||
$rep->run ;
|
||||
exit;
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module reads log's memcached server and write one line by 'set' command .
|
||||
In order to force memcached to be verbose you must laugth it like this:
|
||||
memcached -u root -p 11211 -vv 2> /tmp/logmem1 &
|
||||
|
||||
The memcached log file must to be in input of MemcachedClient .
|
||||
|
||||
|
||||
The lemonldap project (SSO under GPL) uses this module.
|
||||
|
||||
=head1 Options
|
||||
|
||||
- in_file : input file .
|
||||
- out_file : write in output file
|
||||
- naptime : time between 2 cycles (in second)
|
||||
|
||||
|
||||
see slurp_memcached.pl in script directory.
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by eric german <germanlinux@yahoo.fr>.
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
|
||||
L<Apache::Session::MemcachedClient>,
|
||||
L<Apache::Session::Memorycached>,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
#############################################################################
|
||||
#
|
||||
# Apache::Session::Memorycached
|
||||
# Apache persistent user sessions on the network with memcached
|
||||
# Copyright(c) eric german <germanlinux@yahoo.fr>
|
||||
# Distribute under the Artistic License
|
||||
#
|
||||
############################################################################
|
||||
|
||||
package Apache::Session::Memorycached;
|
||||
|
||||
use strict;
|
||||
use vars qw(@ISA $VERSION);
|
||||
|
||||
$VERSION = '2.2.0';
|
||||
@ISA = qw(Apache::Session);
|
||||
|
||||
use Apache::Session;
|
||||
use Apache::Session::Generate::MD5;
|
||||
use Apache::Session::Lock::Memorycached;
|
||||
use Apache::Session::Store::Memorycached;
|
||||
|
||||
sub populate {
|
||||
my $self = shift;
|
||||
|
||||
$self->{object_store} = new Apache::Session::Store::Memorycached $self;
|
||||
$self->{lock_manager} = new Apache::Session::Lock::Memorycached $self;
|
||||
$self->{generate} = \&Apache::Session::Generate::MD5::generate;
|
||||
$self->{validate} = \&Apache::Session::Generate::MD5::validate;
|
||||
$self->{serialize} = \&Apache::Session::Memorycached::none;
|
||||
$self->{unserialize} = \&Apache::Session::Memorycached::none;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub none {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
return;
|
||||
}
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
|
||||
$self->save;
|
||||
$self->{object_store}->close;
|
||||
$self->release_all_locks;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Apache::Session::Memorycached - An implementation of Apache::Session
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Apache::Session::Memorycached;
|
||||
|
||||
tie %session, 'Apache::Session::Memorycached', $cookie, {
|
||||
'servers' => ["10.75.1.19:11211"], #all write operations
|
||||
'local' => ["localhost:11211"], #read-only operations
|
||||
'timeout' => '300'
|
||||
};
|
||||
|
||||
tie %s, 'Apache::Session::Memorycached', undef,
|
||||
{servers => ['mymemcachedserver:port'],
|
||||
'timeout' => '300',
|
||||
'updateOnly' => 1 ,
|
||||
'principal' => uid,
|
||||
};
|
||||
|
||||
In order to optimize the network ,you can use a local memcached server.
|
||||
All read-only opération are sending fisrt at local server .If you need write ou rewrite data , the data is sending at the principal memcached sever and local cache too for synchronisation.
|
||||
|
||||
note : 'updateOnly' => 1 just realize up-date operation not init operation.
|
||||
Init operation is use in order to book and lock the number session but it's not available in this module
|
||||
|
||||
'principal' => uid : this parameter is use to create reverse reference
|
||||
like this : MD5_hex(uid) => id_session in memcached server . By this it usefull to retrieve id_session from principal name . And add uid_MD5 => MD5_hex(uid) in main session .
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module is an implementation of Apache::Session. It uses the memcached system backing
|
||||
store . You may specify servers (principal) and locals caches for locking in arguments to the constructor. See the example, and the documentation for Apache::Session::Store::Memorycached and Cache::Memcached .
|
||||
|
||||
|
||||
=head1 REPLICATION
|
||||
|
||||
Now Apache::Session::Memorycahed inclues replication between memecached servers
|
||||
Two new components provide a replication service .
|
||||
First package is Apache::Session::MemcachedReplicator
|
||||
Second is Apache::Session::MemcachedClient
|
||||
|
||||
It's now possible to do replication master to slave or master to master
|
||||
see man pages and scripts .
|
||||
|
||||
|
||||
=head1 SOAP service
|
||||
|
||||
Now Apache::Session::Memorycached inclues a SOAP service in order to set or
|
||||
get %session in any language . The SOAP service translates data in Perl hashes
|
||||
|
||||
=head2 Installation of SOAP service
|
||||
|
||||
All scripts are in scripts directory
|
||||
|
||||
Put MemcachedSOAPClass.pm and MemcachedSOAP.cgi in the cgi-bin directory of your apache server with the appropriate right (x) .
|
||||
Change in MemcachedSOAP.cgi the memcached server address .
|
||||
(line 11 : $machine = 'ip.ip.ip.ip:11211'; )
|
||||
|
||||
Try the three scripts statTest.pl (first !) then getTest.pl finish with setTest.pl.
|
||||
|
||||
|
||||
The lemonldap project (SSO under GPL) uses this module
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by eric german <germanlinux@yahoo.fr>.
|
||||
|
||||
Completed by Habib ZITOUNI <zitouni.habib@gmail.com> and
|
||||
Hamza AISSAT<asthamza@hotmail.fr>
|
||||
|
||||
SOAP service is a contribution of Casimir ANTUNES .
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<Apache::Session::DB_File>, L<Apache::Session::Flex>,
|
||||
L<Apache::Session::MemcachedClient>,L<Apache::Session::MemcachedReplicator>,
|
||||
L<Apache::Session::MySQL>, L<Apache::Session::Postgres>, L<Apache::Session>
|
|
@ -0,0 +1,279 @@
|
|||
############################################################################
|
||||
#
|
||||
# Apache::Session::Store::Memorycached
|
||||
# Implements session object storage via memcached
|
||||
# Copyright(c) eric german <germanlinux@yahoo.fr>
|
||||
# Distribute under the Artistic License
|
||||
#
|
||||
############################################################################
|
||||
|
||||
package Apache::Session::Store::Memorycached;
|
||||
|
||||
use strict;
|
||||
use Symbol;
|
||||
use Data::Dumper;
|
||||
use Cache::Memcached;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '2.1';
|
||||
|
||||
|
||||
sub new {
|
||||
#This constructor allocate memory space for for the package!!
|
||||
my $class = shift;
|
||||
my $self;
|
||||
$self->{opened} = 0;
|
||||
|
||||
return bless $self, $class;
|
||||
}
|
||||
|
||||
|
||||
sub insert {
|
||||
#This function is called, when a tie instruction is launch with an undef id
|
||||
#Otherwise at the first identification ( cf Login.pm )
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
if (! exists $session->{args}->{updateOnly}
|
||||
|| $session->{args}->{updateOnly} != 1 ) {
|
||||
|
||||
my $retour;
|
||||
my $ryserver = $session->{args}->{servers};
|
||||
my $ryserverlocal = $session->{args}->{local};
|
||||
my $rytimeout = $session->{args}->{timeout}||'0';
|
||||
my $memd= new Cache::Memcached { 'servers' => $ryserver };
|
||||
my $ident = $session->{data}->{_session_id};
|
||||
my $rhash = $session->{data};
|
||||
$retour = $memd->set($ident,$rhash,$rytimeout);
|
||||
if($retour!=1){
|
||||
$memd->set($ident,$rhash,$rytimeout);
|
||||
}
|
||||
if ($ryserverlocal)
|
||||
{
|
||||
my $memdlocal= new Cache::Memcached { 'servers' => $ryserverlocal};
|
||||
my $identlocal = $session->{data}->{_session_id};
|
||||
my $rhashlocal = $session->{data};
|
||||
$retour = $memdlocal->set($identlocal,$rhashlocal,$rytimeout);
|
||||
if($retour!=1){
|
||||
$memdlocal->set($identlocal,$rhashlocal,$rytimeout);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$self->{opened} = 1;
|
||||
|
||||
}
|
||||
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
my $retour;
|
||||
my $ryserver = $session->{args}->{servers};
|
||||
my $ryserverlocal = $session->{args}->{local};
|
||||
my $rytimeout = $session->{args}->{timeout}||'0';
|
||||
my $principalkey;
|
||||
my $keyvalue;
|
||||
my $memd= new Cache::Memcached { 'servers' => $ryserver };
|
||||
|
||||
my $ident = $session->{data}->{_session_id} ;
|
||||
my $rhash = $session->{data};
|
||||
if ( $session->{args}->{principal} ) {
|
||||
$principalkey = $session->{args}->{principal} ;
|
||||
$keyvalue= $session->{data}->{$principalkey} ;
|
||||
$keyvalue = md5_hex($keyvalue) ;
|
||||
$memd->set($keyvalue,$ident,$rytimeout) if $keyvalue;
|
||||
my $identp = $principalkey.'_MD5';
|
||||
$session->{data}->{$identp} = $keyvalue ;
|
||||
}
|
||||
$retour = $memd->set($ident,$rhash,$rytimeout);
|
||||
|
||||
|
||||
|
||||
if($retour!=1){
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($ryserverlocal)
|
||||
{
|
||||
my $memdlocal= new Cache::Memcached { 'servers' => $ryserverlocal};
|
||||
my $identlocal = $session->{data}->{_session_id};
|
||||
my $rhashlocal = $session->{data};
|
||||
#### in order to prepare identify federation ####
|
||||
if ( $session->{args}->{principal} ) {
|
||||
$memdlocal->set($keyvalue,$identlocal,$rytimeout) if $keyvalue;
|
||||
}
|
||||
|
||||
$retour = $memdlocal->set($identlocal,$rhashlocal,$rytimeout);
|
||||
|
||||
|
||||
|
||||
if($retour!=1){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
##################################################
|
||||
$self->{opened} = 1;
|
||||
}
|
||||
|
||||
sub materialize {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
my $ryserver = $session->{args}->{servers};
|
||||
my $rhash;
|
||||
my $ryserverlocal = $session->{args}->{local};
|
||||
my $rytimeout = $session->{args}->{timeout}||'0';
|
||||
if ($ryserverlocal)
|
||||
{
|
||||
my $memdlocal= new Cache::Memcached { 'servers' => $ryserverlocal};
|
||||
my $identlocal = $session->{data}->{_session_id};
|
||||
$rhash = $memdlocal->get($identlocal);
|
||||
}
|
||||
unless ($rhash)
|
||||
{
|
||||
#print STDERR "MATERIALIZE : RIEN SUR SERVEUR LOCAL $$ !!!\n";
|
||||
my $memd= new Cache::Memcached { 'servers' => $ryserver };
|
||||
my $ident = $session->{data}->{_session_id};
|
||||
$rhash = $memd->get($ident);
|
||||
if(!defined($rhash)){
|
||||
|
||||
|
||||
}
|
||||
## the data is in the principal cache notin the local cache
|
||||
## we must put data in it.
|
||||
if ($ryserverlocal && $rhash)
|
||||
{
|
||||
#print STDERR "MATERIALIZE : REPERCUSSION SUR SERVEUR LOCAL $$ !!!\n";
|
||||
my $memdlocal= new Cache::Memcached { 'servers' => $ryserverlocal};
|
||||
my $identlocal = $session->{data}->{_session_id};
|
||||
my $rhashlocal = $session->{data};
|
||||
$memdlocal->set($identlocal,$rhash,$rytimeout);
|
||||
if($!){
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$self->{opened} = 1;
|
||||
|
||||
$session->{data} =$rhash;
|
||||
#if(!defined($rhash)){
|
||||
#$session->{error} = 1;
|
||||
# }
|
||||
|
||||
}
|
||||
|
||||
sub remove {
|
||||
my $self = shift;
|
||||
my $session = shift;
|
||||
|
||||
my $ryserver = $session->{args}->{servers};
|
||||
|
||||
|
||||
my $memd= new Cache::Memcached { 'servers' => $ryserver};
|
||||
my $principalkey;
|
||||
my $identp;
|
||||
my $keyvalue;
|
||||
my $ryserverlocal = $session->{args}->{local};
|
||||
my $ident = $session->{data}->{_session_id} ;
|
||||
if ( $session->{args}->{principal} ) {
|
||||
|
||||
$principalkey = $session->{args}->{principal} ;
|
||||
$identp = $principalkey.'_MD5';
|
||||
$keyvalue= $session->{data}->{$identp} ;
|
||||
$memd->delete($keyvalue) if $keyvalue ;
|
||||
}
|
||||
$memd->delete($ident);
|
||||
if ($ryserverlocal)
|
||||
{
|
||||
my $memdlocal= new Cache::Memcached { 'servers' => $ryserverlocal };
|
||||
my $identlocal = $session->{data}->{_session_id};
|
||||
$memdlocal->delete($keyvalue) if $keyvalue ;
|
||||
$memdlocal->delete($identlocal);
|
||||
}
|
||||
|
||||
$self->{opened} = 0;
|
||||
|
||||
}
|
||||
|
||||
sub close {
|
||||
my $self = shift;
|
||||
|
||||
if ($self->{opened}) {
|
||||
$self->{opened} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
|
||||
if ($self->{opened}) {
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Apache::Session::Store::Memorycached - Store persistent data on the network with memcached
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
||||
use Apache::Session::Store::Memorycached;
|
||||
|
||||
my $store = new Apache::Session::Store::Memorycached;
|
||||
|
||||
$store->insert($ref);
|
||||
$store->update($ref);
|
||||
$store->materialize($ref);
|
||||
$store->remove($ref);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module fulfills the storage interface of Apache::Session. The serialized
|
||||
objects are stored in files on your network in unused memory
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
This module requires one argument in the usual Apache::Session style. The
|
||||
name of the option is servers, and the value is the same of memcached .
|
||||
Example
|
||||
|
||||
tie %s, 'Apache::Session::Memorycached', undef,
|
||||
{servers => ['mymemcachedserver:port'],
|
||||
'timeout' => '300',
|
||||
'updateOnly' => 1 ,
|
||||
'principal' => uid,
|
||||
};
|
||||
|
||||
In order to optimize the network ,you can use a local memcached server.
|
||||
All read-only opération are sending fisrt at local server .If you need write ou rewrite data , the data is sending at the principal memcached sever and local cache too for synchronisation.
|
||||
|
||||
note : 'updateOnly' => 1 just realize up-date operation not init operation.
|
||||
Init operation is use in order to book and lock the number session but it's not available in this module
|
||||
|
||||
'principal' => uid : this parameter is use to create reverse reference
|
||||
like this : MD5_hex(uid) => id_session in memcached server . By this it usefull to retrieve id_session from principal name . And add uid_MD5 => MD5_hex(uid) in main session .
|
||||
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by eric german <germanlinux@yahoo.fr>
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<Apache::Session>
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/perl -w
|
||||
# Filename: MemcachedSOAP.cgi
|
||||
# MemcachedSOAPClass Web Service
|
||||
# This program is a piece of lemonldap web sss framework
|
||||
#
|
||||
# Modify the line with your memcached ip address
|
||||
# copy this file in cgi-bin directory AND changes right (x) in order to run it
|
||||
use MemcachedSOAPClass;
|
||||
|
||||
use SOAP::Transport::HTTP;
|
||||
$machine = 'ip.ip.ip.ip:11211';
|
||||
SOAP::Transport::HTTP::CGI
|
||||
->dispatch_to('MemcachedSOAPClass')
|
||||
->handle;
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/perl
|
||||
package MemcachedSOAPClass;
|
||||
use Apache::Session::Memorycached;
|
||||
# This module comes with lemonldap frameworks project
|
||||
#use Data::Dumper;
|
||||
use strict;
|
||||
|
||||
# IP adress and port of apache server
|
||||
our $machine;
|
||||
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sub status {
|
||||
my $resp = '...... MEMCACHED SOAP OK ......';
|
||||
return $resp;
|
||||
}
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sub getSession {
|
||||
my $nil = shift;
|
||||
my $id_ses = shift;
|
||||
my %Machine = ( 'servers' => [$machine] );
|
||||
my %session;
|
||||
|
||||
tie( %session, 'Apache::Session::Memorycached', $id_ses, \%Machine );
|
||||
|
||||
my %H = %session;
|
||||
|
||||
untie( %session );
|
||||
|
||||
return \%H;
|
||||
}
|
||||
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sub setSession {
|
||||
my $nil = shift;
|
||||
my %session_tmp = @_ ;
|
||||
my %session;
|
||||
my %Machine = ( 'servers' => [$machine] );
|
||||
|
||||
tie( %session, 'Apache::Session::Memorycached', undef, \%Machine );
|
||||
|
||||
for (keys %session_tmp) {
|
||||
$session{$_} = $session_tmp{$_} ;
|
||||
}
|
||||
|
||||
my $numses = $session{ '_session_id' };
|
||||
|
||||
untie( %session );
|
||||
|
||||
return $numses;
|
||||
}
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1;
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/perl
|
||||
use Apache::Session::MemcachedClient;
|
||||
my $rep = Apache::Session::MemcachedClient->new(in_file =>"/tmp/mem1",
|
||||
out_file =>"/tmp/log1",
|
||||
naptime => 2 ,
|
||||
localmemcached => {'servers' => ['localhost:11211'], },
|
||||
remotememcached =>{'servers' => ['localhost:11311'], },
|
||||
signature => 'mastersur11211',
|
||||
safety_mode =>'actived' ,
|
||||
);
|
||||
$rep->run ;
|
||||
exit;
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/perl -w
|
||||
################################################################
|
||||
# this program retrieve a memcached session by a soap call
|
||||
use Data::Dumper;
|
||||
use SOAP::Lite; # +trace => 'debug';
|
||||
|
||||
$HOST = "http://my_soap_server/cgi-bin/MemcachedSOAP.cgi";
|
||||
$NS = "urn:MemcachedSOAPClass";
|
||||
|
||||
$sess = shift; # read from the command line
|
||||
|
||||
my $soap = SOAP::Lite ->readable(1) ->uri($NS) ->proxy($HOST);
|
||||
|
||||
my $lasess = $soap->getSession( $sess );
|
||||
|
||||
if( $lasess->fault ){
|
||||
printf( "\nERROR ( %s ) OCCURRED : %s \n", $lasess->faultcode, $lasess->faultstring );
|
||||
} else {
|
||||
my %H = %{$lasess->result};
|
||||
my @ks = keys( %{$lasess->result} );
|
||||
@ks = sort( @ks );
|
||||
|
||||
print( "\nCLES\t VALEURS\n" );
|
||||
|
||||
for( @ks ){
|
||||
print( "-------------------------------------------------------------------------------\n" );
|
||||
my $loc = Dumper( $H{ $_ } );
|
||||
print( "$_\t $loc\n" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print( "\n");
|
||||
1;
|
||||
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use Apache::Session::Memorycached;
|
||||
use Data::Dumper;
|
||||
use Cache::Memcached;
|
||||
my $serveur = shift;
|
||||
my $option;
|
||||
my $session_id;
|
||||
my @command = ("-s","-m","-d","-i","-TAG","-show","-modify","-delete","-info") ;
|
||||
|
||||
if (index($serveur,"-") != -1){
|
||||
|
||||
$option = $serveur;
|
||||
$serveur = "localhost:11211";
|
||||
}else{
|
||||
$option = shift;
|
||||
}
|
||||
my $contenu;
|
||||
|
||||
if ($option eq "-s" or $option eq "-show"){
|
||||
$session_id = shift;
|
||||
my $memd= new Cache::Memcached { 'servers' => [$serveur]};
|
||||
my $hashref = $memd->get_multi();
|
||||
$contenu = Dumper($hashref);
|
||||
print ("$contenu\n");
|
||||
my %session;
|
||||
|
||||
tie %session, 'Apache::Session::Memorycached', $session_id, { 'servers' => [$serveur]} ;
|
||||
|
||||
$contenu = Dumper(%session);
|
||||
if (keys(%session)==0){
|
||||
print "Aucune valeures pour l'entree [ $session_id ]\n";
|
||||
}else{
|
||||
print "Contenu du memcached pour l'entree [ $session_id ]\n";
|
||||
print ("$contenu\n");
|
||||
}
|
||||
untie %session;
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($option eq "-m" or $option eq "-modify"){
|
||||
$session_id = shift;
|
||||
my $key = shift;
|
||||
my $value = shift;
|
||||
my %session;
|
||||
|
||||
tie %session, 'Apache::Session::Memorycached', $session_id, { 'servers' => [$serveur]} ;
|
||||
|
||||
if (keys(%session)==0){
|
||||
print "Aucune valeures pour l'entree [ $session_id ]\n";
|
||||
exit;
|
||||
}
|
||||
print "Contenu du memcached pour l'entree[ $session_id ] avant modification : \n";
|
||||
$contenu = Dumper(%session);
|
||||
print ("$contenu\n");
|
||||
print "\n";
|
||||
my %Session;
|
||||
tie %Session, 'Apache::Session::Memorycached', undef, { 'servers' => [$serveur]};
|
||||
foreach (keys %session){
|
||||
if ($_ ne $key){
|
||||
$Session{$_} = $session{$_} if $session{$_} ;
|
||||
}else{
|
||||
$Session{$_} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
my $cont = Dumper(%Session);
|
||||
print "Contenu du memcached pour l'entrée[ $session_id ] apres modification : \n";
|
||||
print ("$cont\n");
|
||||
print "\n";
|
||||
untie %Session;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if($option eq "-d" or $option eq "-delete"){
|
||||
$session_id = shift;
|
||||
my $cle = shift;
|
||||
my %session;
|
||||
|
||||
tie %session, 'Apache::Session::Memorycached', $session_id, { 'servers' => [$serveur]} ;
|
||||
|
||||
$contenu = Dumper(%session);
|
||||
if (keys(%session)==0){
|
||||
print "Aucune valeures pour l'entree [ $session_id ]\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
print ("$contenu\n");
|
||||
print "\n";
|
||||
if (!defined($cle)){
|
||||
my $memd= new Cache::Memcached { 'servers' => [$serveur]};
|
||||
|
||||
my $result = $memd->delete($session_id);
|
||||
if ($result){
|
||||
print "L'entree [ $session_id ] a ete supprime du serveur \n";
|
||||
}else{
|
||||
print "L'entree [ $session_id ] n\'a pu etre supprime du serveur \n";
|
||||
}
|
||||
}else{
|
||||
my %Session;
|
||||
tie %Session, 'Apache::Session::Memorycached', undef, { 'servers' => [$serveur]};
|
||||
foreach (keys %session){
|
||||
if ($_ ne $cle){
|
||||
$Session{$_} = $session{$_} if $session{$_} ;
|
||||
}
|
||||
}
|
||||
|
||||
my $cont = Dumper(%Session);
|
||||
print "Contenu du memcached pour l'entrée[ $session_id ] apres modification : \n";
|
||||
print ("$cont\n");
|
||||
print "\n";
|
||||
untie %Session;
|
||||
}
|
||||
exit;
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if($option eq "-i" or $option eq "-info"){
|
||||
|
||||
my $memd= new Cache::Memcached { 'servers' => [$serveur] };
|
||||
my $tag = shift;
|
||||
if (!defined($tag)){
|
||||
my $result = $memd->stats();
|
||||
my $pid = $result->{hosts}->{$serveur}->{misc}->{pid};
|
||||
my $taille = $result->{hosts}->{$serveur}->{malloc}->{arena_size};
|
||||
print "Pid => $pid
|
||||
";
|
||||
my $clef;
|
||||
my $valeur;
|
||||
|
||||
while (($clef, $valeur) = each(%{$result->{total}})) {
|
||||
print "
|
||||
$clef => $valeur\n";
|
||||
}
|
||||
}else{
|
||||
my $result = $memd->stats($tag);
|
||||
$contenu = Dumper($result);
|
||||
print ("$contenu\n");
|
||||
print "\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
if($option eq "-TAG"){
|
||||
print "
|
||||
List of Tags :
|
||||
|
||||
misc => The stats returned by a 'stats' command: pid, uptime, version, bytes, get_hits, etc.
|
||||
|
||||
malloc => The stats returned by a 'stats malloc': total_alloc, arena_size, etc.
|
||||
|
||||
sizes => The stats returned by a 'stats sizes'.
|
||||
|
||||
self => The stats for the \$memd object itself (a copy of \$memd->{'stats'}).
|
||||
|
||||
maps => The stats returned by a 'stats maps'.
|
||||
|
||||
cachedump => The stats returned by a 'stats cachedump'.
|
||||
|
||||
slabs => The stats returned by a 'stats slabs'.
|
||||
|
||||
items => The stats returned by a 'stats items'.\n";
|
||||
exit;
|
||||
}
|
||||
print "Usage : ./memd.pl [serveur::port] -s (-show) [id]
|
||||
-d (-delete) [id]
|
||||
-m (-modify) [id] [Champs] [valeur]
|
||||
-a (-add) [id] [Champs] [valeur]
|
||||
-i (-info) [TAG]
|
||||
Launch \"./memd.pl -TAG\" to get the list of TAG
|
||||
\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/perl -w
|
||||
####################################################################
|
||||
# this program set a session by a request on soap memcached service
|
||||
####################################################################
|
||||
#
|
||||
use Data::Dumper;
|
||||
use SOAP::Lite; # +trace => 'debug';
|
||||
|
||||
$HOST = "http://my_soap_server/cgi-bin/MemcachedSOAP.cgi";
|
||||
|
||||
$NS = "urn:MemcachedSOAPClass";
|
||||
|
||||
my $soap = SOAP::Lite ->readable(1) ->uri($NS) ->proxy($HOST);
|
||||
|
||||
my %SS = ( 'APT_APT' => '00000',
|
||||
'APT_GPE' => '11111',
|
||||
'APT_IL2' => '22222',
|
||||
'APT_RCE' => '33333',
|
||||
'APT_ZRB' => '44444',
|
||||
'affectation' => '66666',
|
||||
'boitier' => '77777',
|
||||
'cn' => '88888',
|
||||
'codique' => '99999',
|
||||
'departement' => 'aaaaa',
|
||||
'dgi' => 'bbbbb',
|
||||
'dn' => 'ccccc',
|
||||
'fonction' => 'ddddd',
|
||||
'liste_applications' => 'eeeee',
|
||||
'mail' => 'fffff',
|
||||
'personaltitle' => 'ggggg',
|
||||
'profil_aptera' => 'hhhhh',
|
||||
'profil_gap' => 'iiiiii',
|
||||
'profil_gdp' => 'jjjjj',
|
||||
'profil_geide' => 'kkkkk',
|
||||
'profil_ghe' => 'lllllll',
|
||||
'profil_rce' => 'mmmm',
|
||||
'profil_seq' => 'nnnn',
|
||||
'uid' => 'Le Vengeur Masqué' );
|
||||
|
||||
|
||||
my $numses = $soap->setSession( %SS );
|
||||
|
||||
if( $numses->fault ){
|
||||
printf( "\nERROR ( %s ) OCCURRED : %s \n", $numses->faultcode, $numses->faultstring );
|
||||
}
|
||||
|
||||
my $NSS = $numses->result;
|
||||
|
||||
my $NSE = $soap->getSession( $NSS );
|
||||
|
||||
if( $NSE->fault ){
|
||||
printf( "\nERROR ( %s ) OCCURRED : %s \n", $NSE->faultcode, $NSE->faultstring );
|
||||
} else {
|
||||
my %H = %{$NSE->result};
|
||||
my @ks = keys( %{$NSE->result} );
|
||||
@ks = sort( @ks );
|
||||
|
||||
print( "\nCLES\t VALEURS\n" );
|
||||
|
||||
for( @ks ){
|
||||
print( "-------------------------------------------------------------------------------\n" );
|
||||
my $loc = Dumper( $H{ $_ } );
|
||||
print( "$_\t $loc\n" );
|
||||
}
|
||||
}
|
||||
|
||||
print( "\n");
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/perl
|
||||
use Apache::Session::MemcachedReplicator;
|
||||
my $rep = Apache::Session::MemcachedReplicator->new(in_file =>"/tmp/logmem1",
|
||||
out_file =>"/tmp/mem1",
|
||||
naptime => 2 ,);
|
||||
|
||||
$rep->run ;
|
||||
exit;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/perl -w
|
||||
###################################################
|
||||
# this program tests soap service
|
||||
# soap server MUST anwers '...... MEMCACHED SOAP OK ......';
|
||||
use Data::Dumper;
|
||||
use SOAP::Lite; # +trace => 'debug';
|
||||
|
||||
$HOST = "http://my_soap_server/cgi-bin/MemcachedSOAP.cgi";
|
||||
$NS = "urn:MemcachedSOAPClass";
|
||||
|
||||
my $soap = SOAP::Lite ->readable(1) ->uri($NS) ->proxy($HOST);
|
||||
|
||||
my $R = $soap->status();
|
||||
|
||||
if( $R->fault ){
|
||||
printf( "\nERROR ( %s ) OCCURRED : %s \n", $lasess->faultcode, $lasess->faultstring );
|
||||
} else {
|
||||
my $r = $R->result;
|
||||
print( "$r\n" );
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# Before `make install' is performed this script should be runnable with
|
||||
# `make test'. After `make install' it should work as `perl 1.t'
|
||||
|
||||
#########################
|
||||
|
||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
||||
|
||||
use Test::More tests => 1;
|
||||
BEGIN { use_ok('Apache::Session::Memorycached') };
|
||||
|
||||
#########################
|
||||
|
||||
# Insert your test code below, the Test::More module is use()ed here so read
|
||||
# its man page ( perldoc Test::More ) for help writing this test script.
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#====================================================================
|
||||
# Test script for Apache::Session::Memorycached
|
||||
#
|
||||
# 2006 (c) Eric German
|
||||
#====================================================================
|
||||
|
||||
#====================================================================
|
||||
# Perl test modules
|
||||
#====================================================================
|
||||
use Test::More tests => 3;
|
||||
|
||||
#====================================================================
|
||||
# Module loading
|
||||
#====================================================================
|
||||
BEGIN{ use_ok( Apache::Session::Memorycached ); }
|
||||
BEGIN{ print "--> Version : ".$Apache::Session::Memorycached::VERSION."\n"; }
|
||||
|
||||
#====================================================================
|
||||
# Object creation
|
||||
#====================================================================
|
||||
my $id;
|
||||
my %session;
|
||||
tie %session, 'Apache::Session::Memorycached', $id,
|
||||
{
|
||||
'servers' => ["localhost:11211"],
|
||||
};
|
||||
|
||||
$id= $session{"_session_id"};
|
||||
ok( $id,"session ID : $id" );
|
||||
$session{'test'}='memcached daemon running' ;
|
||||
$session{'test2'}='ericgerman' ;
|
||||
untie %session ;
|
||||
tie %session, 'Apache::Session::Memorycached', $id,
|
||||
{
|
||||
'servers' => ["localhost:11211"],
|
||||
};
|
||||
$session{test} = 'memcached daemon not running' unless $session{test};
|
||||
is($session{test},'memcached daemon running',"memcached ready");
|
||||
untie %session;
|
||||
|
Loading…
Reference in New Issue