GridGain Developers Hub

Distribution Zones

This section describes GridGain 9 distribution zones. In GridGain 9, you can fine-tune distribution of your partitions on nodes for better performance and stability.

CREATE ZONE

Creates a new distribution zone.

Diagram( Terminal('CREATE ZONE'), Optional(Terminal('IF NOT EXISTS')), NonTerminal('qualified_zone_name'), End({type:'complex'}) )

Diagram( Start({type:'complex'}), Optional(Sequence( Terminal('WITH'), OneOrMore( NonTerminal('parameter', {href:'./grammar-reference/#parameter'}), ','))))

Keywords and parameters:

  • IF NOT EXISTS - create a zone only if a different zone with the same name does not exist.

  • qualified_zone_name - a name of the distribution zone. Can be specified as a case-sensitive string or case-insensitive identifier. Does no need to exists at the moment of table creation, and can be created before writing data.

  • WITH - accepts the following additional parameters:

    • STORAGE_PROFILES - Required. Comma-separated list of the profiles of the storage engines to use.

    • PARTITIONS - the number of partition the data is divided into. Partitions are then split between nodes for storage.

    • REPLICAS - the number of copies of each partition.

    • DATA_NODES_FILTER - specifies the nodes that can be used to store data in the distribution zone based on node attributes. You can configure node attributes by using cli. Filter uses JSONPath rules. If the attribute is not found, all negative comparisons will be valid. For example, $[?(@.storage != 'SSD']} will also include nodes without the storage attribute specified.

    • DATA_NODES_AUTO_ADJUST_SCALE_UP - the delay in seconds between the new node joining and the start of data zone adjustment.

    • DATA_NODES_AUTO_ADJUST_SCALE_DOWN - the delay in seconds between the node leaving the cluster and the start of data zone adjustment.

    • DATA_STORAGE_ENGINE - the name of the data storage engine.

    • CONSISTENCY_MODE - how the zone handles partition majority losses. If set to STRONG_CONSISTENCY, the data will become unavailable until majority is restored (typically, this means nodes leaving and returning to the cluster). HIGH_AVAILABILITY means that the data will be written and read from remaining nodes, accepting possible data loss. Default value: STRONG_CONSISTENCY.

Examples:

Creates an exampleZone distribution zone that is specified as a case-insensitive identifier:

CREATE ZONE IF NOT EXISTS exampleZone WITH STORAGE_PROFILES='default'

Creates a "myExampleZone" distribution zone that is specified as a case-sensitive string:

CREATE ZONE IF NOT EXISTS "myExampleZone" WITH STORAGE_PROFILES='default'

Creates an exampleZone distribution zone that will only use nodes with SSD attribute and adjust 300 seconds after cluster topology changes:

CREATE ZONE IF NOT EXISTS exampleZone WITH DATA_NODES_AUTO_ADJUST_SCALE_UP=300, STORAGE_PROFILES='default'

Creates an exampleZone distribution zone where data will only be stored on nodes that have SSD attribute:

CREATE ZONE IF NOT EXISTS exampleZone WITH STORAGE_PROFILES='default',DATA_NODES_FILTER='$[?(@.storage == "SSD")]'

ALTER ZONE

Modifies a distribution zone.

ALTER ZONE RENAME TO new_qualified_zone_name

Diagram( Terminal('ALTER ZONE'), Optional(Terminal('IF EXISTS')), NonTerminal('qualified_zone_name'), Terminal('RENAME TO'), NonTerminal('new_qualified_zone_name'), )

Keywords and parameters:

  • IF EXISTS - do not throw an error if a zone with the specified name does not exist.

  • qualified_zone_name - the current name of the distribution zone.

  • RENAME TO - renames the selected zone to the new name.

  • new_qualified_zone_name - the new name of the distribution zone (assigned by RENAME).

Examples:

Renames the exampleZone to renamedZone:

ALTER ZONE IF EXISTS exampleZone RENAME TO renamedZone;

ALTER ZONE SET

Diagram( Terminal('ALTER ZONE'), Optional(Terminal('IF EXISTS')), NonTerminal('qualified_zone_name'), Sequence(Terminal('SET'), Optional('('), OneOrMore( NonTerminal('parameter', {href:'./grammar-reference/#parameter'}), ','), Optional(')')))

Keywords and parameters:

  • IF EXISTS - do not throw an error if a zone with the specified name does not exist.

  • qualified_zone_name - a name of the distribution zone.

  • SET - assigns values to any or all of the following parameters:

    • STORAGE_PROFILES - comma-separated list of the profiles of the storage engines to use.

    • PARTITIONS - the number of partitions

    • REPLICAS - the number of copies of each partition.

    • DATA_NODES_FILTER - specifies the nodes that can be used to store data in the distribution zone based on node attributes.

    • DATA_NODES_AUTO_ADJUST_SCALE_UP - the delay in seconds between the new node joining and the start of data zone adjustment.

    • DATA_NODES_AUTO_ADJUST_SCALE_DOWN - the delay in seconds between the node leaving the cluster and the start of data zone adjustment.

Examples:

Sets the number of data replicas to 10:

ALTER ZONE exampleZone SET REPLICAS=10;

Sets data nodes filter to match all nodes:

ALTER ZONE exampleZone SET DATA_NODES_FILTER='$..*'

DROP ZONE

Drops an existing distribution zone.

Diagram( Terminal('DROP ZONE'), Terminal('IF EXISTS'), NonTerminal('qualified_zone_name') )

Keywords and parameters:

  • IF EXISTS - do not throw an error if a zone with the specified name does not exist.

  • qualified_zone_name - the name of the distribution zone.

Examples:

Drop Person table if the one exists:

DROP ZONE IF EXISTS exampleZone