Skip to content
Snippets Groups Projects
Commit 2463d5fe authored by gmantele's avatar gmantele
Browse files

[UWS,TAP] Follow up to the following commit about executionDuration:

47d36bfb
In the UWS and TAP configuration files the executionDuration has to be
provided into milliseconds. But the UWS parameter MUST be in seconds.
So now, UWS is still keeping this duration in seconds (in its
ExecutionDurationController) but TAP keeps it in milliseconds (in order
to avoid unexpected silent modification of the API) and converts it into
seconds for its controller (i.e. TAPExecutionDurationController), for the
default home page and for the Capabilities page.
parent 4a070328
Branches
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ import uws.service.log.UWSLog.LogLevel;
* </p>
*
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.1 (01/2016)
* @version 2.1 (09/2016)
*/
public class TAPSyncJob {
......@@ -248,12 +248,12 @@ public class TAPSyncJob {
if (timeout && error != null && error instanceof InterruptedException){
// Log the timeout:
if (thread.isAlive())
service.getLogger().logTAP(LogLevel.WARNING, this, "TIME_OUT", "Time out (after " + tapParams.getExecutionDuration() + "ms) for the synchonous job " + ID + ", but the thread can not be interrupted!", null);
service.getLogger().logTAP(LogLevel.WARNING, this, "TIME_OUT", "Time out (after " + tapParams.getExecutionDuration() + "seconds) for the synchonous job " + ID + ", but the thread can not be interrupted!", null);
else
service.getLogger().logTAP(LogLevel.INFO, this, "TIME_OUT", "Time out (after " + tapParams.getExecutionDuration() + "ms) for the synchonous job " + ID + ".", null);
service.getLogger().logTAP(LogLevel.INFO, this, "TIME_OUT", "Time out (after " + tapParams.getExecutionDuration() + "seconds) for the synchonous job " + ID + ".", null);
// Report the timeout to the user:
throw new TAPException("Time out! The execution of this synchronous TAP query was limited to " + tapParams.getExecutionDuration() + "ms. You should try again but in asynchronous execution.", UWSException.ACCEPTED_BUT_NOT_COMPLETE);
throw new TAPException("Time out! The execution of this synchronous TAP query was limited to " + tapParams.getExecutionDuration() + "seconds. You should try again but in asynchronous execution.", UWSException.ACCEPTED_BUT_NOT_COMPLETE);
}
// CASE: ERRORS
else if (!thread.isSuccess()){
......
......@@ -16,7 +16,7 @@ package tap.parameters;
* You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Copyright 2012-2016 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI)
*/
......@@ -42,7 +42,7 @@ import uws.job.parameters.InputParamController;
* </ul>
*
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.0 (11/2014)
* @version 2.1 (09/2016)
*/
public class TAPExecutionDurationController implements InputParamController {
......@@ -80,7 +80,7 @@ public class TAPExecutionDurationController implements InputParamController {
// Get the default value from the service connection:
long defaultVal = TAPJob.UNLIMITED_DURATION;
if (service.getExecutionDuration() != null && service.getExecutionDuration().length >= 2)
defaultVal = service.getExecutionDuration()[0];
defaultVal = service.getExecutionDuration()[0] / 1000; // ServiceConnection keeps limits in MILLISECONDS, but the controller MUST work in SECONDS (TAP input and output for this parameter are always in seconds)
// The default value is also limited by the maximum value if any:
long maxVal = getMaxDuration();
......@@ -95,7 +95,7 @@ public class TAPExecutionDurationController implements InputParamController {
public final long getMaxDuration(){
if (service.getExecutionDuration() != null && service.getExecutionDuration().length >= 2){
if (service.getExecutionDuration()[1] > 0)
return service.getExecutionDuration()[1];
return service.getExecutionDuration()[1] / 1000; // ServiceConnection keeps limits in MILLISECONDS, but the controller MUST work in SECONDS (TAP input and output for this parameter are always in seconds)
}
return TAPJob.UNLIMITED_DURATION;
}
......@@ -107,7 +107,8 @@ public class TAPExecutionDurationController implements InputParamController {
return getDefault();
// Get the default and maximum durations for comparison:
long defaultDuration = (Long)getDefault(), maxDuration = getMaxDuration();
long defaultDuration = (Long)getDefault(),
maxDuration = getMaxDuration();
// Parse the given duration:
Long duration;
......
......@@ -16,7 +16,7 @@ package tap.resource;
* You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2015 - Astronomisches Rechen Institut (ARI)
* Copyright 2015-2016 - Astronomisches Rechen Institut (ARI)
*/
import java.io.IOException;
......@@ -52,7 +52,7 @@ import uws.UWSToolBox;
* </p>
*
* @author Gr&eacute;gory Mantelet (ARI)
* @version 2.1 (11/2015)
* @version 2.1 (09/2016)
* @since 2.0
*/
public class HomePage extends ForwardResource {
......@@ -141,8 +141,8 @@ public class HomePage extends ForwardResource {
// Execution duration limit:
writer.print("\n\t\t\t<div class=\"formField\">\n\t\t\t\t<input id=\"toggleDuration\" type=\"checkbox\" onclick=\"toggleTextInput('EXECUTIONDURATION');\" /><label for=\"toggleDuration\"><strong>Duration limit:</strong></label> <input id=\"EXECUTIONDURATION\" type=\"text\" value=\"-1\" list=\"durationList\" disabled=\"disabled\" /> seconds <em>(a value &le; 0 means 'default value')</em>\n\t\t\t\t<datalist id=\"durationList\">");
if (tap.getServiceConnection().getExecutionDuration() != null && tap.getServiceConnection().getExecutionDuration().length >= 2){
writer.print("\n\t\t\t\t\t<option value=\"" + tap.getServiceConnection().getExecutionDuration()[0] + "\">Default</option>");
writer.print("\n\t\t\t\t\t<option value=\"" + tap.getServiceConnection().getExecutionDuration()[1] + "\">Maximum</option>");
writer.print("\n\t\t\t\t\t<option value=\"" + (tap.getServiceConnection().getExecutionDuration()[0] / 1000) + "\">Default</option>");
writer.print("\n\t\t\t\t\t<option value=\"" + (tap.getServiceConnection().getExecutionDuration()[1] / 1000) + "\">Maximum</option>");
}
writer.print("\n\t\t\t\t</datalist>\n\t\t\t</div>");
......
......@@ -68,7 +68,7 @@ import uws.service.request.UWSRequestParser;
* Concrete implementation of a {@link UWSFactory} which is parameterized by a UWS configuration file.
*
* @author Gr&eacute;gory Mantelet (ARI)
* @version 4.2 (06/2016)
* @version 4.2 (09/2016)
* @since 4.2
*/
public class ConfigurableUWSFactory implements UWSFactory {
......@@ -167,7 +167,7 @@ public class ConfigurableUWSFactory implements UWSFactory {
controller = new ExecutionDurationController();
// Set the default execution duration:
controller.setDefaultExecutionDuration(durationController.parseDuration(propValue));
controller.setDefaultExecutionDuration(durationController.parseDuration(propValue) / 1000); // parseDuration(...) returns a duration in ms while executionDuration must be in seconds
// Update the map of controllers for this job list:
mapControllers.put(UWSJob.PARAM_EXECUTION_DURATION, controller);
......@@ -203,7 +203,7 @@ public class ConfigurableUWSFactory implements UWSFactory {
controller = new ExecutionDurationController();
// Set the maximum execution duration:
controller.setMaxExecutionDuration(durationController.parseDuration(propValue));
controller.setMaxExecutionDuration(durationController.parseDuration(propValue) / 1000); // parseDuration(...) returns a duration in ms while executionDuration must be in seconds
// Update the map of controllers for this job list:
mapControllers.put(UWSJob.PARAM_EXECUTION_DURATION, controller);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment