[akka-user] akka (actor typed actors) cluster, 2 nodes in same jvm, they don't join the cluster

2018-03-11 Thread 'Kostas kougios' via Akka User List
I've created an akka cluster with this config on node 1 (flattened):

akka.cluster.roles : [
"distmem-server"
]
akka.logging-filter : "akka.event.slf4j.Slf4jLoggingFilter"
akka.remote.netty.tcp.hostname : "distmem.lan"* <--- this exists in my 
hosts file and points to localhost, but tried 127.0.0.1 too*
akka.cluster.pub-sub.gossip-interval : "150ms"
akka.loglevel : "warning"
akka.loggers : [
"akka.event.slf4j.Slf4jLogger"
]
akka.actor.provider : "cluster"
akka.remote.netty.tcp.port : 2551
akka.dispatchers.split-dispatcher.executor : "fork-join-executor"
akka.cluster.seed-nodes : [
"akka.tcp://dist...@distmem.lan:2551"
]
akka.jvm-exit-on-fatal-error : false
akka.dispatchers.split-dispatcher.fork-join-executor.parallelism-min : 1
akka.dispatchers.split-dispatcher.fork-join-executor.parallelism-max : 8
akka.dispatchers.split-dispatcher.fork-join-executor.parallelism-factor : 2
akka.dispatchers.split-dispatcher.type : "Dispatcher"
akka.remote.retry-gate-closed-for : 500
akka.remote.netty.tcp.maximum-frame-size : "32MB"
akka.dispatchers.split-dispatcher.throughput : 32
akka.cluster.jmx.multi-mbeans-in-same-jvm : "on"

And the config is the same on 2 apart from 

akka.remote.netty.tcp.port : 2552

So I start node 1 (seed node), sleep for 2 secs and start node 2. Each node 
listens for MemberUp events and I get 1 member up event on each node. But 
those are for the node registering on itself.

INFO  c.a.d.Actors akka.tcp://dist...@distmem.lan:2551 : Joined the cluster 
: Member(address = akka.tcp://dist...@distmem.lan:2551, status = Up)
INFO  c.a.d.Actors akka.tcp://dist...@distmem.lan:2552 : Joined the cluster 
: Member(address = akka.tcp://dist...@distmem.lan:2552, status = Up)

My actor system name is "distmem".

So seems both nodes create a separate cluster? Or maybe they don't talk to 
each other? I am not getting any errors/exceptions. Any ideas what is wrong?

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] ActorSystem and system.dispatcher, can those be used globally?

2017-12-13 Thread &#x27;Kostas kougios' via Akka User List
Hi,

We use Guice and we got an AkkaModule that creates an ActorSystem and a 
Materializer that can later on be injected to other classes. I wonder if 
there is a problem with that. My assumption is that if uses of the actor 
system, materializer and dispatcer (used as ExecutionContext for Future's) 
is proper (i.e. all Future's and akka-streams are non-blocking) then it 
might be OK. But if there is blocking it probably isn't. We do 
unfortunately have a lot of blocking code in the project (mainly when we 
query elastic search but on other places too).

Is there any best practice guide on having multiple ActorSystems i.e. in a 
similar way that ExecutionContexts should be split (cpu intensive tasks, 
I/O intensive tasks etc)?

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] akka.typed, is it possible a message is lost when it is send just after the creation of an actor?

2017-08-31 Thread &#x27;Kostas kougios' via Akka User List
I am using the ask pattern to 

system ? (ref => Get(key, ref))

where

private val system = ActorSystem(
  
Actor.supervise(guardian(Map.empty)).onFailure[Throwable](SupervisorStrategy.resume),
  "EvaluateOnceFlushable"
)


Within the guardian actor, I create a children actor and forward the msg:

val c = ctx.spawn(
  Actor.supervise(child(None)).onFailure[Throwable](SupervisorStrategy.resume),
  withK.key.toString
)
c ! msg



Occasionally my ask times out because the child actor doesn't run (I have 
logging for when it receives the msg but it occasionally not logs anything 
and the ask call times out).
Is it possible the c ! msg is never received by the child?


-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: akka typed actor, slow "ask" with time exponentially increasing by the number of messages

2017-08-25 Thread &#x27;Kostas kougios' via Akka User List
Did a quick test commenting out the blocking .awaitFor(). So there was no 
blocking call. But still it is too slow.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] akka typed actor, slow "ask" with time exponentially increasing by the number of messages

2017-08-24 Thread &#x27;Kostas kougios' via Akka User List
Hi, I got this fairly simple actor:

private def actor(state: Option[R], calc: () => Future[R]): 
Actor.Immutable[Message] = Actor.immutable[Message] {
  (_, msg) =>
msg match {
  case Get(replyTo) =>
state match {
  case Some(f) =>
replyTo ! f
Actor.same
  case None =>
val f = calc().awaitFor(maxWaitForFuture)
replyTo ! f
actor(Some(f), calc)
}
  case Flush =>
actor(None, calc)
}
}


There is a blocking calc().awaitFor call, but that's not my concern right 
now. The actual calc returns a Future that just increases an integer, 
nothing more.

I have a test case for it where I send it 400 Get(--) messages using the 
ask pattern, i.e. actor ? Get(_) . It takes 5 seconds for the test to run. 
This seems too long for me. My calc() method just increases an integer (it 
is just a test).
More weirdly when I increase the messages to 800, the time it takes is 
above 20 secs!!!

I did a bit of profiling, 45% of the time is spend on
akka.actor.LightArrayRevolverScheduler$$anon$4.nextTick()

I saw the src code and it seems it sleeps a bit there conditionally.

How can I debug this slowness?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] akka networking for thousands of small messages

