Search in sources :

Example 1 with RecoveryCompleted

use of akka.persistence.RecoveryCompleted in project controller by opendaylight.

the class RecoveringClientActorBehavior method onReceiveRecover.

@Override
AbstractClientActorBehavior<?> onReceiveRecover(final Object recover) {
    if (recover instanceof RecoveryCompleted) {
        final ClientIdentifier nextId;
        if (lastId != null) {
            if (!currentFrontend.equals(lastId.getFrontendId())) {
                LOG.error("{}: Mismatched frontend identifier, shutting down. Current: {} Saved: {}", persistenceId(), currentFrontend, lastId.getFrontendId());
                return null;
            }
            nextId = ClientIdentifier.create(currentFrontend, lastId.getGeneration() + 1);
        } else {
            nextId = ClientIdentifier.create(currentFrontend, 0);
        }
        LOG.debug("{}: persisting new identifier {}", persistenceId(), nextId);
        context().saveSnapshot(nextId);
        return new SavingClientActorBehavior(context(), nextId);
    } else if (recover instanceof SnapshotOffer) {
        lastId = (ClientIdentifier) ((SnapshotOffer) recover).snapshot();
        LOG.debug("{}: recovered identifier {}", persistenceId(), lastId);
    } else {
        LOG.warn("{}: ignoring recovery message {}", persistenceId(), recover);
    }
    return this;
}
Also used : RecoveryCompleted(akka.persistence.RecoveryCompleted) ClientIdentifier(org.opendaylight.controller.cluster.access.concepts.ClientIdentifier) SnapshotOffer(akka.persistence.SnapshotOffer)

Aggregations

RecoveryCompleted (akka.persistence.RecoveryCompleted)1 SnapshotOffer (akka.persistence.SnapshotOffer)1 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)1