X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Factors%2Fclient%2FSavingClientActorBehavior.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Factors%2Fclient%2FSavingClientActorBehavior.java;h=ac5f12fb9d5d8cc00c8a91433a298ad98ee5724c;hb=d0621d28e507d9f6c0b9445d197f90253d34725d;hp=0000000000000000000000000000000000000000;hpb=93fd13870364f77c234d6bd981906d7ef3bd3b46;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/client/SavingClientActorBehavior.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/client/SavingClientActorBehavior.java new file mode 100644 index 0000000000..ac5f12fb9d --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/client/SavingClientActorBehavior.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore.actors.client; + +import akka.persistence.SaveSnapshotFailure; +import akka.persistence.SaveSnapshotSuccess; +import com.google.common.base.Preconditions; +import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Robert Varga + */ +final class SavingClientActorBehavior extends RecoveredClientActorBehavior { + private static final Logger LOG = LoggerFactory.getLogger(SavingClientActorBehavior.class); + private final ClientIdentifier myId; + + SavingClientActorBehavior(final InitialClientActorContext context, final ClientIdentifier nextId) { + super(context); + this.myId = Preconditions.checkNotNull(nextId); + } + + @Override + AbstractClientActorBehavior onReceiveCommand(final Object command) { + if (command instanceof SaveSnapshotFailure) { + LOG.error("{}: failed to persist state", persistenceId(), ((SaveSnapshotFailure) command).cause()); + return null; + } else if (command instanceof SaveSnapshotSuccess) { + context().unstash(); + return context().createBehavior(new ClientActorContext(self(), persistenceId(), myId)); + } else { + LOG.debug("{}: stashing command {}", persistenceId(), command); + context().stash(); + return this; + } + } +} \ No newline at end of file