added config for WorkStealingDispatcher and HawtDispatcher; Tickets 200 and 377
This commit is contained in:
parent
a16e909521
commit
ef79befe9a
8 changed files with 29 additions and 4 deletions
|
|
@ -76,6 +76,7 @@
|
|||
<xsd:attribute name="ref" type="xsd:string"/>
|
||||
<xsd:attribute name="type" type="dispatcher-enum-type"/>
|
||||
<xsd:attribute name="name" type="xsd:string"/>
|
||||
<xsd:attribute name="aggregate" type="xsd:boolean"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="threadpool-type">
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ object AkkaSpringConfigurationTags {
|
|||
val NAME = "name"
|
||||
val REF = "ref"
|
||||
val TYPE = "type"
|
||||
val AGGREGATE = "aggregate" // HawtDispatcher
|
||||
|
||||
// thread pool attributes
|
||||
val QUEUE = "queue"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ object DispatcherFactoryBean {
|
|||
case REACTOR_BASED_THREAD_POOL_EVENT_DRIVEN => Dispatchers.newReactorBasedThreadPoolEventDrivenDispatcher(properties.name)
|
||||
case REACTOR_BASED_SINGLE_THREAD_EVENT_DRIVEN => Dispatchers.newReactorBasedSingleThreadEventDrivenDispatcher(properties.name)
|
||||
case THREAD_BASED => throw new IllegalArgumentException("not implemented yet") //FIXME
|
||||
case HAWT => throw new IllegalArgumentException("not implemented yet") //FIXME
|
||||
case HAWT => Dispatchers.newHawtDispatcher(properties.aggregate)
|
||||
case _ => throw new IllegalArgumentException("unknown dispatcher type")
|
||||
}
|
||||
if ((properties.threadPool != null) && (properties.threadPool.queue != null)) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ trait DispatcherParser extends BeanParser {
|
|||
throw new IllegalArgumentException("Referenced dispatcher not found: '" + ref + "'")
|
||||
}
|
||||
}
|
||||
properties.name = mandatory(dispatcherElement, NAME)
|
||||
|
||||
properties.dispatcherType = mandatory(dispatcherElement, TYPE)
|
||||
if (properties.dispatcherType == THREAD_BASED) {
|
||||
if ((dispatcherElement.getParentNode.getNodeName != "akka:typed-actor") &&
|
||||
|
|
@ -36,6 +36,16 @@ trait DispatcherParser extends BeanParser {
|
|||
throw new IllegalArgumentException("Thread based dispatcher must be nested in typed-actor element!")
|
||||
}
|
||||
}
|
||||
|
||||
if (properties.dispatcherType == HAWT) { // no name for HawtDispatcher
|
||||
properties.name = dispatcherElement.getAttribute(NAME)
|
||||
if (dispatcherElement.hasAttribute(AGGREGATE)) {
|
||||
properties.aggregate = dispatcherElement.getAttribute(AGGREGATE).toBoolean
|
||||
}
|
||||
} else {
|
||||
properties.name = mandatory(dispatcherElement, NAME)
|
||||
}
|
||||
|
||||
val threadPoolElement = DomUtils.getChildElementByTagName(dispatcherElement, THREAD_POOL_TAG);
|
||||
if (threadPoolElement != null) {
|
||||
if (properties.dispatcherType == REACTOR_BASED_SINGLE_THREAD_EVENT_DRIVEN ||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class DispatcherProperties {
|
|||
var dispatcherType: String = ""
|
||||
var name: String = ""
|
||||
var threadPool: ThreadPoolProperties = _
|
||||
var aggregate = true
|
||||
|
||||
/**
|
||||
* Sets the properties to the given builder.
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ http://scalablesolutions.se/akka/akka-0.10.xsd">
|
|||
<!-- executor-based-event-driven-work-stealing-dispatcher -->
|
||||
<akka:dispatcher id="executor-based-event-driven-work-stealing-dispatcher" type="executor-based-event-driven-work-stealing" name="workStealingDispatcher" />
|
||||
|
||||
<!-- hawt-dispatcher
|
||||
<akka:dispatcher id="hawt-dispatcher" type="hawt" name="hawtDispatcher" /> -->
|
||||
<!-- hawt-dispatcher -->
|
||||
<akka:dispatcher id="hawt-dispatcher" type="hawt" aggregate="false" name="test" />
|
||||
|
||||
<!-- thread-based-dispatcher
|
||||
<akka:typed-actor id="typed-actor-with-thread-based-dispatcher"
|
||||
|
|
|
|||
|
|
@ -101,6 +101,17 @@ class DispatcherBeanDefinitionParserTest extends Spec with ShouldMatchers {
|
|||
val xml = <akka:dispatcher id="dispatcher" type="thread-based" name="myDispatcher" />
|
||||
evaluating { parser.parseDispatcher(dom(xml).getDocumentElement) } should produce [IllegalArgumentException]
|
||||
}
|
||||
|
||||
it("should be able to parse the hawt dispatcher configuration") {
|
||||
// hawt
|
||||
val xml = <akka:dispatcher id="dispatcher"
|
||||
type="hawt"
|
||||
aggregate="false" />
|
||||
var props = parser.parseDispatcher(dom(xml).getDocumentElement);
|
||||
assert(props != null)
|
||||
assert(props.dispatcherType === "hawt")
|
||||
assert(props.aggregate === false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ class DispatcherSpringFeatureTest extends FeatureSpec with ShouldMatchers {
|
|||
val dispatcher = context.getBean("hawt-dispatcher").asInstanceOf[HawtDispatcher]
|
||||
assert(dispatcher != null)
|
||||
assert(dispatcher.toString === "HawtDispatchEventDrivenDispatcher")
|
||||
assert(dispatcher.aggregate === false)
|
||||
}
|
||||
|
||||
scenario("get a thread-based-dispatcher from context") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue