Skip to content

Commit

Permalink
Merge branch 'release-2.0' of github.com:akka/akka into release-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorklang committed Nov 17, 2012
2 parents 0eb4df7 + 9388389 commit 2552a61
Show file tree
Hide file tree
Showing 28 changed files with 146 additions and 41 deletions.
22 changes: 21 additions & 1 deletion akka-actor-tests/src/test/scala/akka/util/DurationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,28 @@ package akka.util
import org.scalatest.WordSpec
import org.scalatest.matchers.MustMatchers
import duration._
import akka.testkit.AkkaSpec
import akka.testkit.TestLatch
import java.util.concurrent.TimeoutException
import akka.dispatch.Await
import akka.testkit.TimingTest

class DurationSpec extends WordSpec with MustMatchers {
class DurationSpec extends AkkaSpec {

"A HashedWheelTimer" must {

"not mess up long timeouts" taggedAs TimingTest in {
val longish = Timeout(Long.MaxValue)
val barrier = TestLatch()
val job = system.scheduler.scheduleOnce(longish.duration)(barrier.countDown())
intercept[TimeoutException] {
// this used to fire after 46 seconds due to wrap-around
Await.ready(barrier, 90 seconds)
}
job.cancel()
}

}

"Duration" must {

Expand Down
13 changes: 12 additions & 1 deletion akka-actor/src/main/java/akka/jsr166y/ForkJoinPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ final void deregisterWorker(ForkJoinWorkerThread wt, Throwable ex) {
}

if (ex != null) // rethrow
U.throwException(ex);
rethrow(ex);
}


Expand Down Expand Up @@ -2856,4 +2856,15 @@ private static sun.misc.Unsafe getUnsafe() {
return Unsafe.instance;
}

final static void rethrow(final Throwable t) {
throwSoftUnchecked(t, RuntimeException.class);
}

@SuppressWarnings("unchecked")
private final static <T extends Throwable> void throwSoftUnchecked(
final Throwable t,
final Class<T> infer) throws T {
throw (T)t;
}

}
6 changes: 3 additions & 3 deletions akka-actor/src/main/java/akka/jsr166y/ForkJoinTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ private void reportException(int s) {
(s == EXCEPTIONAL) ? getThrowableException() :
null);
if (ex != null)
U.throwException(ex);
ForkJoinPool.rethrow(ex);
}

// public methods
Expand Down Expand Up @@ -730,7 +730,7 @@ else if (t.doJoin() < NORMAL)
}
}
if (ex != null)
U.throwException(ex);
ForkJoinPool.rethrow(ex);
}