2016-12-02 Thread &#x27;Kostas kougios' via Akka User List
Hi, anyone knows if say I got 2 actors which send very quickly thousands of 
small messages between them. Will akka do any groupping of the messages and 
send them in batches in order to reduce network traffic?

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] New active-object approach blog (2nd attempt)

2015-12-10 Thread Kostas kougios
This is my future-to-be blog about a quite promising (so far) 
active-objects over akka impl for the project I am working on.

I improved my previous (not yet published) blog, basically I started it now 
with a big example with a lot of comments which I believe makes it a better 
read for coders.

Please find it attached as a pdf, it proved hard to paste the text into 
html editors without messing the formatting.

As always please feel free to comment.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


active-objects.pdf
Description: Adobe PDF document


[akka-user] A new active-object approach on top of akka? A new blog, comments are welcomed

2015-12-07 Thread Kostas kougios
 Hi all, 

I am about to publish a blog about this, it is the approach I ended up 
following in my project to sort out different kinds of issues I was facing 
during the implementation of it. So I would be happy to get some feedback 
for the blog, your comments are welcomed.

I tried various approaches before concluding to this one. Initially I've 
impl my code with typed actors but those proved hard to impl the 
distributed logic  and also they are going to be deprecated. It had some 
benefits, OO and type safety. Then I refactored to actors and messaging. 
That proved cumbersome to maintain and hard to test compared to OO code. 
Then I decided due to those issues to try different approaches, 
continuations was one but due to tech limitations I ended up with this 
active object implementation of mine.

So here is the blog. Is it easy to understand? Does it makes sense? Is the 
active object approach good/bad/someone did it already and 
succeeded/failed? 
--

For a lot of IT projects  blah blah ...

The software is implemented in Scala using akka. Initially an 
implementation was done using typed actors but because those were 
deprecated and due to various problems with that model of distributed 
computing, the implementation was switched to akka actors.

Coding such a complex piece of software with actors and message passing 
proved cumbersome. There are several sections of the code that were hard to 
work with and especially hard to unit test. Many times communication 
between 3 types of actors was required and in a sequential fashion. Other 
times scatter/gather patterns have to be applied and even schedules to be 
run in order to modify the state of an actor. Flows of data had to move 
across different actors. Although we implemented utilities that could flow 
the data over all required actors (similar to akka streams), unit testing 
actors using those flows were quite hard due to the volume of participants 
and that there is no type safety. Refactoring was hard as it is hard to 
control who sends and who receives certain messages.
The new active-objects approach

During development we realized that a new approach to coding distributed 
systems is required to ease the development of this software. Standard 
object oriented approaches proved more appropriate and testing via mocking 
traits and classes easier. I ended up implementing a simple 
active-object-like library on top of akka and refactoring actors to active 
objects. 

Those familiarized with spark will feel right at home. Those who know typed 
actors will also easily understand the library as it has a lot of 
similarities - but some significant differences.

Lets go straight into an example. Assuming we have 2 actors, an addition 
and a multiplication one, we want to impl them using this new library.

trait AddService
{
   // add x to y and use the remote multiply service to multiply by z
   def addAndMultiply(x: Int, y: Int, z: Int): R[Int]
}

@remoteService
class AddServiceRemote extends AddService

trait MultiplyService
{
   def multiply(x: Int, y: Int): R[Int]
}

@remoteService
class MultiplyServiceRemote extends MultiplyService


The above definitions are straight forward apart from the @remoteService 
part. This is a marker for a macro that rewrites AddServiceRemote to be a 
remote proxy for AddService. We will go into the details later on.

Now the implementations of the traits:

class MultiplyServiceImpl extends MultiplyService
{
   // returns an R { x * y }
   override def multiply(x: Int, y: Int) = begin {
  x * y
   }

}

class AddServiceImpl(multiplyService: *MultiplyServiceRemote*) extends 
AddService
{

def addAndMultiply(x: Int, y: Int, z: Int) = {
   val sum = x + y
   // since the multiply service is remote, we need a timeout for every call
   implicit val timeout = 1 minute
   multiplyService.multiply(sum, z) // executes remotely, returns an R { 
sum * z }
}
}

Now the above are straight forward. There are some utilities like the begin 
{ }  which returns an R[T] but other than that it feels as if we write 
object oriented code that will execute sequentially. All code runs with 
actor threading semantics which means we could modify local variables 
without synchronization. We can chain calls and the code will execute in a 
pseudo-sequential way, i.e.

def addAndMultiplyAndAddOne(x: Int, y: Int, z: Int) = 
addAndMultiply(x,y,z).map(_ + 1)

The above method will return (x + y)*z + 1 . With the benefit that it all 
seems to run sequentially despite the call to the remote multiplication 
service.

More akka goodies are included. I.e. we can schedule things and resume 
processing as if it is all executed sequentially:

def scheduledMultiplication(x: Int, y: Int, z: Int) = scheduleOnce(500 millis) {
   // this will run after 500 ms of the call, it runs using actor semantics,
   // which means we could modify local variables without synchronization
   x+y
}.andThen 

[akka-user] A new active-object approach on top of akka? Blogging, comments are welcomed

2015-12-07 Thread Kostas kougios
Hi all, 

I am about to publish a blog about this, it is the approach I ended up 
following in my project to sort out different kinds of issues I was facing 
during the implementation of it. So I would be happy to get some feedback 
for the blog, your comments are welcomed.

