Merge "Issue #1769 Crashing FFMP caused by thread wait" into omaha_13.3.1
Former-commit-id:ed477e891e
[formerly483e2813ac
] [formerlyea6731947e
] [formerly41c7be5267
[formerlyea6731947e
[formerly 784852cf5045a32f94ba1923e9fadcd952d45dbb]]] Former-commit-id:41c7be5267
Former-commit-id: 3c83441ba78cd8de0509b446bbd7dc77463041fe [formerly32221a7a7a
] Former-commit-id:be87f2adc3
This commit is contained in:
commit
ec43f5c022
4 changed files with 47 additions and 53 deletions
|
@ -92,6 +92,7 @@ import com.raytheon.uf.viz.monitor.listeners.IMonitorListener;
|
|||
* 02/01/13 1627 D. Hladky removed unused(useless) db load method
|
||||
* 02/19/13 1639 njensen Replaced ConcurrentHashMaps with data structures
|
||||
* 02/20/13 1635 D. Hladky Fixed multi guidance sources
|
||||
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
|
|
@ -20,12 +20,14 @@
|
|||
package com.raytheon.uf.viz.monitor.ffmp.ui.rsc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPAggregateRecord;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord;
|
||||
|
@ -64,6 +66,7 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.listeners.FFMPLoaderEvent;
|
|||
* 01/27/13 1478 D. Hladky revamped the cache file format to help NAS overloading
|
||||
* 02/01/13 1569 D. Hladky Changed to reading aggregate records from pypies
|
||||
* Feb 28, 2013 1729 dhladky Changed the way status messages are sent to the FFMP Dialog.
|
||||
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -81,8 +84,6 @@ public class FFMPDataLoader extends Thread {
|
|||
|
||||
private Date mostRecentTime = null;
|
||||
|
||||
public boolean isDone = false;
|
||||
|
||||
public LOADER_TYPE loadType = null;
|
||||
|
||||
private String siteKey = null;
|
||||
|
@ -99,6 +100,8 @@ public class FFMPDataLoader extends Thread {
|
|||
|
||||
private ArrayList<FFMPLoadListener> loadListeners = new ArrayList<FFMPLoadListener>();
|
||||
|
||||
private CountDownLatch latch;
|
||||
|
||||
public FFMPDataLoader(FFMPResourceData resourceData, Date timeBack,
|
||||
Date mostRecentTime, LOADER_TYPE loadType,
|
||||
ArrayList<String> hucsToLoad) {
|
||||
|
@ -114,6 +117,7 @@ public class FFMPDataLoader extends Thread {
|
|||
this.resourceData = resourceData;
|
||||
this.runner = FFMPRunConfigurationManager.getInstance().getRunner(wfo);
|
||||
this.config = FFMPConfig.getInstance();
|
||||
this.latch = new CountDownLatch(1);
|
||||
|
||||
if ((loadType == LOADER_TYPE.INITIAL)
|
||||
|| (loadType == LOADER_TYPE.GENERAL)) {
|
||||
|
@ -123,6 +127,10 @@ public class FFMPDataLoader extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
public void waitFor() throws InterruptedException {
|
||||
latch.await();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add listener
|
||||
*
|
||||
|
@ -143,7 +151,7 @@ public class FFMPDataLoader extends Thread {
|
|||
|
||||
// kills the loader
|
||||
public void kill() {
|
||||
isDone = true;
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -229,23 +237,23 @@ public class FFMPDataLoader extends Thread {
|
|||
hucsToLoad.add(FFMPRecord.ALL);
|
||||
}
|
||||
|
||||
if (isDone) {
|
||||
if (isDone()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// rate
|
||||
if (rateURI != null) {
|
||||
fireLoaderEvent(loadType, "Processing " + product.getRate(),
|
||||
isDone);
|
||||
isDone());
|
||||
for (String phuc : hucsToLoad) {
|
||||
monitor.processUri(isProductLoad, rateURI, siteKey,
|
||||
product.getRate(), timeBack, phuc);
|
||||
}
|
||||
fireLoaderEvent(loadType, product.getRate(), isDone);
|
||||
fireLoaderEvent(loadType, product.getRate(), isDone());
|
||||
}
|
||||
|
||||
// qpes
|
||||
fireLoaderEvent(loadType, "Processing " + product.getQpe(), isDone);
|
||||
fireLoaderEvent(loadType, "Processing " + product.getQpe(), isDone());
|
||||
FFMPAggregateRecord qpeCache = null;
|
||||
|
||||
if (loadType == LOADER_TYPE.INITIAL) {
|
||||
|
@ -272,13 +280,13 @@ public class FFMPDataLoader extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
fireLoaderEvent(loadType, product.getQpe(), isDone);
|
||||
fireLoaderEvent(loadType, product.getQpe(), isDone());
|
||||
|
||||
int i = 0;
|
||||
for (NavigableMap<Date, List<String>> qpfURIs : qpfs) {
|
||||
// qpf
|
||||
fireLoaderEvent(loadType, "Processing " + product.getQpf(i),
|
||||
isDone);
|
||||
isDone());
|
||||
FFMPAggregateRecord qpfCache = null;
|
||||
|
||||
if (loadType == LOADER_TYPE.INITIAL) {
|
||||
|
@ -329,13 +337,13 @@ public class FFMPDataLoader extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
fireLoaderEvent(loadType, product.getQpf(i), isDone);
|
||||
fireLoaderEvent(loadType, product.getQpf(i), isDone());
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
fireLoaderEvent(loadType, "Processing " + product.getVirtual(),
|
||||
isDone);
|
||||
isDone());
|
||||
FFMPAggregateRecord vgbCache = null;
|
||||
|
||||
if (loadType == LOADER_TYPE.INITIAL) {
|
||||
|
@ -358,7 +366,7 @@ public class FFMPDataLoader extends Thread {
|
|||
product.getVirtual(), timeBack, FFMPRecord.ALL);
|
||||
}
|
||||
|
||||
fireLoaderEvent(loadType, product.getVirtual(), isDone);
|
||||
fireLoaderEvent(loadType, product.getVirtual(), isDone());
|
||||
|
||||
// process guidance all for all only, never uses cache files
|
||||
for (String type : productRun.getGuidanceTypes(product)) {
|
||||
|
@ -371,20 +379,20 @@ public class FFMPDataLoader extends Thread {
|
|||
.get(guidSource.getSourceName());
|
||||
|
||||
fireLoaderEvent(loadType,
|
||||
"Processing " + guidSource.getSourceName(), isDone);
|
||||
"Processing " + guidSource.getSourceName(), isDone());
|
||||
|
||||
monitor.processUris(iguidURIs, isProductLoad, siteKey,
|
||||
guidSource.getSourceName(), timeBack, FFMPRecord.ALL);
|
||||
|
||||
fireLoaderEvent(loadType, guidSource.getSourceName(),
|
||||
isDone);
|
||||
isDone());
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,"General Problem in Loading FFMP Data", e);
|
||||
} finally {
|
||||
isDone = true;
|
||||
latch.countDown();
|
||||
synchronized(this) {
|
||||
this.notifyAll();
|
||||
}
|
||||
|
@ -399,7 +407,7 @@ public class FFMPDataLoader extends Thread {
|
|||
|
||||
long endTime = (System.currentTimeMillis()) - time;
|
||||
System.out.println(loadType.loaderType + " Loader took: " + endTime / 1000 + " seconds");
|
||||
fireLoaderEvent(loadType, message, isDone);
|
||||
fireLoaderEvent(loadType, message, isDone());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -427,7 +435,7 @@ public class FFMPDataLoader extends Thread {
|
|||
if (FFMPMonitor.isRunning()) {
|
||||
return FFMPMonitor.getInstance();
|
||||
} else {
|
||||
isDone = true;
|
||||
latch.countDown();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -520,4 +528,8 @@ public class FFMPDataLoader extends Thread {
|
|||
+ pdataKey;
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
return latch.getCount() == 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -162,6 +162,7 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* Feb 19, 2013 1639 njensen Replaced FFMPCacheRecord with FFMPRecord
|
||||
* Feb 20, 2013 1635 dhladky Fixed multiple guidance display
|
||||
* Feb 28, 2013 1729 dhladky Changed the way the loaders are managed via the status updates.
|
||||
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -475,29 +476,21 @@ public class FFMPResource extends
|
|||
.getDataTime().getRefTime(),
|
||||
LOADER_TYPE.GENERAL);
|
||||
} else {
|
||||
while (!loader.isDone) {
|
||||
try {
|
||||
synchronized (loader) {
|
||||
loader.wait(1000);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Data Loader thread interrupted, dying!", e);
|
||||
}
|
||||
try {
|
||||
loader.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
startLoader(previousMostRecentTime, ffmpRec
|
||||
.getDataTime().getRefTime(),
|
||||
LOADER_TYPE.GENERAL);
|
||||
}
|
||||
|
||||
while (!loader.isDone) {
|
||||
try {
|
||||
synchronized (loader) {
|
||||
loader.wait();
|
||||
}
|
||||
loader.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Data Loader thread interrupted, dying!", e);
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1228,7 +1221,7 @@ public class FFMPResource extends
|
|||
FFMPDrawable drawable = null;
|
||||
|
||||
if (paintTime != null) {
|
||||
if (loader != null && !loader.isDone
|
||||
if (loader != null && !loader.isDone()
|
||||
&& loader.loadType == LOADER_TYPE.GENERAL) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPConfigBasinXML;
|
|||
* 02/01/13 1569 D. Hladky Added constants
|
||||
* Feb 10, 2013 1584 mpduff Add performance logging.
|
||||
* Feb 28, 2013 1729 dhladky Got rid of thread sleeps
|
||||
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -258,25 +259,12 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
|
|||
hucsToLoad);
|
||||
loader.start();
|
||||
|
||||
int i = 0;
|
||||
// make the table load wait for finish of initial data load
|
||||
while (!loader.isDone) {
|
||||
try {
|
||||
// give it 120 or so seconds
|
||||
if (i > 4000) {
|
||||
statusHandler
|
||||
.handle(Priority.WARN,
|
||||
"Didn't load initial data in allotted time, releasing table");
|
||||
break;
|
||||
}
|
||||
synchronized (loader) {
|
||||
loader.wait(1000);
|
||||
}
|
||||
i++;
|
||||
} catch (InterruptedException e) {
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Data Loader thread interrupted, dying!", e);
|
||||
}
|
||||
try {
|
||||
loader.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
statusHandler.handle(Priority.INFO,
|
||||
"Data Loader thread interrupted, dying!", e);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue