2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.actors.client;
10 import akka.persistence.SaveSnapshotFailure;
11 import akka.persistence.SaveSnapshotSuccess;
12 import com.google.common.base.Preconditions;
13 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * @author Robert Varga
20 final class SavingClientActorBehavior extends RecoveredClientActorBehavior<InitialClientActorContext> {
21 private static final Logger LOG = LoggerFactory.getLogger(SavingClientActorBehavior.class);
22 private final ClientIdentifier myId;
24 SavingClientActorBehavior(final InitialClientActorContext context, final ClientIdentifier nextId) {
26 this.myId = Preconditions.checkNotNull(nextId);
30 AbstractClientActorBehavior<?> onReceiveCommand(final Object command) {
31 if (command instanceof SaveSnapshotFailure) {
32 LOG.error("{}: failed to persist state", persistenceId(), ((SaveSnapshotFailure) command).cause());
34 } else if (command instanceof SaveSnapshotSuccess) {
36 return context().createBehavior(myId);
38 LOG.debug("{}: stashing command {}", persistenceId(), command);