I tried various approaches before concluding to this one. Initially I've 
impl my code with typed actors but those proved hard to work with and also 
they are going to be deprecated. They had some benefits, OO and type 
safety. Then I refactored to actors and messaging. That proved cumbersome 
to maintain and hard to test (sorry ! still akka is the best distributed 
computing lib I've worked with ). Then I decided due to those issues to try 
different approaches, continuations was one but due to tech limitations I 
ended up with this active object implementation of mine.

So here is the blog. Is it easy to understand? Does it makes sense? Is the 
active object approach good/bad/someone did it already and 
succeeded/failed? 
--

For a lot of IT projects there is a need to ingest and query large volumes 
of data. Traditional databases fail to distribute these data into multiple 
servers and to respond quickly enough to queries. Big data technologies do 
effectively full table scans on the data even if a small subset of the data 
are required and also the developers need to spend a lot of effort thinking 
of how to structure the data to optimize sets of queries.

At AKT IT I am developing a next generation big data nosql + sql database 
that will distribute the data and queries to multiple servers and is meant 
for tables containing terrabytes of data. This will be a sql distributed 
database, which means developers can normalize the data and index them as 
they do on relational databases.

The software is implemented in Scala using akka. Initially an 
implementation was done using typed actors but because those were 
deprecated and due to various problems with that model of distributed 
computing, the implementation was switched to akka actors.

Coding such a complex piece of software with actors and message passing 
proved cumbersome. There are several sections of the code that were hard to 
work with and especially hard to unit test. Many times communication 
between 3 types of actors was required and in a sequential fashion. Other 
times scatter/gather patterns have to be applied and even schedules to be 
run in order to modify the state of an actor. Flows of data had to move 
across different actors. Although we implemented utilities that could flow 
the data over all required actors (similar to akka streams), unit testing 
actors using those flows were quite hard due to the volume of participants 
and that there is no type safety. Refactoring was hard as it is hard to 
control who sends and who receives certain messages.
The new active-objects approach

During development we realized that a new approach to coding distributed 
systems is required to ease the development of this software. Standard 
object oriented approaches proved more appropriate and testing via mocking 
traits and classes easier. I ended up implementing a simple 
active-object-like library on top of akka and refactoring actors to active 
objects. 

Those familiarized with spark will feel right at home. Those who know typed 
actors will also easily understand the library as it has a lot of 
similarities - but some significant differences.

Lets go straight into an example. Assuming we have 2 actors, an addition 
and a multiplication one, we want to impl them using this new library.

trait AddService
{
   // add x to y and use the remote multiply service to multiply by z
   def addAndMultiply(x: Int, y: Int, z: Int): R[Int]
}

@remoteService
class AddServiceRemote extends AddService

trait MultiplyService
{
   def multiply(x: Int, y: Int): R[Int]
}

@remoteService
class MultiplyServiceRemote extends MultiplyService


The above definitions are straight forward apart from the @remoteService 
part. This is a marker for a macro that rewrites AddServiceRemote to be a 
remote proxy for AddService. We will go into the details later on.

Now the implementations of the traits:

class MultiplyServiceImpl extends MultiplyService
{
   // returns an R { x * y }
   override def multiply(x: Int, y: Int) = begin {
  x * y
   }

}

class AddServiceImpl(multiplyService: *MultiplyServiceRemote*) extends 
AddService
{

def addAndMultiply(x: Int, y: Int, z: Int) = {
   val sum = x + y
   // since the multiply service is remote, we need a timeout for every call
   implicit val timeout = 1 minute
   multiplyService.multiply(sum, z) // executes remotely, returns an R { 
sum * z }
}
}

Now the above are straight forward. There are some utilities like the begin 
{ }  which returns an R[T] but other than that it feels as if we write 
object oriented code that will execute sequentially. All code runs with 
actor threading semantics

[akka-user] code that will block for some time, part of an actor or should I wrap it inside a Feature?

2015-11-09 Thread Kostas kougios
I have some code that will take some time to execute. This code runs in a 
few steps with each step "blocking" for some time to store data into files.

I am thinking in creating a new actor which can receive 1 message for each 
step. Will the block part affect only that actor or will other actors be 
affected (since threads are reused in the actorsystem)?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Re: deserializing ActorRef's after jvm restart, will it point to the correct actor?

2015-11-06 Thread Kostas kougios
Well, I refactored my code to cache actorpaths but indeed during creation 
all actorpaths are local and when they are transmitted over the wire they 
remain local => pointing to the wrong path.

I've manually modified the address part of the path myself so that it 
contains the host & port of the server. But the process seems awkward , am 
I missing something?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Re: deserializing ActorRef's after jvm restart, will it point to the correct actor?

2015-11-06 Thread Kostas kougios
hmm, I think actor paths will always be local during the time of the actor 
creation (all actors are created locally and then send over the wire). 
actor.path.address has a host & port of None, so there is no point sending 
that over the wire. The address part of the path won't automatically be 
fixed during serialization, will it?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Re: deserializing ActorRef's after jvm restart, will it point to the correct actor?

2015-11-06 Thread Kostas kougios
Ok so basically I am going to change my code and serialize endpoints (as 
strings) and then use a resolveOne(..) cache (probably cache refs for a 
short time of a few seconds) unless someone can recommend a better way.


-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: deserializing ActorRef's after jvm restart, will it point to the correct actor?

2015-11-05 Thread Kostas kougios
I could ofcourse do an actorSelection but is there an easier way?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] address is now gated for [5000] ms

2015-11-05 Thread Kostas kougios
I am afraid I got that issue again. That's because actors internally need 
the cluster, so I can't enforce a sequence where all systems are created 
and then all clusters. Now I have to wait for 10 + secs for my tests to run 
despite my settings:

remote {
  retry-gate-closed-for = 500


akka {
  cluster.pub-sub.gossip-interval = 150ms



On Thursday, 22 October 2015 23:33:46 UTC+1, Kostas kougios wrote:
>
> What I found out is that the issue was due to the way I was calling 
> Cluster(system) for all the simulated servers.
>
> Calling 
>
> val system1=
> val cluster1 = 
>
> val system2=
> val cluster2 = 
>
> ...
>
> creates the issue probably due to delays for system2 , 3 etc to open their 
> ports. So a lot of clusters were "gating" each other addresses because the 
> ports were not open. That caused sometimes delays to 10 secs even if gate 
> wait was 500ms.
>
> by doing
>
> val system1=
> val system2=
> .
>
> val cluster1 = 
> val cluster2 = 
> ...
> and then clusterX.join(clusterY)
>
> the issue doesn't occur anymore
>
> Cheers
>
>
>

-- 
>>>>>>>>>>  Read the docs: http://akka.io/docs/
>>>>>>>>>>  Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] deserializing ActorRef's after jvm restart, will it point to the correct actor?

2015-11-05 Thread Kostas kougios
Hi, after my program restarts, it deserializes remote actorrefs but they 
don't seem to be pointing to the actor.

So I got a cluster of say 4 servers (simulated by 4 ActorSystem's running 
on different ports).

Each server serializes ActorRefs from self or other servers. When the 
server restarts, it deserializes them but they dont seem to be valid 
anymore.

Is there a way to deserialize them and be valid? My actorrefs all have 
valid paths, i.e. .../databaseServer/index

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Efficient - transmit only once - broadcast?

2015-11-02 Thread Kostas kougios
I am looking for an efficient way to broadcast a case class only once to my 
akka cluster, i.e. broadcast it only once (so it is serialized only once 
over the wire) and received by multiple actors. Then one of those actors 
will reply back to the sender.

Is there a way to do this? I know I can broadcast it to a Cluster (Dist 
pub/sub) but this will send the message once to each ActorSystem. My 
message might be large so I am looking for a 1-send-over-the-wire only, if 
possible.

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] testing that a message is *not* send

2015-10-27 Thread Kostas kougios
I want to test the negative of a use case, when a msg shall not be send.

TestKit doesn't seem to have something to say dontExpectAnyMessage. 
TestProbe has a field of how many msgs are available to the probe, but that 
seems like a hack.

I've also tried mocking ActorRef and verify(ref.tell..., 0 times) but I get 
a classcast exception.

java.lang.ClassCastException: 
akka.actor.ActorRef$$EnhancerByMockitoWithCGLIB$$12648026 cannot be cast to 
akka.actor.ScalaActorRef

It seems there is no workaround for this class cast exception as the akka 
class hierarchy doesn't allow it.

What's the way to verify a msg is not send?

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] is akka.actor.ActorNotFound possible after context.actorOf(...)?

2015-10-14 Thread Kostas kougios
I've been debugging this issue for a couple of days now. I am getting an 
akka.actor.ActorNotFound after doing actor selection and resolveOne.

By now I am pretty confident that the actor is created via actorOf. Then I 
do

actorDetails.actorSelection(path).resolveOne(timeout)


timeout is long enough to not be the reason of the failure (30 seconds). 
path when the failure occurs is always pointing to a remote actor 
(simulated here via an actorsystem on a different port on the same host, 
2713 for the remote actor, 2710 for the actor doing the resolveOne().

Is there a possibility resolveOne will give this *after* the remote actor 
is created via actorOf()?

2015-10-14 16:39:05,695 ERROR [
*akka.tcp://CRUDEndToEndTest@dist-index:2710/user/databaseServer/index:int-string]*
 
o.d.a.IndexActor - REQ_ID: - split failed for 
Actor[akka://CRUDEndToEndTest/user/databaseServer/index:int-string/349c02eb-3d01-4457-9675-59cbfc678f0e#-1455973132],
 
aborting
*akka.actor.ActorNotFound*: Actor not found for: ActorSelection[Anchor(
*akka.tcp://CRUDEndToEndTest@dist-index:2713/*), 
Path(/user/databaseServer/index:int-string)]
at 
akka.actor.ActorSelection$$anonfun$resolveOne$1.apply(ActorSelection.scala:65) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.actor.ActorSelection$$anonfun$resolveOne$1.apply(ActorSelection.scala:63) 
~[akka-actor_2.11-2.4.0.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) 
~[scala-library-2.11.7.jar:na]
at 
akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
 
~[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.BatchingExecutor$Batch.run(BatchingExecutor.scala:73) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.dispatch.ExecutionContexts$sameThreadExecutionContext$.unbatchedExecute(Future.scala:74)
 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.dispatch.BatchingExecutor$class.execute(BatchingExecutor.scala:120) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.dispatch.ExecutionContexts$sameThreadExecutionContext$.execute(Future.scala:73)
 
~[akka-actor_2.11-2.4.0.jar:na]
at 
scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) 
~[scala-library-2.11.7.jar:na]
at 
scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) 
~[scala-library-2.11.7.jar:na]
at akka.pattern.PromiseActorRef.$bang(AskSupport.scala:345) 
~[akka-actor_2.11-2.4.0.jar:na]
at akka.remote.DefaultMessageDispatcher.dispatch(Endpoint.scala:89) 
~[akka-remote_2.11-2.4.0.jar:na]
at 
akka.remote.EndpointReader$$anonfun$receive$2.applyOrElse(Endpoint.scala:929) 
~[akka-remote_2.11-2.4.0.jar:na]
at akka.actor.Actor$class.aroundReceive(Actor.scala:480) 
~[akka-actor_2.11-2.4.0.jar:na]
at akka.remote.EndpointActor.aroundReceive(Endpoint.scala:405) 
~[akka-remote_2.11-2.4.0.jar:na]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:525) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.actor.ActorCell.invoke(ActorCell.scala:494) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.Mailbox.run(Mailbox.scala:224) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.Mailbox.exec(Mailbox.scala:234) 
[akka-actor_2.11-2.4.0.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) 
[scala-library-2.11.7.jar:na]
at 
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
 
[scala-library-2.11.7.jar:na]
at 
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) 
[scala-library-2.11.7.jar:na]
at 
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
 
[scala-library-2.11.7.jar:na]

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] akka.actor.ActorNotFound: Actor not found for: ActorSelection[Anchor(akka.tcp://DistIdx@dist-index:2710/), Path(/user/databaseServer/index:my-index)]

2015-10-12 Thread Kostas kougios
Running some stress tests on my code produces the following:

2015-10-12 15:38:06.301UTC ERROR[DistIdx-akka.actor.default-dispatcher-22] 
[akka.tcp://DistIdx@dist-index:2720/user/driverActor] 
o.d.a.e.i.ActorExtImpl - Failed to locate index
akka.actor.ActorNotFound: Actor not found for: 
ActorSelection[Anchor(akka.tcp://DistIdx@dist-index:2710/), 
Path(/user/databaseServer/index:my-index)]
at 
akka.actor.ActorSelection$$anonfun$resolveOne$1.apply(ActorSelection.scala:65) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.actor.ActorSelection$$anonfun$resolveOne$1.apply(ActorSelection.scala:63) 
~[akka-actor_2.11-2.4.0.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32) 
~[scala-library-2.11.7.jar:na]
at 
akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
 
~[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.BatchingExecutor$Batch.run(BatchingExecutor.scala:73) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.dispatch.ExecutionContexts$sameThreadExecutionContext$.unbatchedExecute(Future.scala:74)
 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.dispatch.BatchingExecutor$class.execute(BatchingExecutor.scala:120) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.dispatch.ExecutionContexts$sameThreadExecutionContext$.execute(Future.scala:73)
 
~[akka-actor_2.11-2.4.0.jar:na]
at 
scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:40) 
~[scala-library-2.11.7.jar:na]
at 
scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:248) 
~[scala-library-2.11.7.jar:na]
at akka.pattern.PromiseActorRef.$bang(AskSupport.scala:345) 
~[akka-actor_2.11-2.4.0.jar:na]
at akka.actor.EmptyLocalActorRef.specialHandle(ActorRef.scala:553) 
~[akka-actor_2.11-2.4.0.jar:na]
at akka.actor.DeadLetterActorRef.specialHandle(ActorRef.scala:589) 
~[akka-actor_2.11-2.4.0.jar:na]
at akka.actor.DeadLetterActorRef.$bang(ActorRef.scala:579) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.remote.RemoteActorRefProvider$RemoteDeadLetterActorRef.$bang(RemoteActorRefProvider.scala:85)
 
~[akka-remote_2.11-2.4.0.jar:na]
at 
akka.remote.ReliableDeliverySupervisor$$anonfun$gated$1.applyOrElse(Endpoint.scala:328)
 
~[akka-remote_2.11-2.4.0.jar:na]
at akka.actor.Actor$class.aroundReceive(Actor.scala:480) 
~[akka-actor_2.11-2.4.0.jar:na]
at 
akka.remote.ReliableDeliverySupervisor.aroundReceive(Endpoint.scala:188) 
~[akka-remote_2.11-2.4.0.jar:na]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:525) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.actor.ActorCell.invoke(ActorCell.scala:494) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.Mailbox.run(Mailbox.scala:224) 
[akka-actor_2.11-2.4.0.jar:na]
at akka.dispatch.Mailbox.exec(Mailbox.scala:234) 
[akka-actor_2.11-2.4.0.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) 
[scala-library-2.11.7.jar:na]
at 
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
 
[scala-library-2.11.7.jar:na]
at 
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) 
[scala-library-2.11.7.jar:na]
at 
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
 
[scala-library-2.11.7.jar:na]

Ok, so the actor is dead, but how? There is no exception before that (if 
the actor throwed one, wouldn't it be visible in the logs?)


-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: is there a way to know when *really* an actor has stopped

2015-10-08 Thread Kostas kougios
Thanks, I am doing that now and hopefully it works (the issue occurred very 
rarely, so I have to wait and see)

On Friday, 2 October 2015 17:16:35 UTC+1, Ryan Tanner wrote:
>
> Don't create the replacement actor until you've received a Terminated 
> message for the original actor.
>
> On Friday, October 2, 2015 at 8:58:54 AM UTC-6, Kostas kougios wrote:
>>
>> I create a named actor, stop it and recreate it with the same name. 
>> Because stop is async, I end up with exceptions like
>>
>>   akka.actor.InvalidActorNameException: actor name [databaseServer] is 
>> not unique!
>> [info]   at 
>> akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:130)
>> [info]   at 
>> akka.actor.dungeon.Children$class.reserveChild(Children.scala:77)
>> [info]   at akka.actor.ActorCell.reserveChild(ActorCell.scala:373)
>> [info]   at 
>> akka.actor.dungeon.Children$class.makeChild(Children.scala:215)
>> [info]   at 
>> akka.actor.dungeon.Children$class.attachChild(Children.scala:42)
>> [info]   at akka.actor.ActorCell.attachChild(ActorCell.scala:373)
>> [info]   at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:586)
>> [info]   at 
>> org.distributedrange.actors.StreamActor$$anonfun$2.apply(StreamActor.scala:122)
>>
>> I get the same exception even if I set an AtomicBoolean to true at:
>>
>> override def postStop() = {
>>stopped.set(true)
>>super.postStop()
>> }
>>
>>
>> and then
>>
>> while (!stopped.get) {
>>Thread.sleep(1)
>>  }
>>
>>
>> Is there a way to "block" and wait till the actor stops?
>> (don't worry about the block part, it is only for test cases)
>>
>> Thanks
>>
>

-- 
>>>>>>>>>>  Read the docs: http://akka.io/docs/
>>>>>>>>>>  Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] address is now gated for [5000] ms

2015-10-07 Thread Kostas kougios
Hi, I am occasionally getting this when running tests. The test resumes, 
but I wait for 5 secs. Is there a config property to set it to 500ms?
(googling didn't reveal any relevant info)

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] is there a way to know when *really* an actor has stopped

2015-10-02 Thread Kostas kougios
I create a named actor, stop it and recreate it with the same name. Because 
stop is async, I end up with exceptions like

  akka.actor.InvalidActorNameException: actor name [databaseServer] is not 
unique!
[info]   at 
akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:130)
[info]   at 
akka.actor.dungeon.Children$class.reserveChild(Children.scala:77)
[info]   at akka.actor.ActorCell.reserveChild(ActorCell.scala:373)
[info]   at akka.actor.dungeon.Children$class.makeChild(Children.scala:215)
[info]   at akka.actor.dungeon.Children$class.attachChild(Children.scala:42)
[info]   at akka.actor.ActorCell.attachChild(ActorCell.scala:373)
[info]   at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:586)
[info]   at 
org.distributedrange.actors.StreamActor$$anonfun$2.apply(StreamActor.scala:122)

I get the same exception even if I set an AtomicBoolean to true at:

override def postStop() = {
   stopped.set(true)
   super.postStop()
}


and then

while (!stopped.get) {
   Thread.sleep(1)
 }


Is there a way to "block" and wait till the actor stops?
(don't worry about the block part, it is only for test cases)

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] DistributedPubSub, SendToAll (path...) is not sending msg

2015-10-01 Thread Kostas kougios
Path is :
akka://testSystem/user/databaseServer/index:int-string

There are 2 actors with that path on 2 ActorSystems. ActorSystem = 
testSystem. None is receiving the msg

What can be wrong?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: compare self.path.address with a remote actor address

2015-09-29 Thread Kostas kougios
found a solution here:
http://stackoverflow.com/questions/14288068/how-do-i-get-the-absolute-remote-actor-url-from-inside-the-actor
via the RemoteAddressExtension. Not sure if it is the most optimal

On Tuesday, 29 September 2015 13:34:53 UTC+1, Kostas kougios wrote:
>
> I have an akka cluster and keep a member registry. member.address is an 
> instance of UniqueAddress with the host name and port. 
>
> self.path.address is an Address without those. So comparing doesn't work.
>
> What I want to do is filter out self out of the selected actors:
>
> val myAddress=self.path.address
> members.filterNot(_.address == myAddress).map(m => actorSelection(path 
> via m.address...))
>
>
> But it doesn't filter it.
>
>
>

-- 
>>>>>>>>>>  Read the docs: http://akka.io/docs/
>>>>>>>>>>  Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] compare self.path.address with a remote actor address

2015-09-29 Thread Kostas kougios
I have an akka cluster and keep a member registry. member.address is an 
instance of UniqueAddress with the host name and port. 

self.path.address is an Address without those. So comparing doesn't work.

What I want to do is filter out self out of the selected actors:

val myAddress=self.path.address
members.filterNot(_.address == myAddress).map(m => actorSelection(path via 
m.address...))


But it doesn't filter it.


-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] actor names unique across cluster?

2015-09-29 Thread Kostas kougios
Is it possible to create an actor with the same name on a different server? 
(currently my testcase runs in the same jvm)

I am getting

[ERROR] [09/29/2015 13:07:35.555] 
[testSystem-akka.actor.default-dispatcher-22] 
[akka://testSystem/user/databaseServer] actor name [index:int-string] is 
not unique!
akka.actor.InvalidActorNameException: actor name [index:int-string] is not 
unique!

The actor [index:int-string] was created on ActorSystem A and I am trying 
to create [index:int-string] on ActorSystem B. The system name is 
testSystem on both ActorSystems.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] system.actorSelection works only from the same system that created the actor

2015-08-03 Thread Kostas kougios
I've a test case with 2 systems and I am doing 
system2.actorSelection(address of actor on system1) but it gets the 
deadLetters actor. If I do system1.actorSelection, I get the correct actor. 
Isn't this supposed to work across systems?

The actor address : 
akka.tcp://testSystem@127.0.0.1:2720/user/databaseServer/index:int-string
This should be correct because I get the actor if I use 
system1.actorSelection

system1.toString : akka://testSystem
actual address: 

akka.tcp://testSystem@127.0.0.1:2720


system2.toString : akka://testSystem
actual address: 

akka.tcp://testSystem@127.0.0.1:2721



-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] DistributedPubSubExtension, subscriber doesn't receive published message

2015-06-22 Thread Kostas kougios
Hi, using akka cluster and DistributedPubSubExtension, I am creating a 
topic.

The receiving actor (driver) subscribes to the topic:

private val mediator = DistributedPubSubExtension(system).mediator
mediator ! Subscribe(Subscriptions.IndexActorAvailability, self)


override def receive = {
   case SubscribeAck(subscribe) =>
  context become ready
...


The publishing actor (server) publishes a msg during it's startup:

private val mediator = DistributedPubSubExtension(context.system).mediator
  mediator ! Publish(Subscriptions.IndexActorAvailability, IAmAvailable(index, 
self))


But the driver actor never receives it.

Some notes:

1. "context become ready" is certainly executed before the publishing actor 
publishes the msg (I've debugged it)

2. The actors context.system are different (akka - cluster) but the rest of 
the cluster communicates fine.

3. all run under a testcase in the same jvm

Here is my config:

akka {
  log-dead-letters-during-shutdown = off
  loglevel = "INFO"
  cluster {
gossip-interval = 100 ms
leader-actions-interval = 100 ms
seed-nodes = [
  "akka.tcp://testSystem@127.0.0.1:2700",
  "akka.tcp://testSystem@127.0.0.1:2701"
]
  }
  extensions = ["akka.contrib.pattern.DistributedPubSubExtension"]
}

server1 {
  akka {
remote {
  netty.tcp {
port = 2700
  }
}
cluster {
  roles = ["index-server"]
}
  }
}

server2 {
  akka {
remote {
  netty.tcp {
port = 2701
  }
}
cluster {
  roles = ["index-server"]
}
  }
}

driver {
  akka {
remote {
  netty.tcp {
port = 2702
  }
}
cluster {
  roles = ["driver"]
}
  }
}


-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] akka-cluster, speeding up join/memberUp events for end-to-end tests?

2015-06-14 Thread Kostas kougios
Hi,

I am creating an end to end test for my cluster by creating 2 of them in 
the same jvm :

val cluster1 = Cluster(SystemName, server1Config)
val cluster2 = Cluster(SystemName, server2Config)

Thread.sleep(1)


As you can see, I have to use a sleep() to allow the cluster to to talk to 
each other.

Is there a way to speed this up?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] why actors are not POSO's?

2015-06-10 Thread Kostas kougios
In the other thread of mine, I explained a testability issue I have with 
actors which require complex messaging. But also a good question is, why 
are not actors POSO's? It would increase testabilty & maintainability.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Testability (via mocks) of complex actors and actors as POSO's

2015-06-10 Thread Kostas kougios
Actors are not plain scala objects and that creates a couple of testability 
issues for me. I managed to sort them out by creating a thin layer over 
actors to convert my actors to POSO's. (POSO = plain old scala object, if 
there is such a term :) ). So now I am able to mock any references the 
actors get.

But I wonder if there is already something out of the box so that I can 
work out with actors as if they are poso's and still use testkit, 
testactor, testprobe and TestActorRef's.

So for example one of my actors when it receives a msg, it creates a child 
actor via context.actorOf(...) . It then gets some other actor references 
from the akka-cluster. It sends those a msg and then waits for a reply from 
each one of those. Upon reply, it sends itself an other msg via self ! msg.

So there were several issues to easily test this via TestKit, TestProbe, 
TestActorRef. First of all, how would I know that my code actually creates 
the correct actor when calling context.actorOf(...) ? Then how do I 
mock/testprobe() the actors from the cluster since I can't mock the cluster 
itself? Even if I mock the cluster, it becomes tedious to send MemberUp 
events to the actor under test. Finally how do I know that the actor 
actually send itself a msg via self ! msg ?

Now there are some DI ideas out there but are tedious, i.e. to send deps 
via a msg , but even so self can't be mocked.

Anyway as I said I've created a facade and it works nicely along with 
testkit but I wonder if there is something already out there. Also a good 
question is, why actors are not POSO's?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: weird for {} compilation error when using actor ? msg

2015-06-01 Thread Kostas kougios
I suppose it is because first I iterate a Seq[] and then it expects 
sequences. Probably will have to go back to .map-ing.

On Tuesday, 2 June 2015 07:10:10 UTC+1, Kostas kougios wrote:
>
> I've this code 
>
> implicit val to = Timeout(timeout)
> import context.dispatcher
>
> val futures = for {
>actor <- actors
>r <- actor ? msg
> } yield Response(r)
>
>
> (actors is a Seq[ActorRef])
>
> But I get this compilation error:
>
> Error:(25, 7) type mismatch;
>  found   : scala.concurrent.Future[Response]
>  required: scala.collection.GenTraversableOnce[?]
> r <- actor ? msg
>   ^
>
> This is weird, shouldn't it work as per 
> http://doc.akka.io/docs/akka/snapshot/scala/actors.html / Ask: 
> Send-And-Receive-Future ?
>
>
>

-- 
>>>>>>>>>>  Read the docs: http://akka.io/docs/
>>>>>>>>>>  Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] weird for {} compilation error when using actor ? msg

2015-06-01 Thread Kostas kougios
I've this code 

implicit val to = Timeout(timeout)
import context.dispatcher

val futures = for {
   actor <- actors
   r <- actor ? msg
} yield Response(r)


(actors is a Seq[ActorRef])

But I get this compilation error:

Error:(25, 7) type mismatch;
 found   : scala.concurrent.Future[Response]
 required: scala.collection.GenTraversableOnce[?]
r <- actor ? msg
  ^

This is weird, shouldn't it work as per 
http://doc.akka.io/docs/akka/snapshot/scala/actors.html / Ask: 
Send-And-Receive-Future ?


-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] akka message flow

2015-06-01 Thread Kostas kougios
Hi, I need to create a flow of messages, my current usecase is that I get a 
msg in one of my actors which in turn has to send a similar message to the 
cluster (I am also using akka-cluster) and upon confirmation from all 
cluster members to do some local changes and then reply back to the sender. 
But my use case might become more complex in the future.

So apart from using a separate FSM actor (my current actor is not FSM), is 
there any higher level api that can do

broadcast(msg).expectFromAll { case Reply=> true }.andThen(... do local 
changes...).andThen(reply to sender).onTimeout(...fail...)

a bit of googling didn't reveal anything like that.

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] TestProbe() and actorSelection

2015-05-20 Thread Kostas kougios
Hi, I am trying to test actor code that uses actorSelection:

val path = RootActorPath(member.address, name = "/user/clusterKeeper")
context.actorSelection(path).resolveOne(5 seconds).foreach {
clusterKeeper =>
  clusterKeeper ! msg
}


member.address comes from akka clusters and has the address of the remote 
actor.

Now I need to mock/probe the clusterKeeper actor but TestProbe() doesn't 
have a way of defining the name of the actor or it's path. In fact it goes 
down to TestKitBase where it is hardcoded:

val testActor: ActorRef = {
  val impl = system.asInstanceOf[ExtendedActorSystem]
  val ref = impl.systemActorOf(TestActor.props(queue)
.withDispatcher(CallingThreadDispatcher.Id),

*"testActor" + TestKit.testActorId.incrementAndGet) * awaitCond(ref match {
case r: RepointableRef ⇒ r.isStarted
case _ ⇒ true
  }, 1 second, 10 millis)
  ref
}


Is there a way with the testkit to test this? Ofcourse I could create an 
actor myself but then I would have to reimpl all expectMsg or maybe have it 
forward the messages to testkit. 

Similar post :
https://groups.google.com/forum/#!searchin/akka-user/testprobe$20actorSelection/akka-user/ETL4XQr1Sj4/N9lo_6gc8voJ

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Waiting for actor to "become" x in test cases

2015-05-12 Thread Kostas kougios
Hi,

Currently my actor becomes ready when it receives a msg :

class MyActor {
private val mediator = 
DistributedPubSubExtension(context.system).mediator
mediator ! Subscribe(Subscriptions.Index, self)

...
override def receive = {
case SubscribeAck(Subscribe(Subscriptions.Index, None, self)) =>
context become ready
}

def ready =
createPart.receive orElse
retrievePart.receive

}

This creates problems in test cases, when I send a msg to my actor:

myActor ! Create(...) // this is received before SubscribeAck and hence it 
is ignored

My temp solution is to sleep a bit after creating an actor so that I give 
an opportunity to the mediator to send the SubscribeAck:

val indexActor = system.actorOf(Props(IndexActor.empty(IntKey, 
StringValue, cluster.ref)))
// TODO: replace this with something better. This is required so 
that the actor becomes ready
Thread.sleep(5)


Is there a better solution?

Thanks
#

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] TestKit and how to avoid a failing (or sucesful) test affecting the other tests

2015-05-12 Thread Kostas kougios
Hi,

I am having this issue where I sometimes "tell" different actors multiple 
messages and I want to test a single message, so I might have 1 expectMsg. 
But then, this affects the rest of the tests ,i.e. if the receiver is the 
testActor. 

is there a way to "reset" TestKit for each test?

Thanks

(Note: i've asked a more detailed question similar to this but it is 
probably too complex and didn't get any answers yet)

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Isolating akka tests & expectMsg's (especially due to DistributedPubSubExtension)

2015-05-11 Thread Kostas kougios
Hi, I am trying to find the best way to isolate msg expectations when 
testing. I started having issues with messages for one test are making an 
other test (in the same scala-test class) fail, especially since I started 
using akka cluster and broadcasting via DistributedPubSubExtension.

I always create new instances of my actors. But since they use the same 
system (via TestKit) I get this problem where the first test succeeds bit 
subsequent tests fail because of (currently) SubscribeAck message.

One way ofcourse would be to reset the actor system for each test, but it 
doesn't seem to be supported by TestKit.

This is my base test class:

class BaseActorSuite(config: Config = ConfigFactory.empty) extends 
TestKit(ActorSystem("testSystem", config)) with ImplicitSender with 
FunSuiteLike with Matchers with BeforeAndAfterAll
{
override def afterAll {
TestKit.shutdownActorSystem(system)
}
}

And this is how I do testing:

class ClusterKeeperActorTest extends 
BaseActorSuite(ConfigFactory.load("org/distributedrange/cluster/actors/ClusterKeeperActorTest.conf"))
 
with MockitoSugar
{
// simulate a remote cluster keeper
def remoteClusterKeeperActor = {
val remote = TestProbe()
val mediator = DistributedPubSubExtension(system).mediator
mediator ! Subscribe(ClusterKeeperActor.Subscriptions.Index, 
remote.ref)
remote
}

def newActor = system.actorOf(Props(new ClusterKeeperActor))

test("sends SyncIndex to remote cluster keepers") {
val clusterKeeper = newActor
val remoteClusterKeeper = remoteClusterKeeperActor
val rangeRef = RangeRef("id", IntKey.min, IntKey.max, testActor)
clusterKeeper ! SyncIndex(rangeRef)
remoteClusterKeeper.expectMsg(RemoteSyncIndex(rangeRef))
}

test("keeps track of new members") {
val clusterKeeper = newActor
val m1 = mockMember
val m2 = mockMember

clusterKeeper ! MemberUp(m1)
clusterKeeper ! MemberUp(m2)
clusterKeeper ! messages.AllMembers
expectMsg(Set(m1, m2))
}
}

"keeps track of new members" runs fine if I comment out the 1st test, but 
fails otherwise with 

java.lang.AssertionError: assertion failed: expected Set(Mock for Member, 
hashCode: 405006382, Mock for Member, hashCode: 1566584931), found 
*SubscribeAck*
(Subscribe(index,None,Actor[akka://testSystem/system/testActor2#640267634]))

As you can see, the SubscribeAck comes from the 1st test.

Ideas? Is there a way say to reset the mailboxes in-between tests?

Thanks


-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] TypedActor with 3 instances

2014-10-21 Thread Kostas kougios
Say I got 3 jvms, A , B and C. A is calling a method on a typed actor that 
runs on B. Is it possible B to propagate the call to C and then C to send 
the reply to A (not via B)?

Thanks

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: typed actor on a single thread?

2014-04-08 Thread Kostas kougios
attached the test program.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


experiments.tar.gz
Description: Binary data


Re: [akka-user] typed actor on a single thread?

2014-04-08 Thread Kostas kougios
Thanks for the replies, so I suppose this typed actor will work just fine. 
Any execution of the 2 methods will occur at 1 thread at each time and 
state changes within the actor consists of safe publication. I run it and 
it looks good.

trait MapService[K, V]
{
def update(k: K, v: V): Unit
def apply(k:K):Future[V]
}

class MapServiceImpl[K, V] extends MapService[K, V]
{
private val m = collection.mutable.Map.empty[K, V]

override def apply(k: K) = Future.successful(m(k))

override def update(k: K, v: V) = m(k) = v
}

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] typed actor on a single thread?

2014-04-08 Thread Kostas kougios
Hi, I've created a typed actor but it seems it runs on multiple threads. 
How can I run it on 1 single thread so that I can use collections within 
the typed actor &avoid synchronization?

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.