We're updating the issue view to help you get more done. 

Java client cannot work with capabilities



I'm having trouble using capabilities with the java compat libraries.
An isolated test case below gives the following stack trace:

1 2 3 4 5 java.lang.ArithmeticException: / by zero at com.linkedin.norbert.network.client.loadbalancer.LoadBalancerHelpers$class.chooseNext(LoadBalancerFactory.scala:76) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory.chooseNext(RoundRobinLoadBalancerFactory.scala:26) at com.linkedin.norbert.network.client.loadbalancer.RoundRobinLoadBalancerFactory$$anon$1.nextNode(RoundRobinLoadBalancerFactory.scala:36) at com.linkedin.norbert.javacompat.network.RoundRobinLoadBalancerFactory$1.nextNode(RoundRobinLoadBalancerFactory.java:44)

The same exception can be triggered by sendRequest(..capability..) via underlying(). This is somewhat hacky, but sendRequest(..capability..) is not available in the java interface (maybe intentional?)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ClusterClient cc = new InMemoryClusterClient(null, "unittest"); cc.awaitConnectionUninterruptibly(); cc.addNode(1, "localhost:12340"); NetworkServerConfig srvCfg = new NetworkServerConfig(); srvCfg.setClusterClient(cc); NettyNetworkServer ns = new NettyNetworkServer(srvCfg); ns.bind(1, true, 1L); // capability 1 NetworkClientConfig cliCfg = new NetworkClientConfig(); cliCfg.setClusterClient(cc); NettyNetworkClient nc = new NettyNetworkClient(cliCfg, new RoundRobinLoadBalancerFactory()); System.out.println("cc.getNodes() : "+cc.getNodes()); Either eitherLb =(Either) nc.underlying().com$linkedin$norbert$network$client$NetworkClient$$loadBalancer().get(); Object r = eitherLb.right().get(); LoadBalancer lb = (LoadBalancer)r; System.out.println("lb.nextNode : "+lb.nextNode()); System.out.println("lb.nextNode(0) : "+lb.nextNode(Option.apply(0L))); System.out.println("lb.nextNode(1) : "+lb.nextNode(Option.apply(1L)));

The output is:

1 2 3 cc.getNodes() : [JavaNode(1,localhost:12340,true,[],Some(1))] lb.nextNode : Some(Node(1,localhost:12340,[],true,0x00000000)) lb.nextNode(0) : Some(Node(1,localhost:12340,[],true,0x00000000))

The last code line fails with the exception above.
Note that the cc.getNodes() (which gives the java-version of the node) indicates the right capabilities, but the Scala node from nextNode version doesn't seem to have the capabilities?

This is on current HEAD (69c3a7ccbaf22d751f6282e7b6eb9dab19b04954), but the problem occurs on 0.6.29-SNAPSHOT as well.

A patch for RoundRobinLoadBalancerFactory.scala is attached, but this only fixes the divide-by-zero bug.. I still don't get any nodes, and my scala/norbert internals experience is not that high-level, so any pointers/patches/suggestions are welcome!






Joshua Hartman


Johan Ström