Managing Network Communications in Java

As explained in the Network Communications page, eXtremeDB release 7.1.1795 and later allow the IPv6 address protocol for specifying node addresses. The following section describes issues that can be important for developers porting applications that used network communications in prior versions of eXtremeDB. The SSL section describes how to enable SSL security for network communications.

IPv4 vs. IPv6 issues

For developers porting applications built with versions of eXtremeDB prior to release 7.1.1795 the following API changes should be noted:

 

SSL support

To enable SSL support, the application must fill in the SSLParameters. For eXtremeDB High Availability the SSLParameters are set in the MasterConnection.Parameters and ReplicaConnection.Parameters classes. For eXtremeDB Cluster applications the SSLParameters are set in the ClusterTCPParams class. (Please refer to the SSL Parameters page for details on setting the values of these parameters.)

Once the SSLParameters are initialized call the static Database methods sslInit() and sslLoadVerifyLocations(). This must be done after a Database object is created but before the SSL connection is established.

For example, a Java eXtremeDB High Availability master application would look like the following:

     
    Database db = new Database(config);
    db.open("windowmst-db", parameters, DATABASE_SIZE);
     
    MasterConnection con = new MasterConnection(db);
    MasterConnection.Parameters ha_params = new MasterConnection.Parameters();
    ha_params.SSLParameters = new Database.SSLParameters();
    ha_params.SSLParameters.CertificateFile = "../../thlib/certs/client.crt";
     
    ha_params.SSLParameters.PrivateKeyFile = "../../thlib/certs/client.key";
     
    // X509_FILETYPE_PEM
    db.sslInit();
    db.sslLoadVerifyLocations(ca_file, ca_path);
    con.setReplicationMode(ha_params);
     
    // Start listener thread
    Thread listenThread = new Thread(new ThreadStart(Listen));
    listenThread.start();
     

And the replica would look like the following:

     
    Database db = new Database(config);
    db.open("windowrpl-db", parameters, DATABASE_SIZE);
     
    ReplicaConnection con = new ReplicaConnection(db);
     
    ReplicaConnection.Parameters replParams = new ReplicaConnection.Parameters();
    replParams.NotifyDelegate = new ReplicaConnection.ReplicaNotifyDelegate(notifier);
    replParams.SSLParameters = new Database.SSLParameters();
    replParams.SSLParameters.CertificateFile = "../../thlib/certs/client.crt";
    replParams.SSLParameters.PrivateKeyFile = "../../thlib/certs/client.key";
     
    // X509_FILETYPE_PEM
    db.sslInit();
    db.sslLoadVerifyLocations(ca_file, ca_path);
     
    // Attach to master. Analog of mco_nw_attach_master
    con.attachMaster(connectString, replParams, CONNECT_TIMEOUT);