-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runner simplification refactoring #265
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
dee7f5e
temporary new-runner module
malaskowski 5cbb629
early working version
malaskowski ac11166
Message observers replaced with one MessagesSender
malaskowski 3ec4785
Packages cleanup, removed unused metadata persister
malaskowski 0d18675
Packages cleanup
malaskowski a05627d
Suite execution factory
malaskowski f6f492c
CollectorJobScheduler wrapped into OSGi service
malaskowski 3977b8c
Param maxConcurrentSuitesCount configurable, cleanup runner config
malaskowski 107e888
Suite processor extracted
malaskowski fa7631e
Unit tests update
malaskowski a8a9131
Package refactoring
malaskowski 8cf1749
Add suite finished callback
malaskowski 5e449ab
Merge changes to the main runner module
malaskowski 30eb04f
Update manager description
malaskowski ebea53c
changelog update
malaskowski e4602a3
Runner documentation update
malaskowski b7dad27
Remove unused dependencies
malaskowski aec43b3
Factory methods naming convention fix
malaskowski a818169
PR fixes
malaskowski aebda25
Merge branch 'master' into feature/aet-runner-refactoring
Skejven 5488637
Merge remote-tracking branch 'origin/master' into feature/aet-runner-…
malaskowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,35 +13,26 @@ | |
* or implied. See the License for the specific language governing permissions and limitations under | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good changes. thanks! |
||
* the License. | ||
*/ | ||
package com.cognifide.aet.runner.main; | ||
|
||
import com.cognifide.aet.communication.api.queues.JmsConnection; | ||
import com.cognifide.aet.runner.distribution.RunnerMessageListener; | ||
import com.cognifide.aet.runner.distribution.RunnerMode; | ||
import com.cognifide.aet.runner.modules.SimpleRunnerModule; | ||
import com.cognifide.aet.runner.util.MessagesManager; | ||
import com.cognifide.aet.vs.MetadataDAO; | ||
import com.google.inject.Guice; | ||
import com.google.inject.Injector; | ||
package com.cognifide.aet.runner; | ||
|
||
import java.util.Map; | ||
import org.apache.felix.scr.annotations.Activate; | ||
import org.apache.felix.scr.annotations.Component; | ||
import org.apache.felix.scr.annotations.Deactivate; | ||
import org.apache.felix.scr.annotations.Property; | ||
import org.apache.felix.scr.annotations.PropertyOption; | ||
import org.apache.felix.scr.annotations.Reference; | ||
import org.apache.felix.scr.annotations.Service; | ||
import org.apache.sling.commons.osgi.PropertiesUtil; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Runner is an entry point for whole application, it main goal is to coordinate JMS communication | ||
* between workers. | ||
* between workers. This class contains all necessary configuration for the runner bundle. | ||
*/ | ||
@Component(immediate = true, metatype = true, description = "AET Runner", label = "AET Runner") | ||
public class Runner { | ||
@Service(RunnerConfiguration.class) | ||
@Component(metatype = true, description = "AET Runner Configuration", label = "AET Runner Configuration") | ||
public class RunnerConfiguration { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(Runner.class); | ||
private static final Logger LOGGER = LoggerFactory.getLogger(RunnerConfiguration.class); | ||
|
||
private static final int DEFAULT_TASK_RUN_FAILURE_TIMEOUT_SECONDS = 120; | ||
|
||
|
@@ -53,10 +44,12 @@ public class Runner { | |
|
||
private static final String PARAM_MAX_MESSAGES_IN_COLLECTOR_QUEUE = "maxMessagesInCollectorQueue"; | ||
|
||
private static final String RUNNER_MODE = "runnerMode"; | ||
private static final String PARAM_MAX_CONCURRENT_SUITES_PROCESSED_COUNT = "maxConcurrentSuitesCount"; | ||
|
||
private static final int DEFAULT_MAX_CONCURRENT_SUITES_PROCESSED_COUNT = 5; | ||
|
||
@Property(name = PARAM_FAILURE_TIMEOUT, label = "Failure timeout", description = | ||
"Time in seconds, test run will be interrupted if no response was received in duration of this parameter. Default: " | ||
"Time in seconds, after which suite processing will be interrupted if no notification was received in duration of this parameter. Default: " | ||
+ DEFAULT_TASK_RUN_FAILURE_TIMEOUT_SECONDS | ||
+ " sec", longValue = DEFAULT_TASK_RUN_FAILURE_TIMEOUT_SECONDS) | ||
private long ft = DEFAULT_TASK_RUN_FAILURE_TIMEOUT_SECONDS; | ||
|
@@ -84,24 +77,14 @@ public class Runner { | |
+ " messages", intValue = DEFAULT_MAX_MESSAGES_IN_COLLECTOR_QUEUE) | ||
private int maxMessagesInCollectorQueue = DEFAULT_MAX_MESSAGES_IN_COLLECTOR_QUEUE; | ||
|
||
@Property(name = RUNNER_MODE, label = "Runner mode", options = { | ||
@PropertyOption(name = "online", value = "online"), | ||
@PropertyOption(name = "maintenance", value = "maintenance"), | ||
@PropertyOption(name = "offline", value = "offline")}, value = "online", description = "Runner mode: online - listening to AET.runner-in queue only, maintenance - listening to AET.runner-in and AET.maintenance-in queues (running only from AET.maintenance-in queue), offline - listening only to AET-maintenance-in queue.") | ||
private RunnerMode runnerMode; | ||
@Reference | ||
private JmsConnection jmsConnection; | ||
|
||
@Reference | ||
private MessagesManager messagesManager; | ||
|
||
@Reference | ||
private MetadataDAO metadataDAO; | ||
|
||
private RunnerMessageListener messageListener; | ||
@Property(name = PARAM_MAX_CONCURRENT_SUITES_PROCESSED_COUNT, label = "Max Concurrent Suites Count", description = | ||
"Defines the maximum number of suites processed concurrently byt the Runner. Default: " | ||
+ DEFAULT_MAX_CONCURRENT_SUITES_PROCESSED_COUNT | ||
+ " messages", intValue = DEFAULT_MAX_CONCURRENT_SUITES_PROCESSED_COUNT) | ||
private int maxConcurrentSuitesCount = DEFAULT_MAX_CONCURRENT_SUITES_PROCESSED_COUNT; | ||
|
||
@Activate | ||
public void activate(Map properties) { | ||
public void activate(Map<String, String> properties) { | ||
ft = PropertiesUtil.toLong(properties.get(PARAM_FAILURE_TIMEOUT), | ||
DEFAULT_TASK_RUN_FAILURE_TIMEOUT_SECONDS); | ||
mttl = PropertiesUtil | ||
|
@@ -111,26 +94,52 @@ public void activate(Map properties) { | |
maxMessagesInCollectorQueue = PropertiesUtil.toInteger( | ||
properties.get(PARAM_MAX_MESSAGES_IN_COLLECTOR_QUEUE), | ||
DEFAULT_MAX_MESSAGES_IN_COLLECTOR_QUEUE); | ||
maxConcurrentSuitesCount = PropertiesUtil.toInteger( | ||
properties.get(PARAM_MAX_CONCURRENT_SUITES_PROCESSED_COUNT), | ||
DEFAULT_MAX_CONCURRENT_SUITES_PROCESSED_COUNT); | ||
|
||
runnerMode = RunnerMode.valueOf(PropertiesUtil.toString(properties.get(RUNNER_MODE), "online") | ||
.toUpperCase()); | ||
LOGGER.info( | ||
"Runner configured with parameters: [ft: {} sec ; mttl: {} ; urlPackageSize: {} ; maxMessagesInCollectorQueue: {}; maxConcurrentSuitesCount: {}.]", | ||
ft, mttl, urlPackageSize, maxMessagesInCollectorQueue, maxConcurrentSuitesCount); | ||
} | ||
|
||
LOG.info( | ||
"Running with parameters: [ft: {} sec ; mttl: {} ; urlPackageSize: {} ; maxMessagesInCollectorQueue: {}; runnerMode: {}.]", | ||
ft, mttl, urlPackageSize, maxMessagesInCollectorQueue, runnerMode); | ||
|
||
Injector injector = Guice | ||
.createInjector( | ||
new SimpleRunnerModule(ft, mttl, urlPackageSize, maxMessagesInCollectorQueue, | ||
jmsConnection, messagesManager, runnerMode, metadataDAO)); | ||
messageListener = injector.getInstance(RunnerMessageListener.class); | ||
/** | ||
* @return time in seconds, test run will be interrupted if no response was received in duration | ||
* of this parameter. | ||
*/ | ||
public long getFt() { | ||
return ft; | ||
} | ||
|
||
@Deactivate | ||
public void deactivate() { | ||
if (messageListener != null) { | ||
messageListener.close(); | ||
} | ||
|
||
/** | ||
* @return time in seconds after which messages will be thrown out of queues. | ||
*/ | ||
public long getMttl() { | ||
return mttl; | ||
} | ||
|
||
|
||
/** | ||
* @return the maximum amount of messages in the collector queue. | ||
*/ | ||
public int getMaxMessagesInCollectorQueue() { | ||
return maxMessagesInCollectorQueue; | ||
} | ||
|
||
/** | ||
* @return how many links are being sent in one message. Each message is being processed by single | ||
* CollectorListener. | ||
*/ | ||
public int getUrlPackageSize() { | ||
return urlPackageSize; | ||
} | ||
|
||
/** | ||
* @return how many suites can be processed concurrently byt the Runner. | ||
*/ | ||
public int getMaxConcurrentSuitesCount() { | ||
return maxConcurrentSuitesCount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thank you @Skejven !
Actually it looks like guice is referenced also in worker module, but is not used at all there (or am I wrong?).
So we could remove Guice from the worker pom and then also from top-level pom, isn't it?
Then we could remove guice from
feature.xml
file. That would b great, right?(there will be only some transitive dependencies to guice from our functional tests that use Bobcat).
Could be done here or in another pull request if you prefer...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @wiiitek for the review.
I will remove Guice dependency in the separate PR.