BUG-8665: fix memory leak around RangeSets
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardReadTransaction.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.ActorRef;
12 import com.google.common.base.Preconditions;
13 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
14 import org.opendaylight.controller.cluster.datastore.messages.DataExists;
15 import org.opendaylight.controller.cluster.datastore.messages.ReadData;
16
17 /**
18  * Actor for a shard read transaction.
19  *
20  * @author: syedbahm
21  */
22 public class ShardReadTransaction extends ShardTransaction {
23     private final AbstractShardDataTreeTransaction<?> transaction;
24
25     public ShardReadTransaction(AbstractShardDataTreeTransaction<?> transaction, ActorRef shardActor,
26             ShardStats shardStats) {
27         super(shardActor, shardStats, transaction.getIdentifier());
28         this.transaction = Preconditions.checkNotNull(transaction);
29     }
30
31     @Override
32     public void handleReceive(Object message) {
33         if (ReadData.isSerializedType(message)) {
34             readData(transaction, ReadData.fromSerializable(message));
35         } else if (DataExists.isSerializedType(message)) {
36             dataExists(transaction, DataExists.fromSerializable(message));
37         } else {
38             super.handleReceive(message);
39         }
40     }
41
42     @Override
43     protected AbstractShardDataTreeTransaction<?> getDOMStoreTransaction() {
44         return transaction;
45     }
46
47     @Override
48     protected boolean returnCloseTransactionReply() {
49         return false;
50     }
51 }