I read the Akka Java documentation on Multi Node Testing , however all the codes are in Scala. Is there a reason for this? A Google search was also unsuccessful.
EDIT: To reduce the margin of this question, I tried :). A simple Java translation of existing Scala migth codes looks like this:
public class ClusterTest { protected RoleName first; @Test public void SimpleClusterListenerClusterJoinTest() throws Exception { new MultiNodeSpec(new MultiNodeConfig() {{ first = this.role("first"); second = this.role("second"); third = this.role("third"); this.commonConfig(ConfigFactory.parseString( "akka.crdt.convergent.leveldb.destroy-on-shutdown = on\n" + "akka.actor.provider = akka.cluster.ClusterActorRefProvider\n" + "akka.cluster.auto-join = off\n" + "akka.cluster.auto-down = on\n" + "akka.loggers = [\"akka.testkit.TestEventListener\"]\n" + "akka.loglevel = INFO\n" + "akka.remote.log-remote-lifecycle-events = off")); }}) { { Address firstAddress = node(first).address(); @SuppressWarnings("serial") ArrayList<RoleName> firstnode = new ArrayList<RoleName>() {{ add(first); }}; Seq<RoleName> fisrtnodeseq = (Seq<RoleName>)JavaConversions.asScalaBuffer(firstnode).toList(); runOn(fisrtnodeseq, null); Cluster cluster = new Cluster((ExtendedActorSystem) system()); cluster.join(firstAddress);
HOWEVER During startup with arguments: -Dmultinode.max nodes = 4 -Dmultinode.host = 127.0.0.1, etc. According to Multi Node Testing (if I list here all the arguments that the editor complains strongly: [) I will get the following error:
java.lang.IllegalArgumentException: invalid ActorSystem name [ClusterTest_2], must contain only word characters (ie [a-zA-Z0-9] plus non-leading '-') at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:497) at akka.actor.ActorSystem$.apply(ActorSystem.scala:141) at akka.actor.ActorSystem$.apply(ActorSystem.scala:118) at akka.remote.testkit.MultiNodeSpec.<init>(MultiNodeSpec.scala:252) at com.akkamint.demo.ClusterTest$2.<init>(ClusterTest.java:51)
is the internally generated name of ActorSystem?
In addition, I have two questions:
1. How to access gossip from Java, as in Scala code,
awaitCond(Cluster(system).latestGossip.members.exists(m ⇒ m.address == firstAddress && m.status == Up))
and I did not find a way to implement the same in Java. My workaround is to subscribe to the member's events (see above), otherwise I don't know if this is actually the same or not?
2. Thunk function (second argument to runOn method)? What is it? How to use it?
source share