}
@Override
- public void onReceive(Object message) throws Exception {
+ public final void onReceive(Object message) throws Exception {
handleReceive(message);
}
+ /**
+ * Receive and handle an incoming message. If the implementation does not handle this particular message,
+ * it should call {@link #ignoreMessage(Object)} or {@link #unknownMessage(Object)}.
+ *
+ * @param message Incoming message
+ * @throws Exception
+ */
protected abstract void handleReceive(Object message) throws Exception;
- protected void ignoreMessage(Object message) {
- LOG.debug("Unhandled message {}", message);
+ protected final void ignoreMessage(Object message) {
+ LOG.debug("Ignoring unhandled message {}", message);
}
- protected void unknownMessage(Object message) throws Exception {
+ protected final void unknownMessage(Object message) {
LOG.debug("Received unhandled message {}", message);
unhandled(message);
}
}
@Override
- protected void handleReceive(Object message) throws Exception {
+ protected void handleReceive(Object message) {
if (message instanceof RegisterRoleChangeListener) {
// register listeners for this shard
for (ActorRef listener: registeredListeners.values()) {
listener.tell(latestLeaderStateChanged, getSelf());
}
+ } else {
+ unknownMessage(message);
}
}
private final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener;
private boolean notificationsEnabled = false;
- public DataChangeListener(AsyncDataChangeListener<YangInstanceIdentifier,
- NormalizedNode<?, ?>> listener) {
+ public DataChangeListener(AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener) {
this.listener = Preconditions.checkNotNull(listener, "listener should not be null");
}
@Override
- public void handleReceive(Object message) throws Exception {
- if(message instanceof DataChanged){
+ public void handleReceive(Object message) {
+ if (message instanceof DataChanged){
dataChanged(message);
- } else if(message instanceof EnableNotification){
+ } else if (message instanceof EnableNotification){
enableNotification((EnableNotification) message);
+ } else {
+ unknownMessage(message);
}
}
// Do nothing if notifications are not enabled
if(!notificationsEnabled) {
- LOG.debug("Notifications not enabled for listener {} - dropping change notification",
- listener);
+ LOG.debug("Notifications not enabled for listener {} - dropping change notification", listener);
return;
}
}
@Override
- public void handleReceive(Object message) throws Exception {
+ public void handleReceive(Object message) {
if (message instanceof CloseDataChangeListenerRegistration) {
closeListenerRegistration();
+ } else {
+ unknownMessage(message);
}
}
dataChanged((DataTreeChanged)message);
} else if (message instanceof EnableNotification) {
enableNotification((EnableNotification) message);
+ } else {
+ unknownMessage(message);
}
}
registration.close();
getSender().tell(CloseDataTreeChangeListenerRegistrationReply.getInstance(), getSelf());
getSelf().tell(PoisonPill.getInstance(), getSelf());
+ } else {
+ unknownMessage(message);
}
}
}
@Override
- public void handleReceive(Object message) throws Exception {
+ public void handleReceive(Object message) {
if (message instanceof CreateSnapshot) {
createSnapshot();
} else if(ReadData.isSerializedType(message)) {
readData(transaction, ReadData.fromSerializable(message));
} else if(DataExists.isSerializedType(message)) {
dataExists(transaction, DataExists.fromSerializable(message));
-
} else {
super.handleReceive(message);
}
}
@Override
- public void handleReceive(Object message) throws Exception {
+ public void handleReceive(Object message) {
if(ReadData.isSerializedType(message)) {
readData(ReadData.fromSerializable(message));
} else if(DataExists.isSerializedType(message)) {
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActorWithMetering;
-import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionReply;
}
@Override
- public void handleReceive(Object message) throws Exception {
+ public void handleReceive(Object message) {
if (CloseTransaction.isSerializedType(message)) {
closeTransaction(true);
} else if (message instanceof ReceiveTimeout) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Got ReceiveTimeout for inactivity - closing Tx");
- }
+ LOG.debug("Got ReceiveTimeout for inactivity - closing transaction {}", transactionID);
closeTransaction(false);
} else {
- throw new UnknownMessageException(message);
+ unknownMessage(message);
}
}
}
@Override
- public void handleReceive(Object message) throws Exception {
-
+ public void handleReceive(Object message) {
if (message instanceof BatchedModifications) {
batchedModifications((BatchedModifications)message);
} else {
@Override
protected void handleReceive(Object message) {
- if(message instanceof EntityOwnershipChange) {
+ if (message instanceof EntityOwnershipChange) {
onEntityOwnershipChanged((EntityOwnershipChange)message);
+ } else {
+ unknownMessage(message);
}
}