Issue #3332 Fixed race condition which could cause GFE grid saving to hang

Change-Id: I4a2ef9e25999d95ac1ecf204907c59b2f1e85652

Former-commit-id: b01b72b896b894568acce6a8dc4d45328a06067a
This commit is contained in:
Ron Anderson 2014-07-09 08:56:06 -05:00
parent 89c0457b1d
commit 5efba03474
2 changed files with 25 additions and 13 deletions

View file

@ -54,6 +54,7 @@ import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DByte;
import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat;
import com.raytheon.uf.common.dataplugin.gfe.grid.Op;
import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.Lock;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable.LockMode;
import com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable.LockStatus;
@ -185,6 +186,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Apr 02, 2013 #1774 randerso Fixed a possible deadlock issue.
* Aug 27, 2013 #2302 randerso Fix simultaneous save issue
* Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys()
* Jun 30, 2014 #3332 randerso Kept local reference to lock table to avoid
* race conditions with asynchronous updates
*
* </pre>
*
@ -619,21 +622,19 @@ public abstract class Parm implements Comparable<Parm> {
return new TimeRange();
}
if (!isMutable()) {
return getInventorySpan();
}
TimeRange tr = getInventorySpan();
TimeRange tr = new TimeRange();
if (lockTable != null) {
if (lockTable.getLocks().size() > 0) {
tr = lockTable.getLocks().get(0).getTimeRange();
}
for (int i = 1; i < lockTable.getLocks().size(); i++) {
tr = tr.combineWith(lockTable.getLocks().get(i).getTimeRange());
if (isMutable()) {
LockTable lt = this.lockTable;
if (lt != null) {
List<Lock> locks = lt.getLocks();
for (Lock lock : locks) {
tr = tr.combineWith(lock.getTimeRange());
}
}
}
return tr.combineWith(getInventorySpan());
return tr;
}
/**

View file

@ -28,6 +28,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.TimeRange;
/**
@ -40,6 +42,7 @@ import com.raytheon.uf.common.time.TimeRange;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 27, 2013 #2302 randerso Initial creation
* Jun 30, 2014 #3332 randerso Added exception handling
*
* </pre>
*
@ -48,6 +51,9 @@ import com.raytheon.uf.common.time.TimeRange;
*/
public class ParmSaveJob extends Job {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ParmSaveJob.class);
public static class ParmSaveStatus {
boolean successful = false;
@ -127,8 +133,13 @@ public class ParmSaveJob extends Job {
protected IStatus run(IProgressMonitor monitor) {
ParmSaveRequest req = null;
while ((req = this.saveQueue.poll()) != null) {
boolean successful = parm.saveParameterSubClass(req.times);
req.status.setSuccessful(successful);
try {
boolean successful = parm.saveParameterSubClass(req.times);
req.status.setSuccessful(successful);
} catch (Exception e) {
statusHandler.error("Error saving grids for " + this.parm, e);
req.status.setSuccessful(false);
}
}
return Status.OK_STATUS;
}