[ 
https://issues.apache.org/jira/browse/IGNITE-20692?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Aleksandr Polovtcev updated IGNITE-20692:
-----------------------------------------
    Description: 
I propose to introduce a mechanism for producing and consuming events related 
to the lifecycle of Partitions (a.k.a. Replicas). This mechanism can useful for 
other components, such as Index Manager to track which indices should be 
created or dropped because the corresponding partition has been moved.

I imagine this mechanism as follows:

# Make {{ReplicaManager}} extend {{AbstractEventProducer}};
# Create an enum for Replica-related events:

{code:java}
public enum LocalReplicaEvent implements Event {
    /**
     * Fired after a replica has been started on the local node.
     */
    AFTER_REPLICA_CREATED,

    /**
     * Fired before a replica has been stopped on the local node.
     */
    BEFORE_REPLICA_STOPPED;
}
{code}

# Create a class for these events' parameters. I believe we only need the 
{{ReplicationGroupId}} at this point.

{code:java}
public class LocalReplicaEventParameters extends EventParameters {
    /** ID of the created replica. */
    private final ReplicationGroupId groupId;
}
{code}

These events should be fired by the Replica Manager (I believe the correct 
places would be {{ReplicaManager#startReplica}} and 
{{ReplicaManager#stopReplica}}). 

Also note that notification methods return CompletableFutures. These futures 
should block the corresponding operation (adding the new Replica to the 
ReplicaManager#replicas map or stopping a Replica). This will allow to obtain a 
happens-before relationship between the events and their listeners.


  was:
I propose to introduce a mechanism for producing and consuming events related 
to the lifecycle of Partitions (a.k.a. Replicas). This mechanism can useful for 
other components, such as Index Manager to track which indices should be 
created or dropped because the corresponding partition has been moved.

I imagine this mechanism as follows:

# Make {{ReplicaManager}} extend {{AbstractEventProducer}};
# Create an enum for Replica-related events:

{code:java}
public enum LocalReplicaEvent implements Event {
    /**
     * Fired after a replica has been started on the local node.
     */
    AFTER_REPLICA_CREATED,

    /**
     * Fired before a replica has been stopped on the local node.
     */
    BEFORE_REPLICA_STOPPED;
}
{code}

# Create a class for these events' parameters. I believe we only need the 
{{TablePartitionId}} at this point.

{code:java}
public class LocalReplicaEventParameters extends EventParameters {
    /** ID of the created replica. */
    private final ReplicationGroupId groupId;
}
{code}

These events should be fired by the Replica Manager (I believe the correct 
places would be {{ReplicaManager#startReplica}} and 
{{ReplicaManager#stopReplica}}). 

Also note that notification methods return CompletableFutures. These futures 
should block the corresponding operation (adding the new Replica to the 
ReplicaManager#replicas map or stopping a Replica). This will allow to obtain a 
happens-before relationship between the events and their listeners.



> Introduce Partition lifecycle events
> ------------------------------------
>
>                 Key: IGNITE-20692
>                 URL: https://issues.apache.org/jira/browse/IGNITE-20692
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Aleksandr Polovtcev
>            Priority: Major
>              Labels: ignite-3
>
> I propose to introduce a mechanism for producing and consuming events related 
> to the lifecycle of Partitions (a.k.a. Replicas). This mechanism can useful 
> for other components, such as Index Manager to track which indices should be 
> created or dropped because the corresponding partition has been moved.
> I imagine this mechanism as follows:
> # Make {{ReplicaManager}} extend {{AbstractEventProducer}};
> # Create an enum for Replica-related events:
> {code:java}
> public enum LocalReplicaEvent implements Event {
>     /**
>      * Fired after a replica has been started on the local node.
>      */
>     AFTER_REPLICA_CREATED,
>     /**
>      * Fired before a replica has been stopped on the local node.
>      */
>     BEFORE_REPLICA_STOPPED;
> }
> {code}
> # Create a class for these events' parameters. I believe we only need the 
> {{ReplicationGroupId}} at this point.
> {code:java}
> public class LocalReplicaEventParameters extends EventParameters {
>     /** ID of the created replica. */
>     private final ReplicationGroupId groupId;
> }
> {code}
> These events should be fired by the Replica Manager (I believe the correct 
> places would be {{ReplicaManager#startReplica}} and 
> {{ReplicaManager#stopReplica}}). 
> Also note that notification methods return CompletableFutures. These futures 
> should block the corresponding operation (adding the new Replica to the 
> ReplicaManager#replicas map or stopping a Replica). This will allow to obtain 
> a happens-before relationship between the events and their listeners.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to