Merge changes I114cbac1,I45c2e7cd
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardReadWriteTransaction.java
1 /*
2  *
3  *  Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  *  This program and the accompanying materials are made available under the
6  *  terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  and is available at http://www.eclipse.org/legal/epl-v10.html
8  *
9  */
10
11 package org.opendaylight.controller.cluster.datastore;
12
13 import akka.actor.ActorRef;
14 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
15 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
16 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
17 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
18
19 /**
20  * @author: syedbahm
21  * Date: 8/6/14
22  */
23 public class ShardReadWriteTransaction extends ShardWriteTransaction {
24     private final DOMStoreReadWriteTransaction transaction;
25
26     public ShardReadWriteTransaction(DOMStoreReadWriteTransaction transaction, ActorRef shardActor,
27             ShardStats shardStats, String transactionID, short clientTxVersion) {
28         super(transaction, shardActor, shardStats, transactionID, clientTxVersion);
29         this.transaction = transaction;
30     }
31
32     @Override
33     public void handleReceive(Object message) throws Exception {
34         if (message instanceof ReadData) {
35             readData(transaction, (ReadData) message, !SERIALIZED_REPLY);
36
37         } else if (message instanceof DataExists) {
38             dataExists(transaction, (DataExists) message, !SERIALIZED_REPLY);
39
40         } else if(ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
41             readData(transaction, ReadData.fromSerializable(message), SERIALIZED_REPLY);
42
43         } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
44             dataExists(transaction, DataExists.fromSerializable(message), SERIALIZED_REPLY);
45
46         } else {
47             super.handleReceive(message);
48         }
49     }
50 }