orientjs icon indicating copy to clipboard operation
orientjs copied to clipboard

Make the 'host' & 'port' option unneeded for connection with distributed servers

Open 33Fraise33 opened this issue 7 years ago • 1 comments

Currently a configuration as follows is needed when connection to a distributed set of servers:

var server = OrientDB({
   host:     '10.0.1.5',
   port:     2424,
   username: 'root',
   password: 'root_passwd',
   servers:  [{host: '10.0.1.5', port: 2424}, {host: '10.0.1.6', port: 2424}]
});

Now we can check the returned servers available in the distributed config as follows:

server.list().then((a) => {
    console.log(a[0].server.transport.servers);
  });

The issue is that when you add the first server to the host field you get a duplicate value in your servers array. result:

[ { host: '10.0.1.5', port: 2424, active: true },
  { host: '10.0.1.5', port: 2424, active: true },
  { host: '10.0.1.6', port: 2424, active: true } ]

When leaving host empty it adds a localhost entry in the servers array. result:

[ { host: '10.0.1.5', port: 2424, active: true },
  { host: '10.0.1.6', port: 2424, active: true },
  { host: 'localhost', port: 2424, active: false } ]

It should be more logical to define your available servers in the servers array.

33Fraise33 avatar Apr 18 '18 13:04 33Fraise33

From reading the source, the first server (host/post) will be added to the servers pool at boot-up. The easy way to fix your issue is to not duplicate the host/port in the servers list. It would be nice to not have to do that though as the notion of host/port is quite confusing in a distributed mode. Even though the doc says only 1 server out of the whole pool must be on, it feels like the servers aren't equally treated while in fact I think they are.

nicolasembleton avatar Oct 22 '18 04:10 nicolasembleton