Skip to content

tommys-place/orientdb_unixsocket_driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OrientDB UNIX Socket

This is an add-on for OrientDB database to enable UNIX socket connection.

####Reasons for unix socket usage :

  • Unix socket is much faster than TCP/IP and less memory demanding.
  • Unix socket is better choice when communicating with processes inside the same box
  • Support for Nginx unix socket proxying
  • Ideal for OrientDB in-memmory database (session storage)
  • Docker inter container communication through unix sockets instead of linked containers (linked containers will change IP address after restart)

####Features :

  • Zero-copy read/write operations
  • Pure Java implementation
  • TODO - Unix Domain Socket EPOLL - Async I/O

Installation

Configure OrientDB

  1. Copy jar file from ./build/orientdb/lib to installed OrientDB /lib folder
  2. In /build/orientdb/config one can find setup example, search for UNIX SOCKET SUPPORT comment under sockets & listeners for an example.

Only parameter to setup inside xml configuration is network.socket.unix which should contain path to socket file. Default is /tmp/orientdb.sock


Configure OrientJS

  1. Create empty folder

  2. Copy to that folder ./build/demo.js

  3. Position to and execute

    npm install orientjs

  4. Open ./node_modules/orientjs/lib/transport/binary/connection.js in text editor modify createSocket function

    from

    Connection.prototype.createSocket = function () {
    	  var socket = net.createConnection(this.port, this.host);
    	  socket.setNoDelay(true);
    	  socket.setMaxListeners(100);
    	  return socket;
    };

    to

    Connection.prototype.createSocket = function () {
        var socket = null;
        var isUnix = ['linux','darwin'].indexOf(process.platform) > -1 ;
        if (this.host.indexOf('unix:') === 0 && isUnix) {
            var uxPath = this.host.replace('unix:','');
            socket = net.createConnection(uxPath);
        } else {
            socket = net.createConnection(this.port, this.host);
        }
        socket.setNoDelay(true);
        socket.setMaxListeners(100);
        return socket;
    };
  5. Whenever OrientDB driver is used inside Node.JS to connect to the unix socket, unix: prefix should be used.

    var OrientDB = require('orientjs');
    var server = OrientDB({
        host: 'unix:/tmp/orientdb.sock',
        username: 'root',
        password: 'root'
    });
  6. Start app with command below to check if it is working

node demo


Note:

  • File unixsocket.orientdb.jar in ./build folder is built with Java 8. If one have an older version of Java installed, Java sources should be rebuilt with that version.
  • Don't forget to include OrientDB jar's from it's lib folder before building.

|

Reference:

|

Performance analysis TCP/IP vs UNIX SOCKET:

|

Credits:

That's all folks!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published