From 4334640c2224e1b2899d8461887cf8480c8ef1ad Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Sat, 25 Jan 2014 13:58:16 -0600 Subject: [PATCH] Issue #2636 - Fix scheduling gaps at start and end of retrieval plan Change-Id: I43930a2cb69f44c83eeec605861bcf6a52a0a26b Former-commit-id: c0d49492af75d0411d6c0c2541af440302595b6a --- .../bandwidth/data/TimeWindowData.java | 114 +++++++--------- .../bandwidth/BandwidthGraphDataAdapter.java | 126 ++++++++---------- .../bandwidth/BandwidthManager.java | 4 +- .../SubscriptionAllocationMapping.java | 100 ++++++++++++++ .../bandwidth/util/BandwidthDaoUtil.java | 80 ++++++----- .../bandwidth/BandwidthServiceIntTest.java | 55 +------- .../BandwidthGraphDataAdapterTest.java | 35 +---- 7 files changed, 252 insertions(+), 262 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/SubscriptionAllocationMapping.java diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/TimeWindowData.java b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/TimeWindowData.java index 594edbd85b..71155c46b4 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/TimeWindowData.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/data/TimeWindowData.java @@ -20,16 +20,14 @@ package com.raytheon.uf.common.datadelivery.bandwidth.data; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Calendar; -import java.util.Collections; -import java.util.List; import java.util.TimeZone; import com.raytheon.uf.common.datadelivery.registry.Network; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.common.util.StringUtil; /** * Time Window Data object. @@ -44,6 +42,7 @@ import com.raytheon.uf.common.time.util.TimeUtil; * Dec 06, 2012 1397 djohnson Add dynamic serialize class annotation. * Jan 07, 2013 1451 djohnson Use TimeUtil.newGmtCalendar(). * Nov 25, 2013 2545 mpduff Add Network. + * Jan 23, 2014 2636 mpduff Removed binStartTimes, add base time and offset. * * * @@ -60,14 +59,16 @@ public class TimeWindowData implements Comparable { @DynamicSerializeElement private long timeWindowEndTime = 0L; - /** Array of bin start times for this time window. */ - @DynamicSerializeElement - private List binStartTimes; - /** The network for the data */ @DynamicSerializeElement private Network network; + @DynamicSerializeElement + private long baseTime; + + @DynamicSerializeElement + private int offset; + /** * Constructor. * @@ -98,50 +99,6 @@ public class TimeWindowData implements Comparable { * TimeUtil.MILLIS_PER_MINUTE; this.timeWindowEndTime = (windowEndTime / TimeUtil.MILLIS_PER_MINUTE) * TimeUtil.MILLIS_PER_MINUTE; - binStartTimes = new ArrayList(); - } - - /** - * Set the bin times. - * - * @param binTimesArray - */ - public void setBinTimes(List binTimesArray) { - binStartTimes = binTimesArray; - sortBinStartTimes(); - } - - /** - * Add a bin time. - * - * @param binStartTime - */ - public void addBinTime(Long binStartTime) { - if (validBinStartTime(binStartTime)) { - long roundedBinTime = (binStartTime / TimeUtil.MILLIS_PER_MINUTE) - * TimeUtil.MILLIS_PER_MINUTE; - binStartTimes.add(roundedBinTime); - sortBinStartTimes(); - return; - } - } - - /** - * Validate the bin time. - * - * @param binStartTime - * @return true if bin time is within the time window - */ - private boolean validBinStartTime(Long binStartTime) { - return binStartTime >= timeWindowStartTime - && binStartTime <= timeWindowEndTime; - } - - /** - * Sort the bin times. - */ - public void sortBinStartTimes() { - Collections.sort(binStartTimes); } /** @@ -176,15 +133,6 @@ public class TimeWindowData implements Comparable { return timeWindowEndTime; } - /** - * Get the time window end time. - * - * @return - */ - public List getBinStartTimes() { - return binStartTimes; - } - /** * @param timeWindowStartTime * the timeWindowStartTime to set @@ -201,14 +149,6 @@ public class TimeWindowData implements Comparable { this.timeWindowEndTime = timeWindowEndTime; } - /** - * @param binStartTimes - * the binStartTimes to set - */ - public void setBinStartTimes(List binStartTimes) { - this.binStartTimes = binStartTimes; - } - /** * @return the network */ @@ -224,6 +164,36 @@ public class TimeWindowData implements Comparable { this.network = network; } + /** + * @return the offset + */ + public int getOffset() { + return offset; + } + + /** + * @param offset + * the offset to set + */ + public void setOffset(int offset) { + this.offset = offset; + } + + /** + * @return the baseTime + */ + public long getBaseTime() { + return baseTime; + } + + /** + * @param baseTime + * the baseTime to set + */ + public void setBaseTime(long baseTime) { + this.baseTime = baseTime; + } + /** * {@inheritDoc} */ @@ -237,9 +207,15 @@ public class TimeWindowData implements Comparable { StringBuilder sb = new StringBuilder(); sb.append("Start Time:\t").append(sdf.format(cal.getTime())) .append(" Z"); - sb.append("\n"); + sb.append(StringUtil.NEWLINE); cal.setTimeInMillis(this.timeWindowEndTime); sb.append("End Time:\t").append(sdf.format(cal.getTime())).append(" Z"); + cal.setTimeInMillis(this.baseTime); + sb.append(StringUtil.NEWLINE); + sb.append("Base Time:\t").append(sdf.format(cal.getTime())) + .append(" Z"); + sb.append(StringUtil.NEWLINE).append("Availability Offset: ") + .append(offset).append(" minutes"); return sb.toString(); } } 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 8a9f16f080..bd981a9e8e 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 @@ -20,6 +20,7 @@ package com.raytheon.uf.edex.datadelivery.bandwidth; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -41,7 +42,6 @@ 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.BandwidthSubscription; import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval; -import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.BandwidthReservation; import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager; import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan; @@ -63,6 +63,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan; * Nov 27, 2013 2545 mpduff Get data by network * Dec 11, 2013 2566 bgonzale handle case when there are no reservations. * Dec 17, 2013 2636 bgonzale Refactored bucket fill in edex. + * Jan 23, 2014 2636 mpduff Changed download window generation. * * * @@ -96,9 +97,8 @@ class BandwidthGraphDataAdapter { Collection retrievalPlans = retrievalManager .getRetrievalPlans().values(); - Map retrievals = new HashMap(); - Map> reservations = new HashMap>(); Map> networkMap = new HashMap>(); + SubscriptionAllocationMapping subAllocationMapping = new SubscriptionAllocationMapping(); // One retrieval plan per network for (RetrievalPlan retrievalPlan : retrievalPlans) { @@ -118,79 +118,71 @@ class BandwidthGraphDataAdapter { SortedSet buckets = toDescriptions(bandwidthBuckets); bandwidthGraphData.addBucketDescriptions(network, buckets); - // Latency window data - accumulate all the reservations - for (BandwidthBucket bucket : bandwidthBuckets) { - final List requests = retrievalPlan - .getBandwidthAllocationsForBucket(bucket); - for (BandwidthAllocation allocation : requests) { - if (allocation instanceof SubscriptionRetrieval) { - final SubscriptionRetrieval subRetrieval = (SubscriptionRetrieval) allocation; - retrievals.put(allocation.getId(), subRetrieval); - } - } + // Latency window data + List allocationList = EdexBandwidthContextFactory + .getInstance().bandwidthDao + .getBandwidthAllocations(network); - final List bandwidthReservations = retrievalPlan - .getBandwidthReservationsForBucket(bucket); - - if (bandwidthReservations != null) { - for (BandwidthReservation reservation : bandwidthReservations) { - if (!reservations.containsKey(reservation.getId())) { - reservations.put(reservation.getId(), - new ArrayList()); - } - reservations.get(reservation.getId()).add(reservation); - } + for (BandwidthAllocation allocation : allocationList) { + if (allocation instanceof SubscriptionRetrieval) { + final SubscriptionRetrieval subRetrieval = (SubscriptionRetrieval) allocation; + String subName = subRetrieval.getBandwidthSubscription() + .getName(); + subAllocationMapping.addAllocationForSubscription(subName, + allocation); } } } - // Create time windows for each subscription retrieval by aggregating - // them with any reservations they have - for (Long key : retrievals.keySet()) { - final SubscriptionRetrieval retrieval = retrievals.get(key); - BandwidthSubscription dao = retrieval.getBandwidthSubscription(); - String subName = dao.getName(); - SubscriptionPriority priority = dao.getPriority(); - String registryId = retrieval.getBandwidthSubscription() - .getRegistryId(); - Network network = retrieval.getNetwork(); + Map> subAllocationMap = subAllocationMapping + .getSubAllocationMap(); + for (Map.Entry> entry : subAllocationMap + .entrySet()) { + String sub = entry.getKey(); + for (BandwidthAllocation ba : entry.getValue()) { + if (ba instanceof SubscriptionRetrieval) { + ((SubscriptionRetrieval) ba).getBandwidthSubscription() + .getBaseReferenceTime(); + SubscriptionRetrieval sr = (SubscriptionRetrieval) ba; + BandwidthSubscription dao = sr.getBandwidthSubscription(); + SubscriptionPriority priority = dao.getPriority(); + Calendar baseRefTime = ((SubscriptionRetrieval) ba) + .getBandwidthSubscription().getBaseReferenceTime(); + int offset = ((SubscriptionRetrieval) ba) + .getDataSetAvailablityDelay(); + String registryId = sr.getBandwidthSubscription() + .getRegistryId(); + Network network = sr.getNetwork(); - SubscriptionWindowData windowData = null; + SubscriptionWindowData windowData = null; + List subList = networkMap + .get(network); + for (SubscriptionWindowData subData : subList) { + if (subData.getRegistryId().equals(registryId)) { + windowData = subData; + break; + } + } - List subList = networkMap.get(network); - for (SubscriptionWindowData subData : subList) { - if (subData.getRegistryId().equals(registryId)) { - windowData = subData; - break; + if (windowData == null) { + windowData = new SubscriptionWindowData(); + windowData.setNetwork(network); + windowData.setPriority(priority); + windowData.setRegistryId(registryId); + windowData.setSubscriptionName(sub); + networkMap.get(network).add(windowData); + } + + final long startMillis = sr.getStartTime() + .getTimeInMillis(); + final long endMillis = sr.getEndTime().getTimeInMillis(); + TimeWindowData window = new TimeWindowData(startMillis, + endMillis); + window.setBaseTime(baseRefTime.getTimeInMillis()); + window.setOffset(offset); + windowData.addTimeWindow(window); } } - - if (windowData == null) { - windowData = new SubscriptionWindowData(); - windowData.setNetwork(network); - windowData.setPriority(priority); - windowData.setRegistryId(registryId); - windowData.setSubscriptionName(subName); - networkMap.get(network).add(windowData); - } - - final long startMillis = retrieval.getStartTime().getTimeInMillis(); - final long endMillis = startMillis - + (retrieval.getSubscriptionLatency() * TimeUtil.MILLIS_PER_MINUTE); - TimeWindowData window = new TimeWindowData(startMillis, endMillis); - - List binStartTimes = new ArrayList(); - binStartTimes.add(retrieval.getStartTime().getTimeInMillis()); - List retrievalReservations = reservations - .get(retrieval.getIdentifier()); - - if (retrievalReservations != null) { - for (BandwidthReservation reservation : retrievalReservations) { - binStartTimes.add(reservation.getBandwidthBucket()); - } - } - window.setBinStartTimes(binStartTimes); - windowData.addTimeWindow(window); } bandwidthGraphData.setNetworkDataMap(networkMap); diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java index 0dc59bd340..5bbb8a9e3f 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthManager.java @@ -138,6 +138,7 @@ import com.raytheon.uf.edex.registry.ebxml.exception.EbxmlRegistryException; * handlePoint method now schedules most recent. * Jan 14, 2014 2692 dhladky Bad Point scheduling final Empty list. * Jan 14, 2014 2459 mpduff Change to subscription status. + * Jan 25, 2014 2636 mpduff Don't do an initial adhoc query for a new subscription. * * * @@ -639,7 +640,6 @@ public abstract class BandwidthManager .getCycleTimes(); final boolean subscribedToCycles = !CollectionUtil .isNullOrEmpty(cycles); - final boolean useMostRecentDataSetUpdate = !subscribedToCycles; // The subscription has cycles, so we can allocate bandwidth at // expected times @@ -648,8 +648,6 @@ public abstract class BandwidthManager unscheduled = schedule(subscription, Sets.newTreeSet(cycles)); } - unscheduled.addAll(getMostRecent(subscription, - useMostRecentDataSetUpdate)); return unscheduled; } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/SubscriptionAllocationMapping.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/SubscriptionAllocationMapping.java new file mode 100644 index 0000000000..4aed907657 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/SubscriptionAllocationMapping.java @@ -0,0 +1,100 @@ +/** + * 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.edex.datadelivery.bandwidth; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation; +import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval; + +/** + * Data class to hold Subscription to download allocations map + * BandwidthAllocation id to SubscriptionRetrieval map + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 23, 2014   2636     mpduff      Initial creation.
+ * 
+ * 
+ * + * @author mpduff + * @version 1.0 + */ + +public class SubscriptionAllocationMapping { + + /** + * Subscription name to list of BandwidthAllocations for the subscription. + */ + private final Map> subAllocationMap = new HashMap>(); + + /** + * BandwidthAllocation id to SubscriptionRetrieval map. + */ + private final Map subRetrievalMap = new HashMap(); + + /** + * Constructor. + */ + public SubscriptionAllocationMapping() { + + } + + /** + * Add the allocation to the subscription list. + * + * @param subName + * The subscription name for the allocation + * @param allocation + * The allocation to add to the subscription list + */ + public void addAllocationForSubscription(String subName, + BandwidthAllocation allocation) { + if (subAllocationMap.get(subName) == null) { + subAllocationMap + .put(subName, new ArrayList(8)); + } + + subAllocationMap.get(subName).add(allocation); + subRetrievalMap.put(allocation.getId(), + (SubscriptionRetrieval) allocation); + } + + /** + * @return the subAllocationMap + */ + public Map> getSubAllocationMap() { + return subAllocationMap; + } + + /** + * @return the subRetrievalMap + */ + public Map getSubRetrievalMap() { + return subRetrievalMap; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/util/BandwidthDaoUtil.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/util/BandwidthDaoUtil.java index 0b33325be3..e78812ca46 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/util/BandwidthDaoUtil.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/util/BandwidthDaoUtil.java @@ -22,7 +22,6 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.util; import java.util.Arrays; import java.util.Calendar; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -79,6 +78,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus; * Dec 20, 2013 2636 mpduff Fix dataset offset. * Jan 08, 2014 2615 bgonzale Refactored getRetrievalTimes into RecurringSubscription * calculateStart and calculateEnd methods. + * Jan 24, 2014 2636 mpduff Refactored retrieval time generation. * * * @author djohnson @@ -179,40 +179,77 @@ public class BandwidthDaoUtil { // end time when when subscription is last valid for scheduling based on // plan end, subscription end, and active period end. Calendar subscriptionCalculatedEnd = subscription.calculateEnd(planEnd); + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.debug("**** PlanStart: " + planStart.getTime()); + statusHandler.debug("**** PlanEnd : " + planEnd.getTime()); + statusHandler.debug("**** CalculatedStart: " + + subscriptionCalculatedStart.getTime()); + statusHandler.debug("**** CalculatedEnd : " + + subscriptionCalculatedEnd.getTime()); + } + + // drop the start time by 6 hours to account for 4 cycle/day models + subscriptionCalculatedStart = TimeUtil.minCalendarFields( + subscriptionCalculatedStart, Calendar.MINUTE, Calendar.SECOND, + Calendar.MILLISECOND); + subscriptionCalculatedStart.add(Calendar.HOUR_OF_DAY, -6); Calendar start = (Calendar) subscriptionCalculatedStart.clone(); + int availabilityOffset = 0; + try { + availabilityOffset = BandwidthUtil.getDataSetAvailablityOffset( + subscription, start); + } catch (RegistryHandlerException e) { + // Error occurred querying the registry. Log and continue on + statusHandler + .handle(Priority.PROBLEM, + "Unable to retrieve data availability offset, using 0 for the offset.", + e); + } + + /** + * Check the offset times against the start time and the base time + * against the end time. This prevents a missing download window at the + * beginning and the end + */ outerloop: while (!start.after(subscriptionCalculatedEnd)) { for (Integer cycle : hours) { start.set(Calendar.HOUR_OF_DAY, cycle); + Calendar baseTime = (Calendar) start.clone(); + Calendar retrievalTime = TimeUtil.newCalendar(start); // start base equal-to-or-after subscriptionStart - if (start.compareTo(subscriptionCalculatedStart) >= 0) { + if (retrievalTime.compareTo(subscriptionCalculatedStart) >= 0) { for (Integer minute : minutes) { + retrievalTime.set(Calendar.MINUTE, minute); start.set(Calendar.MINUTE, minute); + retrievalTime.add(Calendar.MINUTE, availabilityOffset); + // start minutes equal-to-or-after subscriptionStart - if (start.compareTo(subscriptionCalculatedStart) >= 0) { + if (retrievalTime + .compareTo(subscriptionCalculatedStart) >= 0) { // Check for nonsense if (start.after(subscriptionCalculatedEnd)) { break outerloop; } else { Calendar time = TimeUtil.newCalendar(); - time.setTimeInMillis(start.getTimeInMillis()); + time.setTimeInMillis(retrievalTime + .getTimeInMillis()); /** * Fine grain check by hour and minute, for * subscription(start/end), * activePeriod(start/end) **/ // Subscription Start and End time first - if (time.after(subscriptionCalculatedEnd) + if (start.after(subscriptionCalculatedEnd) || time.before(start)) { // don't schedule this retrieval time, // outside subscription window continue; } - - subscriptionTimes.add(time); + subscriptionTimes.add(baseTime); } } } @@ -224,35 +261,6 @@ public class BandwidthDaoUtil { start.set(Calendar.HOUR_OF_DAY, hours.first()); } - // Now walk the subscription times and throw away anything outside the - // plan hours, taking into account the availability delay... - int availabilityOffset = 0; - Iterator itr = subscriptionTimes.iterator(); - while (itr.hasNext()) { - availabilityOffset = 0; - Calendar time = itr.next(); - - try { - availabilityOffset = BandwidthUtil.getDataSetAvailablityOffset( - subscription, time); - } catch (RegistryHandlerException e) { - // Error occurred querying the registry. Log and continue on - statusHandler - .handle(Priority.PROBLEM, - "Unable to retrieve data availability offset, using 0 for the offset.", - e); - } - - Calendar withAvailabilityOffset = TimeUtil.newCalendar(time); - withAvailabilityOffset.add(Calendar.MINUTE, availabilityOffset); - - // We allow base reference times that are still possible to retrieve - // within the availability window to be included - if (withAvailabilityOffset.before(planStart) || time.after(planEnd)) { - itr.remove(); - } - } - return subscriptionTimes; } 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 1792689883..95c1a6ee9f 100644 --- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java +++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java @@ -30,7 +30,6 @@ import java.io.File; import java.util.Arrays; import java.util.Calendar; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.SortedSet; @@ -89,6 +88,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * Sept 25, 2013 1797 dhladky separated time from gridded time * Oct 21, 2013 2292 mpduff Implement multiple data types. * Dec 02, 2013 2545 mpduff Get data by network. + * Jan 23, 2014 2636 mpduff Removed TimeWindow individual bin code. * * * @author djohnson @@ -583,59 +583,6 @@ public class BandwidthServiceIntTest assertEquals( "Expected there to be two time windows for this subscription over 2 days", 2, subscriptionOneTimeWindows.size()); - final TimeWindowData firstTimeWindow = subscriptionOneTimeWindows - .get(0); - final TimeWindowData secondTimeWindow = subscriptionOneTimeWindows - .get(1); - - final List firstWindowBinStartTimes = firstTimeWindow - .getBinStartTimes(); - final List secondWindowBinStartTimes = secondTimeWindow - .getBinStartTimes(); - - assertEquals("Incorrect number of bin start times found.", 2, - firstWindowBinStartTimes.size()); - assertEquals("Incorrect number of bin start times found.", 2, - secondWindowBinStartTimes.size()); - - final List subscriptionRetrievals = bandwidthDao - .getSubscriptionRetrievals(subscription.getProvider(), - subscription.getDataSetName()); - - final Iterator iter = subscriptionRetrievals - .iterator(); - - // First retrieval window - long expectedBinStartTime = iter.next().getStartTime() - .getTimeInMillis(); - - assertEquals( - "Incorrect first bin start time in the first time window.", - expectedBinStartTime, firstWindowBinStartTimes.get(0) - .longValue()); - - expectedBinStartTime += (TimeUtil.MILLIS_PER_MINUTE * 3); - assertEquals( - "Incorrect second bin start time in the first time window.", - expectedBinStartTime, firstWindowBinStartTimes.get(1) - .longValue()); - - // Second retrieval window - expectedBinStartTime = iter.next().getStartTime().getTimeInMillis(); - - assertEquals( - "Incorrect first bin start time in the second time window.", - expectedBinStartTime, secondWindowBinStartTimes.get(0) - .longValue()); - - // The middle bucket was already reserved, so we went ahead six minutes - // and used that bucket - expectedBinStartTime += (TimeUtil.MILLIS_PER_MINUTE * 6); - - assertEquals( - "Incorrect second bin start time in the second time window.", - expectedBinStartTime, secondWindowBinStartTimes.get(1) - .longValue()); } @Test diff --git a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapterTest.java b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapterTest.java index bf2d95e777..051f3ef6e6 100644 --- a/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapterTest.java +++ b/tests/unit/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthGraphDataAdapterTest.java @@ -34,7 +34,6 @@ import com.raytheon.uf.common.datadelivery.registry.Network; import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthBucket; import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalManager; -import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan; /** * Test class for {@link BandwidthGraphdataAdapter}. @@ -45,7 +44,8 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalPlan; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Nov 25, 2013 mpduff Initial creation + * Nov 25, 2013 mpduff Initial creation. + * Jan 25, 2014 2636 mpduff Removed test that has since become invalid. * * * @@ -59,8 +59,6 @@ public class BandwidthGraphDataAdapterTest { private static final RetrievalManager retrievalManagerMock = mock(RetrievalManager.class); - private static final RetrievalPlan retrievalPlan = new RetrievalPlan(); - private static final SortedSet bucketSet = new TreeSet(); private static final BandwidthGraphDataAdapter adapter = new BandwidthGraphDataAdapter( @@ -141,33 +139,4 @@ public class BandwidthGraphDataAdapterTest { } } } - - @Test - public void testOverfilledBucketsOverflowToLaterBuckets() { - Iterator iter = bucketSet.iterator(); - - // Get the first bucket and fill it 4.5 buckets worth - BandwidthBucket bucket = iter.next(); - bucket.setCurrentSize((BUCKET_SIZE * 4) + (BUCKET_SIZE / 2)); - - int idx = 0; - SortedSet descriptions = adapter - .toDescriptions(bucketSet); - - Iterator it = descriptions.iterator(); - while (it.hasNext()) { - BandwidthBucketDescription bbd = it.next(); - if (idx <= 3) { - assertTrue("First four buckets should be full", - bbd.getUsedBytes() == bucket.getBucketSize()); - idx++; - } else if (idx == 4) { - assertTrue("Bucket should be half full", - bbd.getUsedBytes() == bucket.getBucketSize() / 2); - idx++; - } else { - assertTrue("Bucket should be empty", bbd.getUsedBytes() == 0); - } - } - } }