/**
Expand Down Expand Up @@ -787,7 +787,7 @@ else if (t.doJoin() < NORMAL)
}
}
if (ex != null)
U.throwException(ex);
ForkJoinPool.rethrow(ex);
return tasks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ public Timeout newTimeout(TimerTask task, Duration delay) {
void scheduleTimeout(HashedWheelTimeout timeout, long delay) {
// Prepare the required parameters to schedule the timeout object.
long relativeIndex = (delay + tickDuration - 1) / tickDuration;
// if the previous line had an overflow going on, then we’ll just schedule this timeout
// one tick early; that shouldn’t matter since we’re talking 270 years here
if (relativeIndex < 0) relativeIndex = delay / tickDuration;
if (relativeIndex == 0) {
relativeIndex = 1;
}
Expand Down Expand Up @@ -313,7 +316,7 @@ public void run() {

while (!shutdown()) {
final long deadline = waitForNextTick();
if (deadline > 0) {
if (deadline > Long.MIN_VALUE) {
fetchExpiredTimeouts(expiredTimeouts, deadline);
notifyExpiredTimeouts(expiredTimeouts);
}
Expand Down Expand Up @@ -346,7 +349,7 @@ private void fetchExpiredTimeouts(
HashedWheelTimeout timeout = i.next();
if (timeout.remainingRounds <= 0) {
i.remove();
if (timeout.deadline <= deadline) {
if (timeout.deadline - deadline <= 0) {
expiredTimeouts.add(timeout);
} else {
// Handle the case where the timeout is put into a wrong
Expand Down Expand Up @@ -382,6 +385,12 @@ private void notifyExpiredTimeouts(
expiredTimeouts.clear();
}

/**
* calculate goal nanoTime from startTime and current tick number,
* then wait until that goal has been reached.
*
* @return Long.MIN_VALUE if received a shutdown request, current time otherwise (with Long.MIN_VALUE changed by +1)
*/
private long waitForNextTick() {
final long deadline = startTime + tickDuration * tick;

Expand All @@ -392,7 +401,8 @@ private long waitForNextTick() {

if (sleepTimeMs <= 0) {
tick += 1;
return currentTime;
if (currentTime == Long.MIN_VALUE) return -Long.MAX_VALUE;
else return currentTime;
}

// Check if we run on windows, as if thats the case we will need
Expand All @@ -408,7 +418,7 @@ private long waitForNextTick() {
Thread.sleep(sleepTimeMs);
} catch (InterruptedException e) {
if (shutdown()) {
return -1;
return Long.MIN_VALUE;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion akka-docs/_sphinx/pygments/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@
author = "Akka",
packages = ['styles'],
entry_points = entry_points,
html_use_smartypants = false
)
2 changes: 1 addition & 1 deletion akka-docs/common/duration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ method calls instead:
Deadline
========

Durations have a brother name :class:`Deadline`, which is a class holding a representation
Durations have a brother named :class:`Deadline`, which is a class holding a representation
of an absolute point in time, and support deriving a duration from this by calculating the
difference between now and the deadline. This is useful when you want to keep one overall
deadline without having to take care of the book-keeping wrt. the passing of time yourself::
Expand Down
1 change: 1 addition & 0 deletions akka-docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
html_show_copyright = True
htmlhelp_basename = 'Akkadoc'
html_add_permalinks = ''
html_use_smartypants = False

html_context = {
'include_analytics': 'online' in tags
Expand Down
8 changes: 4 additions & 4 deletions akka-docs/general/jmm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Prior to Java 5, the Java Memory Model (JMM) was ill defined. It was possible to
shared memory was accessed by multiple threads, such as:

* a thread not seeing values written by other threads: a visibility problem
* a thread observing 'impossible' behavior of other threads, caused by instructions not being executed in the order

expected: an instruction reordering problem.
* a thread observing 'impossible' behavior of other threads, caused by
instructions not being executed in the order expected: an instruction
reordering problem.

With the implementation of JSR 133 in Java 5, a lot of these issues have been resolved. The JMM is a set of rules based
on the "happens-before" relation, which constrain when one memory access must happen before another, and conversely,
Expand Down Expand Up @@ -114,4 +114,4 @@ Since Akka runs on the JVM there are still some rules to be followed.
}
}
* Messages **should** be immutable, this is to avoid the shared mutable state trap.
* Messages **should** be immutable, this is to avoid the shared mutable state trap.
4 changes: 2 additions & 2 deletions akka-docs/general/message-send-semantics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ which is a user-level concern.
Ordering is preserved on a per-sender basis
-------------------------------------------

Actor ``A1` sends messages ``M1``, ``M2``, ``M3`` to ``A2``
Actor ``A1`` sends messages ``M1``, ``M2``, ``M3`` to ``A2``
Actor ``A3`` sends messages ``M4``, ``M5``, ``M6`` to ``A2``

This means that:
Expand All @@ -66,4 +66,4 @@ This means that:
5) ``A2`` can see messages from ``A1`` interleaved with messages from ``A3``
6) Since there is no guaranteed delivery, none, some or all of the messages may arrive to ``A2``

.. _Erlang documentation: http://www.erlang.org/faq/academic.html
.. _Erlang documentation: http://www.erlang.org/faq/academic.html
2 changes: 1 addition & 1 deletion akka-docs/general/supervision.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ which explains the existence of the fourth choice (as a supervisor also is
subordinate to another supervisor higher up) and has implications on the first
three: resuming an actor resumes all its subordinates, restarting an actor
entails restarting all its subordinates (but see below for more details),
similarly terminating an actor will also terminating all its subordinates. It
similarly terminating an actor will also terminate all its subordinates. It
should be noted that the default behavior of the :meth:`preRestart` hook of the
:class:`Actor` class is to terminate all its children before restarting, but
this hook can be overridden; the recursive restart applies to all children left
Expand Down
2 changes: 1 addition & 1 deletion akka-docs/intro/what-is-akka.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The Typesafe Stack is all fully open source.
Typesafe Console
================

On top of the Typesafe Stack we have also have commercial product called Typesafe
On top of the Typesafe Stack we also have commercial product called Typesafe
Console which provides the following features:

#. Slick Web UI with real-time view into the system
Expand Down
2 changes: 1 addition & 1 deletion akka-docs/intro/why-akka.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ and then there's the whole package, the Akka Microkernel, which is a standalone
container to deploy your Akka application in. With CPUs growing more and more
cores every cycle, Akka is the alternative that provides outstanding performance
even if you're only running it on one machine. Akka also supplies a wide array
of concurrency-paradigms, allowing for users to choose the right tool for the
of concurrency-paradigms, allowing users to choose the right tool for the
job.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void usePatternsAskPipe() {

final ArrayList<Future<Object>> futures = new ArrayList<Future<Object>>();
futures.add(ask(actorA, "request", 1000)); // using 1000ms timeout
futures.add(ask(actorB, "reqeest", t)); // using timeout from above
futures.add(ask(actorB, "request", t)); // using timeout from above

final Future<Iterable<Object>> aggregate = Futures.sequence(futures, system.dispatcher());

Expand Down Expand Up @@ -313,7 +313,7 @@ public static class HotSwapActor extends UntypedActor {
Procedure<Object> angry = new Procedure<Object>() {
@Override
public void apply(Object message) {
if (message.equals("foo")) {
if (message.equals("bar")) {
getSender().tell("I am already angry?");
} else if (message.equals("foo")) {
getContext().become(happy);
Expand Down
2 changes: 1 addition & 1 deletion akka-docs/java/event-bus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ at runtime::

system.eventStream.setLogLevel(Logging.DebugLevel());

This means that log events for a level which will not be logged are not
This means that log events for a level which will not be logged are
typically not dispatched at all (unless manual subscriptions to the respective
event class have been done)

Expand Down
1 change: 1 addition & 0 deletions akka-docs/java/fault-tolerance-sample.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ Full Source Code of the Fault Tolerance Sample (Java)
------------------------------------------------------

.. includecode:: code/akka/docs/actor/japi/FaultHandlingDocSample.java#all
:exclude: imports,messages,dummydb

3 changes: 0 additions & 3 deletions akka-docs/java/fault-tolerance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ sample as it is easy to follow the log output to understand what is happening in

fault-tolerance-sample

.. includecode:: code/akka/docs/actor/japi/FaultHandlingDocSample.java#all
:exclude: imports,messages,dummydb

Creating a Supervisor Strategy
------------------------------

Expand Down
6 changes: 3 additions & 3 deletions akka-docs/java/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ In addition to being able to supply looked-up remote actors as routees, you can
make the router deploy its created children on a set of remote hosts; this will
be done in round-robin fashion. In order to do that, wrap the router
configuration in a :class:`RemoteRouterConfig`, attaching the remote addresses of
the nodes to deploy to. Naturally, this requires your to include the
the nodes to deploy to. Naturally, this requires you to include the
``akka-remote`` module on your classpath:

.. includecode:: code/akka/docs/jrouting/RouterViaProgramExample.java#remoteRoutees
Expand Down Expand Up @@ -104,7 +104,7 @@ Routers vs. Supervision
^^^^^^^^^^^^^^^^^^^^^^^

As explained in the previous section, routers create new actor instances as
children of the “head” router, who therefor also is their supervisor. The
children of the “head” router, who therefore also is their supervisor. The
supervisor strategy of this actor can be configured by means of the
:meth:`RouterConfig.supervisorStrategy` property, which is supported for all
built-in router types. It defaults to “always escalate”, which leads to the
Expand Down Expand Up @@ -338,7 +338,7 @@ Configured Custom Router

It is possible to define configuration properties for custom routers. In the ``router`` property of the deployment
configuration you define the fully qualified class name of the router class. The router class must extend
``akka.routing.CustomRouterConfig`` and and have constructor with ``com.typesafe.config.Config`` parameter.
``akka.routing.CustomRouterConfig`` and have a constructor with one ``com.typesafe.config.Config`` parameter.
The deployment section of the configuration is passed to the constructor.

Custom Resizer
Expand Down
2 changes: 1 addition & 1 deletion akka-docs/scala/event-bus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ at runtime::

system.eventStream.setLogLevel(Logging.DebugLevel)

This means that log events for a level which will not be logged are not
This means that log events for a level which will not be logged are
typically not dispatched at all (unless manual subscriptions to the respective
event class have been done)

Expand Down
1 change: 1 addition & 0 deletions akka-docs/scala/fault-tolerance-sample.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ Full Source Code of the Fault Tolerance Sample (Scala)
------------------------------------------------------

.. includecode:: code/akka/docs/actor/FaultHandlingDocSample.scala#all
:exclude: imports,messages,dummydb

3 changes: 0 additions & 3 deletions akka-docs/scala/fault-tolerance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ sample as it is easy to follow the log output to understand what is happening in

fault-tolerance-sample

.. includecode:: code/akka/docs/actor/FaultHandlingDocSample.scala#all
:exclude: imports,messages,dummydb

Creating a Supervisor Strategy
------------------------------

Expand Down
2 changes: 1 addition & 1 deletion akka-docs/scala/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ And it's companion object:

And the OKResponse:

.. includecode:: code/docs/io/HTTPServer.scala
.. includecode:: code/akka/docs/io/HTTPServer.scala
:include: ok-response

A ``main`` method to start everything up:
Expand Down
6 changes: 3 additions & 3 deletions akka-docs/scala/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ In addition to being able to supply looked-up remote actors as routees, you can
make the router deploy its created children on a set of remote hosts; this will
be done in round-robin fashion. In order to do that, wrap the router
configuration in a :class:`RemoteRouterConfig`, attaching the remote addresses of
the nodes to deploy to. Naturally, this requires your to include the
the nodes to deploy to. Naturally, this requires you to include the
``akka-remote`` module on your classpath:

.. includecode:: code/akka/docs/routing/RouterViaProgramExample.scala#remoteRoutees
Expand Down Expand Up @@ -104,7 +104,7 @@ Routers vs. Supervision
^^^^^^^^^^^^^^^^^^^^^^^

As explained in the previous section, routers create new actor instances as
children of the “head” router, who therefor also is their supervisor. The
children of the “head” router, who therefore also is their supervisor. The
supervisor strategy of this actor can be configured by means of the
:meth:`RouterConfig.supervisorStrategy` property, which is supported for all
built-in router types. It defaults to “always escalate”, which leads to the
Expand Down Expand Up @@ -338,7 +338,7 @@ Configured Custom Router

It is possible to define configuration properties for custom routers. In the ``router`` property of the deployment
configuration you define the fully qualified class name of the router class. The router class must extend
``akka.routing.RouterConfig`` and and have constructor with ``com.typesafe.config.Config`` parameter.
``akka.routing.RouterConfig`` and have a constructor with one ``com.typesafe.config.Config`` parameter.
The deployment section of the configuration is passed to the constructor.

Custom Resizer
Expand Down
30 changes: 30 additions & 0 deletions akka-remote/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,36 @@ akka {

# (O) Maximum time window that a client should try to reconnect for
reconnection-time-window = 600s

# (I&O) Used to configure the number of I/O worker threads on server sockets
server-socket-worker-pool {
# Min number of threads to cap factor-based number to
pool-size-min = 2

# The pool size factor is used to determine thread pool size
# using the following formula: ceil(available processors * factor).
# Resulting size is then bounded by the pool-size-min and
# pool-size-max values.
pool-size-factor = 2.0

# Max number of threads to cap factor-based number to
pool-size-max = 128
}

# (I&O) Used to configure the number of I/O worker threads on client sockets
client-socket-worker-pool {
# Min number of threads to cap factor-based number to
pool-size-min = 2

# The pool size factor is used to determine thread pool size
# using the following formula: ceil(available processors * factor).
# Resulting size is then bounded by the pool-size-min and
# pool-size-max values.
pool-size-factor = 2.0

# Max number of threads to cap factor-based number to
pool-size-max = 128
}
}

# The dispatcher used for the system actor "network-event-sender"
Expand Down
Loading

0 comments on commit 2552a61

Please sign in to comment.