SOLR-10496: Do not cast TriggerEvent to concrete sub-class because it might have been created from TriggerEventQueue

This commit is contained in:
Shalin Shekhar Mangar 2017-07-06 10:03:41 +05:30
parent b452b3c451
commit 23fe3e1aa0
1 changed files with 4 additions and 6 deletions

View File

@ -111,16 +111,14 @@ public class ComputePlanAction implements TriggerAction {
Policy.Suggester suggester;
switch (event.getEventType()) {
case NODEADDED:
NodeAddedTrigger.NodeAddedEvent nodeAddedEvent = (NodeAddedTrigger.NodeAddedEvent) event;
suggester = session.getSuggester(CollectionParams.CollectionAction.MOVEREPLICA)
.hint(Policy.Suggester.Hint.TARGET_NODE, nodeAddedEvent.getProperty(TriggerEvent.NODE_NAME));
log.debug("Created suggester with targetNode: {}", nodeAddedEvent.getProperty(TriggerEvent.NODE_NAME));
.hint(Policy.Suggester.Hint.TARGET_NODE, event.getProperty(TriggerEvent.NODE_NAME));
log.debug("Created suggester with targetNode: {}", event.getProperty(TriggerEvent.NODE_NAME));
break;
case NODELOST:
NodeLostTrigger.NodeLostEvent nodeLostEvent = (NodeLostTrigger.NodeLostEvent) event;
suggester = session.getSuggester(CollectionParams.CollectionAction.MOVEREPLICA)
.hint(Policy.Suggester.Hint.SRC_NODE, nodeLostEvent.getProperty(TriggerEvent.NODE_NAME));
log.debug("Created suggester with srcNode: {}", nodeLostEvent.getProperty(TriggerEvent.NODE_NAME));
.hint(Policy.Suggester.Hint.SRC_NODE, event.getProperty(TriggerEvent.NODE_NAME));
log.debug("Created suggester with srcNode: {}", event.getProperty(TriggerEvent.NODE_NAME));
break;
default:
throw new UnsupportedOperationException("No support for events other than nodeAdded and nodeLost, received: " + event.getEventType());