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

Revision 6, 1.5 kB (checked in by jesus, 5 years ago)

robustness in the transport layers (sql and mq) and a skeleton config

Line 
1 package Cornea::StorageNode;
2 use strict;
3
4 =pod
5
6 =item id()
7
8 The unique identifier.
9
10 =item state()
11
12 The state of the node: {open,closed,offline,decommissioned}
13
14 =item total_storage()
15
16 The total storage in kilobytes.
17
18 =item used_storage()
19
20 The amount of storage used in kilobytes.
21
22 =item fqdn()
23
24 The fully-qualified domain name of the node.
25
26 =item location()
27
28 Described as DataCenter/Cage/Row/Rack/PDU
29
30 =item distance()
31
32 Distance between two nodes w.r.t. their location.
33
34 =cut
35
36 sub new_from_row {
37   my $class = shift;
38   my $hash = shift;
39   bless $hash, $class;
40 }
41 sub id { shift->{id}; }
42 sub state { shift->{state}; }
43 sub total_storage { shift->{total_storage}; }
44 sub used_storage { shift->{used_storage}; }
45 sub fqdn { shift->{fqdn}; }
46 sub location { shift->{location}; }
47
48 sub distance() {
49   my $self = shift;
50   my $other = shift;
51   my @a = split /\//, $self->location();
52   my @b = split /\//, $other->location();
53
54   my $dist = 0;
55   while(defined(my $a_v = shift @a) || defined(my $b_v = shift @b)) {
56     $dist <<= 1;
57     $dist |= 1 if($a_v != $b_v);
58   }
59   return $dist;
60 }
61
62 sub put {
63   my $self = shift;
64   my $source = shift;
65   my ($serviceId,$assetId,$repId) = @_;
66
67   if(ref $source eq 'Cornea::StorageNode' or
68      ref $source eq 'Cornea::StorageNodeList') {
69     # This is a storage node(list) from which to copy.
70   }
71   else {
72     # This is an actual asset
73   }
74 }
75
76 sub delete {
77   my $self = shift;
78   my ($serviceId,$assetId,$repId) = @_;
79 }
80
81 sub fetch {
82   my $self = shift;
83   my ($serviceId,$assetId,$repId) = @_;
84 }
85
86 1;
Note: See TracBrowser for help on using the browser.