Merge branch 'omaha_14.2.1' of cm2:/home/garmenda/deliveries/14.2.1/AWIPS2_baseline.14.2.1 into master_14.2.1

Former-commit-id: be05eaa7b2 [formerly a68bda6858] [formerly 4e3096631d] [formerly 4e3096631d [formerly d4b6d22ae2]] [formerly f999e48df0 [formerly 4e3096631d [formerly d4b6d22ae2] [formerly f999e48df0 [formerly 3605f0373a6ce7b417d942991e50029c2d0c964b]]]]
Former-commit-id: f999e48df0
Former-commit-id: 5bf765180a2d6593156d0375a4966e4e0a0220a7 [formerly 2bdb02ad2c8ccb7c77ded0fd2df41688dea93867] [formerly 82756e3855 [formerly 3ab2df3507]]
Former-commit-id: 82756e3855
Former-commit-id: 86ec9a50d4
This commit is contained in:
Brian.Dyke 2014-03-14 08:44:39 -04:00
commit 6f76636104
9 changed files with 381 additions and 305 deletions

View file

@ -128,7 +128,7 @@
<memory-setting> <memory-setting>
<command-line-args> <command-line-args>
<first-arg>-perspective</first-arg> <first-arg>-perspective</first-arg>
<second-arg>National Centers</second-arg> <second-arg>NCP</second-arg>
</command-line-args> </command-line-args>
<ini-substitutions> <ini-substitutions>
@ -175,11 +175,11 @@
<ini-substitutions> <ini-substitutions>
<max-memory> <max-memory>
<value>512M</value> <value>256M</value>
</max-memory> </max-memory>
<max-perm> <max-perm>
<value>128m</value> <value>64M</value>
</max-perm> </max-perm>
</ini-substitutions> </ini-substitutions>
</memory-setting> </memory-setting>
@ -196,7 +196,7 @@
</max-memory> </max-memory>
<max-perm> <max-perm>
<value>128m</value> <value>128M</value>
</max-perm> </max-perm>
</ini-substitutions> </ini-substitutions>
</memory-setting> </memory-setting>
@ -230,7 +230,7 @@
</max-memory> </max-memory>
<max-perm> <max-perm>
<value>128m</value> <value>64M</value>
</max-perm> </max-perm>
</ini-substitutions> </ini-substitutions>
</memory-setting> </memory-setting>
@ -238,7 +238,7 @@
<memory-setting> <memory-setting>
<command-line-args> <command-line-args>
<first-arg>-perspective</first-arg> <first-arg>-perspective</first-arg>
<second-arg>National Centers</second-arg> <second-arg>NCP</second-arg>
</command-line-args> </command-line-args>
<ini-substitutions> <ini-substitutions>
@ -251,6 +251,142 @@
</max-perm> </max-perm>
</ini-substitutions> </ini-substitutions>
</memory-setting> </memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>activatesite</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>avnsetup</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>metar</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>windrose</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>cigvisdist</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>cigvistrend</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>hydroTimeSeries</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<memory-setting>
<command-line-args>
<first-arg>-component</first-arg>
<second-arg>autodqc</second-arg>
</command-line-args>
<ini-substitutions>
<max-memory>
<value>256M</value>
</max-memory>
<max-perm>
<value>64M</value>
</max-perm>
</ini-substitutions>
</memory-setting>
<!-- memory default overrides for a particular site type (wfo, ncep, etc) --> <!-- memory default overrides for a particular site type (wfo, ncep, etc) -->
<!-- site-type names need to be all lower case --> <!-- site-type names need to be all lower case -->

View file

