@Override
public void registerInterest(String regionName, Object keyOfInterest, InterestResultPolicy policy,
boolean isDurable, boolean receiveValues) {
if (keyOfInterest instanceof String && keyOfInterest.equals("ALL_KEYS")) {
registerInterestRegex(regionName, ".*", isDurable, receiveValues);
} else if (keyOfInterest instanceof List) {
if (this.isPrimary) {
notifySecondariesAndClient(regionName, keyOfInterest, policy, isDurable, receiveValues,
InterestType.KEY);
} else {
throw new IllegalStateException(
"This process is not the primary server for the given client");
}
} else {
if (this.isPrimary) {
notifySecondariesAndClient(regionName, keyOfInterest, policy, isDurable, receiveValues,
InterestType.KEY);
if (policy == InterestResultPolicy.KEYS_VALUES) {
enqueueInitialValue(null, regionName, keyOfInterest);
}
} else {
throw new IllegalStateException(
"This process is not the primary server for the given client");
}
}
}