Merge "Bug 2820 - LLDP TLV support and testing"
[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
18 /**
19  * @author: syedbahm
20  * Date: 8/6/14
21  */
22 public class ShardReadWriteTransaction extends ShardWriteTransaction {
23     public ShardReadWriteTransaction(ReadWriteShardDataTreeTransaction transaction, ActorRef shardActor,
24             ShardStats shardStats, String transactionID, short clientTxVersion) {
25         super(transaction, shardActor, shardStats, transactionID, clientTxVersion);
26     }
27
28     @Override
29     public void handleReceive(Object message) throws Exception {
30         if (message instanceof ReadData) {
31             readData((ReadData) message, !SERIALIZED_REPLY);
32
33         } else if (message instanceof DataExists) {
34             dataExists((DataExists) message, !SERIALIZED_REPLY);
35
36         } else if(ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
37             readData(ReadData.fromSerializable(message), SERIALIZED_REPLY);
38
39         } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
40             dataExists(DataExists.fromSerializable(message), SERIALIZED_REPLY);
41         } else {
42             super.handleReceive(message);
43         }
44     }
45 }