Merge "Issue #1647 Apply WMO header, increase frequency of bandwidth manager tasks" into development
Former-commit-id:90b18cc477
[formerly fdb6fdd88c80e1f9d33c5d0b72aca389910599ed] Former-commit-id:2262872d2d
This commit is contained in:
commit
def94b337f
20 changed files with 317 additions and 40 deletions
|
@ -3,6 +3,8 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.retrieval;
|
|||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.edex.core.EdexException;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
||||
|
||||
|
@ -19,6 +21,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
|||
* Oct 11, 2012 0726 djohnson Add SW history, use generics,
|
||||
* separate work method from loop control.
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -29,7 +32,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.BandwidthAllocation;
|
|||
public abstract class RetrievalAgent<ALLOCATION_TYPE extends BandwidthAllocation>
|
||||
extends Thread {
|
||||
|
||||
private static final int SLEEP_TIME = 300000;
|
||||
private static final long SLEEP_TIME = TimeUtil.MILLIS_PER_MINUTE;
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(RetrievalAgent.class);
|
||||
|
@ -122,7 +125,8 @@ public abstract class RetrievalAgent<ALLOCATION_TYPE extends BandwidthAllocation
|
|||
|
||||
notifier.wait(SLEEP_TIME);
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Interrupted while waiting for notification.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
<bean id="crawlerCommunicationStrategy" class="com.raytheon.uf.edex.datadelivery.harvester.crawler.FileCommunicationStrategy" />
|
||||
|
||||
<bean id="MetaDataProcessor" class="com.raytheon.uf.edex.datadelivery.harvester.CrawlMetaDataHandler" depends-on="registryInit,registerDataDeliveryHandlers">
|
||||
<bean id="MetaDataProcessor" class="com.raytheon.uf.edex.datadelivery.harvester.CrawlMetaDataHandler" depends-on="registryInit,registerDataDeliveryHandlers,registryManagerInstanceInitializer">
|
||||
<constructor-arg ref="crawlerCommunicationStrategy" />
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="res"/>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -30,7 +30,8 @@ Require-Bundle: com.raytheon.uf.common.status;bundle-version="1.12.1174",
|
|||
com.raytheon.uf.common.dataplugin.grid;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.parameter;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.event;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.stats;bundle-version="1.0.0"
|
||||
com.raytheon.uf.common.stats;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.decodertools;bundle-version="1.12.1174"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.edex.datadelivery.retrieval;
|
||||
|
|
|
@ -21,7 +21,12 @@
|
|||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.SerializeRetrievedDataToDirectory">
|
||||
<constructor-arg value="/awips2/crawl" />
|
||||
<constructor-arg value="${sbn.retrieval.transfer.directory}" />
|
||||
<constructor-arg>
|
||||
<bean class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.AlwaysSameWmoHeader">
|
||||
<constructor-arg value="${sbn.retrieval.transfer.wmo.header}" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<constructor-arg>
|
||||
<bean
|
||||
class="com.raytheon.uf.edex.datadelivery.retrieval.handlers.DeserializeRetrievedDataFromDirectory">
|
||||
<constructor-arg value="/awips2/crawl" />
|
||||
<constructor-arg value="${sbn.retrieval.transfer.directory}" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<constructor-arg>
|
||||
|
|
|
@ -32,6 +32,20 @@
|
|||
<constructor-arg ref="retrievalDao" />
|
||||
<constructor-arg ref="retrievalTaskList" />
|
||||
<constructor-arg ref="subNotifyTask" />
|
||||
<!-- How often to execute the retrieval tasks -->
|
||||
<constructor-arg>
|
||||
<bean class="com.raytheon.uf.common.time.domain.Durations"
|
||||
factory-method="fromString">
|
||||
<constructor-arg value="${retrieval.task.frequency}" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
<!-- How often to execute the subscription notify tasks -->
|
||||
<constructor-arg>
|
||||
<bean class="com.raytheon.uf.common.time.domain.Durations"
|
||||
factory-method="fromString">
|
||||
<constructor-arg value="${subnotify.task.frequency}" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<camelContext id="dataDeliveryNotify-camel"
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
sbn.retrieval.transfer.directory=/awips2/crawl
|
||||
# TODO: What WMO Header should be used for SBN retrievals?
|
||||
# The one below is just a random one to get things working...
|
||||
sbn.retrieval.transfer.wmo.header=SMYG10 LYBM 280000
|
||||
# How often to check for retrievals to process
|
||||
# Valid units: [MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS]
|
||||
retrieval.task.frequency=1 MINUTES
|
||||
# How often to check for retrieved subscriptions to notify of
|
||||
# Valid units: [MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS]
|
||||
subnotify.task.frequency=1 MINUTES
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* 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.retrieval.handlers;
|
||||
|
||||
/**
|
||||
* Applies a WMO header that is always the same.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 04, 2013 1647 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AlwaysSameWmoHeader implements IWmoHeaderApplier {
|
||||
|
||||
private final String wmoHeader;
|
||||
|
||||
public AlwaysSameWmoHeader(String wmoHeader) {
|
||||
this.wmoHeader = wmoHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String applyWmoHeader(String data) {
|
||||
return wmoHeader + "\n" + data;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,10 +24,13 @@ import java.io.FileFilter;
|
|||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import com.raytheon.edex.esb.Headers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Coverage;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDapRetrievalResponse;
|
||||
import com.raytheon.uf.edex.wmo.message.WMOMessage;
|
||||
|
||||
/**
|
||||
* Deserializes the retrieved data in a directory.
|
||||
|
@ -39,14 +42,14 @@ import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDapRetrievalRespo
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Mar 05, 2013 1647 djohnson Remove WMO header.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DeserializeRetrievedDataFromDirectory implements
|
||||
IRetrievalsFinder {
|
||||
public class DeserializeRetrievedDataFromDirectory implements IRetrievalsFinder {
|
||||
|
||||
private static final FileFilter NO_DIRECTORIES = new FileFilter() {
|
||||
@Override
|
||||
|
@ -65,8 +68,7 @@ public class DeserializeRetrievedDataFromDirectory implements
|
|||
public DeserializeRetrievedDataFromDirectory(File directory) {
|
||||
this.directory = directory;
|
||||
try {
|
||||
this.jaxbManager = new JAXBManager(
|
||||
RetrievalResponseXml.class,
|
||||
this.jaxbManager = new JAXBManager(RetrievalResponseXml.class,
|
||||
OpenDapRetrievalResponse.class, Coverage.class);
|
||||
} catch (JAXBException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
|
@ -78,8 +80,7 @@ public class DeserializeRetrievedDataFromDirectory implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RetrievalResponseXml findRetrievals()
|
||||
throws Exception {
|
||||
public RetrievalResponseXml findRetrievals() throws Exception {
|
||||
|
||||
final File[] files = directory.listFiles(NO_DIRECTORIES);
|
||||
|
||||
|
@ -89,8 +90,10 @@ public class DeserializeRetrievedDataFromDirectory implements
|
|||
|
||||
final File file = files[0];
|
||||
try {
|
||||
WMOMessage message = new WMOMessage(FileUtil.file2bytes(file),
|
||||
new Headers());
|
||||
return (RetrievalResponseXml) jaxbManager
|
||||
.jaxbUnmarshalFromXmlFile(file);
|
||||
.unmarshalFromXml(new String(message.getMessageBody()));
|
||||
} finally {
|
||||
file.delete();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* 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.retrieval.handlers;
|
||||
|
||||
/**
|
||||
* Apply a WMO compliant header to text data.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 04, 2013 1647 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IWmoHeaderApplier {
|
||||
|
||||
/**
|
||||
* Apply a WMO compliant header.
|
||||
*
|
||||
* @param data
|
||||
* the data
|
||||
* @return the data with a WMO compliant header
|
||||
*/
|
||||
String applyWmoHeader(final String data);
|
||||
|
||||
}
|
|
@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.time.domain.api.IDuration;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
|
||||
/**
|
||||
|
@ -41,6 +42,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 07, 2011 dhladky Initial creation
|
||||
* Aug 09, 2012 1022 djohnson Use {@link ExecutorService} for retrieval.
|
||||
* Mar 04, 2013 1647 djohnson RetrievalTasks are now scheduled via constructor parameter.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,28 +59,26 @@ public class RetrievalHandler {
|
|||
|
||||
private final List<RetrievalTask> retrievalTasks;
|
||||
|
||||
private final SubscriptionNotifyTask subNotifyTask;
|
||||
|
||||
public RetrievalHandler(ScheduledExecutorService executorService,
|
||||
IRetrievalDao retrievalDao, List<RetrievalTask> retrievalTasks,
|
||||
SubscriptionNotifyTask subNotifyTask) {
|
||||
SubscriptionNotifyTask subNotifyTask,
|
||||
IDuration retrievalTaskFrequency, IDuration subnotifyTaskFrequency) {
|
||||
this.executorService = executorService;
|
||||
this.retrievalTasks = retrievalTasks;
|
||||
this.subNotifyTask = subNotifyTask;
|
||||
|
||||
// set all Running state retrievals to pending
|
||||
retrievalDao.resetRunningRetrievalsToPending();
|
||||
|
||||
for (RetrievalTask retrievalTask : retrievalTasks) {
|
||||
executorService.scheduleWithFixedDelay(retrievalTask, 1, 5,
|
||||
TimeUnit.MINUTES);
|
||||
executorService.scheduleWithFixedDelay(retrievalTask, 1,
|
||||
retrievalTaskFrequency.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
executorService.scheduleWithFixedDelay(subNotifyTask, 1, 1,
|
||||
TimeUnit.MINUTES);
|
||||
executorService.scheduleWithFixedDelay(subNotifyTask, 1,
|
||||
subnotifyTaskFrequency.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void notify(List<String> subscriptions) {
|
||||
statusHandler.info("Notifying that subscriptions are available.");
|
||||
statusHandler.debug("Notifying that subscriptions are available.");
|
||||
|
||||
for (RetrievalTask retrievalTask : retrievalTasks) {
|
||||
executorService.execute(retrievalTask);
|
||||
|
|
|
@ -22,6 +22,7 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
|
|||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
||||
|
||||
|
@ -40,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
|||
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
|
||||
* Jan 30, 2013 1543 djohnson Constrain to the network retrievals are pulled for.
|
||||
* Feb 15, 2013 1543 djohnson Using xml for retrievals now.
|
||||
* Mar 05, 2013 1647 djohnson Change no retrievals found message to debug.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -88,8 +90,10 @@ public class RetrievalTask implements Runnable {
|
|||
// This forces the return from the while loop once there are
|
||||
// no more retrievals to process
|
||||
if (retrievalPluginDataObject == null) {
|
||||
statusHandler.info("No " + network
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug("No " + network
|
||||
+ " retrievals found.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDapRetrievalRespo
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 15, 2013 1543 djohnson Serialize data out as XML.
|
||||
* Mar 05, 2013 1647 djohnson Apply WMO header.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,11 +55,15 @@ public class SerializeRetrievedDataToDirectory implements
|
|||
|
||||
private final File targetDirectory;
|
||||
|
||||
private final IWmoHeaderApplier wmoHeaderWrapper;
|
||||
|
||||
/**
|
||||
* @param directory
|
||||
*/
|
||||
public SerializeRetrievedDataToDirectory(File directory) {
|
||||
public SerializeRetrievedDataToDirectory(File directory,
|
||||
IWmoHeaderApplier wmoHeaderWrapper) {
|
||||
this.targetDirectory = directory;
|
||||
this.wmoHeaderWrapper = wmoHeaderWrapper;
|
||||
try {
|
||||
this.jaxbManager = new JAXBManager(RetrievalResponseXml.class,
|
||||
OpenDapRetrievalResponse.class, Coverage.class);
|
||||
|
@ -81,7 +86,9 @@ public class SerializeRetrievedDataToDirectory implements
|
|||
.toString());
|
||||
final String xml = jaxbManager
|
||||
.marshalToXml(retrievalPluginDataObjects);
|
||||
FileUtil.bytes2File(xml.getBytes(), output);
|
||||
final String textForFile = wmoHeaderWrapper.applyWmoHeader(xml);
|
||||
|
||||
FileUtil.bytes2File(textForFile.getBytes(), output);
|
||||
} catch (Exception e) {
|
||||
throw new SerializationException(e);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
|
|||
* Oct 10, 2012 0726 djohnson Use the subRetrievalKey for notifying the retrieval manager.
|
||||
* Nov 25, 2012 1268 dhladky Added additional fields to process subscription tracking
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* Mar 05, 2013 1647 djohnson Debug log running message.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -215,7 +216,7 @@ public class SubscriptionNotifyTask implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
statusHandler.info("SubscriptionNotifyTask() - Running...");
|
||||
statusHandler.debug("SubscriptionNotifyTask() - Running...");
|
||||
try {
|
||||
SubscriptionDelay nextSub = subscriptionQueue.peek();
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* 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.retrieval.handlers;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.edex.esb.Headers;
|
||||
import com.raytheon.uf.edex.wmo.message.WMOHeader;
|
||||
import com.raytheon.uf.edex.wmo.message.WMOMessage;
|
||||
|
||||
/**
|
||||
* Test {@link AlwaysSameWmoHeader}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 04, 2013 1647 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class AlwaysSameWmoHeaderTest {
|
||||
|
||||
private static final AlwaysSameWmoHeader WRAPPER = new AlwaysSameWmoHeader(
|
||||
"SMYG10 LYBM 280000");
|
||||
|
||||
private static final String wrapped = WRAPPER.applyWmoHeader("someData");
|
||||
|
||||
private static WMOMessage message;
|
||||
|
||||
private static WMOHeader wmoHeader;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
message = new WMOMessage(wrapped, new Headers());
|
||||
wmoHeader = message.getWmoHeader();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsValidWmoHeader() {
|
||||
assertThat(wmoHeader.isValid(), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableT1() {
|
||||
assertThat(wmoHeader.getT1(), is(equalTo('S')));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableT2() {
|
||||
assertThat(wmoHeader.getT2(), is(equalTo('M')));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableA1() {
|
||||
assertThat(wmoHeader.getA1(), is(equalTo('Y')));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableA2() {
|
||||
assertThat(wmoHeader.getA2(), is(equalTo('G')));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableIi() {
|
||||
assertThat(wmoHeader.getIi(), is(equalTo(10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableCCCC() {
|
||||
assertThat(wmoHeader.getCccc(), is(equalTo("LYBM")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableYYGGgg() {
|
||||
assertThat(wmoHeader.getYYGGgg(), is(equalTo("280000")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsParseableMessage() {
|
||||
assertThat(message.getMessageBody(), is(equalTo("someData".getBytes())));
|
||||
}
|
||||
}
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.common.util.TestUtil;
|
|||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 12, 2013 1543 djohnson Can only test the retrieval response is now not null.
|
||||
* Feb 15, 2013 1543 djohnson Some renames.
|
||||
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -70,7 +71,8 @@ public class DeserializeRetrievedDataFromDirectoryTest {
|
|||
RetrievalResponseXml retrievalPluginDataObjects = RetrievalPluginDataObjectsFixture.INSTANCE
|
||||
.get();
|
||||
|
||||
new SerializeRetrievedDataToDirectory(directory)
|
||||
new SerializeRetrievedDataToDirectory(directory,
|
||||
new AlwaysSameWmoHeader("SMYG10 LYBM 280000"))
|
||||
.processRetrievedPluginDataObjects(retrievalPluginDataObjects);
|
||||
|
||||
final RetrievalResponseXml restored = service
|
||||
|
@ -88,7 +90,8 @@ public class DeserializeRetrievedDataFromDirectoryTest {
|
|||
RetrievalResponseXml retrievalPluginDataObjects = RetrievalPluginDataObjectsFixture.INSTANCE
|
||||
.get();
|
||||
|
||||
new SerializeRetrievedDataToDirectory(directory)
|
||||
new SerializeRetrievedDataToDirectory(directory,
|
||||
new AlwaysSameWmoHeader("SMYG10 LYBM 280000"))
|
||||
.processRetrievedPluginDataObjects(retrievalPluginDataObjects);
|
||||
|
||||
service.findRetrievals();
|
||||
|
|
|
@ -29,6 +29,8 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.time.domain.Durations;
|
||||
import com.raytheon.uf.common.time.domain.api.IDuration;
|
||||
import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
||||
|
||||
/**
|
||||
|
@ -46,6 +48,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
|||
* Jan 30, 2013 1543 djohnson RetrievalTask now requires a Network.
|
||||
* Feb 05, 2013 1580 mpduff EventBus refactor.
|
||||
* Feb 07, 2013 1543 djohnson Move test to its proper test class, as per peer review comments.
|
||||
* Mar 04, 2013 1647 djohnson RetrievalTasks are now scheduled via constructor parameter.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -55,6 +58,12 @@ import com.raytheon.uf.edex.datadelivery.retrieval.db.IRetrievalDao;
|
|||
|
||||
public class RetrievalHandlerTest {
|
||||
|
||||
private static final IDuration RETRIEVAL_TASK_FREQUENCY = Durations.of(5,
|
||||
TimeUnit.MINUTES);
|
||||
|
||||
private static final IDuration SUBNOTIFY_TASK_FREQUENCY = Durations.of(1,
|
||||
TimeUnit.MINUTES);
|
||||
|
||||
private final ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
|
||||
|
||||
private final IRetrievalDao mockDao = mock(IRetrievalDao.class);
|
||||
|
@ -63,11 +72,9 @@ public class RetrievalHandlerTest {
|
|||
|
||||
private final SubscriptionNotifyTask subNotifyTask = mock(SubscriptionNotifyTask.class);
|
||||
|
||||
private final IRetrievalResponseCompleter retrievalCompleter = mock(IRetrievalResponseCompleter.class);
|
||||
|
||||
private final RetrievalHandler handler = new RetrievalHandler(
|
||||
executorService, mockDao, Arrays.asList(retrievalTask),
|
||||
subNotifyTask);
|
||||
subNotifyTask, RETRIEVAL_TASK_FREQUENCY, SUBNOTIFY_TASK_FREQUENCY);
|
||||
|
||||
@Test
|
||||
public void testAllRunningRetrievalsAreResetToPendingOnConstruction() {
|
||||
|
@ -82,14 +89,14 @@ public class RetrievalHandlerTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRetrievalTaskIsScheduledEveryFiveMinutesWithInitialDelayOfOneMinute() {
|
||||
verify(executorService).scheduleWithFixedDelay(retrievalTask, 1, 5,
|
||||
TimeUnit.MINUTES);
|
||||
public void testRetrievalTaskIsScheduledPerConstructorParameter() {
|
||||
verify(executorService).scheduleWithFixedDelay(retrievalTask, 1,
|
||||
RETRIEVAL_TASK_FREQUENCY.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionNotifyTaskIsScheduledEveryMinuteWithInitialDelayOfOneMinute() {
|
||||
verify(executorService).scheduleWithFixedDelay(subNotifyTask, 1, 1,
|
||||
TimeUnit.MINUTES);
|
||||
public void testSubscriptionNotifyTaskIsScheduledPerConstructorParameter() {
|
||||
verify(executorService).scheduleWithFixedDelay(subNotifyTask, 1,
|
||||
SUBNOTIFY_TASK_FREQUENCY.getMillis(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse
|
|||
* Feb 07, 2013 1543 djohnson Add test to simulate SBN retrieval task behavior.
|
||||
* Feb 12, 2013 1543 djohnson Retrieval responses are now sent further down the chain.
|
||||
* Feb 15, 2013 1543 djohnson Class renames.
|
||||
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -223,7 +224,8 @@ public class RetrievalTaskTest {
|
|||
final File testDirectory = TestUtil
|
||||
.setupTestClassDir(RetrievalTaskTest.class);
|
||||
IRetrievalPluginDataObjectsProcessor serializeToDirectory = new SerializeRetrievedDataToDirectory(
|
||||
testDirectory);
|
||||
testDirectory, new AlwaysSameWmoHeader(
|
||||
"SMYG10 LYBM 280000"));
|
||||
|
||||
RetrievalTask downloadTask = new RetrievalTask(Network.OPSNET,
|
||||
retrievalDataFinder, serializeToDirectory,
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.raytheon.uf.common.util.TestUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 01, 2013 1543 djohnson Initial creation
|
||||
* Feb 15, 2013 1543 djohnson Class renames.
|
||||
* Mar 05, 2013 1647 djohnson Pass wmo header strategy to constructor.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,7 +55,7 @@ public class SerializeRetrievedDataToDirectoryTest {
|
|||
.setupTestClassDir(SerializeRetrievedDataToDirectoryTest.class);
|
||||
|
||||
private final SerializeRetrievedDataToDirectory service = new SerializeRetrievedDataToDirectory(
|
||||
directory);
|
||||
directory, new AlwaysSameWmoHeader("SMYG10 LYBM 280000"));
|
||||
|
||||
@BeforeClass
|
||||
public static void classSetUp() {
|
||||
|
|
Loading…
Add table
Reference in a new issue