diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/BandwidthBucketDescription.java b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/BandwidthBucketDescription.java
new file mode 100644
index 0000000000..279b0be83b
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/BandwidthBucketDescription.java
@@ -0,0 +1,157 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.uf.common.datadelivery.bandwidth.data;
+
+import com.raytheon.uf.common.datadelivery.registry.Network;
+import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
+import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
+
+/**
+ * Describes a bucket, especially the total bytes available and bytes used. Used
+ * by the UI to display information about buckets. Comparable by startime and
+ * bucketSize
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Sep 20, 2013 2397 bgonzale Initial creation
+ *
+ *
+ *
+ * @author bgonzale
+ * @version 1.0
+ */
+
+@DynamicSerialize
+public class BandwidthBucketDescription implements
+ Comparable {
+
+ @DynamicSerializeElement
+ private Network network;
+
+ // Number of bytes of bandwidth;
+ @DynamicSerializeElement
+ private long bucketSize;
+
+ // Number of allocated bytes
+ @DynamicSerializeElement
+ private long usedBytes;
+
+ @DynamicSerializeElement
+ private long bucketStartTime;
+
+ /**
+ * Default Constructor.
+ */
+ public BandwidthBucketDescription() {
+ }
+
+ /**
+ * Initialize all fields Constructor.
+ *
+ * @param network
+ * @param bucketSize
+ * @param usedBytes
+ * @param bucketStartTime
+ */
+ public BandwidthBucketDescription(Network network, long bucketSize,
+ long usedBytes, long bucketStartTime) {
+ this.network = network;
+ this.bucketSize = bucketSize;
+ this.usedBytes = usedBytes;
+ this.bucketStartTime = bucketStartTime;
+ }
+
+ /**
+ * Compare by bucket start time. If bucket start times are equal, then
+ * compare by bucket size.
+ */
+ @Override
+ public int compareTo(BandwidthBucketDescription o) {
+ long compStart = this.bucketStartTime - o.getBucketStartTime();
+ int retval = (int) (compStart == 0 ? this.bucketSize - o.bucketSize
+ : compStart);
+ return retval;
+ }
+
+ /**
+ * @return the network
+ */
+ public Network getNetwork() {
+ return network;
+ }
+
+ /**
+ * @param network
+ * the network to set
+ */
+ public void setNetwork(Network network) {
+ this.network = network;
+ }
+
+ /**
+ * @return the bucketSize
+ */
+ public long getBucketSize() {
+ return bucketSize;
+ }
+
+ /**
+ * @param bucketSize
+ * the bucketSize to set
+ */
+ public void setBucketSize(long bucketSize) {
+ this.bucketSize = bucketSize;
+ }
+
+ /**
+ * @return the usedBytes
+ */
+ public long getUsedBytes() {
+ return usedBytes;
+ }
+
+ /**
+ * @param usedBytes
+ * the usedBytes to set
+ */
+ public void setUsedBytes(long usedBytes) {
+ this.usedBytes = usedBytes;
+ }
+
+ /**
+ * @return the bucketStartTime
+ */
+ public long getBucketStartTime() {
+ return bucketStartTime;
+ }
+
+ /**
+ * @param bucketStartTime
+ * the bucketStartTime to set
+ */
+ public void setBucketStartTime(long bucketStartTime) {
+ this.bucketStartTime = bucketStartTime;
+ }
+
+}
diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/BandwidthGraphData.java b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/BandwidthGraphData.java
index 7d045becea..f4cb0add4c 100644
--- a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/BandwidthGraphData.java
+++ b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/BandwidthGraphData.java
@@ -20,13 +20,17 @@
package com.raytheon.uf.common.datadelivery.bandwidth.data;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.SortedSet;
import java.util.TreeMap;
+import java.util.TreeSet;
+import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@@ -43,6 +47,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Nov 25, 2012 1269 lvenable Initial creation.
* Dec 06, 2012 1397 djohnson Add dynamic serialize class annotation.
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
+ * Sep 20, 2013 2397 bgonzale Added Map of Bucket Descriptions.
*
*
*
@@ -59,6 +64,10 @@ public class BandwidthGraphData {
@DynamicSerializeElement
private Map priorityMap;
+ /** Network -> Bandwidth Bucket Descriptions */
+ @DynamicSerializeElement
+ private Map> networkBucketMap;
+
/** Bin duration in minutes */
@DynamicSerializeElement
private int binTimeInMins;
@@ -116,6 +125,36 @@ public class BandwidthGraphData {
this.priorityMap = priorityMap;
}
+ /**
+ * @return the networkBucketMap
+ */
+ public Map> getNetworkBucketMap() {
+ return networkBucketMap;
+ }
+
+ /**
+ * @param networkBucketMap
+ * the networkBucketMap to set
+ */
+ public void setNetworkBucketMap(
+ Map> networkBucketMap) {
+ /*
+ * Ensure bucket description set sorting. This is done like this because
+ * the thrift version we are using is recreating the SortedSet as a
+ * HashSet on deserialization and causing
+ * getNetworkBucketMap().get(Network) to throw
+ * "java.lang.ClassCastException: java.util.HashSet cannot be cast to java.util.SortedSet"
+ */
+ this.networkBucketMap = new HashMap>();
+ for (Entry> descEntry : networkBucketMap
+ .entrySet()) {
+ this.networkBucketMap.put(descEntry.getKey(),
+ new TreeSet(
+ (Collection) descEntry
+ .getValue()));
+ }
+ }
+
/**
* @return the binTimeInMins
*/
diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapter.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapter.java
index aa9542cab2..3cd7844b21 100644
--- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapter.java
+++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapter.java
@@ -26,11 +26,14 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedSet;
+import java.util.TreeSet;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
+import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthBucketDescription;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.bandwidth.data.TimeWindowData;
+import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription.SubscriptionPriority;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@@ -57,6 +60,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan;
* Jan 25, 2013 1528 djohnson Subscription priority is now an enum.
* Jun 24, 2013 2106 djohnson Access bucket allocations through RetrievalPlan.
* Jul 11, 2013 2106 djohnson Use priority straight from the BandwidthSubscription.
+ * Sep 20, 2013 2397 bgonzale Add Map of Bucket Descriptions to BandwidthGraphData.
*
*
*
@@ -103,6 +107,7 @@ class BandwidthGraphDataAdapter {
.create();
Multimap subNameToRetrievals = ArrayListMultimap
.create();
+ Map> networkBucketMap = new HashMap>();
Collection retrievalPlans = retrievalManager
.getRetrievalPlans().values();
@@ -113,6 +118,8 @@ class BandwidthGraphDataAdapter {
.getBucketsInWindow(TimeUtil.currentTimeMillis(),
Long.MAX_VALUE);
+ networkBucketMap.put(retrievalPlan.getNetwork(),
+ toDescriptions(bandwidthBuckets));
// Add all subscription retrievals to a collection keyed by sub
// name, and associate all of the bandwidth reservations with their
// associated retrievals
@@ -170,8 +177,24 @@ class BandwidthGraphDataAdapter {
bandwidthGraphData.setDataMap(dataMap);
bandwidthGraphData.setPriorityMap(priorityMap);
+ bandwidthGraphData.setNetworkBucketMap(networkBucketMap);
return bandwidthGraphData;
}
+ /*
+ * Return BandwithBucketDescription objects for the given BandwidthBuckets.
+ */
+ private SortedSet toDescriptions(
+ SortedSet bandwidthBuckets) {
+ SortedSet descriptions = new TreeSet();
+ for (BandwidthBucket bucket : bandwidthBuckets) {
+ BandwidthBucketDescription desc = new BandwidthBucketDescription(
+ bucket.getNetwork(), bucket.getBucketSize(),
+ bucket.getCurrentSize(), bucket.getBucketStartTime());
+ descriptions.add(desc);
+ }
+ return descriptions;
+ }
+
}
diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java
index c4a18950d4..04fc7fabe2 100644
--- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java
+++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java
@@ -42,6 +42,7 @@ import com.raytheon.uf.common.datadelivery.bandwidth.BandwidthService;
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthRequest;
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
import com.raytheon.uf.common.datadelivery.bandwidth.WfoBandwidthService;
+import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthBucketDescription;
import com.raytheon.uf.common.datadelivery.bandwidth.data.BandwidthGraphData;
import com.raytheon.uf.common.datadelivery.bandwidth.data.SubscriptionStatusSummary;
import com.raytheon.uf.common.datadelivery.bandwidth.data.TimeWindowData;
@@ -59,6 +60,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthBucket;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthMap;
+import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
/**
@@ -529,10 +531,18 @@ public class BandwidthServiceIntTest extends AbstractWfoBandwidthManagerIntTest
service.schedule(subscription2);
BandwidthGraphData graphData = service.getBandwidthGraphData();
+ RetrievalPlan opsnetPlan = retrievalManager.getPlan(Network.OPSNET);
assertEquals("Incorrect number of subscriptions returned!",
- retrievalManager.getPlan(Network.OPSNET).getBucketMinutes(),
+ opsnetPlan.getBucketMinutes(),
graphData.getBinTimeInMinutes());
+ SortedSet descs = graphData
+ .getNetworkBucketMap().get(Network.OPSNET);
+ long earliestTime = descs.first().getBucketStartTime();
+ long latestTime = descs.last().getBucketStartTime();
+ assertEquals("Incorrect number of buckets returned", opsnetPlan
+ .getBucketsInWindow(earliestTime, latestTime).size(),
+ descs.size());
}
@Test