这是indexloc提供的服务,不要输入任何密码
Skip to content

Implementation of Partition Group Definition for ZookeeperDiscoveryStrategy #92

@chnsagitchen

Description

@chnsagitchen

Please describe the problem you are trying to solve

When leveraging ZookeeperDiscoveryStrategy for Hazelcast node auto discovery, it is in short of the implementation to define the partition group with this SPI. When reading the codes, I believe there are two ways to achieve this:

  1. Implement the getPartitionGroupStrategy in AbstractDiscoveryStrategy which ZookeeperDiscoveryStrategy extends. This is the way suggested in Hazelcast document: https://docs.hazelcast.com/imdg/4.1.2/clusters/partition-group-configuration.html for SPI. But one of the challenge here is that there is no allMembers information passed to the getPartitionGroupStrategy callback method: https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/internal/partition/membergroup/SPIAwareMemberGroupFactory.java#L66. We could pass allMembers information as the arguments of getPartitionGroupStrategy, for the existing clients who have implement getPartitionGroupStrategy, they could ignore this information. And for the specific node, we need to label the node with overwriting https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/spi/discovery/AbstractDiscoveryStrategy.java#L60 for ZookeeperDiscoveryStrategy to pass the label to https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/cluster/impl/MemberImpl.java#L125 and used as the indicator in getPartitionGroupStrategy

  2. instead of use SPI member group factory mechanism, we could use PLACEMENT_AWARE: https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/internal/partition/membergroup/MemberGroupFactoryFactory.java#L48. This also requires us to provide PartitionGroupMetaData.PARTITION_GROUP_PLACEMENT attribute during discovery, which could be done as described in (1)

Please describe the desired behavior

I expect client could define the partition group based on user level attribute, e.g. data center, region, e.t.c

Describe alternatives you've considered
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions