Configure Client

Clients use the dynamic configuration API to update User Code Namespaces on the cluster.

You must create a Client.java file containing the configuration and save it to your configuration folder.

Ensure that you have configured your data structure with the same User Code Namespaces referenced in your client configuration.

The file will be similar to the following:

package com.hazelcast.namespaces.dyamicconfig;

import com.hazelcast.client.HazelcastClient;
import com.hazelcast.config.UserCodeNamespaceConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.EntryProcessor;

public class Client {

    public static void main(String[] args) {
        HazelcastInstance client = HazelcastClient.newHazelcastClient();

        EntryProcessor entryProcessor = new IncrementingEntryProcessor();
        UserCodeNamespaceConfig namespaceConfig = new UserCodeNamespaceConfig("namespace_name"); (1)
        namespaceConfig.addClass(IncrementingEntryProcessor.class); (2)

        // dynamically add the namespace config
        client.getConfig().getNamespacesConfig().addNamespaceConfig(namespaceConfig); (3)
        // execute the entry processor
        client.getMap("map_name").executeOnKey("key", entryProcessor); (4)
    }
}
1 Creates a UserCodeNamespaceConfig with a name of namespace_name
2 Adds the defined class from the classpath to the UserCodeNamespaceConfig
3 Gets the Hazelcast configuration from the client instance and adds the UserCodeNamespaceConfig to the Config
4 Executes IncrementingEntryProcessor from the classpath on the key in the Map