Merge "Issue #1164 Revereted Friedman changes to time matcher over last 5 months. Fixed original issues for DRs 14699 and 15160 by getting rid of setTimeList on AbstractTimeMatcher and instead calling redoTimeMatching when a resource is added. Also made time matching happen in job when resource is removed." into development
Former-commit-id:89fb0a5bee
[formerly 9b20aae000c7d4ac25dada94390eb3e8d70a6cc9] Former-commit-id:bb68c93607
This commit is contained in:
commit
50c95b06f9
5 changed files with 42 additions and 161 deletions
|
@ -105,18 +105,6 @@ public abstract class AbstractTimeMatcher {
|
||||||
DataTime[] availableTimes, IDescriptor descriptor)
|
DataTime[] availableTimes, IDescriptor descriptor)
|
||||||
throws VizException;
|
throws VizException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the matched list of times to a particular resource
|
|
||||||
*
|
|
||||||
* @param dataTimes
|
|
||||||
* @param rsc
|
|
||||||
* @param descriptor
|
|
||||||
* @throws VizException
|
|
||||||
*/
|
|
||||||
public abstract void setTimeList(DataTime[] dataTimes,
|
|
||||||
AbstractVizResource<?, ?> rsc, IDescriptor descriptor)
|
|
||||||
throws VizException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a list of RenderableDisplays, determine the order to instantiate
|
* Given a list of RenderableDisplays, determine the order to instantiate
|
||||||
* them in to get the correct time match settings, should only be called
|
* them in to get the correct time match settings, should only be called
|
||||||
|
|
|
@ -64,6 +64,7 @@ import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||||
import com.raytheon.uf.viz.core.rsc.IResourceGroup;
|
import com.raytheon.uf.viz.core.rsc.IResourceGroup;
|
||||||
import com.raytheon.uf.viz.core.rsc.ResourceGroup;
|
import com.raytheon.uf.viz.core.rsc.ResourceGroup;
|
||||||
import com.raytheon.uf.viz.core.rsc.ResourceList;
|
import com.raytheon.uf.viz.core.rsc.ResourceList;
|
||||||
|
import com.raytheon.uf.viz.core.time.TimeMatchingJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractDescriptor
|
* AbstractDescriptor
|
||||||
|
@ -192,33 +193,37 @@ public abstract class AbstractDescriptor extends ResourceGroup implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basis != newBasis) {
|
if (basis != newBasis) {
|
||||||
redoTimeMatching();
|
TimeMatchingJob.scheduleTimeMatch(AbstractDescriptor.this);
|
||||||
|
if (renderableDisplay != null
|
||||||
|
&& renderableDisplay.getContainer() != null) {
|
||||||
|
IDisplayPaneContainer container = renderableDisplay.getContainer();
|
||||||
|
for (IDisplayPane pane : container.getDisplayPanes()) {
|
||||||
|
if (pane.getDescriptor() != AbstractDescriptor.this) {
|
||||||
|
TimeMatchingJob.scheduleTimeMatch(pane.getDescriptor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void redoTimeMatching() throws VizException {
|
|
||||||
if (getTimeMatcher() != null) {
|
|
||||||
getTimeMatcher().redoTimeMatching(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (renderableDisplay != null
|
|
||||||
&& renderableDisplay.getContainer() != null) {
|
|
||||||
IDisplayPaneContainer container = renderableDisplay.getContainer();
|
|
||||||
for (IDisplayPane pane : container.getDisplayPanes()) {
|
|
||||||
if (pane.getDescriptor() != this) {
|
|
||||||
if (pane.getDescriptor().getTimeMatcher() != null) {
|
|
||||||
pane.getDescriptor().getTimeMatcher()
|
|
||||||
.redoTimeMatching(pane.getDescriptor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void postAddListener(ResourcePair rp) {
|
protected void postAddListener(ResourcePair rp) {
|
||||||
|
if (rp.getResource() != null && getTimeMatcher() != null) {
|
||||||
|
// We need to run time matching immediately beacuse order
|
||||||
|
// constructed is important for time matching so we must do it now
|
||||||
|
// instead of scheduling since another resource could be added by
|
||||||
|
// the time it runs
|
||||||
|
AbstractTimeMatcher tm = getTimeMatcher();
|
||||||
|
tm.redoTimeMatching(rp.getResource());
|
||||||
|
try {
|
||||||
|
tm.redoTimeMatching(this);
|
||||||
|
} catch (VizException e) {
|
||||||
|
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -169,8 +169,7 @@ public abstract class AbstractRequestableResourceData extends
|
||||||
// 3. Throw an exception of no data available and user has not specified
|
// 3. Throw an exception of no data available and user has not specified
|
||||||
// to suppress load errors
|
// to suppress load errors
|
||||||
// 4. Retrieve the PluginDataObjects for all DataTimes
|
// 4. Retrieve the PluginDataObjects for all DataTimes
|
||||||
// 5. Notify the time matcher that load has completed with the set of
|
// 5. Construct resource with loaded pdos
|
||||||
// datatimes
|
|
||||||
DataTime[] availableTimes = this.getAvailableTimes();
|
DataTime[] availableTimes = this.getAvailableTimes();
|
||||||
DataTime[] dataTimes = descriptor.getTimeMatcher().initialLoad(
|
DataTime[] dataTimes = descriptor.getTimeMatcher().initialLoad(
|
||||||
loadProperties, availableTimes, descriptor);
|
loadProperties, availableTimes, descriptor);
|
||||||
|
@ -205,9 +204,8 @@ public abstract class AbstractRequestableResourceData extends
|
||||||
}
|
}
|
||||||
|
|
||||||
resource = constructResource(loadProperties, data);
|
resource = constructResource(loadProperties, data);
|
||||||
descriptor.getTimeMatcher().setTimeList(dataTimes, resource,
|
|
||||||
descriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ import com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay;
|
||||||
import com.raytheon.uf.viz.core.drawables.FrameCoordinator;
|
import com.raytheon.uf.viz.core.drawables.FrameCoordinator;
|
||||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||||
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
|
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
|
||||||
|
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||||
import com.raytheon.uf.viz.core.exception.VizException;
|
import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.uf.viz.core.globals.VizGlobalsManager;
|
import com.raytheon.uf.viz.core.globals.VizGlobalsManager;
|
||||||
|
@ -61,7 +62,6 @@ import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType;
|
||||||
import com.raytheon.uf.viz.core.rsc.IResourceGroup;
|
import com.raytheon.uf.viz.core.rsc.IResourceGroup;
|
||||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||||
import com.raytheon.uf.viz.core.rsc.ResourceList;
|
import com.raytheon.uf.viz.core.rsc.ResourceList;
|
||||||
import com.raytheon.uf.viz.core.time.TimeMatchingJob;
|
|
||||||
import com.raytheon.uf.viz.d2d.core.D2DLoadProperties;
|
import com.raytheon.uf.viz.d2d.core.D2DLoadProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,8 +73,6 @@ import com.raytheon.uf.viz.d2d.core.D2DLoadProperties;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Feb 10, 2009 chammack Initial creation
|
* Feb 10, 2009 chammack Initial creation
|
||||||
* 2012-04-20 DR 14699 D. Friedman Work around race conditions
|
|
||||||
* 2012-08-14 DR 15160 D. Friedman Reduce chance of UI blocking
|
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -95,7 +93,9 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
@Override
|
@Override
|
||||||
public void disposed(AbstractVizResource<?, ?> resource) {
|
public void disposed(AbstractVizResource<?, ?> resource) {
|
||||||
if ((resource == timeMatchBasis)) {
|
if ((resource == timeMatchBasis)) {
|
||||||
internalSetTimeMatchBasis(null);
|
synchronized (D2DTimeMatcher.this) {
|
||||||
|
timeMatchBasis = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,15 +123,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
|
|
||||||
private AbstractTimeMatchingConfigurationFactory configFactory;
|
private AbstractTimeMatchingConfigurationFactory configFactory;
|
||||||
|
|
||||||
// DR 14699 work arounds
|
|
||||||
private boolean needRetry;
|
|
||||||
private int nRetries;
|
|
||||||
|
|
||||||
// DR 15160 state
|
|
||||||
private transient boolean pendingTmbChange = false;
|
|
||||||
private transient boolean inTimeMatch = false;
|
|
||||||
private transient AbstractVizResource<?, ?> pendingTimeMatchBasis;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -162,15 +153,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
public void redoTimeMatching(IDescriptor descriptor) throws VizException {
|
public void redoTimeMatching(IDescriptor descriptor) throws VizException {
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (inTimeMatch) {
|
|
||||||
needRetry = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pendingTmbChange = false;
|
|
||||||
inTimeMatch = true;
|
|
||||||
needRetry = false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (timeMatchBasis != null) {
|
if (timeMatchBasis != null) {
|
||||||
IDescriptor tmDescriptor = timeMatchBasis.getDescriptor();
|
IDescriptor tmDescriptor = timeMatchBasis.getDescriptor();
|
||||||
if (tmDescriptor != null && tmDescriptor != descriptor) {
|
if (tmDescriptor != null && tmDescriptor != descriptor) {
|
||||||
|
@ -194,11 +176,8 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
Iterator<ResourcePair> pairIterator = descriptor.getResourceList()
|
Iterator<ResourcePair> pairIterator = descriptor.getResourceList()
|
||||||
.listIterator();
|
.listIterator();
|
||||||
while (pairIterator.hasNext()) {
|
while (pairIterator.hasNext()) {
|
||||||
ResourcePair rp = pairIterator.next();
|
AbstractVizResource<?, ?> rsc = pairIterator.next()
|
||||||
AbstractVizResource<?, ?> rsc = rp
|
|
||||||
.getResource();
|
.getResource();
|
||||||
if (rsc == null && rp.getResourceData() instanceof AbstractRequestableResourceData)
|
|
||||||
needRetry = true;
|
|
||||||
recursiveOverlay(descriptor, new FramesInfo(timeSteps, -1,
|
recursiveOverlay(descriptor, new FramesInfo(timeSteps, -1,
|
||||||
resourceTimeMap), rsc);
|
resourceTimeMap), rsc);
|
||||||
}
|
}
|
||||||
|
@ -215,38 +194,18 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
timeMatchUpdate(entry.getKey(), entry.getValue());
|
timeMatchUpdate(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
|
||||||
boolean scheduleRetry = false;
|
|
||||||
synchronized (this) {
|
|
||||||
inTimeMatch = false;
|
|
||||||
if (pendingTmbChange) {
|
|
||||||
pendingTmbChange = false;
|
|
||||||
changeTimeMatchBasis(pendingTimeMatchBasis);
|
|
||||||
pendingTimeMatchBasis = null;
|
|
||||||
scheduleRetry = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needRetry) {
|
|
||||||
if (nRetries < 200) {
|
|
||||||
++nRetries;
|
|
||||||
scheduleRetry = true;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
nRetries = 0;
|
|
||||||
}
|
|
||||||
if (scheduleRetry)
|
|
||||||
TimeMatchingJob.scheduleTimeMatch(descriptor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int indexToUpdateTo(IDescriptor descriptor, DataTime[] oldTimes,
|
private int indexToUpdateTo(IDescriptor descriptor, DataTime[] oldTimes,
|
||||||
int oldIndex, DataTime[] frames, int startFrame) {
|
int oldIndex, DataTime[] frames, int startFrame) {
|
||||||
int frameToUse = startFrame;
|
int frameToUse = startFrame;
|
||||||
IDisplayPaneContainer container = descriptor.getRenderableDisplay()
|
IRenderableDisplay display = descriptor.getRenderableDisplay();
|
||||||
.getContainer();
|
if (display != null && display.getContainer() != null) {
|
||||||
if (container != null && container.getLoopProperties().isLooping()) {
|
IDisplayPaneContainer container = display.getContainer();
|
||||||
return frameToUse;
|
if (container.getLoopProperties().isLooping()) {
|
||||||
|
return frameToUse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (descriptor.getFrameCoordinator().getAnimationMode()) {
|
switch (descriptor.getFrameCoordinator().getAnimationMode()) {
|
||||||
case Latest: {
|
case Latest: {
|
||||||
|
@ -347,8 +306,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
if (rsc instanceof IResourceGroup) {
|
if (rsc instanceof IResourceGroup) {
|
||||||
for (ResourcePair rp : ((IResourceGroup) rsc).getResourceList()) {
|
for (ResourcePair rp : ((IResourceGroup) rsc).getResourceList()) {
|
||||||
AbstractVizResource<?, ?> rsc1 = rp.getResource();
|
AbstractVizResource<?, ?> rsc1 = rp.getResource();
|
||||||
if (rsc1 == null && rp.getResourceData() instanceof AbstractRequestableResourceData)
|
|
||||||
needRetry = true;
|
|
||||||
recursiveOverlay(descriptor, framesInfo, rsc1);
|
recursiveOverlay(descriptor, framesInfo, rsc1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,9 +314,7 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
TimeMatchingConfiguration config = getConfiguration(rsc
|
TimeMatchingConfiguration config = getConfiguration(rsc
|
||||||
.getLoadProperties());
|
.getLoadProperties());
|
||||||
DataTime[] timeSteps = getFrameTimes(descriptor, framesInfo);
|
DataTime[] timeSteps = getFrameTimes(descriptor, framesInfo);
|
||||||
if (Arrays.equals(timeSteps, config.getLastBaseTimes()) &&
|
if (Arrays.equals(timeSteps, config.getLastBaseTimes())) {
|
||||||
config.getLastFrameTimes() != null &&
|
|
||||||
config.getLastFrameTimes().length > 0) {
|
|
||||||
framesInfo.getTimeMap().put(rsc, config.getLastFrameTimes());
|
framesInfo.getTimeMap().put(rsc, config.getLastFrameTimes());
|
||||||
} else {
|
} else {
|
||||||
config = config.clone();
|
config = config.clone();
|
||||||
|
@ -733,7 +688,9 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
IDescriptor descriptor) {
|
IDescriptor descriptor) {
|
||||||
if ((resource == timeMatchBasis)
|
if ((resource == timeMatchBasis)
|
||||||
&& (descriptor instanceof AbstractDescriptor)) {
|
&& (descriptor instanceof AbstractDescriptor)) {
|
||||||
internalSetTimeMatchBasis(null);
|
synchronized (this) {
|
||||||
|
timeMatchBasis = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,41 +819,6 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
return timeMatchBasis;
|
return timeMatchBasis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.raytheon.uf.viz.core.AbstractTimeMatcher#setTimeList(com.raytheon
|
|
||||||
* .uf.common.time.DataTime[],
|
|
||||||
* com.raytheon.uf.viz.core.rsc.AbstractVizResource,
|
|
||||||
* com.raytheon.uf.viz.core.drawables.IDescriptor)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setTimeList(DataTime[] dataTimes,
|
|
||||||
AbstractVizResource<?, ?> rsc, IDescriptor descriptor)
|
|
||||||
throws VizException {
|
|
||||||
((AbstractDescriptor) descriptor).getTimeMatchingMap().put(rsc,
|
|
||||||
dataTimes);
|
|
||||||
|
|
||||||
// if the resource is the basis , set the time to the last
|
|
||||||
// time
|
|
||||||
if (dataTimes.length > 0
|
|
||||||
&& (rsc == timeMatchBasis || timeMatchBasis == null)) {
|
|
||||||
boolean setFrameTimes = true;
|
|
||||||
// If there are any null times we do not want to set this as the
|
|
||||||
// frame times, that means we were matched against a time match
|
|
||||||
// basis that has since been removed.
|
|
||||||
for (DataTime time : dataTimes) {
|
|
||||||
setFrameTimes = setFrameTimes && time != null;
|
|
||||||
}
|
|
||||||
if (setFrameTimes) {
|
|
||||||
descriptor.setFramesInfo(new FramesInfo(dataTimes,
|
|
||||||
dataTimes.length - 1));
|
|
||||||
changeTimeMatchBasis(rsc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasTimeMatchBasis() {
|
public boolean hasTimeMatchBasis() {
|
||||||
return (timeMatchBasis != null);
|
return (timeMatchBasis != null);
|
||||||
}
|
}
|
||||||
|
@ -1027,17 +949,4 @@ public class D2DTimeMatcher extends AbstractTimeMatcher implements
|
||||||
configFactory.resetMultiload();
|
configFactory.resetMultiload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For DR 15160
|
|
||||||
protected void internalSetTimeMatchBasis(AbstractVizResource<?, ?> timeMatchBasis) {
|
|
||||||
synchronized (this) {
|
|
||||||
if (inTimeMatch) {
|
|
||||||
pendingTmbChange = true;
|
|
||||||
pendingTimeMatchBasis = timeMatchBasis;
|
|
||||||
} else {
|
|
||||||
pendingTmbChange = false;
|
|
||||||
pendingTimeMatchBasis = null;
|
|
||||||
changeTimeMatchBasis(timeMatchBasis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -659,25 +659,6 @@ public class NCTimeMatcher extends AbstractTimeMatcher implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't do anything. D2D calls this method (for their TimeMatcher) in
|
|
||||||
// AbstractRequestableResource
|
|
||||||
//
|
|
||||||
@Override
|
|
||||||
public void setTimeList(DataTime[] dataTimes,
|
|
||||||
AbstractVizResource<?, ?> rsc, IDescriptor descriptor) {
|
|
||||||
|
|
||||||
// can leave this out here and have it done with all other rscs in their
|
|
||||||
// init()
|
|
||||||
// ((AbstractDescriptor) descriptor).getTimeMatchingMap().put(rsc,
|
|
||||||
// dataTimes);
|
|
||||||
|
|
||||||
// set the frame times and the frame index on the descriptor.
|
|
||||||
descriptor.setDataTimes(dataTimes);
|
|
||||||
descriptor.setFrame(dataTimes.length - 1);
|
|
||||||
|
|
||||||
// frameTimes = new ArrayList<DataTime>( Arrays.asList( dataTimes ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is called by raytheon's NcAutoUpdater
|
// This is called by raytheon's NcAutoUpdater
|
||||||
|
|
||||||
// Assume that the frameTimes have been changed. We will need to update the
|
// Assume that the frameTimes have been changed. We will need to update the
|
||||||
|
|
Loading…
Add table
Reference in a new issue