Failing to set the confd mode as salve using com.tailf.ha.Ha;

We are using the confd as master/slave.

In master node, the confd.conf shows:

< confdIpcAddress>
< ip>127.0.0.1< /ip>
< port>4565< /port>
< /confdIpcAddress>

< confdIpcExtraListenIp>10.54.8.35< /confdIpcExtraListenIp>
< ha>
< ip>10.54.8.35< /ip>
< enabled>true< /enabled>
< /ha>

On Slave, the confd.conf shows:

< confdIpcAddress>
< ip>127.0.0.1< /ip>
< port>4565< /port>
< /confdIpcAddress>

< confdIpcExtraListenIp>10.54.8.37< /confdIpcExtraListenIp>
< ha>
< ip>10.54.8.37< /ip>
< enabled>true< /enabled>
< /ha>

We are using the com.tailf.ha.Ha for managing the nodes.

Master is getting set properly.

Ha confdha = new Ha(s, “mynode”);
ConfBuf buff = new ConfBuf(“master”);
confdha.beMaster(buff);

But while setting the slave like this:

Ha confdha = new Ha(s, “mynode”);
ConfBuf buff = new ConfBuf(“master”);
String peerIPAddress = “10.54.8.35:4565”;
ConfBuf buff1 = new ConfBuf(“slave”);

ConfBuf buff2 = new ConfBuf(peerIPAddress);
ConfHaNode node = new ConfHaNode(buff, buff2);
confdha.beSlave(buff1, node, true);

We are getting the following exception:

com.tailf.ha.HaException: wrong response for HA:BESLAVE responded with: {error,25}
at com.tailf.ha.Ha.checkResponse(Ha.java:258)
at com.tailf.ha.Ha.beSlave(Ha.java:130)

And the confd.log is showing:

30-May-2016::00:39:15.959 WRTC-10 confd[13019]: - Failed to connect to master: invalid IP address

Also tried using String peerIPAddress = “10.54.8.35”; still same problem.

We are using confd 4.2.

Can you please throw some light on this? Why does it say invalid IP address?

The second argument to ConfDHaNode should be of type ConfIPv4 and if I’m not misstaken yours is ConfBuf.

See this example from the confd.tailf.ha docs:

  Socket s0 = new Socket("localhost", 4565);
  Socket s1 = new Socket("localhost", 4575);
  Socket s2 = new Socket("localhost", 4585);

  Ha ha0 = new Ha(s0, "clus0");
  Ha ha1 = new Ha(s1, "clus0");
  Ha ha2 = new Ha(s2, "clus0");

  ConfHaNode master =
      new ConfHaNode(new ConfBuf("node0"),
                     new ConfIPv4(InetAddress.getByName("localhost")));


  ha0.beMaster(master.nodeid);
  Thread.sleep(500);

  ha1.beSlave(new ConfBuf("node1"), master, true);
  Thread.sleep(500);

  ha2.beSlave(new ConfBuf("node2"), master, true);
  Thread.sleep(500);

  HaStatus status0 = ha0.status();
  HaStatus status1 = ha1.status();
  HaStatus status2 = ha2.status();