@ -62,12 +62,14 @@ import com.vividsolutions.jts.geom.Polygon;
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------- -------- ----------- --------------------------
* Jul 30, 2010 mschenke Initial creation * Jul 30, 2010 mschenke Initial creation
* Oct 31, 2012 DR 15287 D. Friedman Fix overlap calculation * Oct 31, 2012 15287 D. Friedman Fix overlap calculation
* Nov 06, 2012 DR 15157 D. Friedman Allow configured inclusion percentage * Nov 06, 2012 15157 D. Friedman Allow configured inclusion percentage
* Oct 10, 2013 2104 mschenke Fixed broken percentage calculation * Oct 10, 2013 2104 mschenke Fixed broken percentage calculation
* Mar 11, 2014 2896 bsteffen Limit the number of divisions.
*
* *
* </pre> * </pre>
* *
@ -322,11 +324,22 @@ public class SatBestResResourceData extends AbstractRequestableResourceData {
double threshold = targetGeometry.getEnvelope().getSpan(0) double threshold = targetGeometry.getEnvelope().getSpan(0)
/ targetGeometry.getGridRange().getSpan(0); / targetGeometry.getGridRange().getSpan(0);
int xDiv = (int) (envWidth / 100);
int yDiv = (int) (envHeight / 100);
if (xDiv * yDiv > 1024 * 1024) {
/* Don't wasste too much time/memory, preserve aspect ratio. */
if (xDiv > yDiv) {
yDiv = 1024 * yDiv / xDiv;
xDiv = 1024;
} else {
xDiv = 1024 * xDiv / yDiv;
yDiv = 1024;
}
}
Geometry intersection = EnvelopeIntersection Geometry intersection = EnvelopeIntersection
.createEnvelopeIntersection(gridGeometry.getEnvelope(), .createEnvelopeIntersection(gridGeometry.getEnvelope(),
targetGeometry.getEnvelope(), threshold, targetGeometry.getEnvelope(), threshold, xDiv,
(int) (envWidth / 100.0), yDiv);
(int) (envHeight / 100.0));
if (area == null) { if (area == null) {
area = intersection; area = intersection;
} else { } else {

View file

@ -30,5 +30,7 @@ insert into awips.satellite_units values (28,'SounderCloudAmountPixel');
insert into awips.satellite_units values (29,'RainfallRatePixel'); insert into awips.satellite_units values (29,'RainfallRatePixel');
insert into awips.satellite_units values (43,'IRPixel'); insert into awips.satellite_units values (43,'IRPixel');
insert into awips.satellite_units values (48,'IRPixel'); insert into awips.satellite_units values (48,'IRPixel');
insert into awips.satellite_units values (55,'IRPixel');
insert into awips.satellite_units values (57,'IRPixel');
insert into awips.satellite_units values (60,'PercentOfNormalTPWPixel'); insert into awips.satellite_units values (60,'PercentOfNormalTPWPixel');
insert into awips.satellite_units values (64,'IRPixel'); insert into awips.satellite_units values (64,'IRPixel');

View file

@ -24,6 +24,15 @@
<styleRule> <styleRule>
<paramLevelMatches> <paramLevelMatches>
<parameter>Imager 11 micron IR</parameter> <parameter>Imager 11 micron IR</parameter>
<parameter>Imager 12 micron IR</parameter>
<parameter>Imager 13 micron (IR)</parameter>
<parameter>Imager 3.9 micron IR</parameter>
<parameter>Sounder 11.03 micron imagery</parameter>
<parameter>Sounder 3.98 micron imagery</parameter>
<parameter>Sounder 4.45 micron imagery</parameter>
<parameter>Sounder 14.06 micron imagery</parameter>
<parameter>Polar IR</parameter>
<parameter>Polar 3.7u</parameter>
</paramLevelMatches> </paramLevelMatches>
<imageStyle> <imageStyle>
<displayUnits>C</displayUnits> <displayUnits>C</displayUnits>
@ -40,6 +49,9 @@
<styleRule> <styleRule>
<paramLevelMatches> <paramLevelMatches>
<parameter>Imager 6.7-6.5 micron IR (WV)</parameter> <parameter>Imager 6.7-6.5 micron IR (WV)</parameter>
<parameter>Sounder 6.51 micron imagery</parameter>
<parameter>Sounder 7.02 micron imagery</parameter>
<parameter>Sounder 7.43 micron imagery</parameter>
</paramLevelMatches> </paramLevelMatches>
<imageStyle> <imageStyle>
<range scale="LINEAR"> <range scale="LINEAR">
@ -72,6 +84,8 @@
<styleRule> <styleRule>
<paramLevelMatches> <paramLevelMatches>
<parameter>Imager Visible</parameter> <parameter>Imager Visible</parameter>
<parameter>Sounder Visible imagery</parameter>
<parameter>Polar Vis</parameter>
</paramLevelMatches> </paramLevelMatches>
<imageStyle> <imageStyle>
<range scale="LINEAR"> <range scale="LINEAR">
@ -84,6 +98,7 @@
<styleRule> <styleRule>
<paramLevelMatches> <paramLevelMatches>
<parameter>satDif11u3_9uIR</parameter> <parameter>satDif11u3_9uIR</parameter>
<parameter>poesDif11u3_7uIR</parameter>
</paramLevelMatches> </paramLevelMatches>
<imageStyle> <imageStyle>
<displayUnits>bit</displayUnits> <displayUnits>bit</displayUnits>
@ -129,166 +144,6 @@
</colorbarLabeling> </colorbarLabeling>
</imageStyle> </imageStyle>
</styleRule> </styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Imager 12 micron IR</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>55</minValue>
<maxValue>-109</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Imager 13 micron (IR)</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>55</minValue>
<maxValue>-109</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Imager 3.9 micron IR</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>55</minValue>
<maxValue>-109</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder 11.03 micron imagery</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>55</minValue>
<maxValue>-109</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder 6.51 micron imagery</parameter>
</paramLevelMatches>
<imageStyle>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>255</maxValue>
</range>
<defaultColormap>Sat/WV/Gray Scale Water Vapor</defaultColormap>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder 7.02 micron imagery</parameter>
</paramLevelMatches>
<imageStyle>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>255</maxValue>
</range>
<defaultColormap>Sat/WV/Gray Scale Water Vapor</defaultColormap>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder 7.43 micron imagery</parameter>
</paramLevelMatches>
<imageStyle>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>255</maxValue>
</range>
<defaultColormap>Sat/WV/Gray Scale Water Vapor</defaultColormap>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder Visible imagery</parameter>
</paramLevelMatches>
<imageStyle>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>255</maxValue>
</range>
<defaultColormap>Sat/VIS/ZA (Vis Default)</defaultColormap>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder 3.98 micron imagery</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>255</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder 4.45 micron imagery</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>255</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Sounder 14.06 micron imagery</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>55</minValue>
<maxValue>-109</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule> <styleRule>
<paramLevelMatches> <paramLevelMatches>
<parameter>Sounder Based Derived Lifted Index (LI)</parameter> <parameter>Sounder Based Derived Lifted Index (LI)</parameter>
@ -469,65 +324,4 @@
</dataMapping> </dataMapping>
</imageStyle> </imageStyle>
</styleRule> </styleRule>
<!-- Polar Satellite Rules -->
<styleRule>
<paramLevelMatches>
<parameter>Polar IR</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>55</minValue>
<maxValue>-109</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Polar Vis</parameter>
</paramLevelMatches>
<imageStyle>
<range scale="LINEAR">
<minValue>0</minValue>
<maxValue>255</maxValue>
</range>
<defaultColormap>Sat/VIS/ZA (Vis Default)</defaultColormap>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>Polar 3.7u</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>C</displayUnits>
<range scale="LINEAR">
<minValue>55</minValue>
<maxValue>-109</maxValue>
</range>
<defaultColormap>Sat/IR/CIRA (IR Default)</defaultColormap>
<colorbarLabeling>
<values>40 20 0 -20 -40 -60 -80</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
<styleRule>
<paramLevelMatches>
<parameter>poesDif11u3_7uIR</parameter>
</paramLevelMatches>
<imageStyle>
<displayUnits>bit</displayUnits>
<range scale="LINEAR">
<minValue>-79</minValue>
<maxValue>177</maxValue>
</range>
<defaultColormap>Sat/VIS/CA (Low Light Vis)</defaultColormap>
<colorbarLabeling>
<values>-50 0 50 100 150</values>
</colorbarLabeling>
</imageStyle>
</styleRule>
</styleRuleset> </styleRuleset>

View file

@ -1,5 +1,8 @@
package com.raytheon.uf.edex.datadelivery.bandwidth.retrieval; package com.raytheon.uf.edex.datadelivery.bandwidth.retrieval;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.common.datadelivery.registry.Network; import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
@ -23,6 +26,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
* Nov 09, 2012 1286 djohnson Add ability to kill the threads when BandwidthManager instance is replaced. * Nov 09, 2012 1286 djohnson Add ability to kill the threads when BandwidthManager instance is replaced.
* Mar 05, 2013 1647 djohnson Sleep one minute between checks. * Mar 05, 2013 1647 djohnson Sleep one minute between checks.
* Jan 30, 2014 2686 dhladky refactor of retrieval. * Jan 30, 2014 2686 dhladky refactor of retrieval.
* Feb 10, 2014 2678 dhladky Prevent duplicate allocations.
* *
* </pre> * </pre>
* *
@ -102,28 +106,38 @@ public abstract class RetrievalAgent<ALLOCATION_TYPE extends BandwidthAllocation
* @throws EdexException * @throws EdexException
*/ */
public void doRun() throws EdexException { public void doRun() throws EdexException {
statusHandler.info(network+ ": Checking for bandwidth allocations to process...");
BandwidthAllocation reservation = retrievalManager.nextAllocation(
network, getAgentType());
if (reservation == RetrievalManager.POISON_PILL) { statusHandler.info(network
statusHandler + ": Checking for bandwidth allocations to process...");
.info("Received kill request, this thread is shutting down..."); List<BandwidthAllocation> allocationReservations = retrievalManager
dead = true; .getRecentAllocations(network, getAgentType());
return;
}
if (reservation != null) { if (allocationReservations != null) {
ALLOCATION_TYPE allocation = getAllocationTypeClass().cast(
reservation); List<ALLOCATION_TYPE> allocations = new ArrayList<ALLOCATION_TYPE>(
statusHandler.info(network+": Processing allocation id [" allocationReservations.size());
+ allocation.getId() + "]");
for (BandwidthAllocation bandwidthAlloc : allocationReservations) {
if (bandwidthAlloc == RetrievalManager.POISON_PILL) {
statusHandler
.info("Received kill request, this thread is shutting down...");
dead = true;
return;
}
// cast to type class
ALLOCATION_TYPE allocation = (ALLOCATION_TYPE) getAllocationTypeClass()
.cast(bandwidthAlloc);
allocations.add(allocation);
statusHandler.info(network + ": Processing allocation["
+ allocation.getId() + "]");
}
processAllocations(allocations);
processAllocation(allocation);
} else { } else {
synchronized (notifier) { synchronized (notifier) {
try { try {
statusHandler.info(network+": None found, sleeping for [" statusHandler.info(network + ": None found, sleeping for ["
+ SLEEP_TIME + "]"); + SLEEP_TIME + "]");
notifier.wait(SLEEP_TIME); notifier.wait(SLEEP_TIME);
@ -152,12 +166,12 @@ public abstract class RetrievalAgent<ALLOCATION_TYPE extends BandwidthAllocation
/** /**
* Process the {@link BandwidthAllocation} retrieved. * Process the {@link BandwidthAllocation} retrieved.
* *
* @param allocation * @param allocations
* the allocation * the allocations
* @throws EdexException * @throws EdexException
* on error processing the allocation * on error processing the allocation
*/ */
abstract void processAllocation(ALLOCATION_TYPE allocation) abstract void processAllocations(List<ALLOCATION_TYPE> allocations)
throws EdexException; throws EdexException;
/** /**
* Get the network * Get the network
@ -166,4 +180,4 @@ public abstract class RetrievalAgent<ALLOCATION_TYPE extends BandwidthAllocation
public Network getNetwork() { public Network getNetwork() {
return network; return network;
} }
} }

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
* Jul 09, 2013 2106 djohnson Only needs to unregister from the EventBus when used in an EDEX instance, so handled in EdexBandwidthManager. * Jul 09, 2013 2106 djohnson Only needs to unregister from the EventBus when used in an EDEX instance, so handled in EdexBandwidthManager.
* Oct 03, 2013 2267 bgonzale Added check for no retrieval plan matching in the proposed retrieval plans. * Oct 03, 2013 2267 bgonzale Added check for no retrieval plan matching in the proposed retrieval plans.
* Jan 30, 2014 2686 dhladky refactor of retrieval. * Jan 30, 2014 2686 dhladky refactor of retrieval.
* Feb 10, 2014 2678 dhladky Prevent duplicate allocations.
* *
* </pre> * </pre>
* *
@ -53,7 +54,7 @@ public class RetrievalManager {
// Package-private on purpose so agents have visibility // Package-private on purpose so agents have visibility
static final BandwidthAllocation POISON_PILL = new BandwidthAllocation(); static final BandwidthAllocation POISON_PILL = new BandwidthAllocation();
private final IBandwidthDao bandwidthDao; private final IBandwidthDao bandwidthDao;
// A Map of the Paths to retrievalPlans // A Map of the Paths to retrievalPlans
@ -193,6 +194,32 @@ public class RetrievalManager {
} }
return null; return null;
} }
/***
* Method used in practice because we need to search for expired allocations.
* @param network
* @param agentType
* @return
*/
public List<BandwidthAllocation> getRecentAllocations(Network network, String agentType) {
List<BandwidthAllocation> allocations = null;
if (shutdown) {
allocations = new ArrayList<BandwidthAllocation>(1);
allocations.add(POISON_PILL);
return allocations;
}
RetrievalPlan plan = getRetrievalPlans().get(network);
if (plan != null) {
synchronized (plan) {
return plan.getRecentAllocations(agentType);
}
}
return allocations;
}
public final RetrievalPlan getPlan(Network network) { public final RetrievalPlan getPlan(Network network) {
return getRetrievalPlans().get(network); return getRetrievalPlans().get(network);
@ -288,4 +315,4 @@ public class RetrievalManager {
retrievalPlan.init(); retrievalPlan.init();
} }
} }
} }

View file

@ -1,5 +1,6 @@
package com.raytheon.uf.edex.datadelivery.bandwidth.retrieval; package com.raytheon.uf.edex.datadelivery.bandwidth.retrieval;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -50,6 +51,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* BandwidthReservations. Add constrained bucket addition method. * BandwidthReservations. Add constrained bucket addition method.
* Added debug logging. * Added debug logging.
* Jan 08, 2014 2615 bgonzale Log registry bandwidth calculation errors. * Jan 08, 2014 2615 bgonzale Log registry bandwidth calculation errors.
* Feb 10, 2014 2678 dhladky Prevent duplicate allocations.
* *
* </pre> * </pre>
* *
@ -388,6 +390,40 @@ public class RetrievalPlan {
return reservation; return reservation;
} }
/**
* Get the scheduled allocations from recent buckets
*
* @param agentType
*
* @return reservations
*/
public List<BandwidthAllocation> getRecentAllocations(String agentType) {
List<BandwidthAllocation> reservations = null;
synchronized (bucketsLock) {
// Get the portion of the Map that is before the
// current time (DO NOT want to return future reservations)
final List<BandwidthBucket> buckets = bucketsDao
.getWhereStartTimeIsLessThanOrEqualTo(
TimeUtil.currentTimeMillis(), network);
// Iterate over the buckets and find all
// BandwidthAllocation that are in the READY state
for (BandwidthBucket bucket : buckets) {
BandwidthAllocation allocationReservation = associator.getNextReservation(bucket, agentType);
if (allocationReservation != null) {
if (reservations == null) {
reservations = new ArrayList<BandwidthAllocation>();
}
reservations.add(allocationReservation);
}
}
}
return reservations;
}
public void updateRequestMapping(long requestId, public void updateRequestMapping(long requestId,
Set<BandwidthBucket> buckets) { Set<BandwidthBucket> buckets) {
@ -706,4 +742,4 @@ public class RetrievalPlan {
this.associator.copyState(fromPlan.associator); this.associator.copyState(fromPlan.associator);
} }
} }

View file

@ -1,3 +1,4 @@
/** /**
* *
*/ */
@ -6,6 +7,8 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.retrieval;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import com.raytheon.uf.common.datadelivery.registry.Network; import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Provider; import com.raytheon.uf.common.datadelivery.registry.Provider;
@ -55,6 +58,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.util.RetrievalGeneratorUtilit
* RetrievalTasks (PerformRetrievalsThenReturnFinder). * RetrievalTasks (PerformRetrievalsThenReturnFinder).
* Added constructor that sets the retrievalQueue to null. * Added constructor that sets the retrievalQueue to null.
* Jan 30, 2014 2686 dhladky refactor of retrieval. * Jan 30, 2014 2686 dhladky refactor of retrieval.
* Feb 10, 2014 2678 dhladky Prevent duplicate allocations.
* *
* </pre> * </pre>
* *
@ -86,59 +90,108 @@ public class SubscriptionRetrievalAgent extends
} }
@Override @Override
void processAllocation(SubscriptionRetrieval retrieval) void processAllocations(List<SubscriptionRetrieval> subRetrievals)
throws EdexException { throws EdexException {
Subscription<?, ?> sub;
try {
sub = bandwidthDao.getSubscriptionRetrievalAttributes(retrieval)
.getSubscription();
} catch (SerializationException e) {
throw new EdexException("Unable to deserialize the subscription.",
e);
}
final String originalSubName = sub.getName();
SubscriptionBundle bundle = new SubscriptionBundle(); SubscriptionBundle bundle = new SubscriptionBundle();
Provider provider = getProvider(sub.getProvider()); ConcurrentHashMap<Subscription<?, ?>, SubscriptionRetrieval> retrievalsMap = new ConcurrentHashMap<Subscription<?, ?>, SubscriptionRetrieval>();
if (provider == null) {
statusHandler.error("provider was null, skipping subscription ["
+ originalSubName + "]");
return;
}
bundle.setBundleId(sub.getSubscriptionId());
bundle.setPriority(retrieval.getPriority());
bundle.setProvider(provider);
bundle.setConnection(provider.getConnection());
bundle.setSubscription(sub);
retrieval.setActualStart(TimeUtil.newGmtCalendar()); // Get subs from allocations and search for duplicates
retrieval.setStatus(RetrievalStatus.RETRIEVAL); for (SubscriptionRetrieval subRetrieval : subRetrievals) {
// update database Subscription<?, ?> sub = null;
bandwidthDao.update(retrieval);
// generateRetrieval will pipeline the RetrievalRecord Objects created to the DB.
// The PK objects returned are sent to the RetrievalQueue for processing.
List<RetrievalRequestRecordPK> retrievals = generateRetrieval(bundle,
retrieval.getIdentifier());
if (!CollectionUtil.isNullOrEmpty(retrievals)) {
try { try {
Object[] payload = retrievals.toArray(); sub = bandwidthDao.getSubscriptionRetrievalAttributes(
RetrievalGeneratorUtilities.sendToRetrieval(destinationUri, subRetrieval).getSubscription();
network, payload); } catch (SerializationException e) {
} catch (Exception e) { throw new EdexException(
statusHandler.handle(Priority.PROBLEM, "Unable to deserialize the subscription.", e);
"Couldn't send RetrievalRecords to Queue!", e); }
// We only allow one subscription retrieval per DSM update.
// Remove any duplicate subscription allocations/retrievals, cancel them.
if (!retrievalsMap.containsKey(sub)) {
retrievalsMap.put(sub, subRetrieval);
} else {
// Check for most recent startTime, that's the one we want for
// retrieval.
SubscriptionRetrieval currentRetrieval = retrievalsMap.get(sub);
if (subRetrieval.getStartTime().getTime()
.after(currentRetrieval.getStartTime().getTime())) {
// Replace it in the map, set previous to canceled.
currentRetrieval.setStatus(RetrievalStatus.CANCELLED);
bandwidthDao.update(currentRetrieval);
retrievalsMap.replace(sub, subRetrieval);
statusHandler
.info("More recent, setting previous allocation to Cancelled ["
+ currentRetrieval.getIdentifier()
+ "] "
+ sub.getName());
} else {
// Not more recent, cancel
subRetrieval.setStatus(RetrievalStatus.CANCELLED);
bandwidthDao.update(subRetrieval);
statusHandler
.info("Older, setting to Cancelled ["
+ currentRetrieval.getIdentifier() + "] "
+ sub.getName());
}
}
}
for (Entry<Subscription<?, ?>, SubscriptionRetrieval> entry: retrievalsMap.entrySet()) {
SubscriptionRetrieval retrieval = entry.getValue();
Subscription<?, ?> sub = entry.getKey();
final String originalSubName = sub.getName();
Provider provider = getProvider(sub.getProvider());
if (provider == null) {
statusHandler
.error("provider was null, skipping subscription ["
+ originalSubName + "]");
return;
}
bundle.setBundleId(sub.getSubscriptionId());
bundle.setPriority(retrieval.getPriority());
bundle.setProvider(provider);
bundle.setConnection(provider.getConnection());
bundle.setSubscription(sub);
retrieval.setActualStart(TimeUtil.newGmtCalendar());
retrieval.setStatus(RetrievalStatus.RETRIEVAL);
// update database
bandwidthDao.update(retrieval);
// generateRetrieval will pipeline the RetrievalRecord Objects
// created to the DB.
// The PK objects returned are sent to the RetrievalQueue for
// processing.
List<RetrievalRequestRecordPK> retrievals = generateRetrieval(
bundle, retrieval.getIdentifier());
if (!CollectionUtil.isNullOrEmpty(retrievals)) {
try {
Object[] payload = retrievals.toArray();
RetrievalGeneratorUtilities.sendToRetrieval(destinationUri,
network, payload);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Couldn't send RetrievalRecords to Queue!", e);
}
statusHandler.info("Sent " + retrievals.size()
+ " retrievals to queue. " + network.toString());
} else {
// Normally this is the job of the SubscriptionNotifyTask, but
// if no
// retrievals were generated we have to send it manually
RetrievalManagerNotifyEvent retrievalManagerNotifyEvent = new RetrievalManagerNotifyEvent();
retrievalManagerNotifyEvent.setId(Long.toString(retrieval
.getId()));
EventBus.publish(retrievalManagerNotifyEvent);
} }
statusHandler.info("Sent " + retrievals.size()
+ " retrievals to queue. " + network.toString());
} else {
// Normally this is the job of the SubscriptionNotifyTask, but if no
// retrievals were generated we have to send it manually
RetrievalManagerNotifyEvent retrievalManagerNotifyEvent = new RetrievalManagerNotifyEvent();
retrievalManagerNotifyEvent.setId(Long.toString(retrieval.getId()));
EventBus.publish(retrievalManagerNotifyEvent);
} }
} }
@ -266,4 +319,4 @@ public class SubscriptionRetrievalAgent extends
} }
} }
} }

View file

@ -15,6 +15,7 @@
<!-- Fed from plugin notification --> <!-- Fed from plugin notification -->
<from uri="jms-durable:grid-staticdata-generate" /> <from uri="jms-durable:grid-staticdata-generate" />
<doTry> <doTry>
<bean ref="serializationUtil" method="transformFromThrift" />
<bean ref="staticDataGenerator" method="processNotification"/> <bean ref="staticDataGenerator" method="processNotification"/>
<to uri="direct-vm:stageNotification"/> <to uri="direct-vm:stageNotification"/>
<doCatch> <doCatch>