Skip to content

Conversation

@sunkai-cai
Copy link
Contributor

Fixes #1464

Changes proposed in this pull request:

  • add timeout of JobConfiguration
  • support timeout for ElasticJobExecutor

@codecov-commenter
Copy link

codecov-commenter commented Jul 7, 2021

Codecov Report

Merging #1923 (9427640) into master (adcf88c) will decrease coverage by 0.01%.
The diff coverage is 81.48%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1923      +/-   ##
============================================
- Coverage     85.66%   85.64%   -0.02%     
  Complexity      114      114              
============================================
  Files           276      276              
  Lines          6026     6048      +22     
  Branches        922      925       +3     
============================================
+ Hits           5162     5180      +18     
- Misses          525      528       +3     
- Partials        339      340       +1     
Impacted Files Coverage Δ
...sphere/elasticjob/executor/ElasticJobExecutor.java 87.73% <76.19%> (-3.57%) ⬇️
...hardingsphere/elasticjob/api/JobConfiguration.java 74.50% <100.00%> (+1.04%) ⬆️
...re/elasticjob/infra/pojo/JobConfigurationPOJO.java 100.00% <100.00%> (ø)
.../namespace/job/parser/JobBeanDefinitionParser.java 100.00% <100.00%> (ø)
...rdingsphere/elasticjob/infra/json/GsonFactory.java 100.00% <0.00%> (ø)
...ticjob/lite/internal/snapshot/SnapshotService.java 82.53% <0.00%> (+1.58%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update adcf88c...9427640. Read the comment docs.

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Not sure if I'm asking too late. Should this PR add documentation?

Copy link
Member

@linghengqian linghengqian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I rebase the relevant branch, but it seems that some unit tests timeout.

@sunkai-cai
Copy link
Contributor Author

Maybe this is not a good design。 We need redesign it if we need the timeout features。

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds timeout support for ElasticJob by introducing a new maxRuntimeSeconds configuration parameter. The timeout feature allows jobs to be interrupted if they run longer than the specified duration.

  • Added maxRuntimeSeconds parameter to JobConfiguration with a default value of -1 (no timeout)
  • Updated the ElasticJobExecutor to monitor job execution time and cancel jobs that exceed the timeout
  • Updated Spring XML namespace support and YAML serialization to include the new timeout parameter

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
elasticjob.xsd Added XML schema attribute for max-runtime-seconds configuration
JobBeanDefinitionTag.java Added constant for max-runtime-seconds XML attribute
JobBeanDefinitionParser.java Added parsing support for max-runtime-seconds from XML
JobConfiguration.java Added maxRuntimeSeconds field and builder method
JobConfigurationPOJO.java Added maxRuntimeSeconds field for YAML serialization
ElasticJobExecutor.java Implemented timeout logic with Future monitoring and cancellation
Various test files Updated tests to include maxRuntimeSeconds in expected configurations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +424 to +425
* if job running for a long time more than it, will enabled interrupting.
* 0 means do not timeout.
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has grammatical errors. Should be 'If job runs for a long time more than it, interrupting will be enabled.' Also, the documentation is inconsistent - it says '0 means no timeout' but the default value is -1.

Suggested change
* if job running for a long time more than it, will enabled interrupting.
* 0 means do not timeout.
* If job runs for a long time more than this value, interrupting will be enabled.
* A value of -1 means no timeout.

Copilot uses AI. Check for mistakes.
int sumWaitTime = 0;
int maxRunTime = jobConfig.getMaxRunTimeSeconds() > 0 ? jobConfig.getMaxRunTimeSeconds() * 1000 : 0;
while (!futures.isEmpty()) {
//waiting process Done
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment has incorrect capitalization and grammar. Should be '// Waiting for process to complete' or '// Wait for process done'.

Suggested change
//waiting process Done
// Waiting for process to complete

Copilot uses AI. Check for mistakes.
Comment on lines +183 to +184
// ignore process Exception and Canceled for future
// TODO Consider increasing the status of job failure, and how to handle the overall loop of job failure
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment has grammatical errors. Should be 'ignore process exceptions and cancellations for futures' and 'TODO: Consider tracking job failure status and how to handle overall job failure loops'.

Suggested change
// ignore process Exception and Canceled for future
// TODO Consider increasing the status of job failure, and how to handle the overall loop of job failure
// ignore process exceptions and cancellations for futures
// TODO: Consider tracking job failure status and how to handle overall job failure loops

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +171
BlockUtils.sleep(100);
sumWaitTime += 100;
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 100 (milliseconds) is hardcoded and used in multiple places. Consider extracting it as a named constant like TIMEOUT_CHECK_INTERVAL_MILLIS = 100 to improve maintainability.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest to support timeout for JobConfiguration

4 participants