Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
* Copyright (c) 2015 Brocade Communications 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;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import akka.actor.ActorSelection;
import akka.dispatch.Futures;
import akka.dispatch.OnComplete;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Optional;
import java.util.SortedSet;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.AbstractRead;
import org.opendaylight.controller.cluster.datastore.messages.BatchedModifications;
import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
import org.opendaylight.controller.cluster.datastore.modification.AbstractModification;
import org.opendaylight.controller.cluster.datastore.modification.DeleteModification;
import org.opendaylight.controller.cluster.datastore.modification.MergeModification;
import org.opendaylight.controller.cluster.datastore.modification.Modification;
import org.opendaylight.controller.cluster.datastore.modification.WriteModification;
import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
/**
* Redirects front-end transaction operations to a shard for processing. Instances of this class are used
* when the destination shard is remote to the caller.
*
* @author Thomas Pantelis
*/
final class RemoteTransactionContext extends TransactionContext {
private static final Logger LOG = LoggerFactory.getLogger(RemoteTransactionContext.class);
private final ActorUtils actorUtils;
private final ActorSelection actor;
private final OperationLimiter limiter;
private BatchedModifications batchedModifications;
private int totalBatchedModificationsSent;
private int batchPermits;
/**
* We have observed a failed modification batch. This transaction context is effectively doomed, as the backend
* does not have a correct view of the world. If this happens, we do not limit operations but rather short-cut them
* to a either a no-op (modifications) or a failure (reads). Once the transaction is ready, though, we send the
* message to resynchronize with the backend, sharing a 'lost message' failure path.
*/
private volatile Throwable failedModification;
RemoteTransactionContext(final TransactionIdentifier identifier, final ActorSelection actor,
final ActorUtils actorUtils, final short remoteTransactionVersion, final OperationLimiter limiter) {
super(identifier, remoteTransactionVersion);
this.limiter = requireNonNull(limiter);
this.actor = actor;
this.actorUtils = actorUtils;
}
private ActorSelection getActor() {
return actor;
}
protected ActorUtils getActorUtils() {
return actorUtils;
}
@Override
void closeTransaction() {
LOG.debug("Tx {} closeTransaction called", getIdentifier());
TransactionContextCleanup.untrack(this);
actorUtils.sendOperationAsync(getActor(), new CloseTransaction(getTransactionVersion()).toSerializable());
}
@Override
Future