Commit 77afb338 authored by Andrea Aime's avatar Andrea Aime
Browse files

[GEOS-7281] move input-less processes to RUNNING state during execution

parent 3d447efd
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2014 - Open Source Geospatial Foundation. All rights reserved.
Copyright (C) 2014 - 2015 - Open Source Geospatial Foundation. All rights reserved.
This code is licensed under the GPL 2.0 license, available at the root
application directory.
-->
......@@ -311,4 +311,6 @@
<bean id="rasterSizeEstimators" class="org.geoserver.wps.validator.RasterSizeEstimator"/>
<bean id="rawDataSizeEstimator" class="org.geoserver.wps.validator.RawDataSizeEstimator"/>
<bean id="geometrySizeEstimator" class="org.geoserver.wps.validator.GeometrySizeEstimator"/>
<bean id="processStartupFilter" class="org.geoserver.wps.executor.ProcessStartupFilter"/>
</beans>
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
......@@ -92,7 +92,7 @@ public class DefaultProcessManager implements ProcessManager, ExtensionPriority,
public Map<String, Object> submitChained(String executionId, Name processName,
Map<String, Object> inputs, ProgressListener listener) throws ProcessException {
// straight execution, no thread pooling, we're already running in the parent process thread
ProcessFactory pf = GeoServerProcessors.createProcessFactory(processName, false);
ProcessFactory pf = GeoServerProcessors.createProcessFactory(processName, true);
if (pf == null) {
throw new WPSException("No such process: " + processName);
}
......@@ -190,7 +190,7 @@ public class DefaultProcessManager implements ProcessManager, ExtensionPriority,
// transfer the thread locals to this execution context
threadLocalTransfer.apply();
ProcessFactory pf = GeoServerProcessors.createProcessFactory(processName, false);
ProcessFactory pf = GeoServerProcessors.createProcessFactory(processName, true);
if (pf == null) {
throw new WPSException("No such process: " + processName);
}
......
/* (c) 2015 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.wps.executor;
import java.util.Map;
import java.util.logging.Logger;
import org.geoserver.platform.ExtensionPriority;
import org.geoserver.wps.process.DelegatingProcessFactory;
import org.geoserver.wps.process.ProcessFilter;
import org.geotools.process.Process;
import org.geotools.process.ProcessException;
import org.geotools.process.ProcessFactory;
import org.geotools.util.DelegateProgressListener;
import org.geotools.util.logging.Logging;
import org.opengis.feature.type.Name;
import org.opengis.util.ProgressListener;
/**
* A process filter making sure the {@link ProgressListener#started()} method is called upon execution
* no matter if the process has inputs or not
*
* @author Andrea Aime - GeoSolutions
*
*/
public class ProcessStartupFilter implements ProcessFilter, ExtensionPriority {
public class ProcessStartupWrapper implements Process {
Process delegate;
public ProcessStartupWrapper(Process delegate) {
super();
this.delegate = delegate;
}
@Override
public Map<String, Object> execute(Map<String, Object> input, ProgressListener monitor)
throws ProcessException {
if(monitor != null) {
monitor.started();
monitor = new DelegateProgressListener(monitor) {
@Override
public void started() {
// do not pass over, we already called "started"
}
};
}
return delegate.execute(input, monitor);
}
}
static final Logger LOGGER = Logging.getLogger(ProcessStartupFilter.class);
@Override
public ProcessFactory filterFactory(ProcessFactory pf) {
return new ProcessStartupFactory(pf);
}
class ProcessStartupFactory extends DelegatingProcessFactory {
public ProcessStartupFactory(ProcessFactory delegate) {
super(delegate);
}
@Override
public Process create(Name name) {
Process process = delegate.create(name);
return new ProcessStartupWrapper(process);
}
}
@Override
public int getPriority() {
return ExtensionPriority.LOWEST + 1;
}
}
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved
* (c) 2001 - 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
......@@ -375,7 +375,11 @@ public class WPSExecutionManager implements ApplicationContextAware,
longSteps++;
}
float longStepPercentage = 98f / longSteps;
float inputPercentage = 1 + inputsLongSteps * longStepPercentage;
// Set the base to 0 in case of no inputs, as there is really nothing to do there,
// this will make the process call the listener startup notification instead
// otherwise the executor SubProgressListener won't delegate that method down
int inputsBase = inputs.size() == 0 ? 0 : 1;
float inputPercentage = inputsBase + inputsLongSteps * longStepPercentage;
float outputPercentage = (hasComplexOutputs() ? longStepPercentage : 0) + 1;
float executionPercentage = 100 - inputPercentage - outputPercentage;
ProgressListener listener = notifier.getProgressListener();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment