I have made some progress and is now able to answer my primary question 
(please correct me if I am wrong).

>But does that mean a Cluster has been established? (See post above)

The answer is "No, the cluster was not started ( even though remoting was 
established ). Since there was no seed node specified, the node needed to 
be manually joined. A console log is printed hinting that. 

So in my test adding the following line for *Node1*:

 private val system = ActorSystem( Platform.NAME );
 Cluster(system).join(AddressFromURIString.parse(
"akka.tcp://[email protected]:9000"));
has got things moving. I even saw MemberUp event ( for Node2 ) on Node1.

I think I am able to move forward for now.


On Wednesday, March 26, 2014 1:00:35 PM UTC+11, Mohammad Bhuyan wrote:
>
> Hi,
>
> I am using AKKA 2.3.0 with Scala 2.10.3
>
> I am trying a basic 2 node cluster exercise in Scala using Akka. Where I 
> would like each node to have a cluster monitor and print console messages 
> on member join. So that I know, there is a cluster.
>
> Just like the example provided in docs, reactive etc. Simple enough!
>
> Let me first present what I have and then I will come to my 
> questions/confusions.
>
> *(1) Source code of the node and monitor class *
>
> object Platform {
>   final val NAME = "concenter";  
> }
>
> class Platform extends Bootable {
>   private val system = ActorSystem( Platform.NAME );
>   system.actorOf(Props[ClusterMonitor], name = "clusterListener");
>
>   def startup = {
>     System.out.println("Greetings Earthling!");
>   }
>
>   def shutdown = {
>     system.shutdown();
>     System.out.println("Goodbye Blue Sky, Goodbye!");
>   }
> }
>
> class ClusterMonitor extends Actor with ActorLogging {
>   private val cluster = Cluster(context.system)
>   override def preStart(): Unit = {
>     System.out.println("Subscribing to Cluster Event");
>     cluster.subscribe(self, initialStateMode = InitialStateAsEvents, 
> classOf[MemberEvent], classOf[UnreachableMember], 
> classOf[ClusterDomainEvent] );
>   }
>
>   override def postStop(): Unit = {
>     cluster.unsubscribe(self);
>     System.out.println("Unsubscribed from Cluster Event");
>   }
>   def receive = {
>     case MemberUp(member) =>     log.info(">>>>>>>>>>> Member is Up: {}", 
> member.address)
>     case UnreachableMember(member) =>       log.info(">>>>>>>>>>> Member 
> detected as unreachable: {}", member)
>     case MemberRemoved(member, previousStatus) => log.info(">>>>>>>>>>> 
> Member is Removed: {} after {}", member.address, previousStatus)
>     case _: MemberEvent => log.info( "XXXXXXX" );
>     case cdev: ClusterDomainEvent => { log.info( "YYYYY: " + cdev.toString() 
> ); }
>   }
> }   
> (*2) Node 1 configuration. This node is always explicitly started first.*
> akka {
> //STDOUT logging for Debugging
> loggers = ["akka.event.Logging$DefaultLogger"]
> actor {
> provider = "akka.cluster.ClusterActorRefProvider"
> }
> remote {
> netty.tcp {
> hostname = "127.0.0.1"
> port = 9000
> }
> }
> cluster {
>      log-info = on
> }
>
> }
>
> (3*) Node 2 configuration. This node is always explicitly started after 
> Node 1.*
>
> akka {
> //STDOUT logging for Debugging
> loggers = ["akka.event.Logging$DefaultLogger"]
> actor {
> provider = "akka.cluster.ClusterActorRefProvider"
> }
> remote {
> netty.tcp {
> hostname = "127.0.0.1"
> port = 9090
> }
> }
> cluster {
>      log-info = on
>      seed-nodes = [ "akka.tcp://[email protected]:9000" ]
> }
> }
> *(4) An execution session, I have the following output from Node  1 ( Node 
> 2 is started and taken down )*
>
> Starting Akka...
> Running Akka 2.3.0
> [warning] Akka home is not defined
> [DEBUG] [03/26/2014 12:22:32.446] [main] [EventStream(akka://concenter)] 
> logger log1-Logging$DefaultLogger started
> [DEBUG] [03/26/2014 12:22:32.447] [main] [EventStream(akka://concenter)] 
> Default Loggers started
> [INFO] [03/26/2014 12:22:32.497] [main] [Remoting] Starting remoting
> [INFO] [03/26/2014 12:22:32.695] [main] [Remoting] Remoting started; 
> listening on addresses :[akka.tcp://[email protected]:9000]
> [INFO] [03/26/2014 12:22:32.696] [main] [Remoting] Remoting now listens on 
> addresses: [akka.tcp://[email protected]:9000]
> [INFO] [03/26/2014 12:22:32.708] [main] [Cluster(akka://concenter)] 
> Cluster Node [akka.tcp://[email protected]:9000] - Starting up...
> [INFO] [03/26/2014 12:22:32.784] [main] [Cluster(akka://concenter)] 
> Cluster Node [akka.tcp://[email protected]:9000] - Registered cluster 
> JMX MBean [akka:type=Cluster]
> [INFO] [03/26/2014 12:22:32.784] [main] [Cluster(akka://concenter)] 
> Cluster Node [akka.tcp://[email protected]:9000] - Started up 
> successfully
> [INFO] [03/26/2014 12:22:32.789] 
> [concenter-akka.actor.default-dispatcher-3] [Cluster(akka://concenter)] 
> Cluster Node [akka.tcp://[email protected]:9000] - Metrics will be 
> retreived from MBeans, and may be incorrect on some platforms. To increase 
> metric accuracy add the 'sigar.jar' to the classpath and the appropriate 
> platform-specific native libary to 'java.library.path'. Reason: 
> java.lang.ClassNotFoundException: org.hyperic.sigar.Sigar
> [INFO] [03/26/2014 12:22:32.789] 
> [concenter-akka.actor.default-dispatcher-14] [Cluster(akka://concenter)] 
> Cluster Node [akka.tcp://[email protected]:9000] - No seed-nodes 
> configured, manual cluster join required
> [INFO] [03/26/2014 12:22:32.790] 
> [concenter-akka.actor.default-dispatcher-3] [Cluster(akka://concenter)] 
> Cluster Node [akka.tcp://[email protected]:9000] - Metrics collection 
> has started successfully
> Starting up concenter.Platform
> Greetings Earthling!
> Subscribing to Cluster Event
> Successfully started Akka
>
> [INFO] [03/26/2014 12:22:35.809] 
> [concenter-akka.actor.default-dispatcher-21] [akka.tcp://
> [email protected]:9000/user/clusterListener] YYYYY: 
> ClusterMetricsChanged(Set(NodeMetrics(akka.tcp://[email protected]:9000,1395796955800,Set(Metric(heap-memory-used,24796920,Some(EWMA(2.479692E7,0.15910417746033534))),
>  
> Metric(heap-memory-max,3817865216,None), Metric(processors,8,None), 
> Metric(system-load-average,2.2978515625,None), 
> Metric(heap-memory-committed,257425408,Some(EWMA(2.57425408E8,0.15910417746033534)))))))
>
> [INFO] [03/26/2014 12:22:59.810] 
> [concenter-akka.actor.default-dispatcher-21] [akka.tcp://
> [email protected]:9000/user/clusterListener] YYYYY: 
> ClusterMetricsChanged(Set(NodeMetrics(akka.tcp://[email protected]:9000,1395796979809,Set(Metric(heap-memory-used,26584712,Some(EWMA(2.6584712E7,0.15910417746033534))),
>  
> Metric(heap-memory-max,3817865216,None), Metric(processors,8,None), 
> Metric(system-load-average,2.55810546875,None), 
> Metric(heap-memory-committed,257425408,Some(EWMA(2.57425408E8,0.15910417746033534)))))))
>
> [INFO] [03/26/2014 12:23:08.800] 
> [concenter-akka.actor.default-dispatcher-14] [akka.tcp://
> [email protected]:9000/user/clusterListener] YYYYY: 
> ClusterMetricsChanged(Set(NodeMetrics(akka.tcp://[email protected]:9000,1395796988799,Set(Metric(heap-memory-used,26810728,Some(EWMA(2.6810728E7,0.15910417746033534))),
>  
> Metric(heap-memory-max,3817865216,None), Metric(processors,8,None), 
> Metric(system-load-average,2.619140625,None), 
> Metric(heap-memory-committed,257425408,Some(EWMA(2.57425408E8,0.15910417746033534)))))))
>
> [INFO] [03/26/2014 12:23:11.800] 
> [concenter-akka.actor.default-dispatcher-4] [akka.tcp://
> [email protected]:9000/user/clusterListener] YYYYY: 
> ClusterMetricsChanged(Set(NodeMetrics(akka.tcp://[email protected]:9000,1395796991800,Set(Metric(heap-memory-used,26810728,Some(EWMA(2.6810728E7,0.15910417746033534))),
>  
> Metric(heap-memory-max,3817865216,None), Metric(processors,8,None), 
> Metric(system-load-average,2.619140625,None), 
> Metric(heap-memory-committed,257425408,Some(EWMA(2.57425408E8,0.15910417746033534)))))))
>
> *[DEBUG] [03/26/2014 12:23:12.818] 
> [concenter-akka.remote.default-remote-dispatcher-22] [Remoting] Associated 
> [akka.tcp://[email protected]:9000 <http://[email protected]:9000>] <- 
> [akka.tcp://[email protected]:9090 <http://[email protected]:9090>]*
>
> [DEBUG] [03/26/2014 12:23:12.873] 
> [concenter-akka.remote.default-remote-dispatcher-27] 
> [akka.serialization.Serialization(akka://concenter)] Using 
> serializer[akka.cluster.protobuf.ClusterMessageSerializer] for message 
> [akka.cluster.InternalClusterAction$InitJoinNack]
>
> [INFO] [03/26/2014 12:23:14.800] 
> [concenter-akka.actor.default-dispatcher-21] [akka.tcp://
> [email protected]:9000/user/clusterListener] YYYYY: 
> ClusterMetricsChanged(Set(NodeMetrics(akka.tcp://[email protected]:9000,1395796994799,Set(Metric(heap-memory-used,35955000,Some(EWMA(3.5955E7,0.15910417746033534))),
>  
> Metric(heap-memory-max,3817865216,None), Metric(processors,8,None), 
> Metric(system-load-average,2.5693359375,None), 
> Metric(heap-memory-committed,257425408,Some(EWMA(2.57425408E8,0.15910417746033534)))))))
>
> [INFO] [03/26/2014 12:23:41.800] 
> [concenter-akka.actor.default-dispatcher-4] [akka.tcp://
> [email protected]:9000/user/clusterListener] YYYYY: 
> ClusterMetricsChanged(Set(NodeMetrics(akka.tcp://[email protected]:9000,1395797021799,Set(Metric(heap-memory-used,36148720,Some(EWMA(3.614872E7,0.15910417746033534))),
>  
> Metric(heap-memory-max,3817865216,None), Metric(processors,8,None), 
> Metric(system-load-average,2.2724609375,None), 
> Metric(heap-memory-committed,257425408,Some(EWMA(2.57425408E8,0.15910417746033534)))))))
>
> *Now coming to my questions:*
>
> (1) I can see in above that I "remoting" has been established. But does 
> that mean a Cluster has been established? This is my primary question. As 
> far I understand, akka clustering is a layer on top of remoting.
> (2) To determine the answer to my question, I am trying to listen to 
> "cluster event". In my case, as you can see above, my listener is only 
> getting ClusterDomainEvent. While it proves that my listener is working but 
> I expected a MemberUP when Node 2 is booted.
> (3) Whenever I bring down any of these nodes, Ctrl+c I get console output:
>
> ^C
> Shutting down Akka...
> Shutting down concenter.Platform
> Goodbye Blue Sky, Goodbye!
> Successfully shut down Akka
>
> Here, I get my message for kernel shutdown, where I am doing actorsystem 
> shutdown. To my surprise no output from postStop of my listener actor? 
> Shouldn't I expect that?
>
> Thank you for your time.
>
> Regards,
>
> Mohammad
>
>
>
>  
>
>
>
>

-- 
>>>>>>>>>>      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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to