Changed all 'def foo(): Unit = { .. }' to 'def foo() { .. }'
This commit is contained in:
parent
07b29c0627
commit
db8a20ea37
49 changed files with 153 additions and 152 deletions
|
|
@ -181,7 +181,7 @@ public class JavaFutureTests {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> result = fold("", 15000,listFutures, new Function2<String,String,String>(){
|
Future<String> result = fold("", 15000,listFutures, new Function2<String,String,String>() {
|
||||||
public String apply(String r, String t) {
|
public String apply(String r, String t) {
|
||||||
return r + t;
|
return r + t;
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +203,7 @@ public class JavaFutureTests {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> result = reduce(listFutures, 15000, new Function2<String,String,String>(){
|
Future<String> result = reduce(listFutures, 15000, new Function2<String,String,String>() {
|
||||||
public String apply(String r, String t) {
|
public String apply(String r, String t) {
|
||||||
return r + t;
|
return r + t;
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +221,7 @@ public class JavaFutureTests {
|
||||||
listStrings.add("test");
|
listStrings.add("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Iterable<String>> result = traverse(listStrings, new Function<String,Future<String>>(){
|
Future<Iterable<String>> result = traverse(listStrings, new Function<String,Future<String>>() {
|
||||||
public Future<String> apply(final String r) {
|
public Future<String> apply(final String r) {
|
||||||
return future(new Callable<String>() {
|
return future(new Callable<String>() {
|
||||||
public String call() {
|
public String call() {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class AkkaExceptionSpec extends WordSpec with MustMatchers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def verify(clazz: java.lang.Class[_]): Unit = {
|
def verify(clazz: java.lang.Class[_]) {
|
||||||
clazz.getConstructor(Array(classOf[String]): _*)
|
clazz.getConstructor(Array(classOf[String]): _*)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ object IOActorSpec {
|
||||||
|
|
||||||
var socket: SocketHandle = _
|
var socket: SocketHandle = _
|
||||||
|
|
||||||
override def preStart: Unit = {
|
override def preStart {
|
||||||
socket = connect(ioManager, host, port)
|
socket = connect(ioManager, host, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ abstract class ActorModelSpec extends JUnitSuite {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def dispatcherShouldProcessMessagesInParallel: Unit = {
|
def dispatcherShouldProcessMessagesInParallel {
|
||||||
implicit val dispatcher = newInterceptedDispatcher
|
implicit val dispatcher = newInterceptedDispatcher
|
||||||
val aStart, aStop, bParallel = new CountDownLatch(1)
|
val aStart, aStop, bParallel = new CountDownLatch(1)
|
||||||
val a, b = newTestActor
|
val a, b = newTestActor
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class Report(
|
||||||
val legendTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm")
|
val legendTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm")
|
||||||
val fileTimestampFormat = new SimpleDateFormat("yyyyMMddHHmmss")
|
val fileTimestampFormat = new SimpleDateFormat("yyyyMMddHHmmss")
|
||||||
|
|
||||||
def html(statistics: Seq[Stats]): Unit = {
|
def html(statistics: Seq[Stats]) {
|
||||||
|
|
||||||
val current = statistics.last
|
val current = statistics.last
|
||||||
val sb = new StringBuilder
|
val sb = new StringBuilder
|
||||||
|
|
|
||||||
|
|
@ -12,23 +12,23 @@ import akka.actor.ActorRef;
|
||||||
public class JavaEventHandler {
|
public class JavaEventHandler {
|
||||||
|
|
||||||
|
|
||||||
public static void notify(Object message){
|
public static void notify(Object message) {
|
||||||
EventHandler$.MODULE$.notify(message);
|
EventHandler$.MODULE$.notify(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(ActorRef instance, Object message){
|
public static void debug(ActorRef instance, Object message) {
|
||||||
EventHandler$.MODULE$.debug(instance, message);
|
EventHandler$.MODULE$.debug(instance, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(ActorRef instance, Object message){
|
public static void info(ActorRef instance, Object message) {
|
||||||
EventHandler$.MODULE$.info(instance,message);
|
EventHandler$.MODULE$.info(instance,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warning(ActorRef instance, Object message){
|
public static void warning(ActorRef instance, Object message) {
|
||||||
EventHandler$.MODULE$.warning(instance,message);
|
EventHandler$.MODULE$.warning(instance,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(ActorRef instance, Object message){
|
public static void error(ActorRef instance, Object message) {
|
||||||
EventHandler$.MODULE$.debug(instance,message);
|
EventHandler$.MODULE$.debug(instance,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ object Actor {
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
def spawn(body: ⇒ Unit)(implicit dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher): Unit = {
|
def spawn(body: ⇒ Unit)(implicit dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher) {
|
||||||
actorOf(Props(self ⇒ { case "go" ⇒ try { body } finally { self.stop() } }).withDispatcher(dispatcher)) ! "go"
|
actorOf(Props(self ⇒ { case "go" ⇒ try { body } finally { self.stop() } }).withDispatcher(dispatcher)) ! "go"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ private[akka] class ActorCell(
|
||||||
@volatile
|
@volatile
|
||||||
var mailbox: Mailbox = _
|
var mailbox: Mailbox = _
|
||||||
|
|
||||||
def start(): Unit = {
|
def start() {
|
||||||
if (props.supervisor.isDefined) props.supervisor.get.link(self)
|
if (props.supervisor.isDefined) props.supervisor.get.link(self)
|
||||||
mailbox = dispatcher.createMailbox(this)
|
mailbox = dispatcher.createMailbox(this)
|
||||||
Actor.registry.register(self)
|
Actor.registry.register(self)
|
||||||
|
|
@ -200,7 +200,7 @@ private[akka] class ActorCell(
|
||||||
case msg ⇒ msg.channel
|
case msg ⇒ msg.channel
|
||||||
}
|
}
|
||||||
|
|
||||||
def systemInvoke(envelope: SystemEnvelope): Unit = {
|
def systemInvoke(envelope: SystemEnvelope) {
|
||||||
def create(recreation: Boolean): Unit = try {
|
def create(recreation: Boolean): Unit = try {
|
||||||
actor.get() match {
|
actor.get() match {
|
||||||
case null ⇒
|
case null ⇒
|
||||||
|
|
@ -226,7 +226,7 @@ private[akka] class ActorCell(
|
||||||
|
|
||||||
def resume(): Unit = dispatcher resume this
|
def resume(): Unit = dispatcher resume this
|
||||||
|
|
||||||
def terminate(): Unit = {
|
def terminate() {
|
||||||
receiveTimeout = None
|
receiveTimeout = None
|
||||||
cancelReceiveTimeout
|
cancelReceiveTimeout
|
||||||
Actor.provider.evict(self.address)
|
Actor.provider.evict(self.address)
|
||||||
|
|
@ -279,7 +279,7 @@ private[akka] class ActorCell(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def invoke(messageHandle: Envelope): Unit = {
|
def invoke(messageHandle: Envelope) {
|
||||||
guard.lock.lock()
|
guard.lock.lock()
|
||||||
try {
|
try {
|
||||||
if (!mailbox.isClosed) {
|
if (!mailbox.isClosed) {
|
||||||
|
|
@ -320,7 +320,7 @@ private[akka] class ActorCell(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def handleFailure(fail: Failed): Unit = {
|
def handleFailure(fail: Failed) {
|
||||||
props.faultHandler match {
|
props.faultHandler match {
|
||||||
case AllForOnePermanentStrategy(trapExit, maxRetries, within) if trapExit.exists(_.isAssignableFrom(fail.cause.getClass)) ⇒
|
case AllForOnePermanentStrategy(trapExit, maxRetries, within) if trapExit.exists(_.isAssignableFrom(fail.cause.getClass)) ⇒
|
||||||
restartLinkedActors(fail.cause, maxRetries, within)
|
restartLinkedActors(fail.cause, maxRetries, within)
|
||||||
|
|
@ -426,7 +426,7 @@ private[akka] class ActorCell(
|
||||||
denied == false // if we weren't denied, we have a go
|
denied == false // if we weren't denied, we have a go
|
||||||
}
|
}
|
||||||
|
|
||||||
protected[akka] def restartLinkedActors(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Unit = {
|
protected[akka] def restartLinkedActors(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]) {
|
||||||
props.faultHandler.lifeCycle match {
|
props.faultHandler.lifeCycle match {
|
||||||
case Temporary ⇒
|
case Temporary ⇒
|
||||||
val i = _linkedActors.values.iterator
|
val i = _linkedActors.values.iterator
|
||||||
|
|
@ -466,7 +466,7 @@ private[akka] class ActorCell(
|
||||||
|
|
||||||
def clearActorContext(): Unit = setActorContext(null)
|
def clearActorContext(): Unit = setActorContext(null)
|
||||||
|
|
||||||
def setActorContext(newContext: ActorContext): Unit = {
|
def setActorContext(newContext: ActorContext) {
|
||||||
@tailrec
|
@tailrec
|
||||||
def lookupAndSetSelfFields(clazz: Class[_], actor: Actor, newContext: ActorContext): Boolean = {
|
def lookupAndSetSelfFields(clazz: Class[_], actor: Actor, newContext: ActorContext): Boolean = {
|
||||||
val success = try {
|
val success = try {
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,7 @@ private[akka] case class RemoteActorRef private[akka] (
|
||||||
|
|
||||||
protected[akka] override def timeout: Long = _timeout
|
protected[akka] override def timeout: Long = _timeout
|
||||||
|
|
||||||
def postMessageToMailbox(message: Any, channel: UntypedChannel): Unit = {
|
def postMessageToMailbox(message: Any, channel: UntypedChannel) {
|
||||||
val chSender = if (channel.isInstanceOf[ActorRef]) Some(channel.asInstanceOf[ActorRef]) else None
|
val chSender = if (channel.isInstanceOf[ActorRef]) Some(channel.asInstanceOf[ActorRef]) else None
|
||||||
Actor.remote.send[Any](message, chSender, None, remoteAddress, timeout, true, this, loader)
|
Actor.remote.send[Any](message, chSender, None, remoteAddress, timeout, true, this, loader)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,12 +60,12 @@ private[actor] final class ActorRegistry private[actor] () extends ListenerManag
|
||||||
notifyListeners(ActorRegistered(address, actor))
|
notifyListeners(ActorRegistered(address, actor))
|
||||||
}
|
}
|
||||||
|
|
||||||
private[akka] def registerTypedActor(actorRef: ActorRef, proxy: AnyRef): Unit = {
|
private[akka] def registerTypedActor(actorRef: ActorRef, proxy: AnyRef) {
|
||||||
if (typedActorsByUuid.putIfAbsent(actorRef.uuid, proxy) eq null)
|
if (typedActorsByUuid.putIfAbsent(actorRef.uuid, proxy) eq null)
|
||||||
notifyListeners(TypedActorRegistered(actorRef.address, actorRef, proxy))
|
notifyListeners(TypedActorRegistered(actorRef.address, actorRef, proxy))
|
||||||
}
|
}
|
||||||
|
|
||||||
private[akka] def unregisterTypedActor(actorRef: ActorRef, proxy: AnyRef): Unit = {
|
private[akka] def unregisterTypedActor(actorRef: ActorRef, proxy: AnyRef) {
|
||||||
if (typedActorsByUuid.remove(actorRef.uuid, proxy))
|
if (typedActorsByUuid.remove(actorRef.uuid, proxy))
|
||||||
notifyListeners(TypedActorUnregistered(actorRef.address, actorRef, proxy))
|
notifyListeners(TypedActorUnregistered(actorRef.address, actorRef, proxy))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -487,12 +487,12 @@ trait FSM[S, D] extends ListenerManagement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def processMsg(value: Any, source: AnyRef): Unit = {
|
private def processMsg(value: Any, source: AnyRef) {
|
||||||
val event = Event(value, currentState.stateData)
|
val event = Event(value, currentState.stateData)
|
||||||
processEvent(event, source)
|
processEvent(event, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
private[akka] def processEvent(event: Event, source: AnyRef): Unit = {
|
private[akka] def processEvent(event: Event, source: AnyRef) {
|
||||||
val stateFunc = stateFunctions(currentState.stateName)
|
val stateFunc = stateFunctions(currentState.stateName)
|
||||||
val nextState = if (stateFunc isDefinedAt event) {
|
val nextState = if (stateFunc isDefinedAt event) {
|
||||||
stateFunc(event)
|
stateFunc(event)
|
||||||
|
|
@ -503,7 +503,7 @@ trait FSM[S, D] extends ListenerManagement {
|
||||||
applyState(nextState)
|
applyState(nextState)
|
||||||
}
|
}
|
||||||
|
|
||||||
private[akka] def applyState(nextState: State): Unit = {
|
private[akka] def applyState(nextState: State) {
|
||||||
nextState.stopReason match {
|
nextState.stopReason match {
|
||||||
case None ⇒ makeTransition(nextState)
|
case None ⇒ makeTransition(nextState)
|
||||||
case _ ⇒
|
case _ ⇒
|
||||||
|
|
@ -513,7 +513,7 @@ trait FSM[S, D] extends ListenerManagement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private[akka] def makeTransition(nextState: State): Unit = {
|
private[akka] def makeTransition(nextState: State) {
|
||||||
if (!stateFunctions.contains(nextState.stateName)) {
|
if (!stateFunctions.contains(nextState.stateName)) {
|
||||||
terminate(stay withStopReason Failure("Next state %s does not exist".format(nextState.stateName)))
|
terminate(stay withStopReason Failure("Next state %s does not exist".format(nextState.stateName)))
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -535,7 +535,7 @@ trait FSM[S, D] extends ListenerManagement {
|
||||||
|
|
||||||
override def postStop() { terminate(stay withStopReason Shutdown) }
|
override def postStop() { terminate(stay withStopReason Shutdown) }
|
||||||
|
|
||||||
private def terminate(nextState: State): Unit = {
|
private def terminate(nextState: State) {
|
||||||
if (!currentState.stopReason.isDefined) {
|
if (!currentState.stopReason.isDefined) {
|
||||||
val reason = nextState.stopReason.get
|
val reason = nextState.stopReason.get
|
||||||
reason match {
|
reason match {
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ trait IO {
|
||||||
|
|
||||||
// only reinvoke messages from the original message to avoid stack overflow
|
// only reinvoke messages from the original message to avoid stack overflow
|
||||||
private var reinvoked = false
|
private var reinvoked = false
|
||||||
private def reinvoke(): Unit = {
|
private def reinvoke() {
|
||||||
if (!reinvoked && (_next eq Idle) && _messages.nonEmpty) {
|
if (!reinvoked && (_next eq Idle) && _messages.nonEmpty) {
|
||||||
try {
|
try {
|
||||||
reinvoked = true
|
reinvoked = true
|
||||||
|
|
@ -208,7 +208,7 @@ trait IO {
|
||||||
}
|
}
|
||||||
|
|
||||||
@tailrec
|
@tailrec
|
||||||
private def run(): Unit = {
|
private def run() {
|
||||||
_next match {
|
_next match {
|
||||||
case ByteStringLength(continuation, handle, message, waitingFor) ⇒
|
case ByteStringLength(continuation, handle, message, waitingFor) ⇒
|
||||||
context.currentMessage = message
|
context.currentMessage = message
|
||||||
|
|
@ -256,7 +256,7 @@ class IOManager(bufferSize: Int = 8192) extends Actor {
|
||||||
|
|
||||||
var worker: IOWorker = _
|
var worker: IOWorker = _
|
||||||
|
|
||||||
override def preStart: Unit = {
|
override def preStart {
|
||||||
worker = new IOWorker(self, bufferSize)
|
worker = new IOWorker(self, bufferSize)
|
||||||
worker.start()
|
worker.start()
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +279,7 @@ class IOManager(bufferSize: Int = 8192) extends Actor {
|
||||||
case IO.Close(handle) ⇒ worker(Close(handle))
|
case IO.Close(handle) ⇒ worker(Close(handle))
|
||||||
}
|
}
|
||||||
|
|
||||||
override def postStop: Unit = {
|
override def postStop {
|
||||||
worker(Shutdown)
|
worker(Shutdown)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
private val buffer = ByteBuffer.allocate(bufferSize)
|
private val buffer = ByteBuffer.allocate(bufferSize)
|
||||||
|
|
||||||
private val thread = new Thread("io-worker") {
|
private val thread = new Thread("io-worker") {
|
||||||
override def run(): Unit = {
|
override def run() {
|
||||||
while (selector.isOpen) {
|
while (selector.isOpen) {
|
||||||
selector select ()
|
selector select ()
|
||||||
val keys = selector.selectedKeys.iterator
|
val keys = selector.selectedKeys.iterator
|
||||||
|
|
@ -359,7 +359,7 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def process(key: SelectionKey): Unit = {
|
private def process(key: SelectionKey) {
|
||||||
val handle = key.attachment.asInstanceOf[IO.Handle]
|
val handle = key.attachment.asInstanceOf[IO.Handle]
|
||||||
try {
|
try {
|
||||||
if (key.isConnectable) key.channel match {
|
if (key.isConnectable) key.channel match {
|
||||||
|
|
@ -387,7 +387,7 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private def cleanup(handle: IO.Handle, cause: Option[Exception]): Unit = {
|
private def cleanup(handle: IO.Handle, cause: Option[Exception]) {
|
||||||
handle match {
|
handle match {
|
||||||
case server: IO.ServerHandle ⇒ accepted -= server
|
case server: IO.ServerHandle ⇒ accepted -= server
|
||||||
case writable: IO.WriteHandle ⇒ writes -= writable
|
case writable: IO.WriteHandle ⇒ writes -= writable
|
||||||
|
|
@ -409,19 +409,19 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
private def setOps(handle: IO.Handle, ops: Int): Unit =
|
private def setOps(handle: IO.Handle, ops: Int): Unit =
|
||||||
channels(handle) keyFor selector interestOps ops
|
channels(handle) keyFor selector interestOps ops
|
||||||
|
|
||||||
private def addOps(handle: IO.Handle, ops: Int): Unit = {
|
private def addOps(handle: IO.Handle, ops: Int) {
|
||||||
val key = channels(handle) keyFor selector
|
val key = channels(handle) keyFor selector
|
||||||
val cur = key.interestOps
|
val cur = key.interestOps
|
||||||
key interestOps (cur | ops)
|
key interestOps (cur | ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def removeOps(handle: IO.Handle, ops: Int): Unit = {
|
private def removeOps(handle: IO.Handle, ops: Int) {
|
||||||
val key = channels(handle) keyFor selector
|
val key = channels(handle) keyFor selector
|
||||||
val cur = key.interestOps
|
val cur = key.interestOps
|
||||||
key interestOps (cur - (cur & ops))
|
key interestOps (cur - (cur & ops))
|
||||||
}
|
}
|
||||||
|
|
||||||
private def connect(socket: IO.SocketHandle, channel: SocketChannel): Unit = {
|
private def connect(socket: IO.SocketHandle, channel: SocketChannel) {
|
||||||
if (channel.finishConnect) {
|
if (channel.finishConnect) {
|
||||||
removeOps(socket, OP_CONNECT)
|
removeOps(socket, OP_CONNECT)
|
||||||
socket.owner ! IO.Connected(socket)
|
socket.owner ! IO.Connected(socket)
|
||||||
|
|
@ -431,7 +431,7 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@tailrec
|
@tailrec
|
||||||
private def accept(server: IO.ServerHandle, channel: ServerSocketChannel): Unit = {
|
private def accept(server: IO.ServerHandle, channel: ServerSocketChannel) {
|
||||||
val socket = channel.accept
|
val socket = channel.accept
|
||||||
if (socket ne null) {
|
if (socket ne null) {
|
||||||
socket configureBlocking false
|
socket configureBlocking false
|
||||||
|
|
@ -442,7 +442,7 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@tailrec
|
@tailrec
|
||||||
private def read(handle: IO.ReadHandle, channel: ReadChannel): Unit = {
|
private def read(handle: IO.ReadHandle, channel: ReadChannel) {
|
||||||
buffer.clear
|
buffer.clear
|
||||||
val readLen = channel read buffer
|
val readLen = channel read buffer
|
||||||
if (readLen == -1) {
|
if (readLen == -1) {
|
||||||
|
|
@ -455,7 +455,7 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@tailrec
|
@tailrec
|
||||||
private def write(handle: IO.WriteHandle, channel: WriteChannel): Unit = {
|
private def write(handle: IO.WriteHandle, channel: WriteChannel) {
|
||||||
val queue = writes(handle)
|
val queue = writes(handle)
|
||||||
if (queue.nonEmpty) {
|
if (queue.nonEmpty) {
|
||||||
val (buf, bufs) = queue.dequeue
|
val (buf, bufs) = queue.dequeue
|
||||||
|
|
@ -473,7 +473,7 @@ private[akka] class IOWorker(ioManager: ActorRef, val bufferSize: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@tailrec
|
@tailrec
|
||||||
private def addRequest(req: Request): Unit = {
|
private def addRequest(req: Request) {
|
||||||
val requests = _requests.get
|
val requests = _requests.get
|
||||||
if (_requests compareAndSet (requests, req :: requests))
|
if (_requests compareAndSet (requests, req :: requests))
|
||||||
selector wakeup ()
|
selector wakeup ()
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ sealed class Supervisor(handler: FaultHandlingStrategy, maxRestartsHandler: (Act
|
||||||
*/
|
*/
|
||||||
final class SupervisorActor private[akka] (maxRestartsHandler: (ActorRef, MaximumNumberOfRestartsWithinTimeRangeReached) ⇒ Unit) extends Actor {
|
final class SupervisorActor private[akka] (maxRestartsHandler: (ActorRef, MaximumNumberOfRestartsWithinTimeRangeReached) ⇒ Unit) extends Actor {
|
||||||
|
|
||||||
override def postStop(): Unit = {
|
override def postStop() {
|
||||||
val i = linkedActors.iterator
|
val i = linkedActors.iterator
|
||||||
while (i.hasNext) {
|
while (i.hasNext) {
|
||||||
val ref = i.next
|
val ref = i.next
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ class BalancingDispatcher(
|
||||||
registerForExecution(buddy.mailbox, false, false)
|
registerForExecution(buddy.mailbox, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected[akka] override def shutdown(): Unit = {
|
protected[akka] override def shutdown() {
|
||||||
super.shutdown()
|
super.shutdown()
|
||||||
buddies.clear()
|
buddies.clear()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ class Dispatcher(
|
||||||
registerForExecution(mbox, false, true)
|
registerForExecution(mbox, false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected[akka] def executeTask(invocation: TaskInvocation): Unit = {
|
protected[akka] def executeTask(invocation: TaskInvocation) {
|
||||||
try {
|
try {
|
||||||
executorService.get() execute invocation
|
executorService.get() execute invocation
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ abstract class Mailbox extends MessageQueue with SystemMessageQueue with Runnabl
|
||||||
* Internal method to enforce a volatile write of the status
|
* Internal method to enforce a volatile write of the status
|
||||||
*/
|
*/
|
||||||
@tailrec
|
@tailrec
|
||||||
final def acknowledgeStatus(): Unit = {
|
final def acknowledgeStatus() {
|
||||||
val s = _status.get()
|
val s = _status.get()
|
||||||
if (_status.compareAndSet(s, s)) ()
|
if (_status.compareAndSet(s, s)) ()
|
||||||
else acknowledgeStatus()
|
else acknowledgeStatus()
|
||||||
|
|
@ -112,7 +112,7 @@ abstract class Mailbox extends MessageQueue with SystemMessageQueue with Runnabl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def processAllSystemMessages(): Unit = {
|
def processAllSystemMessages() {
|
||||||
var nextMessage = systemDequeue()
|
var nextMessage = systemDequeue()
|
||||||
while (nextMessage ne null) {
|
while (nextMessage ne null) {
|
||||||
nextMessage.invoke()
|
nextMessage.invoke()
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ final case class SystemEnvelope(val receiver: ActorCell, val message: SystemMess
|
||||||
/**
|
/**
|
||||||
* @return whether to proceed with processing other messages
|
* @return whether to proceed with processing other messages
|
||||||
*/
|
*/
|
||||||
final def invoke(): Unit = {
|
final def invoke() {
|
||||||
receiver systemInvoke this
|
receiver systemInvoke this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +105,7 @@ abstract class MessageDispatcher extends Serializable {
|
||||||
/**
|
/**
|
||||||
* Attaches the specified actor instance to this dispatcher
|
* Attaches the specified actor instance to this dispatcher
|
||||||
*/
|
*/
|
||||||
final def attach(actor: ActorCell): Unit = {
|
final def attach(actor: ActorCell) {
|
||||||
guard.lock.lock()
|
guard.lock.lock()
|
||||||
try {
|
try {
|
||||||
startIfUnstarted()
|
startIfUnstarted()
|
||||||
|
|
@ -118,7 +118,7 @@ abstract class MessageDispatcher extends Serializable {
|
||||||
/**
|
/**
|
||||||
* Detaches the specified actor instance from this dispatcher
|
* Detaches the specified actor instance from this dispatcher
|
||||||
*/
|
*/
|
||||||
final def detach(actor: ActorCell): Unit = {
|
final def detach(actor: ActorCell) {
|
||||||
guard withGuard {
|
guard withGuard {
|
||||||
unregister(actor)
|
unregister(actor)
|
||||||
if (uuids.isEmpty && _tasks.get == 0) {
|
if (uuids.isEmpty && _tasks.get == 0) {
|
||||||
|
|
@ -134,11 +134,11 @@ abstract class MessageDispatcher extends Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final def startIfUnstarted(): Unit = {
|
protected final def startIfUnstarted() {
|
||||||
if (active.isOff) guard withGuard { active.switchOn { start() } }
|
if (active.isOff) guard withGuard { active.switchOn { start() } }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected[akka] final def dispatchTask(block: () ⇒ Unit): Unit = {
|
protected[akka] final def dispatchTask(block: () ⇒ Unit) {
|
||||||
_tasks.getAndIncrement()
|
_tasks.getAndIncrement()
|
||||||
try {
|
try {
|
||||||
startIfUnstarted()
|
startIfUnstarted()
|
||||||
|
|
@ -170,7 +170,7 @@ abstract class MessageDispatcher extends Serializable {
|
||||||
* Only "private[akka] for the sake of intercepting calls, DO NOT CALL THIS OUTSIDE OF THE DISPATCHER,
|
* Only "private[akka] for the sake of intercepting calls, DO NOT CALL THIS OUTSIDE OF THE DISPATCHER,
|
||||||
* and only call it under the dispatcher-guard, see "attach" for the only invocation
|
* and only call it under the dispatcher-guard, see "attach" for the only invocation
|
||||||
*/
|
*/
|
||||||
protected[akka] def register(actor: ActorCell): Unit = {
|
protected[akka] def register(actor: ActorCell) {
|
||||||
if (uuids add actor.uuid) {
|
if (uuids add actor.uuid) {
|
||||||
systemDispatch(SystemEnvelope(actor, Create, NullChannel)) //FIXME should this be here or moved into ActorCell.start perhaps?
|
systemDispatch(SystemEnvelope(actor, Create, NullChannel)) //FIXME should this be here or moved into ActorCell.start perhaps?
|
||||||
} else System.err.println("Couldn't register: " + actor)
|
} else System.err.println("Couldn't register: " + actor)
|
||||||
|
|
@ -180,7 +180,7 @@ abstract class MessageDispatcher extends Serializable {
|
||||||
* Only "private[akka] for the sake of intercepting calls, DO NOT CALL THIS OUTSIDE OF THE DISPATCHER,
|
* Only "private[akka] for the sake of intercepting calls, DO NOT CALL THIS OUTSIDE OF THE DISPATCHER,
|
||||||
* and only call it under the dispatcher-guard, see "detach" for the only invocation
|
* and only call it under the dispatcher-guard, see "detach" for the only invocation
|
||||||
*/
|
*/
|
||||||
protected[akka] def unregister(actor: ActorCell): Unit = {
|
protected[akka] def unregister(actor: ActorCell) {
|
||||||
if (uuids remove actor.uuid) {
|
if (uuids remove actor.uuid) {
|
||||||
val mailBox = actor.mailbox
|
val mailBox = actor.mailbox
|
||||||
mailBox.become(Mailbox.Closed)
|
mailBox.become(Mailbox.Closed)
|
||||||
|
|
@ -193,7 +193,7 @@ abstract class MessageDispatcher extends Serializable {
|
||||||
* Overridable callback to clean up the mailbox for a given actor,
|
* Overridable callback to clean up the mailbox for a given actor,
|
||||||
* called when an actor is unregistered.
|
* called when an actor is unregistered.
|
||||||
*/
|
*/
|
||||||
protected def cleanUpMailboxFor(actor: ActorCell, mailBox: Mailbox): Unit = {
|
protected def cleanUpMailboxFor(actor: ActorCell, mailBox: Mailbox) {
|
||||||
|
|
||||||
if (mailBox.hasSystemMessages) {
|
if (mailBox.hasSystemMessages) {
|
||||||
var envelope = mailBox.systemDequeue()
|
var envelope = mailBox.systemDequeue()
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ trait PromiseStreamIn[A] {
|
||||||
final def enqueue(elem: Future[A]): Unit =
|
final def enqueue(elem: Future[A]): Unit =
|
||||||
elem foreach (enqueue(_))
|
elem foreach (enqueue(_))
|
||||||
|
|
||||||
final def enqueue(elem1: Future[A], elem2: Future[A], elems: Future[A]*): Unit = {
|
final def enqueue(elem1: Future[A], elem2: Future[A], elems: Future[A]*) {
|
||||||
this += elem1 += elem2
|
this += elem1 += elem2
|
||||||
elems foreach (enqueue(_))
|
elems foreach (enqueue(_))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ trait Supervision { self: DeathWatch =>
|
||||||
val activeEntries = new ConcurrentHashMap[ActorRef, ActiveEntry](1024)
|
val activeEntries = new ConcurrentHashMap[ActorRef, ActiveEntry](1024)
|
||||||
val passiveEntries = new ConcurrentHashMap[ActorRef, PassiveEntry](1024)
|
val passiveEntries = new ConcurrentHashMap[ActorRef, PassiveEntry](1024)
|
||||||
|
|
||||||
def registerMonitorable(monitor: ActorRef, monitorsSupervisor: Option[ActorRef], faultHandlingStrategy: FaultHandlingStrategy): Unit = {
|
def registerMonitorable(monitor: ActorRef, monitorsSupervisor: Option[ActorRef], faultHandlingStrategy: FaultHandlingStrategy) {
|
||||||
read.lock()
|
read.lock()
|
||||||
try {
|
try {
|
||||||
activeEntries.putIfAbsent(monitor, ActiveEntry(strategy = faultHandlingStrategy))
|
activeEntries.putIfAbsent(monitor, ActiveEntry(strategy = faultHandlingStrategy))
|
||||||
|
|
@ -39,7 +39,7 @@ trait Supervision { self: DeathWatch =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def deregisterMonitorable(monitor: ActorRef): Unit = {
|
def deregisterMonitorable(monitor: ActorRef) {
|
||||||
read.lock()
|
read.lock()
|
||||||
try {
|
try {
|
||||||
activeEntries.remove(monitor)
|
activeEntries.remove(monitor)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class BoundedBlockingQueue[E <: AnyRef](
|
||||||
private val notEmpty = lock.newCondition()
|
private val notEmpty = lock.newCondition()
|
||||||
private val notFull = lock.newCondition()
|
private val notFull = lock.newCondition()
|
||||||
|
|
||||||
def put(e: E): Unit = { //Blocks until not full
|
def put(e: E) { //Blocks until not full
|
||||||
if (e eq null) throw new NullPointerException
|
if (e eq null) throw new NullPointerException
|
||||||
lock.lock()
|
lock.lock()
|
||||||
try {
|
try {
|
||||||
|
|
@ -157,7 +157,7 @@ class BoundedBlockingQueue[E <: AnyRef](
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def clear(): Unit = {
|
override def clear() {
|
||||||
lock.lock()
|
lock.lock()
|
||||||
try {
|
try {
|
||||||
backing.clear
|
backing.clear
|
||||||
|
|
@ -273,7 +273,7 @@ class BoundedBlockingQueue[E <: AnyRef](
|
||||||
elements(last).asInstanceOf[E]
|
elements(last).asInstanceOf[E]
|
||||||
}
|
}
|
||||||
|
|
||||||
def remove(): Unit = {
|
def remove() {
|
||||||
if (last < 0) throw new IllegalStateException
|
if (last < 0) throw new IllegalStateException
|
||||||
val target = elements(last)
|
val target = elements(last)
|
||||||
last = -1 //To avoid 2 subsequent removes without a next in between
|
last = -1 //To avoid 2 subsequent removes without a next in between
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class TypedConsumerPublishRequestorTest extends JUnitSuite {
|
||||||
r1.method.getName < r2.method.getName
|
r1.method.getName < r2.method.getName
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
def setUp: Unit = {
|
def setUp{
|
||||||
publisher = actorOf(new TypedConsumerPublisherMock)
|
publisher = actorOf(new TypedConsumerPublisherMock)
|
||||||
requestor = actorOf(new TypedConsumerPublishRequestor)
|
requestor = actorOf(new TypedConsumerPublishRequestor)
|
||||||
requestor ! InitPublishRequestor(publisher)
|
requestor ! InitPublishRequestor(publisher)
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ trait ProducerSupport { this: Actor ⇒
|
||||||
* @param msg message to produce
|
* @param msg message to produce
|
||||||
* @param pattern exchange pattern
|
* @param pattern exchange pattern
|
||||||
*/
|
*/
|
||||||
protected def produce(msg: Any, pattern: ExchangePattern): Unit = {
|
protected def produce(msg: Any, pattern: ExchangePattern) {
|
||||||
val cmsg = Message.canonicalize(msg)
|
val cmsg = Message.canonicalize(msg)
|
||||||
val exchange = createExchange(pattern).fromRequestMessage(cmsg)
|
val exchange = createExchange(pattern).fromRequestMessage(cmsg)
|
||||||
processor.process(exchange, new AsyncCallback {
|
processor.process(exchange, new AsyncCallback {
|
||||||
|
|
@ -101,7 +101,7 @@ trait ProducerSupport { this: Actor ⇒
|
||||||
// later by another thread.
|
// later by another thread.
|
||||||
val replyChannel = channel
|
val replyChannel = channel
|
||||||
|
|
||||||
def done(doneSync: Boolean): Unit = {
|
def done(doneSync: Boolean) {
|
||||||
(doneSync, exchange.isFailed) match {
|
(doneSync, exchange.isFailed) match {
|
||||||
case (true, true) ⇒ dispatchSync(exchange.toFailureMessage(cmsg.headers(headersToCopy)))
|
case (true, true) ⇒ dispatchSync(exchange.toFailureMessage(cmsg.headers(headersToCopy)))
|
||||||
case (true, false) ⇒ dispatchSync(exchange.toResponseMessage(cmsg.headers(headersToCopy)))
|
case (true, false) ⇒ dispatchSync(exchange.toResponseMessage(cmsg.headers(headersToCopy)))
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ private[akka] class AsyncCallbackAdapter(exchange: Exchange, callback: AsyncCall
|
||||||
|
|
||||||
def resume(): Unit = ()
|
def resume(): Unit = ()
|
||||||
|
|
||||||
def stop(): Unit = {
|
def stop() {
|
||||||
running = false
|
running = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class ConsumerPublishRequestorTest extends JUnitSuite {
|
||||||
var consumer: LocalActorRef = _
|
var consumer: LocalActorRef = _
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
def setUp: Unit = {
|
def setUp{
|
||||||
publisher = actorOf(new ConsumerPublisherMock)
|
publisher = actorOf(new ConsumerPublisherMock)
|
||||||
requestor = actorOf(new ConsumerPublishRequestor)
|
requestor = actorOf(new ConsumerPublishRequestor)
|
||||||
requestor ! InitPublishRequestor(publisher)
|
requestor ! InitPublishRequestor(publisher)
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def shouldThrowExceptionWhenIdNotSet: Unit = {
|
def shouldThrowExceptionWhenIdNotSet{
|
||||||
val actor = actorOf[Tester1]
|
val actor = actorOf[Tester1]
|
||||||
val latch = (actor ? SetExpectedMessageCount(1)).as[CountDownLatch].get
|
val latch = (actor ? SetExpectedMessageCount(1)).as[CountDownLatch].get
|
||||||
val endpoint = actorEndpoint("actor:id:")
|
val endpoint = actorEndpoint("actor:id:")
|
||||||
|
|
@ -218,7 +218,7 @@ class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def shouldThrowExceptionWhenUuidNotSet: Unit = {
|
def shouldThrowExceptionWhenUuidNotSet{
|
||||||
val actor = actorOf[Tester1]
|
val actor = actorOf[Tester1]
|
||||||
val latch = (actor ? SetExpectedMessageCount(1)).as[CountDownLatch].get
|
val latch = (actor ? SetExpectedMessageCount(1)).as[CountDownLatch].get
|
||||||
val endpoint = actorEndpoint("actor:uuid:")
|
val endpoint = actorEndpoint("actor:uuid:")
|
||||||
|
|
@ -228,7 +228,7 @@ class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def shouldSendMessageToActorAndTimeout(): Unit = {
|
def shouldSendMessageToActorAndTimeout() {
|
||||||
val actor = actorOf(Props[Tester3].withTimeout(Timeout(1)))
|
val actor = actorOf(Props[Tester3].withTimeout(Timeout(1)))
|
||||||
val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
|
val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
|
||||||
val exchange = endpoint.createExchange(ExchangePattern.InOut)
|
val exchange = endpoint.createExchange(ExchangePattern.InOut)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class LocalBookKeeper {
|
||||||
numberOfBookies = 3;
|
numberOfBookies = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalBookKeeper(int numberOfBookies){
|
public LocalBookKeeper(int numberOfBookies) {
|
||||||
this();
|
this();
|
||||||
this.numberOfBookies = numberOfBookies;
|
this.numberOfBookies = numberOfBookies;
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +87,7 @@ public class LocalBookKeeper {
|
||||||
boolean b = waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
|
boolean b = waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeZookeper(){
|
public void initializeZookeper() {
|
||||||
//initialize the zk client with values
|
//initialize the zk client with values
|
||||||
try {
|
try {
|
||||||
zkc = new ZooKeeper("127.0.0.1", ZooKeeperDefaultPort, new emptyWatcher());
|
zkc = new ZooKeeper("127.0.0.1", ZooKeeperDefaultPort, new emptyWatcher());
|
||||||
|
|
@ -107,7 +107,7 @@ public class LocalBookKeeper {
|
||||||
tmpDirs = new File[numberOfBookies];
|
tmpDirs = new File[numberOfBookies];
|
||||||
bs = new BookieServer[numberOfBookies];
|
bs = new BookieServer[numberOfBookies];
|
||||||
|
|
||||||
for(int i = 0; i < numberOfBookies; i++){
|
for(int i = 0; i < numberOfBookies; i++) {
|
||||||
tmpDirs[i] = File.createTempFile("bookie" + Integer.toString(i), "test");
|
tmpDirs[i] = File.createTempFile("bookie" + Integer.toString(i), "test");
|
||||||
tmpDirs[i].delete();
|
tmpDirs[i].delete();
|
||||||
tmpDirs[i].mkdir();
|
tmpDirs[i].mkdir();
|
||||||
|
|
@ -119,7 +119,7 @@ public class LocalBookKeeper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException, InterruptedException {
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
if(args.length < 1){
|
if(args.length < 1) {
|
||||||
usage();
|
usage();
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +127,7 @@ public class LocalBookKeeper {
|
||||||
lb.runZookeeper(1000);
|
lb.runZookeeper(1000);
|
||||||
lb.initializeZookeper();
|
lb.initializeZookeper();
|
||||||
lb.runBookies();
|
lb.runBookies();
|
||||||
while (true){
|
while (true) {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ public class DistributedQueue {
|
||||||
private final String prefix = "qn-";
|
private final String prefix = "qn-";
|
||||||
|
|
||||||
|
|
||||||
public DistributedQueue(ZooKeeper zookeeper, String dir, List<ACL> acl){
|
public DistributedQueue(ZooKeeper zookeeper, String dir, List<ACL> acl) {
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
|
|
||||||
if(acl != null){
|
if(acl != null) {
|
||||||
this.acl = acl;
|
this.acl = acl;
|
||||||
}
|
}
|
||||||
this.zookeeper = zookeeper;
|
this.zookeeper = zookeeper;
|
||||||
|
|
@ -73,21 +73,21 @@ public class DistributedQueue {
|
||||||
List<String> childNames = null;
|
List<String> childNames = null;
|
||||||
try{
|
try{
|
||||||
childNames = zookeeper.getChildren(dir, watcher);
|
childNames = zookeeper.getChildren(dir, watcher);
|
||||||
}catch (KeeperException.NoNodeException e){
|
}catch (KeeperException.NoNodeException e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String childName : childNames){
|
for(String childName : childNames) {
|
||||||
try{
|
try{
|
||||||
//Check format
|
//Check format
|
||||||
if(!childName.regionMatches(0, prefix, 0, prefix.length())){
|
if(!childName.regionMatches(0, prefix, 0, prefix.length())) {
|
||||||
LOG.warn("Found child node with improper name: " + childName);
|
LOG.warn("Found child node with improper name: " + childName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String suffix = childName.substring(prefix.length());
|
String suffix = childName.substring(prefix.length());
|
||||||
Long childId = new Long(suffix);
|
Long childId = new Long(suffix);
|
||||||
orderedChildren.put(childId,childName);
|
orderedChildren.put(childId,childName);
|
||||||
}catch(NumberFormatException e){
|
}catch(NumberFormatException e) {
|
||||||
LOG.warn("Found child node with improper format : " + childName + " " + e,e);
|
LOG.warn("Found child node with improper format : " + childName + " " + e,e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -107,31 +107,31 @@ public class DistributedQueue {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
childNames = zookeeper.getChildren(dir, false);
|
childNames = zookeeper.getChildren(dir, false);
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
LOG.warn("Caught: " +e,e);
|
LOG.warn("Caught: " +e,e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String childName : childNames){
|
for(String childName : childNames) {
|
||||||
try{
|
try{
|
||||||
//Check format
|
//Check format
|
||||||
if(!childName.regionMatches(0, prefix, 0, prefix.length())){
|
if(!childName.regionMatches(0, prefix, 0, prefix.length())) {
|
||||||
LOG.warn("Found child node with improper name: " + childName);
|
LOG.warn("Found child node with improper name: " + childName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String suffix = childName.substring(prefix.length());
|
String suffix = childName.substring(prefix.length());
|
||||||
long childId = Long.parseLong(suffix);
|
long childId = Long.parseLong(suffix);
|
||||||
if(childId < minId){
|
if(childId < minId) {
|
||||||
minId = childId;
|
minId = childId;
|
||||||
minName = childName;
|
minName = childName;
|
||||||
}
|
}
|
||||||
}catch(NumberFormatException e){
|
}catch(NumberFormatException e) {
|
||||||
LOG.warn("Found child node with improper format : " + childName + " " + e,e);
|
LOG.warn("Found child node with improper format : " + childName + " " + e,e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(minId < Long.MAX_VALUE){
|
if(minId < Long.MAX_VALUE) {
|
||||||
return minName;
|
return minName;
|
||||||
}else{
|
}else{
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -153,19 +153,19 @@ public class DistributedQueue {
|
||||||
// Since other clients are remove()ing and take()ing nodes concurrently,
|
// Since other clients are remove()ing and take()ing nodes concurrently,
|
||||||
// the child with the smallest sequence number in orderedChildren might be gone by the time we check.
|
// the child with the smallest sequence number in orderedChildren might be gone by the time we check.
|
||||||
// We don't call getChildren again until we have tried the rest of the nodes in sequence order.
|
// We don't call getChildren again until we have tried the rest of the nodes in sequence order.
|
||||||
while(true){
|
while(true) {
|
||||||
try{
|
try{
|
||||||
orderedChildren = orderedChildren(null);
|
orderedChildren = orderedChildren(null);
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
if(orderedChildren.size() == 0 ) throw new NoSuchElementException();
|
if(orderedChildren.size() == 0 ) throw new NoSuchElementException();
|
||||||
|
|
||||||
for(String headNode : orderedChildren.values()){
|
for(String headNode : orderedChildren.values()) {
|
||||||
if(headNode != null){
|
if(headNode != null) {
|
||||||
try{
|
try{
|
||||||
return zookeeper.getData(dir+"/"+headNode, false, null);
|
return zookeeper.getData(dir+"/"+headNode, false, null);
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
//Another client removed the node first, try next
|
//Another client removed the node first, try next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -185,21 +185,21 @@ public class DistributedQueue {
|
||||||
public byte[] remove() throws NoSuchElementException, KeeperException, InterruptedException {
|
public byte[] remove() throws NoSuchElementException, KeeperException, InterruptedException {
|
||||||
TreeMap<Long,String> orderedChildren;
|
TreeMap<Long,String> orderedChildren;
|
||||||
// Same as for element. Should refactor this.
|
// Same as for element. Should refactor this.
|
||||||
while(true){
|
while(true) {
|
||||||
try{
|
try{
|
||||||
orderedChildren = orderedChildren(null);
|
orderedChildren = orderedChildren(null);
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
if(orderedChildren.size() == 0) throw new NoSuchElementException();
|
if(orderedChildren.size() == 0) throw new NoSuchElementException();
|
||||||
|
|
||||||
for(String headNode : orderedChildren.values()){
|
for(String headNode : orderedChildren.values()) {
|
||||||
String path = dir +"/"+headNode;
|
String path = dir +"/"+headNode;
|
||||||
try{
|
try{
|
||||||
byte[] data = zookeeper.getData(path, false, null);
|
byte[] data = zookeeper.getData(path, false, null);
|
||||||
zookeeper.delete(path, -1);
|
zookeeper.delete(path, -1);
|
||||||
return data;
|
return data;
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
// Another client deleted the node first.
|
// Another client deleted the node first.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,11 +211,11 @@ public class DistributedQueue {
|
||||||
|
|
||||||
CountDownLatch latch;
|
CountDownLatch latch;
|
||||||
|
|
||||||
public LatchChildWatcher(){
|
public LatchChildWatcher() {
|
||||||
latch = new CountDownLatch(1);
|
latch = new CountDownLatch(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(WatchedEvent event){
|
public void process(WatchedEvent event) {
|
||||||
LOG.debug("Watcher fired on path: " + event.getPath() + " state: " +
|
LOG.debug("Watcher fired on path: " + event.getPath() + " state: " +
|
||||||
event.getState() + " type " + event.getType());
|
event.getState() + " type " + event.getType());
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
|
@ -235,26 +235,26 @@ public class DistributedQueue {
|
||||||
public byte[] take() throws KeeperException, InterruptedException {
|
public byte[] take() throws KeeperException, InterruptedException {
|
||||||
TreeMap<Long,String> orderedChildren;
|
TreeMap<Long,String> orderedChildren;
|
||||||
// Same as for element. Should refactor this.
|
// Same as for element. Should refactor this.
|
||||||
while(true){
|
while(true) {
|
||||||
LatchChildWatcher childWatcher = new LatchChildWatcher();
|
LatchChildWatcher childWatcher = new LatchChildWatcher();
|
||||||
try{
|
try{
|
||||||
orderedChildren = orderedChildren(childWatcher);
|
orderedChildren = orderedChildren(childWatcher);
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
zookeeper.create(dir, new byte[0], acl, CreateMode.PERSISTENT);
|
zookeeper.create(dir, new byte[0], acl, CreateMode.PERSISTENT);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(orderedChildren.size() == 0){
|
if(orderedChildren.size() == 0) {
|
||||||
childWatcher.await();
|
childWatcher.await();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String headNode : orderedChildren.values()){
|
for(String headNode : orderedChildren.values()) {
|
||||||
String path = dir +"/"+headNode;
|
String path = dir +"/"+headNode;
|
||||||
try{
|
try{
|
||||||
byte[] data = zookeeper.getData(path, false, null);
|
byte[] data = zookeeper.getData(path, false, null);
|
||||||
zookeeper.delete(path, -1);
|
zookeeper.delete(path, -1);
|
||||||
return data;
|
return data;
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
// Another client deleted the node first.
|
// Another client deleted the node first.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -267,11 +267,11 @@ public class DistributedQueue {
|
||||||
* @return true if data was successfully added
|
* @return true if data was successfully added
|
||||||
*/
|
*/
|
||||||
public boolean offer(byte[] data) throws KeeperException, InterruptedException{
|
public boolean offer(byte[] data) throws KeeperException, InterruptedException{
|
||||||
for(;;){
|
for(;;) {
|
||||||
try{
|
try{
|
||||||
zookeeper.create(dir+"/"+prefix, data, acl, CreateMode.PERSISTENT_SEQUENTIAL);
|
zookeeper.create(dir+"/"+prefix, data, acl, CreateMode.PERSISTENT_SEQUENTIAL);
|
||||||
return true;
|
return true;
|
||||||
}catch(KeeperException.NoNodeException e){
|
}catch(KeeperException.NoNodeException e) {
|
||||||
zookeeper.create(dir, new byte[0], acl, CreateMode.PERSISTENT);
|
zookeeper.create(dir, new byte[0], acl, CreateMode.PERSISTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +287,7 @@ public class DistributedQueue {
|
||||||
public byte[] peek() throws KeeperException, InterruptedException{
|
public byte[] peek() throws KeeperException, InterruptedException{
|
||||||
try{
|
try{
|
||||||
return element();
|
return element();
|
||||||
}catch(NoSuchElementException e){
|
}catch(NoSuchElementException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +302,7 @@ public class DistributedQueue {
|
||||||
public byte[] poll() throws KeeperException, InterruptedException {
|
public byte[] poll() throws KeeperException, InterruptedException {
|
||||||
try{
|
try{
|
||||||
return remove();
|
return remove();
|
||||||
}catch(NoSuchElementException e){
|
}catch(NoSuchElementException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,7 @@ object TransactionLog {
|
||||||
/**
|
/**
|
||||||
* Starts up the transaction log.
|
* Starts up the transaction log.
|
||||||
*/
|
*/
|
||||||
def start(): Unit = {
|
def start() {
|
||||||
isConnected switchOn {
|
isConnected switchOn {
|
||||||
bookieClient = new BookKeeper(zooKeeperServers)
|
bookieClient = new BookKeeper(zooKeeperServers)
|
||||||
zkClient = new AkkaZkClient(zooKeeperServers, sessionTimeout, connectionTimeout)
|
zkClient = new AkkaZkClient(zooKeeperServers, sessionTimeout, connectionTimeout)
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ In order to get better metrics, please put "sigar.jar" to the classpath, and add
|
||||||
/*
|
/*
|
||||||
* Refreshes locally cached metrics from ZooKeeper, and invokes plugged monitors
|
* Refreshes locally cached metrics from ZooKeeper, and invokes plugged monitors
|
||||||
*/
|
*/
|
||||||
private[akka] def refresh(): Unit = {
|
private[akka] def refresh() {
|
||||||
|
|
||||||
storeMetricsInZK(getLocalMetrics)
|
storeMetricsInZK(getLocalMetrics)
|
||||||
refreshMetricsCacheFromZK()
|
refreshMetricsCacheFromZK()
|
||||||
|
|
@ -172,7 +172,7 @@ In order to get better metrics, please put "sigar.jar" to the classpath, and add
|
||||||
/*
|
/*
|
||||||
* Refreshes metrics manager cache from ZooKeeper
|
* Refreshes metrics manager cache from ZooKeeper
|
||||||
*/
|
*/
|
||||||
private def refreshMetricsCacheFromZK(): Unit = {
|
private def refreshMetricsCacheFromZK() {
|
||||||
val allMetricsFromZK = getAllMetricsFromZK
|
val allMetricsFromZK = getAllMetricsFromZK
|
||||||
|
|
||||||
localNodeMetricsCache.keySet.foreach { key ⇒
|
localNodeMetricsCache.keySet.foreach { key ⇒
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ The ``traverse`` method is similar to ``sequence``, but it takes a sequence of `
|
||||||
|
|
||||||
Iterable<String> listStrings = ... //Just a sequence of Strings
|
Iterable<String> listStrings = ... //Just a sequence of Strings
|
||||||
|
|
||||||
Future<Iterable<String>> result = traverse(listStrings, new Function<String,Future<String>>(){
|
Future<Iterable<String>> result = traverse(listStrings, new Function<String,Future<String>>() {
|
||||||
public Future<String> apply(final String r) {
|
public Future<String> apply(final String r) {
|
||||||
return future(new Callable<String>() {
|
return future(new Callable<String>() {
|
||||||
public String call() {
|
public String call() {
|
||||||
|
|
@ -229,7 +229,7 @@ Then there's a method that's called ``fold`` that takes a start-value, a sequenc
|
||||||
|
|
||||||
Iterable<Future<String>> futures = ... //A sequence of Futures, in this case Strings
|
Iterable<Future<String>> futures = ... //A sequence of Futures, in this case Strings
|
||||||
|
|
||||||
Future<String> result = fold("", 15000, futures, new Function2<String, String, String>(){ //Start value is the empty string, timeout is 15 seconds
|
Future<String> result = fold("", 15000, futures, new Function2<String, String, String>() { //Start value is the empty string, timeout is 15 seconds
|
||||||
public String apply(String r, String t) {
|
public String apply(String r, String t) {
|
||||||
return r + t; //Just concatenate
|
return r + t; //Just concatenate
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +251,7 @@ If the sequence passed to ``fold`` is empty, it will return the start-value, in
|
||||||
|
|
||||||
Iterable<Future<String>> futures = ... //A sequence of Futures, in this case Strings
|
Iterable<Future<String>> futures = ... //A sequence of Futures, in this case Strings
|
||||||
|
|
||||||
Future<String> result = reduce(futures, 15000, new Function2<String, String, String>(){ //Timeout is 15 seconds
|
Future<String> result = reduce(futures, 15000, new Function2<String, String, String>() { //Timeout is 15 seconds
|
||||||
public String apply(String r, String t) {
|
public String apply(String r, String t) {
|
||||||
return r + t; //Just concatenate
|
return r + t; //Just concatenate
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -466,7 +466,7 @@ The API for server managed remote typed actors is nearly the same as for untyped
|
||||||
.. code-block:: scala
|
.. code-block:: scala
|
||||||
|
|
||||||
class RegistrationServiceImpl extends TypedActor with RegistrationService {
|
class RegistrationServiceImpl extends TypedActor with RegistrationService {
|
||||||
def registerUser(user: User): Unit = {
|
def registerUser(user: User) {
|
||||||
... // register user
|
... // register user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -489,7 +489,7 @@ They are also useful if you need to perform some cleanup when a client disconnec
|
||||||
.. code-block:: scala
|
.. code-block:: scala
|
||||||
|
|
||||||
class RegistrationServiceImpl extends TypedActor with RegistrationService {
|
class RegistrationServiceImpl extends TypedActor with RegistrationService {
|
||||||
def registerUser(user: User): Unit = {
|
def registerUser(user: User) {
|
||||||
... // register user
|
... // register user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ If you have a POJO with an interface implementation separation like this:
|
||||||
.. code-block:: scala
|
.. code-block:: scala
|
||||||
|
|
||||||
public class RegistrationServiceImpl extends TypedActor with RegistrationService {
|
public class RegistrationServiceImpl extends TypedActor with RegistrationService {
|
||||||
def register(user: User, cred: Credentials): Unit = {
|
def register(user: User, cred: Credentials) {
|
||||||
... // register user
|
... // register user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,15 +62,15 @@ class Journal(queuePath: String, syncJournal: ⇒ Boolean) {
|
||||||
private val CMD_CONFIRM_REMOVE = 6
|
private val CMD_CONFIRM_REMOVE = 6
|
||||||
private val CMD_ADD_XID = 7
|
private val CMD_ADD_XID = 7
|
||||||
|
|
||||||
private def open(file: File): Unit = {
|
private def open(file: File) {
|
||||||
writer = new FileOutputStream(file, true).getChannel
|
writer = new FileOutputStream(file, true).getChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
def open(): Unit = {
|
def open() {
|
||||||
open(queueFile)
|
open(queueFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
def roll(xid: Int, openItems: List[QItem], queue: Iterable[QItem]): Unit = {
|
def roll(xid: Int, openItems: List[QItem], queue: Iterable[QItem]) {
|
||||||
writer.close
|
writer.close
|
||||||
val tmpFile = new File(queuePath + "~~" + System.currentTimeMillis)
|
val tmpFile = new File(queuePath + "~~" + System.currentTimeMillis)
|
||||||
open(tmpFile)
|
open(tmpFile)
|
||||||
|
|
@ -89,13 +89,13 @@ class Journal(queuePath: String, syncJournal: ⇒ Boolean) {
|
||||||
open
|
open
|
||||||
}
|
}
|
||||||
|
|
||||||
def close(): Unit = {
|
def close() {
|
||||||
writer.close
|
writer.close
|
||||||
for (r ← reader) r.close
|
for (r ← reader) r.close
|
||||||
reader = None
|
reader = None
|
||||||
}
|
}
|
||||||
|
|
||||||
def erase(): Unit = {
|
def erase() {
|
||||||
try {
|
try {
|
||||||
close()
|
close()
|
||||||
queueFile.delete
|
queueFile.delete
|
||||||
|
|
@ -108,7 +108,7 @@ class Journal(queuePath: String, syncJournal: ⇒ Boolean) {
|
||||||
|
|
||||||
def isReplaying(): Boolean = replayer.isDefined
|
def isReplaying(): Boolean = replayer.isDefined
|
||||||
|
|
||||||
private def add(allowSync: Boolean, item: QItem): Unit = {
|
private def add(allowSync: Boolean, item: QItem) {
|
||||||
val blob = ByteBuffer.wrap(item.pack())
|
val blob = ByteBuffer.wrap(item.pack())
|
||||||
size += write(false, CMD_ADDX.toByte, blob.limit)
|
size += write(false, CMD_ADDX.toByte, blob.limit)
|
||||||
do {
|
do {
|
||||||
|
|
@ -136,7 +136,7 @@ class Journal(queuePath: String, syncJournal: ⇒ Boolean) {
|
||||||
size += write(true, CMD_REMOVE.toByte)
|
size += write(true, CMD_REMOVE.toByte)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def removeTentative(allowSync: Boolean): Unit = {
|
private def removeTentative(allowSync: Boolean) {
|
||||||
size += write(allowSync, CMD_REMOVE_TENTATIVE.toByte)
|
size += write(allowSync, CMD_REMOVE_TENTATIVE.toByte)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,14 +155,14 @@ class Journal(queuePath: String, syncJournal: ⇒ Boolean) {
|
||||||
size += write(true, CMD_CONFIRM_REMOVE.toByte, xid)
|
size += write(true, CMD_CONFIRM_REMOVE.toByte, xid)
|
||||||
}
|
}
|
||||||
|
|
||||||
def startReadBehind(): Unit = {
|
def startReadBehind() {
|
||||||
val pos = if (replayer.isDefined) replayer.get.position else writer.position
|
val pos = if (replayer.isDefined) replayer.get.position else writer.position
|
||||||
val rj = new FileInputStream(queueFile).getChannel
|
val rj = new FileInputStream(queueFile).getChannel
|
||||||
rj.position(pos)
|
rj.position(pos)
|
||||||
reader = Some(rj)
|
reader = Some(rj)
|
||||||
}
|
}
|
||||||
|
|
||||||
def fillReadBehind(f: QItem ⇒ Unit): Unit = {
|
def fillReadBehind(f: QItem ⇒ Unit) {
|
||||||
val pos = if (replayer.isDefined) replayer.get.position else writer.position
|
val pos = if (replayer.isDefined) replayer.get.position else writer.position
|
||||||
for (rj ← reader) {
|
for (rj ← reader) {
|
||||||
if (rj.position == pos) {
|
if (rj.position == pos) {
|
||||||
|
|
@ -178,7 +178,7 @@ class Journal(queuePath: String, syncJournal: ⇒ Boolean) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def replay(name: String)(f: JournalItem ⇒ Unit): Unit = {
|
def replay(name: String)(f: JournalItem ⇒ Unit) {
|
||||||
size = 0
|
size = 0
|
||||||
var lastUpdate = 0L
|
var lastUpdate = 0L
|
||||||
val TEN_MB = 10L * 1024 * 1024
|
val TEN_MB = 10L * 1024 * 1024
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@ class PersistentQueue(persistencePath: String, val name: String, val config: Con
|
||||||
* Return a transactionally-removed item to the queue. This is a rolled-
|
* Return a transactionally-removed item to the queue. This is a rolled-
|
||||||
* back transaction.
|
* back transaction.
|
||||||
*/
|
*/
|
||||||
def unremove(xid: Int): Unit = {
|
def unremove(xid: Int) {
|
||||||
synchronized {
|
synchronized {
|
||||||
if (!closed) {
|
if (!closed) {
|
||||||
if (keepJournal()) journal.unremove(xid)
|
if (keepJournal()) journal.unremove(xid)
|
||||||
|
|
@ -279,7 +279,7 @@ class PersistentQueue(persistencePath: String, val name: String, val config: Con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def confirmRemove(xid: Int): Unit = {
|
def confirmRemove(xid: Int) {
|
||||||
synchronized {
|
synchronized {
|
||||||
if (!closed) {
|
if (!closed) {
|
||||||
if (keepJournal()) journal.confirmRemove(xid)
|
if (keepJournal()) journal.confirmRemove(xid)
|
||||||
|
|
@ -288,7 +288,7 @@ class PersistentQueue(persistencePath: String, val name: String, val config: Con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def flush(): Unit = {
|
def flush() {
|
||||||
while (remove(false).isDefined) {}
|
while (remove(false).isDefined) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ class PersistentQueue(persistencePath: String, val name: String, val config: Con
|
||||||
xidCounter
|
xidCounter
|
||||||
}
|
}
|
||||||
|
|
||||||
private final def fillReadBehind(): Unit = {
|
private final def fillReadBehind() {
|
||||||
// if we're in read-behind mode, scan forward in the journal to keep memory as full as
|
// if we're in read-behind mode, scan forward in the journal to keep memory as full as
|
||||||
// possible. this amortizes the disk overhead across all reads.
|
// possible. this amortizes the disk overhead across all reads.
|
||||||
while (keepJournal() && journal.inReadBehind && _memoryBytes < maxMemorySize()) {
|
while (keepJournal() && journal.inReadBehind && _memoryBytes < maxMemorySize()) {
|
||||||
|
|
@ -338,7 +338,7 @@ class PersistentQueue(persistencePath: String, val name: String, val config: Con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def replayJournal(): Unit = {
|
def replayJournal() {
|
||||||
if (!keepJournal()) return
|
if (!keepJournal()) return
|
||||||
|
|
||||||
EventHandler.debug(this, "Replaying transaction journal for '%s'".format(name))
|
EventHandler.debug(this, "Replaying transaction journal for '%s'".format(name))
|
||||||
|
|
@ -380,7 +380,7 @@ class PersistentQueue(persistencePath: String, val name: String, val config: Con
|
||||||
|
|
||||||
// ----- internal implementations
|
// ----- internal implementations
|
||||||
|
|
||||||
private def _add(item: QItem): Unit = {
|
private def _add(item: QItem) {
|
||||||
discardExpired
|
discardExpired
|
||||||
if (!journal.inReadBehind) {
|
if (!journal.inReadBehind) {
|
||||||
queue += item
|
queue += item
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ class QueueCollection(queueFolder: String, private var queueConfigs: Configurati
|
||||||
* Retrieve an item from a queue and pass it to a continuation. If no item is available within
|
* Retrieve an item from a queue and pass it to a continuation. If no item is available within
|
||||||
* the requested time, or the server is shutting down, None is passed.
|
* the requested time, or the server is shutting down, None is passed.
|
||||||
*/
|
*/
|
||||||
def remove(key: String, timeout: Int, transaction: Boolean, peek: Boolean)(f: Option[QItem] ⇒ Unit): Unit = {
|
def remove(key: String, timeout: Int, transaction: Boolean, peek: Boolean)(f: Option[QItem] ⇒ Unit) {
|
||||||
queue(key) match {
|
queue(key) match {
|
||||||
case None ⇒
|
case None ⇒
|
||||||
queueMisses.incr
|
queueMisses.incr
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ case class DurableDispatcher(
|
||||||
|
|
||||||
override def createMailbox(actorRef: LocalActorRef): AnyRef = _storage.createFor(actorRef)
|
override def createMailbox(actorRef: LocalActorRef): AnyRef = _storage.createFor(actorRef)
|
||||||
|
|
||||||
protected[akka] override def dispatch(invocation: MessageInvocation): Unit = {
|
protected[akka] override def dispatch(invocation: MessageInvocation) {
|
||||||
if (invocation.channel.isInstanceOf[ActorPromise])
|
if (invocation.channel.isInstanceOf[ActorPromise])
|
||||||
throw new IllegalArgumentException("Durable mailboxes do not support Future-based messages from ?")
|
throw new IllegalArgumentException("Durable mailboxes do not support Future-based messages from ?")
|
||||||
super.dispatch(invocation)
|
super.dispatch(invocation)
|
||||||
|
|
@ -125,7 +125,7 @@ case class DurablePinnedDispatcher(
|
||||||
|
|
||||||
override def createMailbox(actorRef: LocalActorRef): AnyRef = _storage.createFor(actorRef)
|
override def createMailbox(actorRef: LocalActorRef): AnyRef = _storage.createFor(actorRef)
|
||||||
|
|
||||||
protected[akka] override def dispatch(invocation: MessageInvocation): Unit = {
|
protected[akka] override def dispatch(invocation: MessageInvocation) {
|
||||||
if (invocation.channel.isInstanceOf[ActorPromise])
|
if (invocation.channel.isInstanceOf[ActorPromise])
|
||||||
throw new IllegalArgumentException("Actor has a durable mailbox that does not support ?")
|
throw new IllegalArgumentException("Actor has a durable mailbox that does not support ?")
|
||||||
super.dispatch(invocation)
|
super.dispatch(invocation)
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ trait EmbeddedAppServer extends Bootable {
|
||||||
server = Option(configuration.configure.asInstanceOf[Server]) map { s ⇒ //Set the correct classloader to our contexts
|
server = Option(configuration.configure.asInstanceOf[Server]) map { s ⇒ //Set the correct classloader to our contexts
|
||||||
applicationLoader foreach { loader ⇒
|
applicationLoader foreach { loader ⇒
|
||||||
//We need to provide the correct classloader to the servlets
|
//We need to provide the correct classloader to the servlets
|
||||||
def setClassLoader(handlers: Seq[Handler]): Unit = {
|
def setClassLoader(handlers: Seq[Handler]) {
|
||||||
handlers foreach {
|
handlers foreach {
|
||||||
case c: ContextHandler ⇒ c.setClassLoader(loader)
|
case c: ContextHandler ⇒ c.setClassLoader(loader)
|
||||||
case c: HandlerCollection ⇒ setClassLoader(c.getHandlers)
|
case c: HandlerCollection ⇒ setClassLoader(c.getHandlers)
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ class RemoteActorRefProvider extends ActorRefProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
case deploy ⇒ None // non-remote actor
|
case deploy ⇒ None // non-remote actor
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case e: Exception ⇒
|
case e: Exception ⇒
|
||||||
newFuture completeWithException e // so the other threads gets notified of error
|
newFuture completeWithException e // so the other threads gets notified of error
|
||||||
|
|
|
||||||
|
|
@ -812,7 +812,7 @@ trait NettyRemoteServerModule extends RemoteServerModule {
|
||||||
* <p/>
|
* <p/>
|
||||||
* NOTE: You need to call this method if you have registered an actor by a custom ID.
|
* NOTE: You need to call this method if you have registered an actor by a custom ID.
|
||||||
*/
|
*/
|
||||||
def unregisterPerSession(id: String): Unit = {
|
def unregisterPerSession(id: String) {
|
||||||
|
|
||||||
if (_isRunning.isOn) {
|
if (_isRunning.isOn) {
|
||||||
EventHandler.info(this, "Unregistering server side remote actor with id [%s]".format(id))
|
EventHandler.info(this, "Unregistering server side remote actor with id [%s]".format(id))
|
||||||
|
|
@ -890,10 +890,10 @@ class RemoteServerHandler(
|
||||||
val sessionActors = new ChannelLocal[ConcurrentHashMap[String, ActorRef]]()
|
val sessionActors = new ChannelLocal[ConcurrentHashMap[String, ActorRef]]()
|
||||||
|
|
||||||
//Writes the specified message to the specified channel and propagates write errors to listeners
|
//Writes the specified message to the specified channel and propagates write errors to listeners
|
||||||
private def write(channel: Channel, payload: AkkaRemoteProtocol): Unit = {
|
private def write(channel: Channel, payload: AkkaRemoteProtocol) {
|
||||||
channel.write(payload).addListener(
|
channel.write(payload).addListener(
|
||||||
new ChannelFutureListener {
|
new ChannelFutureListener {
|
||||||
def operationComplete(future: ChannelFuture): Unit = {
|
def operationComplete(future: ChannelFuture) {
|
||||||
if (future.isCancelled) {
|
if (future.isCancelled) {
|
||||||
//Not interesting at the moment
|
//Not interesting at the moment
|
||||||
} else if (!future.isSuccess) {
|
} else if (!future.isSuccess) {
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,14 @@ trait MultiJvmSync extends WordSpec with MustMatchers with BeforeAndAfterAll {
|
||||||
MultiJvmSync.start(getClass.getName, nodes)
|
MultiJvmSync.start(getClass.getName, nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
def onStart(): Unit = {}
|
def onStart() {}
|
||||||
|
|
||||||
override def afterAll() = {
|
override def afterAll() = {
|
||||||
MultiJvmSync.end(getClass.getName, nodes)
|
MultiJvmSync.end(getClass.getName, nodes)
|
||||||
onEnd()
|
onEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
def onEnd(): Unit = {}
|
def onEnd() {}
|
||||||
|
|
||||||
def barrier(name: String, timeout: Duration = FileBasedBarrier.DefaultTimeout) = {
|
def barrier(name: String, timeout: Duration = FileBasedBarrier.DefaultTimeout) = {
|
||||||
MultiJvmSync.barrier(name, nodes, getClass.getName, timeout)
|
MultiJvmSync.barrier(name, nodes, getClass.getName, timeout)
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,5 @@ class QuietReporter(inColor: Boolean) extends StandardOutReporter(false, inColor
|
||||||
case _ ⇒ super.apply(event)
|
case _ ⇒ super.apply(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def makeFinalReport(resourceName: String, duration: Option[Long], summaryOption: Option[Summary]): Unit = {}
|
override def makeFinalReport(resourceName: String, duration: Option[Long], summaryOption: Option[Summary]) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class HttpConcurrencyTestStress extends JUnitSuite {
|
||||||
|
|
||||||
object HttpConcurrencyTestStress {
|
object HttpConcurrencyTestStress {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
def beforeClass: Unit = {
|
def beforeClass{
|
||||||
startCamelService
|
startCamelService
|
||||||
|
|
||||||
val workers = for (i ← 1 to 8) yield actorOf[HttpServerWorker]
|
val workers = for (i ← 1 to 8) yield actorOf[HttpServerWorker]
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ object ScalaDom {
|
||||||
.getDOMImplementation
|
.getDOMImplementation
|
||||||
.createDocument(null, null, null)
|
.createDocument(null, null, null)
|
||||||
|
|
||||||
def build(node: Node, parent: JNode): Unit = {
|
def build(node: Node, parent: JNode) {
|
||||||
val jnode: JNode = node match {
|
val jnode: JNode = node match {
|
||||||
case e: Elem ⇒ {
|
case e: Elem ⇒ {
|
||||||
val jn = doc.createElement(e.label)
|
val jn = doc.createElement(e.label)
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ class Agent[T](initialValue: T) {
|
||||||
/**
|
/**
|
||||||
* Dispatch a function to update the internal state.
|
* Dispatch a function to update the internal state.
|
||||||
*/
|
*/
|
||||||
def send(f: T ⇒ T): Unit = {
|
def send(f: T ⇒ T) {
|
||||||
def dispatch = updater ! Update(f)
|
def dispatch = updater ! Update(f)
|
||||||
if (Stm.activeTransaction) { get; deferred(dispatch) }
|
if (Stm.activeTransaction) { get; deferred(dispatch) }
|
||||||
else dispatch
|
else dispatch
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ abstract class UntypedTransactor extends UntypedActor {
|
||||||
* Implement a general pattern for using coordinated transactions.
|
* Implement a general pattern for using coordinated transactions.
|
||||||
*/
|
*/
|
||||||
@throws(classOf[Exception])
|
@throws(classOf[Exception])
|
||||||
final def onReceive(message: Any): Unit = {
|
final def onReceive(message: Any) {
|
||||||
message match {
|
message match {
|
||||||
case coordinated @ Coordinated(message) ⇒ {
|
case coordinated @ Coordinated(message) ⇒ {
|
||||||
val others = coordinate(message)
|
val others = coordinate(message)
|
||||||
|
|
@ -87,19 +87,19 @@ abstract class UntypedTransactor extends UntypedActor {
|
||||||
* A Receive block that runs before the coordinated transaction is entered.
|
* A Receive block that runs before the coordinated transaction is entered.
|
||||||
*/
|
*/
|
||||||
@throws(classOf[Exception])
|
@throws(classOf[Exception])
|
||||||
def before(message: Any): Unit = {}
|
def before(message: Any) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Receive block to run inside the coordinated transaction.
|
* The Receive block to run inside the coordinated transaction.
|
||||||
*/
|
*/
|
||||||
@throws(classOf[Exception])
|
@throws(classOf[Exception])
|
||||||
def atomically(message: Any): Unit = {}
|
def atomically(message: Any) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Receive block that runs after the coordinated transaction.
|
* A Receive block that runs after the coordinated transaction.
|
||||||
*/
|
*/
|
||||||
@throws(classOf[Exception])
|
@throws(classOf[Exception])
|
||||||
def after(message: Any): Unit = {}
|
def after(message: Any) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bypass transactionality and behave like a normal actor.
|
* Bypass transactionality and behave like a normal actor.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class TestBarrier(count: Int) {
|
||||||
|
|
||||||
def await(): Unit = await(TestBarrier.DefaultTimeout)
|
def await(): Unit = await(TestBarrier.DefaultTimeout)
|
||||||
|
|
||||||
def await(timeout: Duration): Unit = {
|
def await(timeout: Duration) {
|
||||||
try {
|
try {
|
||||||
barrier.await(Testing.testTime(timeout.toNanos), TimeUnit.NANOSECONDS)
|
barrier.await(Testing.testTime(timeout.toNanos), TimeUnit.NANOSECONDS)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ class TestEventListener extends EventHandler.DefaultListener {
|
||||||
|
|
||||||
def addFilter(filter: EventFilter): Unit = filters ::= filter
|
def addFilter(filter: EventFilter): Unit = filters ::= filter
|
||||||
|
|
||||||
def removeFilter(filter: EventFilter): Unit = {
|
def removeFilter(filter: EventFilter) {
|
||||||
@scala.annotation.tailrec
|
@scala.annotation.tailrec
|
||||||
def removeFirst(list: List[EventFilter], zipped: List[EventFilter] = Nil): List[EventFilter] = list match {
|
def removeFirst(list: List[EventFilter], zipped: List[EventFilter] = Nil): List[EventFilter] = list match {
|
||||||
case head :: tail if head == filter ⇒ tail.reverse_:::(zipped)
|
case head :: tail if head == filter ⇒ tail.reverse_:::(zipped)
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,7 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec
|
||||||
case s if s.startsWith("akka-") => Iterator.single(s.drop(5))
|
case s if s.startsWith("akka-") => Iterator.single(s.drop(5))
|
||||||
case _ => Iterator.empty
|
case _ => Iterator.empty
|
||||||
}
|
}
|
||||||
val (repos, configs) = (project.moduleConfigurations ++ extraConfigs).foldLeft((Set.empty[String], Set.empty[String])){
|
val (repos, configs) = (project.moduleConfigurations ++ extraConfigs).foldLeft((Set.empty[String], Set.empty[String])) {
|
||||||
case ((repos, configs), ModuleConfiguration(org, name, ver, MavenRepository(repoName, repoPath))) =>
|
case ((repos, configs), ModuleConfiguration(org, name, ver, MavenRepository(repoName, repoPath))) =>
|
||||||
val repoId = repoName.replaceAll("""[^a-zA-Z]""", "_")
|
val repoId = repoName.replaceAll("""[^a-zA-Z]""", "_")
|
||||||
val configId = org.replaceAll("""[^a-zA-Z]""", "_") +
|
val configId = org.replaceAll("""[^a-zA-Z]""", "_") +
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ object JvmIO {
|
||||||
|
|
||||||
def ignoreOutputStream = (out: OutputStream) => ()
|
def ignoreOutputStream = (out: OutputStream) => ()
|
||||||
|
|
||||||
def transfer(in: InputStream, out: OutputStream): Unit = {
|
def transfer(in: InputStream, out: OutputStream) {
|
||||||
try {
|
try {
|
||||||
val buffer = new Array[Byte](BufferSize)
|
val buffer = new Array[Byte](BufferSize)
|
||||||
def read {
|
def read {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue