How do you detect whether the instance is the master instance?
The Solution
@Reference private SlingRepository repository;
public boolean isMasterRepository(){
final String isMaster =
repository.getDescriptor("crx.cluster.master");
return StringUtils.isNotBlank(isMaster) && Boolean.parseBoolean(isMaster);
}
With this code, we can detect whether the current instance is running as the master.
In the execution function, the first conditional should be to detect whether it is running as the master instance or not, and if it is not, it should terminate the function call.
With this code, we can detect whether the current instance is running as the master.
In the execution function, the first conditional should be to detect whether it is running as the master instance or not, and if it is not, it should terminate the function call.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.