A newer version of Hazelcast Operator is available.

View latest

Configuring Maps

Hazelcast maps are used to distribute data across a cluster and make it easy to scale your applications while protecting data against member failures. You can create and configure maps using the Map resource.

Configuring the Map Resource

Below are the configuration options for the Map resource. You can find more detailed information in API Reference page.

Field Description

name

Name of the map config to be created. If empty, the CR name will be used. It cannot be updated after the map config is created successfully.

hazelcastResourceName

HazelcastResourceName defines the name of the Hazelcast resource.

backupCount

Count of synchronous backups.

timeToLiveSeconds

Maximum time in seconds for each entry to stay in the map.

maxIdleSeconds

Maximum time in seconds for each entry to stay idle in the map.

eviction

Configuration for removing data from the map when it reaches its max size.

  • evictionPolicy: Eviction policy to be applied when map reaches its max size according to the max size policy.

  • maxSize: Max size of the map.

  • maxSizePolicy: Policy for deciding if the maxSize is reached.

indexes

Indexes to be created for the map data.

attributes

Custom attributes for field queries when using the Predicates API

persistenceEnabled

When enabled, map data will be persisted.

Persistence should be enabled for Hazelcast before enabling it for the map. You can learn about enabling persistence for Hazelcast in Persistence, Backup and Restore.

mapStore

Configuration options when you want to load/store the map entries from/to a persistent data store such as a relational database. You can learn more at Working With External Data.

  • className: Name of your class implementing MapLoader and/or MapStore interface.

  • initialMode: Sets the initial entry loading mode.

  • writeDelaySeconds: Policy for deciding if the maxSize is reached.

  • writeBatchSize: Used to create batches when writing to map store.

  • writeCoealescing: It is meaningful if you are using write behind in MapStore. When it is set to true, only the latest store operation on a key during the write-delay-seconds will be reflected to MapStore.

  • propertiesSecretName: Name of the secret holding the properties for the MapStore classes implementing the MapLoaderLifecycleSupport interface.

entryListeners

Configuration options for listening for the map-level or entry-based events using the listeners provided by the Hazelcast’s eventing framework. You can learn more at Distributed Object Events.

  • className: Name of your class implementing a MapListener sub-interface.

  • includeValues: An optional attribute that indicates whether the map event should contains the map value.

  • local: An optional attribute that indicates whether you can listen to the map on the local member.

nearCache

Configuration options for server side Near Cache. You can learn more at Near Cache.

  • name: name of the near cache.

  • inMemoryFormat: specifies in which format data will be stored in your near cache.

  • invalidateOnChange: specifies whether the cached entries are evicted when the entries are updated or removed.

  • timeToLiveSeconds: maximum number of seconds for each entry to stay in the Near Cache.

  • maxIdleSeconds: maximum number of seconds each entry can stay in the Near Cache as untouched (not read).

  • cacheLocalEntries: specifies whether the local entries are cached.

  • eviction: specifies the eviction behavior in Near Cache.

    • evictionPolicy: is the policy to be applied when near cache reaches its max size according to the max size policy.

    • maxSizePolicy: type of the policy for deciding if the maxSize is reached.

    • size: is the maximum size of the Near Cache used for maxSizePolicy.

Example Configuration

The following Map resource creates a map configuration for the Hazelcast custom resource that is defined in the hazelcastResourceName field.

Example configuration
apiVersion: hazelcast.com/v1alpha1
kind: Map
metadata:
  name: map-sample
spec:
  hazelcastResourceName: hazelcast-sample
  backupCount: 1
  timeToLiveSeconds: 0
  maxIdleSeconds: 0
  eviction:
    evictionPolicy: NONE
    maxSize: 0
    maxSizePolicy: PER_NODE
  indexes:
    - type: HASH
      name: index1
      attributes:
        - "name"
        - "age"
    - type: BITMAP
      attributes:
        - "name"
      bitMapIndexOptions:
        uniqueKey: id
        uniqueKeyTransition: RAW
  attributes:
    - name: attribute1
      extractorClassName: class1
  persistenceEnabled: true
  entryListeners:
    - className: com.example.MyListener
      includeValues: true
      local: false
  nearCache:
    name: mostly-read-map
    inMemoryFormat: OBJECT
    invalidateOnChange: true
    timeToLiveSeconds: 300
    maxIdleSeconds: 300
    eviction:
      evictionPolicy: NONE
      maxSizePolicy: ENTRY_COUNT
      size: 5000
    cacheLocalEntries: true

After creating the Map resource, you can learn about its status with the following command

kubectl get map map-sample -o wide
NAME         STATUS    HAZELCAST-RESOURCE   MESSAGE
map-sample   Success   hazelcast-sample