Skip to main content
Version: 5.17

User Code Deployment

warning

User Code Deployment is deprecated. Use User Code Namespaces or Module Deployment instead.

Hazelcast allows you to deploy your own custom and domain classes to cluster members. From Operator, you can deploy your application code from external buckets and ConfigMap objects in Kubernetes.

This topic explains how to configure code deployments. It also brings together examples of when you might use code deployments as part of the configuration of other features, such as the implementation of an external data store or an executor service for the asynchronous execution of tasks.

Configure User Code Deployment​

Operator provides the following configuration options for the User Code Deployment feature. For more information, see the API reference.

FieldDescription
clientEnabledWhen set to true, this option enables custom code deployment from Hazelcast clients.
bucketConfig

JAR files from an external bucket are placed under the Java classpath when the following parameter values are supplied:

  • secretName: Name of the Secret object which holds the credentials for your cloud provider.
  • bucketURI: Full path for the external bucket. For example: gs://your-bucket/path/to/jars.
configMaps

Files specified are placed under the Java classpath.

warning

The data stored in a ConfigMap cannot exceed 1 MiB. For more info, see Kubernetes Documentation for Config Map.

remoteURLsFiles downloaded from these URLS will be placed under the Java classpath.
triggerSequenceTriggers a rolling restart to begin another download of the custom code.

Example configuration​

The example configuration below:

  • Downloads the JAR files from the specified external bucket and places them under the classpath of each of the Hazelcast members.
  • Puts all the files specified in the ConfigMap objects under the classpath of each of the Hazelcast members.
warning

Mounted persistent volumes are not supported; only cloud provider external buckets are supported.

User Code Deployment in AWS S3:

yaml
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
name: hazelcast
spec:
userCodeDeployment:
clientEnabled: true
bucketConfig:
secretName: map-store-bucket-secret (1)
bucketURI: s3://map-store-bucket/path/to/jars (2)
configMaps:
- domain-classes-cm
- entryprocessor-cm
remoteURLs:
- https://example.com/entry-processor.jar
triggerSequence: "001"
1 Name of the secret with credentials for accessing the bucket URI.
2 URI of the bucket where backup data will be stored.

Configure an external data store​

The MapLoader and MapStore interfaces in Hazelcast allow you to load map entries from and save map entries to an external data store. See Working with an external data store for implementation details.

To use an external data store, you need to create MapLoader and/or MapStore classes and add configuration. In Operator:

  1. Deploy the MapLoader and/or MapStore classes to the classpath of each Hazelcast member.
  2. Configure a Map resource for the MapLoader or MapStore.

Use the following configuration options in the Map resource for a MapStore. The example shows how you might implement these options. For more detailed information, see the API reference.

FieldDescription
initialModeSets the initial entry loading mode. LAZY is the default load mode, where load is asynchronous. EAGER means map operations are blocked until all partitions are loaded.
classNameName of your class that implements the MapLoader and/or MapStore interface.
writeDelaySecondsNumber of seconds to delay the storing of map entries.
writeBatchSizeUsed to create batches when writing to the map store. In default mode, with a value of less than two, Hazelcast tries to write all map entries in one go.
writeCoealescingFor use with write-behind mode in a MapStore. When this option is set to true, Hazelcast coalesces updates on a specific key, and so applies only the last update. Set this option to false to store all updates performed on a key to the data store.
propertiesSecretNameYou can use properties to give information to the MapStore implementation. In this case, properties are taken from the secret with the given name.

Example MapStore configuration​

An example Map resource with MapStore configuration.

Example configuration
yaml
apiVersion: hazelcast.com/v1alpha1
kind: Map
metadata:
name: map-sample
spec:
hazelcastResourceName: hazelcast-sample
mapStore:
className: com.example.SimpleStore
propertiesSecretName: props
initialMode: LAZY
writeDelaySeconds: 1
writeBatchSize: 20
writeCoalescing: false

Configure executor services​

Hazelcast offers an executor service (IExecutorService), which is an implementation of java.util.concurrent.ExecutorService. With IExecutorService, you can execute tasks asynchronously and perform other useful tasks.

To use the executor service, you need to create Callable and/or Runnable classes and add configuration. In Operator:

  1. Deploy your Callable or Runnable classes to the classpath of each Hazelcast member.
  2. Configure a Hazelcast resource for the Callable or Runnable interface.

There are three variants of the executor service:

  • Executor Service
  • Durable Executor Service
  • Scheduled Executor Service

Configuration options for a Hazelcast resource to work with all three variants are shown in this section, along with examples of how you might implement these options. For more detailed information, see Java executor service.

See the API reference for more information.

FieldDescription
nameThe name of the executor service.
poolSizeThe number of executor threads per member.
queueCapacityTask queue capacity of the executor.

Example executor services​

An example Hazelcast resource with executor services configured:

yaml
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
name: hazelcast
spec:
executorServices:
- name: service1
capacity: 8
queueCapacity: 0

Configure an entry processor with operator​

An entry processor executes your code on a map entry in an atomic way. To implement the EntryProcessor interface, you can deploy an EntryProcessor class from Operator to the classpath of a Hazelcast member. See Entry processor for more information.