use of alma.acs.pubsubtest.config.TerminationSpecT in project ACS by ACS-Community.
the class PubSubExecutor method execute.
/**
* Run the specified pub/sub container and components.
* Since no timeout is passed to this method, one of the following must be true:
* <ul>
* <li>The XML spec contains the (optional) <code>Termination</code> element
* that defines a timeout, or
* <li>No pub/sub component has an unbounded number of events, which means
* that all component definitions must contain the <code>numberOfEvents</code> attribute.
* </ul>
* @param scenario
* @throws Throwable
*/
public void execute(PubSubScenario scenario) throws Throwable {
PubSubInfrastructureSpec pubSubSpec = scenario.getSpec();
TerminationSpecT teminationSpec = pubSubSpec.getTermination();
if (teminationSpec == null) {
for (PublisherSpecT pubSpec : pubSubSpec.getPublisher()) {
if (!pubSpec.hasNumberOfEvents() || pubSpec.getNumberOfEvents() <= 0) {
throw new IllegalArgumentException("Publisher " + pubSpec.getComponentName() + " needs numberOfEvents >= 0, or call 'execute' with a timeout.");
}
}
for (SubscriberSpecT subSpec : pubSubSpec.getSubscriber()) {
if (!subSpec.hasNumberOfEvents() || subSpec.getNumberOfEvents() <= 0) {
throw new IllegalArgumentException("Subscriber " + subSpec.getComponentName() + " needs numberOfEvents >= 0, or call 'execute' with a timeout.");
}
}
// timeout is implied by the finite number of events
execute(scenario, -1, null);
} else {
// use timeout from XML, complementary to any finite number of events if those are specified.
long timeout = teminationSpec.getTimeout();
TimeUnit timeUnit = TimeUnit.valueOf(teminationSpec.getTimeUnit().toString());
m_logger.fine("Will use timeout from the XML spec: timeout=" + timeout + ", timeUnit=" + timeUnit);
execute(scenario, timeout, timeUnit);
}
}
Aggregations