This is a prerelease version.

View latest

Configure 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.

Configure the Map Resource

You can use any of the following configuration options in the Map resource. For more information, see the API reference.

Field Description

name

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

hazelcastResourceName

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 maximum size.

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

  • maxSize: Maximum 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

Whether to persist map data.

Persistence should be enabled for Hazelcast before enabling it for the map. You can learn about enabling persistence for Hazelcast in backup-restore.adoc#enabling-persistence.

mapStore

Configuration options for loading or storing map entries using a persistent data store such as a relational database. You can learn more at Working with external data.

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

  • initialMode: The initial entry loading mode.

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

  • writeBatchSize: Enables using batches when writing to MapStore.

  • writeCoealescing: When set to true, only the latest store operation on a key during the write-delay-seconds will be reflected to MapStore when using write behind.

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

entryListeners

Configuration options for listening for 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: The format data will be stored in your near cache.

  • invalidateOnChange: 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: Whether local entries are cached.

  • eviction: The eviction behavior to use in near cache.

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

    • maxSizePolicy: Type of the policy for deciding if the maximum size is reached.

    • size: 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 check its status:

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