[pve-devel] r5718 - in pve-cluster/trunk/data: . perl

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Mar 17 12:00:43 CET 2011


Author: dietmar
Date: 2011-03-17 12:00:43 +0100 (Thu, 17 Mar 2011)
New Revision: 5718

Modified:
   pve-cluster/trunk/data/ChangeLog
   pve-cluster/trunk/data/perl/Cluster.pm
Log:
impl. task list


Modified: pve-cluster/trunk/data/ChangeLog
===================================================================
--- pve-cluster/trunk/data/ChangeLog	2011-03-17 08:55:50 UTC (rev 5717)
+++ pve-cluster/trunk/data/ChangeLog	2011-03-17 11:00:43 UTC (rev 5718)
@@ -1,3 +1,10 @@
+2011-03-17  Proxmox Support Team  <support at proxmox.com>
+
+	* perl/Cluster.pm (get_nodelist): simply return an array of node
+	names.
+	(get_tasklist): get cluster wide task list
+	(broadcast_tasklist): send tasklist to cluster nodes
+
 2011-03-10  Proxmox Support Team  <support at proxmox.com>
 
 	* perl/Cluster.pm (rrd_dump): cache RRD data for one second (avoid

Modified: pve-cluster/trunk/data/perl/Cluster.pm
===================================================================
--- pve-cluster/trunk/data/perl/Cluster.pm	2011-03-17 08:55:50 UTC (rev 5717)
+++ pve-cluster/trunk/data/perl/Cluster.pm	2011-03-17 11:00:43 UTC (rev 5718)
@@ -266,8 +266,9 @@
 my $ipcc_update_status = sub {
     my ($name, $data) = @_;
 
+    my $raw = ref($data) ? encode_json($data) : $data;
     # update status
-    my $bindata = pack "Z[256]Z*", $name, ref($data) ? encode_json($data) : $data;
+    my $bindata = pack "Z[256]Z*", $name, $raw;
 
     return &$ipcc_send_rec(4, $bindata);
 };
@@ -365,36 +366,57 @@
 
     my $result = [];
 
-    if (!$nodelist) {
+    my $nodename = PVE::INotify::nodename();
 
-	my $nodename = PVE::INotify::nodename();
-
-	push @$result, { node => $nodename };
-
-	return $result;
+    if (!$nodelist || !$nodelist->{$nodename}) {
+	return [ $nodename ];
     }
 
-    foreach my $node (keys %$nodelist) {
-	push @$result, { node => $node };
-    }
-
-    return $result;
+    return [ keys %$nodelist ];
 }
 
-sub broadcast_vminfo {
+sub broadcast_tasklist {
     my ($data) = @_;
 
     eval {
-	&$ipcc_update_status("vminfo", $data);
+	&$ipcc_update_status("tasklist", $data);
     };
 
     warn $@ if $@;
 }
 
-sub get_vminfo {
+my $tasklistcache = {};
+
+sub get_tasklist {
     my ($nodename) = @_;
 
-    return  &$ipcc_get_status("vminfo", $nodename);
+    my $kvstore = $versions->{kvstore} || {};
+
+    my $nodelist = get_nodelist();
+
+    my $res = [];
+    foreach my $node (@$nodelist) {
+	next if $nodename && ($nodename ne $node);
+	eval {
+	    my $ver = $kvstore->{$node}->{tasklist} if $kvstore->{$node};
+	    my $cd = $tasklistcache->{$node};
+	    if (!$cd || !$ver || ($cd->{version} != $ver)) {
+		my $raw = &$ipcc_get_status("tasklist", $node) || '[]';
+		my $data = decode_json($raw);
+		push @$res, @$data;
+		$cd = $tasklistcache->{$node} = {
+		    data => $data,
+		    version => $ver,
+		};
+	    } elsif ($cd && $cd->{data}) {
+		push @$res, @{$cd->{data}};
+	    }
+	};
+	my $err = $@;
+	syslog('err', $err) if $err;
+    }
+
+    return $res;
 }
 
 sub broadcast_rrd {



More information about the pve-devel mailing list