BUG-5280: implement message queueing
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / actors / client / InitialClientActorContext.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.controller.cluster.datastore.actors.client;
9
10 import akka.actor.ActorSystem;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
13
14 /**
15  *
16  * @author Robert Varga
17  */
18 final class InitialClientActorContext extends AbstractClientActorContext {
19     private final AbstractClientActor actor;
20
21     InitialClientActorContext(final AbstractClientActor actor, final String persistenceId) {
22         super(actor.self(), persistenceId);
23         this.actor = Preconditions.checkNotNull(actor);
24     }
25
26     void saveSnapshot(final ClientIdentifier snapshot) {
27         actor.saveSnapshot(snapshot);
28     }
29
30     ClientActorBehavior createBehavior(final ClientIdentifier clientId) {
31         final ActorSystem system = actor.getContext().system();
32         final ClientActorContext context = new ClientActorContext(self(), system.scheduler(), system.dispatcher(),
33             persistenceId(), clientId);
34
35         return actor.initialBehavior(context);
36     }
37
38     void stash() {
39         actor.stash();
40     }
41
42     void unstash() {
43         actor.unstashAll();
44     }
45 }