Revision: 8152
http://sourceforge.net/p/bigdata/code/8152
Author: thompsonbry
Date: 2014-04-30 18:32:23 +0000 (Wed, 30 Apr 2014)
Log Message:
-----------
Added method to GangliaService for the caller to specify the hosts of interest.
Marked the HostReportComparable as Serializable to support use cases where the IHALoadBalancerPolicy is set remotely (this is done in the HA LBS test suite).
@see #624 (HA LBS)
Modified Paths:
--------------
branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/GangliaService.java
branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/HostReportComparator.java
Modified: branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/GangliaService.java
===================================================================
--- branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/GangliaService.java 2014-04-30 17:52:58 UTC (rev 8151)
+++ branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/GangliaService.java 2014-04-30 18:32:23 UTC (rev 8152)
@@ -1364,15 +1364,43 @@
*/
public IHostReport[] getHostReport(final String[] reportOn,
final Comparator<IHostReport> comparator) {
+
+ final String[] hosts = gangliaState.getKnownHosts();
+ return getHostReport(hosts, reportOn, comparator);
+
+ }
+
+ /**
+ * Return a host report based on the current state (similar to
+ * <code>gstat -a</code>).
+ * <p>
+ * Note: The report will not be accurate immediately as the
+ * {@link GangliaService} needs to build up a model of the current state of
+ * the monitored hosts.
+ *
+ * @param hosts
+ * The hosts for which host reports will be returned.
+ * @param reportOn
+ * The metrics to be reported for each host. The
+ * {@link IHostReport#getMetrics()} is an ordered map and will
+ * reflect the metrics in the order in which they are requested
+ * here.
+ * @param comparator
+ * The comparator used to order the {@link IHostReport}s.
+ *
+ * @return The {@link IHostReport}s for each specified host ordered by the
+ * given {@link Comparator}.
+ */
+ public IHostReport[] getHostReport(final String[] hosts,
+ final String[] reportOn, final Comparator<IHostReport> comparator) {
+
if (reportOn == null || reportOn.length == 0)
throw new IllegalArgumentException();
if (comparator == null)
throw new IllegalArgumentException();
- final String[] hosts = gangliaState.getKnownHosts();
-
final IHostReport[] a = new IHostReport[hosts.length];
for (int i = 0; i < a.length; i++) {
Modified: branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/HostReportComparator.java
===================================================================
--- branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/HostReportComparator.java 2014-04-30 17:52:58 UTC (rev 8151)
+++ branches/RDR/bigdata-ganglia/src/java/com/bigdata/ganglia/HostReportComparator.java 2014-04-30 18:32:23 UTC (rev 8152)
@@ -15,14 +15,21 @@
*/
package com.bigdata.ganglia;
+import java.io.Serializable;
import java.util.Comparator;
/**
* Orders {@link IHostReport}s.
*/
-public class HostReportComparator implements Comparator<IHostReport> {
+public class HostReportComparator implements Comparator<IHostReport>,
+ Serializable {
- private final String metricName;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private final String metricName;
private final boolean asc;
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|