Merge branch 'master' into wip-1503-remove-stm-patriknw
Conflicts: akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala akka-docs/modules/camel.rst
This commit is contained in:
commit
e456213e31
179 changed files with 2334 additions and 2138 deletions
|
|
@ -9,6 +9,8 @@ import akka.actor.Props;
|
|||
|
||||
//#import-future
|
||||
import akka.dispatch.Future;
|
||||
import akka.dispatch.Await;
|
||||
import akka.util.Duration;
|
||||
|
||||
//#import-future
|
||||
|
||||
|
|
@ -28,8 +30,9 @@ import akka.actor.UntypedActorFactory;
|
|||
import akka.dispatch.MessageDispatcher;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import scala.Option;
|
||||
import java.lang.Object;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
|
@ -42,7 +45,7 @@ public class UntypedActorTestBase {
|
|||
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
|
||||
//#system-actorOf
|
||||
myActor.tell("test");
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -52,7 +55,7 @@ public class UntypedActorTestBase {
|
|||
ActorRef myActor = system.actorOf(new Props(MyUntypedActor.class));
|
||||
//#context-actorOf
|
||||
myActor.tell("test");
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -67,7 +70,7 @@ public class UntypedActorTestBase {
|
|||
}));
|
||||
//#creating-constructor
|
||||
myActor.tell("test");
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -80,7 +83,7 @@ public class UntypedActorTestBase {
|
|||
"myactor");
|
||||
//#creating-props
|
||||
myActor.tell("test");
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -93,19 +96,10 @@ public class UntypedActorTestBase {
|
|||
}));
|
||||
|
||||
//#using-ask
|
||||
Future future = myActor.ask("Hello", 1000);
|
||||
future.await();
|
||||
if (future.isCompleted()) {
|
||||
Option resultOption = future.result();
|
||||
if (resultOption.isDefined()) {
|
||||
Object result = resultOption.get();
|
||||
// ...
|
||||
} else {
|
||||
//... whatever
|
||||
}
|
||||
}
|
||||
Future<Object> future = myActor.ask("Hello", 1000);
|
||||
Object result = Await.result(future, Duration.create(1, TimeUnit.SECONDS));
|
||||
//#using-ask
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -113,7 +107,7 @@ public class UntypedActorTestBase {
|
|||
ActorSystem system = ActorSystem.create("MySystem");
|
||||
ActorRef myActor = system.actorOf(new Props(MyReceivedTimeoutUntypedActor.class));
|
||||
myActor.tell("Hello");
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -123,7 +117,7 @@ public class UntypedActorTestBase {
|
|||
//#poison-pill
|
||||
myActor.tell(poisonPill());
|
||||
//#poison-pill
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -133,7 +127,7 @@ public class UntypedActorTestBase {
|
|||
//#kill
|
||||
victim.tell(kill());
|
||||
//#kill
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -147,7 +141,7 @@ public class UntypedActorTestBase {
|
|||
myActor.tell("foo");
|
||||
myActor.tell("bar");
|
||||
myActor.tell("bar");
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
public static class MyActor extends UntypedActor {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class DispatcherDocTestBase {
|
|||
|
||||
@After
|
||||
public void tearDown() {
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class LoggingDocTestBase {
|
|||
}
|
||||
}));
|
||||
myActor.tell("test");
|
||||
system.stop();
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
//#my-actor
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Dispatchers (Java)
|
|||
.. sidebar:: Contents
|
||||
|
||||
.. contents:: :local:
|
||||
|
||||
|
||||
The Dispatcher is an important piece that allows you to configure the right semantics and parameters for optimal performance, throughput and scalability. Different Actors have different needs.
|
||||
|
||||
Akka supports dispatchers for both event-driven lightweight threads, allowing creation of millions of threads on a single workstation, and thread-based Actors, where each dispatcher is bound to a dedicated OS thread.
|
||||
|
|
@ -44,7 +44,7 @@ There are 4 different types of message dispatchers:
|
|||
|
||||
It is recommended to define the dispatcher in :ref:`configuration` to allow for tuning for different environments.
|
||||
|
||||
Example of a custom event-based dispatcher, which can be fetched with ``system.dispatcherFactory().lookup("my-dispatcher")``
|
||||
Example of a custom event-based dispatcher, which can be fetched with ``system.dispatcherFactory().lookup("my-dispatcher")``
|
||||
as in the example above:
|
||||
|
||||
.. includecode:: ../scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala#my-dispatcher-config
|
||||
|
|
@ -115,7 +115,7 @@ Priority event-based
|
|||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Sometimes it's useful to be able to specify priority order of messages, that is done by using Dispatcher and supply
|
||||
an UnboundedPriorityMailbox or BoundedPriorityMailbox with a ``java.util.Comparator[Envelope]`` or use a
|
||||
an UnboundedPriorityMailbox or BoundedPriorityMailbox with a ``java.util.Comparator[Envelope]`` or use a
|
||||
``akka.dispatch.PriorityGenerator`` (recommended).
|
||||
|
||||
Creating a Dispatcher using PriorityGenerator:
|
||||
|
|
@ -129,9 +129,9 @@ Work-sharing event-based
|
|||
|
||||
The ``BalancingDispatcher`` is a variation of the ``Dispatcher`` in which Actors of the same type can be set up to
|
||||
share this dispatcher and during execution time the different actors will steal messages from other actors if they
|
||||
have less messages to process.
|
||||
have less messages to process.
|
||||
Although the technique used in this implementation is commonly known as "work stealing", the actual implementation is probably
|
||||
best described as "work donating" because the actor of which work is being stolen takes the initiative.
|
||||
best described as "work donating" because the actor of which work is being stolen takes the initiative.
|
||||
This can be a great way to improve throughput at the cost of a little higher latency.
|
||||
|
||||
.. includecode:: ../scala/code/akka/docs/dispatcher/DispatcherDocSpec.scala#my-balancing-config
|
||||
|
|
@ -154,8 +154,9 @@ if not specified otherwise.
|
|||
akka {
|
||||
actor {
|
||||
default-dispatcher {
|
||||
task-queue-size = 1000 # If negative (or zero) then an unbounded mailbox is used (default)
|
||||
# If positive then a bounded mailbox is used and the capacity is set to the number specified
|
||||
# If negative (or zero) then an unbounded mailbox is used (default)
|
||||
# If positive then a bounded mailbox is used and the capacity is set to the number specified
|
||||
task-queue-size = 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ The source object is translated to a String according to the following rules:
|
|||
* in case of a class an approximation of its simpleName
|
||||
* and in all other cases the simpleName of its class
|
||||
|
||||
The log message may contain argument placeholders ``{}``, which will be substituted if the log level
|
||||
The log message may contain argument placeholders ``{}``, which will be substituted if the log level
|
||||
is enabled.
|
||||
|
||||
Event Handler
|
||||
=============
|
||||
|
||||
Logging is performed asynchronously through an event bus. You can configure which event handlers that should
|
||||
subscribe to the logging events. That is done using the 'event-handlers' element in the :ref:`configuration`.
|
||||
Logging is performed asynchronously through an event bus. You can configure which event handlers that should
|
||||
subscribe to the logging events. That is done using the 'event-handlers' element in the :ref:`configuration`.
|
||||
Here you can also define the log level.
|
||||
|
||||
.. code-block:: ruby
|
||||
|
|
@ -40,16 +40,17 @@ Here you can also define the log level.
|
|||
akka {
|
||||
# Event handlers to register at boot time (Logging$DefaultLogger logs to STDOUT)
|
||||
event-handlers = ["akka.event.Logging$DefaultLogger"]
|
||||
loglevel = "DEBUG" # Options: ERROR, WARNING, INFO, DEBUG
|
||||
# Options: ERROR, WARNING, INFO, DEBUG
|
||||
loglevel = "DEBUG"
|
||||
}
|
||||
|
||||
The default one logs to STDOUT and is registered by default. It is not intended to be used for production. There is also an :ref:`slf4j-java`
|
||||
The default one logs to STDOUT and is registered by default. It is not intended to be used for production. There is also an :ref:`slf4j-java`
|
||||
event handler available in the 'akka-slf4j' module.
|
||||
|
||||
Example of creating a listener:
|
||||
|
||||
.. includecode:: code/akka/docs/event/LoggingDocTestBase.java
|
||||
:include: imports,imports-listener,my-event-listener
|
||||
:include: imports,imports-listener,my-event-listener
|
||||
|
||||
|
||||
.. _slf4j-java:
|
||||
|
|
@ -57,7 +58,7 @@ Example of creating a listener:
|
|||
SLF4J
|
||||
=====
|
||||
|
||||
Akka provides an event handler for `SL4FJ <http://www.slf4j.org/>`_. This module is available in the 'akka-slf4j.jar'.
|
||||
Akka provides an event handler for `SL4FJ <http://www.slf4j.org/>`_. This module is available in the 'akka-slf4j.jar'.
|
||||
It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4J backend, we recommend `Logback <http://logback.qos.ch/>`_:
|
||||
|
||||
.. code-block:: xml
|
||||
|
|
@ -69,10 +70,10 @@ It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
You need to enable the Slf4jEventHandler in the 'event-handlers' element in
|
||||
the :ref:`configuration`. Here you can also define the log level of the event bus.
|
||||
You need to enable the Slf4jEventHandler in the 'event-handlers' element in
|
||||
the :ref:`configuration`. Here you can also define the log level of the event bus.
|
||||
More fine grained log levels can be defined in the configuration of the SLF4J backend
|
||||
(e.g. logback.xml). The String representation of the source object that is used when
|
||||
(e.g. logback.xml). The String representation of the source object that is used when
|
||||
creating the ``LoggingAdapter`` correspond to the name of the SL4FJ logger.
|
||||
|
||||
.. code-block:: ruby
|
||||
|
|
@ -89,9 +90,9 @@ Since the logging is done asynchronously the thread in which the logging was per
|
|||
Mapped Diagnostic Context (MDC) with attribute name ``sourceThread``.
|
||||
With Logback the thread name is available with ``%X{sourceThread}`` specifier within the pattern layout configuration::
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout>
|
||||
<pattern>%date{ISO8601} %-5level %logger{36} %X{sourceThread} - %msg%n</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout>
|
||||
<pattern>%date{ISO8601} %-5level %logger{36} %X{sourceThread} - %msg%n</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue