The message does not carry any state and can be made a singleton.
Change-Id: Iadcbe0cb8de949dbc57240772bcfd9ddf23d42ad
Signed-off-by: Robert Varga <rovarga@cisco.com>
currentBehavior.getLeaderPayloadVersion()), raftActor.self());
}
- LeaderTransitioning leaderTransitioning = new LeaderTransitioning();
for(String peerId: context.getPeerIds()) {
ActorSelection followerActor = context.getPeerActorSelection(peerId);
if(followerActor != null) {
- followerActor.tell(leaderTransitioning, context.getActor());
+ followerActor.tell(LeaderTransitioning.INSTANCE, context.getActor());
}
}
*
* @author Thomas Pantelis
*/
-public class LeaderTransitioning implements Serializable {
+public final class LeaderTransitioning implements Serializable {
private static final long serialVersionUID = 1L;
+ public static final LeaderTransitioning INSTANCE = new LeaderTransitioning();
+
+ private LeaderTransitioning() {
+ // Hidden on purpose
+ }
+
+ @SuppressWarnings({ "static-method", "unused" })
+ private LeaderTransitioning readResolve() {
+ return INSTANCE;
+ }
}
MessageCollectorActor.clearMessages(notifierActor);
- raftActorRef.tell(new LeaderTransitioning(), ActorRef.noSender());
+ raftActorRef.tell(LeaderTransitioning.INSTANCE, ActorRef.noSender());
leaderStateChange = MessageCollectorActor.expectFirstMatching(notifierActor, LeaderStateChanged.class);
assertEquals("getMemberId", persistenceId, leaderStateChange.getMemberId());