Bug 1446: Add JMX stats for clustered data store
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardReadTransaction.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
15 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
16 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
17 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
18 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
19 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21
22 /**
23  * @author: syedbahm
24  * Date: 8/6/14
25  */
26 public class ShardReadTransaction extends ShardTransaction {
27     private final DOMStoreReadTransaction transaction;
28
29     public ShardReadTransaction(DOMStoreReadTransaction transaction, ActorRef shardActor,
30             SchemaContext schemaContext, ShardStats shardStats) {
31         super(shardActor, schemaContext, shardStats);
32         this.transaction = transaction;
33     }
34
35     @Override
36     public void handleReceive(Object message) throws Exception {
37         if(ReadData.SERIALIZABLE_CLASS.equals(message.getClass())) {
38             readData(transaction, ReadData.fromSerializable(message));
39         } else if(DataExists.SERIALIZABLE_CLASS.equals(message.getClass())) {
40             dataExists(transaction, DataExists.fromSerializable(message));
41         } else {
42             super.handleReceive(message);
43         }
44     }
45
46     @Override
47     protected DOMStoreTransaction getDOMStoreTransaction() {
48         return transaction;
49     }
50 }