root/trunk/perl/lib/Cornea/StorageNode.pm

Revision 3, 0.9 kB (checked in by jesus, 9 years ago)

skeleton perl implementation with some feedback from Ciprian about eventual replication. algorithm is there, guts are not.

Line 
1 package Cornea::StorageNode;
2 use strict;
3
4 =pod
5
6 =item location()
7
8 Described as DataCenter/Cage/Row/Rack/PDU
9
10 =item distance()
11
12 Distance between two nodes w.r.t. their location.
13
14 =cut
15
16 sub location() {
17 }
18
19 sub distance() {
20   my $self = shift;
21   my $other = shift;
22   my @a = split /\//, $self->location();
23   my @b = split /\//, $other->location();
24
25   my $dist = 0;
26   while(defined(my $a_v = shift @a) || defined(my $b_v = shift @b)) {
27     $dist <<= 1;
28     $dist |= 1 if($a_v != $b_v);
29   }
30   return $dist;
31 }
32
33 sub put {
34   my $self = shift;
35   my $source = shift;
36   my ($serviceId,$assetId,$repId) = @_;
37
38   if(ref $source eq 'Cornea::StorageNode' or
39      ref $source eq 'Cornea::StorageNodeList') {
40     # This is a storage node(list) from which to copy.
41   }
42   else {
43     # This is an actual asset
44   }
45 }
46
47 sub delete {
48   my $self = shift;
49   my ($serviceId,$assetId,$repId) = @_;
50 }
51
52 sub fetch {
53   my $self = shift;
54   my ($serviceId,$assetId,$repId) = @_;
55 }
56
57 1;
Note: See TracBrowser for help on using the browser.