Project

General

Profile

Bug #8123

portal hazelcast client should load config directly from xml

Added by Dave Vieglais almost 7 years ago. Updated over 6 years ago.

Status:
Testing
Priority:
Normal
Assignee:
Category:
d1_portal_servlet
Target version:
Start date:
2017-07-06
Due date:
% Done:

50%

Milestone:
None
Product Version:
*
Story Points:
Sprint:

Description

The hazelcast client for the portal is selectively pulling config values from the configuration file after loading with FileSystemXmlConfig and adding them to a hand crafted ClientConfig instance. Instead, the client should be initiated with the config loaded directly form the XML file since FileSystemXmlConfig is a subclass of ClientConfig.

This will ensure that configuration properties of the hazelcast client can be easily set without changing the code.

In the current version, only address, user, and password are being set - all other configuration is being ignored.

https://repository.dataone.org/software/cicore/trunk/d1_portal_servlet/src/main/java/org/dataone/portal/session/SessionHelper.java

History

#1 Updated by Rob Nahf almost 7 years ago

in Hz 2.4.1 (http://docs.hazelcast.org/docs/2.4.1/javadoc/), FileSystemXmlConfig is not a subclass of ClientConfig, but Config. Using (the underdocumented) ClientConfigBuilder, however, may be the way to instantiate a ClientConfig object from an xml file.

In v3.0, ClientConfigBuilder goes away and XMLClientConfigBuilder appears, and there's a manual: (http://docs.hazelcast.org/docs/latest/manual/html-single/)

If you want to specify your own configuration file to create a Config object, the Hazelcast client supports the following.

Config cfg = new XmlClientConfigBuilder(xmlFileName).build();

Config cfg = new XmlClientConfigBuilder(inputStream).build();

#2 Updated by Rob Nahf almost 7 years ago

the ClientConfigBuilder is not made for XML, but for reading .properties files. The newer hazelcast-client definition (https://hazelcast.com/schema/client-config/) doesn't come into existence until v3.0, which would require a bigger refactor. (http://docs.hazelcast.org/docs/3.0/manual/html/ch01s02.html)

#3 Updated by Rob Nahf almost 7 years ago

  • Status changed from New to In Progress
  • Assignee changed from Jing Tao to Rob Nahf
  • % Done changed from 0 to 30

#4 Updated by Rob Nahf almost 7 years ago

From dave, the issue was discovered while trying to deal with failed client reconnects. So the issue is making sure Hz 2.x has enough power to deal with these issues. Documentation about the client config properties is limited, but I found the 2.4 source code: https://github.com/hazelcast/hazelcast/blob/maintenance-2.x/hazelcast-client/src/main/java/com/hazelcast/client/ClientConfigBuilder.java

public class ClientConfigBuilder {

private static final ILogger logger = Logger.getLogger(ClientConfigBuilder.class.getName());

public final static String GROUP_NAME = "hazelcast.client.group.name";
public final static String GROUP_PASS = "hazelcast.client.group.pass";
public final static String CONNECTION_TIMEOUT = "hazelcast.client.connection.timeout";
public final static String CONNECTION_ATTEMPT_LIMIT = "hazelcast.client.connection.attempts.limit";
public final static String RECONNECTION_TIMEOUT = "hazelcast.client.reconnection.timeout";
public final static String RECONNECTION_ATTEMPT_LIMIT = "hazelcast.client.reconnection.attempts.limit";
public final static String SHUFFLE_ADDRESSES = "hazelcast.client.shuffle.addresses";
public final static String UPDATE_AUTOMATIC = "hazelcast.client.update.automatic";
public final static String ADDRESSES = "hazelcast.client.addresses";

So this is what we have to work with - looks like enough.

The hazelcast-client.xml file is in cn-buildout/dataone-cn-portal, so we will need to change this file formal from XML to simple .properties file, and make it available for d1_portal_servlet.

Below are the defaults:

public class ClientConfig {

private GroupConfig groupConfig = new GroupConfig();
private final List<InetSocketAddress> addressList = new ArrayList<InetSocketAddress>(10);
private Credentials credentials;
private int connectionTimeout = 30000;
private int initialConnectionAttemptLimit = 1;
private int reconnectionAttemptLimit = 1;
private int reConnectionTimeOut = 5000;
private boolean shuffle = false;
private boolean updateAutomatic = true;
private SocketInterceptor socketInterceptor = null;

#5 Updated by Rob Nahf almost 7 years ago

  • Status changed from In Progress to Testing
  • % Done changed from 30 to 50

in 2.3 branch (portal-servlet and dataonc-cn-portal), changed the hazelcast-client.xml to hazelcast-client.properties, and set reconnection parameters of 10sec / 10x similar to https://github.com/hazelcast/hazelcast/issues/298.

These reconnection values should be played with in sandbox...

#6 Updated by Jing Tao over 6 years ago

  • Target version changed from CCI-2.3.6 to CCI-2.3.7

#7 Updated by Dave Vieglais over 6 years ago

  • Sprint set to CCI-2.3.7

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 14.8 MB)