Merge "Fixed for bug 1197"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / NoOpCohort.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.cluster.datastore;
10
11 import akka.actor.UntypedActor;
12 import org.opendaylight.controller.cluster.datastore.messages.AbortTransaction;
13 import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply;
14 import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransaction;
15 import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransactionReply;
16 import org.opendaylight.controller.cluster.datastore.messages.CommitTransaction;
17 import org.opendaylight.controller.cluster.datastore.messages.CommitTransactionReply;
18 import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransaction;
19 import org.opendaylight.controller.cluster.datastore.messages.PreCommitTransactionReply;
20
21 public class NoOpCohort extends UntypedActor {
22
23     @Override public void onReceive(Object message) throws Exception {
24         if (message.getClass().equals(CanCommitTransaction.SERIALIZABLE_CLASS)) {
25             getSender().tell(new CanCommitTransactionReply(false).toSerializable(), getSelf());
26         } else if (message.getClass().equals(PreCommitTransaction.SERIALIZABLE_CLASS)) {
27             getSender().tell(
28                 new PreCommitTransactionReply().toSerializable(),
29                 getSelf());
30         } else if (message.getClass().equals(CommitTransaction.SERIALIZABLE_CLASS)) {
31             getSender().tell(new CommitTransactionReply().toSerializable(), getSelf());
32         } else if (message.getClass().equals(AbortTransaction.SERIALIZABLE_CLASS)) {
33             getSender().tell(new AbortTransactionReply().toSerializable(), getSelf());
34         } else {
35             throw new Exception ("Not recognized message received,message="+message);
36         }
37
38     }
39 }
40