Switching to AbortPolicy by default
This commit is contained in:
parent
afe1e37648
commit
a7e9ff4fba
4 changed files with 11 additions and 9 deletions
|
|
@ -34,7 +34,6 @@ import akka.actor.ActorSystem
|
||||||
* .setCorePoolSize(16)
|
* .setCorePoolSize(16)
|
||||||
* .setMaxPoolSize(128)
|
* .setMaxPoolSize(128)
|
||||||
* .setKeepAliveTimeInMillis(60000)
|
* .setKeepAliveTimeInMillis(60000)
|
||||||
* .setRejectionPolicy(new CallerRunsPolicy)
|
|
||||||
* .buildThreadPool
|
* .buildThreadPool
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
@ -49,7 +48,6 @@ import akka.actor.ActorSystem
|
||||||
* .setCorePoolSize(16)
|
* .setCorePoolSize(16)
|
||||||
* .setMaxPoolSize(128)
|
* .setMaxPoolSize(128)
|
||||||
* .setKeepAliveTimeInMillis(60000)
|
* .setKeepAliveTimeInMillis(60000)
|
||||||
* .setRejectionPolicy(new CallerRunsPolicy())
|
|
||||||
* .buildThreadPool();
|
* .buildThreadPool();
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
@ -123,7 +121,13 @@ class Dispatcher(
|
||||||
executorService.get() execute mbox
|
executorService.get() execute mbox
|
||||||
true
|
true
|
||||||
} catch {
|
} catch {
|
||||||
case e: RejectedExecutionException ⇒ executorService.get() execute mbox; true //Retry once
|
case e: RejectedExecutionException ⇒
|
||||||
|
try {
|
||||||
|
executorService.get() execute mbox
|
||||||
|
true
|
||||||
|
} catch { //Retry once
|
||||||
|
case e: RejectedExecutionException ⇒ mbox.setAsIdle(); throw e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else false
|
} else false
|
||||||
} else false
|
} else false
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import akka.actor.ActorSystem
|
||||||
* .setCorePoolSize(16)
|
* .setCorePoolSize(16)
|
||||||
* .setMaxPoolSize(128)
|
* .setMaxPoolSize(128)
|
||||||
* .setKeepAliveTimeInMillis(60000)
|
* .setKeepAliveTimeInMillis(60000)
|
||||||
* .setRejectionPolicy(new CallerRunsPolicy)
|
|
||||||
* .build
|
* .build
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
@ -36,7 +35,6 @@ import akka.actor.ActorSystem
|
||||||
* .setCorePoolSize(16)
|
* .setCorePoolSize(16)
|
||||||
* .setMaxPoolSize(128)
|
* .setMaxPoolSize(128)
|
||||||
* .setKeepAliveTimeInMillis(60000)
|
* .setKeepAliveTimeInMillis(60000)
|
||||||
* .setRejectionPolicy(new CallerRunsPolicy())
|
|
||||||
* .build();
|
* .build();
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ package akka.dispatch
|
||||||
import java.util.Collection
|
import java.util.Collection
|
||||||
import java.util.concurrent._
|
import java.util.concurrent._
|
||||||
import atomic.{ AtomicLong, AtomicInteger }
|
import atomic.{ AtomicLong, AtomicInteger }
|
||||||
import ThreadPoolExecutor.CallerRunsPolicy
|
|
||||||
import akka.util.Duration
|
import akka.util.Duration
|
||||||
import akka.event.Logging.{ Warning, Error }
|
import akka.event.Logging.{ Warning, Error }
|
||||||
import akka.actor.ActorSystem
|
import akka.actor.ActorSystem
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor.{ AbortPolicy }
|
||||||
|
|
||||||
object ThreadPoolConfig {
|
object ThreadPoolConfig {
|
||||||
type Bounds = Int
|
type Bounds = Int
|
||||||
|
|
@ -21,7 +21,7 @@ object ThreadPoolConfig {
|
||||||
val defaultCorePoolSize: Int = 16
|
val defaultCorePoolSize: Int = 16
|
||||||
val defaultMaxPoolSize: Int = 128
|
val defaultMaxPoolSize: Int = 128
|
||||||
val defaultTimeout: Duration = Duration(60000L, TimeUnit.MILLISECONDS)
|
val defaultTimeout: Duration = Duration(60000L, TimeUnit.MILLISECONDS)
|
||||||
def defaultFlowHandler: FlowHandler = flowHandler(new CallerRunsPolicy)
|
def defaultFlowHandler: FlowHandler = flowHandler(new AbortPolicy)
|
||||||
|
|
||||||
def flowHandler(rejectionHandler: RejectedExecutionHandler): FlowHandler = Left(rejectionHandler)
|
def flowHandler(rejectionHandler: RejectedExecutionHandler): FlowHandler = Left(rejectionHandler)
|
||||||
def flowHandler(bounds: Int): FlowHandler = Right(bounds)
|
def flowHandler(bounds: Int): FlowHandler = Right(bounds)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ akka {
|
||||||
task-queue-size = -1 # Specifies the bounded capacity of the task queue (< 1 == unbounded)
|
task-queue-size = -1 # Specifies the bounded capacity of the task queue (< 1 == unbounded)
|
||||||
task-queue-type = "linked" # Specifies which type of task queue will be used, can be "array" or "linked" (default)
|
task-queue-type = "linked" # Specifies which type of task queue will be used, can be "array" or "linked" (default)
|
||||||
allow-core-timeout = on # Allow core threads to time out
|
allow-core-timeout = on # Allow core threads to time out
|
||||||
rejection-policy = "caller-runs" # abort, caller-runs, discard-oldest, discard
|
rejection-policy = "abort" # abort, caller-runs, discard-oldest, discard
|
||||||
throughput = 5 # Throughput for Dispatcher, set to 1 for complete fairness
|
throughput = 5 # Throughput for Dispatcher, set to 1 for complete fairness
|
||||||
throughput-deadline-time = -1 # Throughput deadline for Dispatcher, set to 0 or negative for no deadline
|
throughput-deadline-time = -1 # Throughput deadline for Dispatcher, set to 0 or negative for no deadline
|
||||||
mailbox-capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default)
|
mailbox-capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default)
|
||||||
|
|
@ -128,7 +128,7 @@ akka {
|
||||||
task-queue-size = -1 # Specifies the bounded capacity of the task queue (< 1 == unbounded)
|
task-queue-size = -1 # Specifies the bounded capacity of the task queue (< 1 == unbounded)
|
||||||
task-queue-type = "linked" # Specifies which type of task queue will be used, can be "array" or "linked" (default)
|
task-queue-type = "linked" # Specifies which type of task queue will be used, can be "array" or "linked" (default)
|
||||||
allow-core-timeout = on # Allow core threads to time out
|
allow-core-timeout = on # Allow core threads to time out
|
||||||
rejection-policy = "caller-runs" # abort, caller-runs, discard-oldest, discard
|
rejection-policy = "abort" # abort, caller-runs, discard-oldest, discard
|
||||||
throughput = 5 # Throughput for Dispatcher, set to 1 for complete fairness
|
throughput = 5 # Throughput for Dispatcher, set to 1 for complete fairness
|
||||||
throughput-deadline-time = -1 # Throughput deadline for Dispatcher, set to 0 or negative for no deadline
|
throughput-deadline-time = -1 # Throughput deadline for Dispatcher, set to 0 or negative for no deadline
|
||||||
mailbox-capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default)
|
mailbox-capacity = -1 # If negative (or zero) then an unbounded mailbox is used (default)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue