*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Optional;
import java.util.Collection;
+import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
private static final Logger LOG = LoggerFactory.getLogger(DefaultShardDataTreeChangeListenerPublisher.class);
private String logContext;
- DefaultShardDataTreeChangeListenerPublisher(String logContext) {
+ DefaultShardDataTreeChangeListenerPublisher(final String logContext) {
this.logContext = logContext;
}
}
@Override
- protected void notifyListener(AbstractDOMDataTreeChangeListenerRegistration<?> registration,
- Collection<DataTreeCandidate> changes) {
+ protected void notifyListener(final AbstractDOMDataTreeChangeListenerRegistration<?> registration,
+ final Collection<DataTreeCandidate> changes) {
LOG.debug("{}: notifyListener: listener: {}", logContext, registration.getInstance());
registration.getInstance().onDataTreeChanged(changes);
}
}
@Override
- public void registerTreeChangeListener(YangInstanceIdentifier treeId, DOMDataTreeChangeListener listener,
- Optional<DataTreeCandidate> initialState,
- Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ public void registerTreeChangeListener(final YangInstanceIdentifier treeId,
+ final DOMDataTreeChangeListener listener, final Optional<DataTreeCandidate> initialState,
+ final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
registerTreeChangeListener(treeId, listener, onRegistration);
if (initialState.isPresent()) {
}
}
- void registerTreeChangeListener(YangInstanceIdentifier treeId, DOMDataTreeChangeListener listener,
- Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ void registerTreeChangeListener(final YangInstanceIdentifier treeId, final DOMDataTreeChangeListener listener,
+ final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
LOG.debug("{}: registerTreeChangeListener: path: {}, listener: {}", logContext, treeId, listener);
AbstractDOMDataTreeChangeListenerRegistration<DOMDataTreeChangeListener> registration =
onRegistration.accept(registration);
}
- static void notifySingleListener(YangInstanceIdentifier treeId, DOMDataTreeChangeListener listener,
- DataTreeCandidate state, String logContext) {
+ static void notifySingleListener(final YangInstanceIdentifier treeId, final DOMDataTreeChangeListener listener,
+ final DataTreeCandidate state, final String logContext) {
LOG.debug("{}: notifySingleListener: path: {}, listener: {}", logContext, treeId, listener);
DefaultShardDataTreeChangeListenerPublisher publisher =
new DefaultShardDataTreeChangeListenerPublisher(logContext);
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.base.Verify;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.OptionalLong;
import java.util.Queue;
import java.util.SortedSet;
// delete everything first
mod.delete(YangInstanceIdentifier.EMPTY);
- final java.util.Optional<NormalizedNode<?, ?>> maybeNode = snapshot.getRootNode();
+ final Optional<NormalizedNode<?, ?>> maybeNode = snapshot.getRootNode();
if (maybeNode.isPresent()) {
// Add everything from the remote node back
mod.write(YangInstanceIdentifier.EMPTY, maybeNode.get());
}
Optional<DataTreeCandidate> readCurrentData() {
- final java.util.Optional<NormalizedNode<?, ?>> currentState =
- dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY);
- return currentState.isPresent() ? Optional.of(DataTreeCandidates.fromNormalizedNode(
- YangInstanceIdentifier.EMPTY, currentState.get())) : Optional.<DataTreeCandidate>absent();
+ return dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY)
+ .map(state -> DataTreeCandidates.fromNormalizedNode(YangInstanceIdentifier.EMPTY, state));
}
public void registerTreeChangeListener(final YangInstanceIdentifier path, final DOMDataTreeChangeListener listener,
@Override
ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction,
- final java.util.Optional<SortedSet<String>> participatingShardNames) {
+ final Optional<SortedSet<String>> participatingShardNames) {
final DataTreeModification snapshot = transaction.getSnapshot();
final TransactionIdentifier id = transaction.getIdentifier();
LOG.debug("{}: readying transaction {}", logContext, id);
}
public Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier path) {
- return Optional.fromJavaUtil(dataTree.takeSnapshot().readNode(path));
+ return dataTree.takeSnapshot().readNode(path);
}
DataTreeSnapshot takeSnapshot() {
tempStack.forEach(queue::addFirst);
}
- private Collection<String> extractPrecedingShardNames(
- final java.util.Optional<SortedSet<String>> participatingShardNames) {
+ private Collection<String> extractPrecedingShardNames(final Optional<SortedSet<String>> participatingShardNames) {
return participatingShardNames.map((Function<SortedSet<String>, Collection<String>>)
set -> set.headSet(shard.getShardName())).orElse(Collections.<String>emptyList());
}
@Override
ShardDataTreeCohort createReadyCohort(final TransactionIdentifier txId, final DataTreeModification mod,
- final java.util.Optional<SortedSet<String>> participatingShardNames) {
+ final Optional<SortedSet<String>> participatingShardNames) {
SimpleShardDataTreeCohort cohort = new SimpleShardDataTreeCohort(this, mod, txId,
cohortRegistry.createCohort(schemaContext, txId, shard::executeInSelf,
COMMIT_STEP_TIMEOUT), participatingShardNames);
// Exposed for ShardCommitCoordinator so it does not have deal with local histories (it does not care), this mimics
// the newReadWriteTransaction()
ShardDataTreeCohort newReadyCohort(final TransactionIdentifier txId, final DataTreeModification mod,
- final java.util.Optional<SortedSet<String>> participatingShardNames) {
+ final Optional<SortedSet<String>> participatingShardNames) {
if (txId.getHistoryId().getHistoryId() == 0) {
return createReadyCohort(txId, mod, participatingShardNames);
}
*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Optional;
+import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import akka.actor.ActorContext;
import akka.actor.ActorRef;
import akka.actor.Props;
-import com.google.common.base.Optional;
+import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
class ShardDataTreeChangeListenerPublisherActorProxy extends AbstractShardDataTreeNotificationPublisherActorProxy
implements ShardDataTreeChangeListenerPublisher {
- ShardDataTreeChangeListenerPublisherActorProxy(ActorContext actorContext, String actorName, String logContext) {
+ ShardDataTreeChangeListenerPublisherActorProxy(final ActorContext actorContext, final String actorName,
+ final String logContext) {
super(actorContext, actorName, logContext);
}
@Override
- public void registerTreeChangeListener(YangInstanceIdentifier treeId,
- DOMDataTreeChangeListener listener, Optional<DataTreeCandidate> currentState,
- Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
+ public void registerTreeChangeListener(final YangInstanceIdentifier treeId,
+ final DOMDataTreeChangeListener listener, final Optional<DataTreeCandidate> currentState,
+ final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
final ShardDataTreeChangePublisherActor.RegisterListener regMessage =
new ShardDataTreeChangePublisherActor.RegisterListener(treeId, listener, currentState, onRegistration);
log.debug("{}: Sending {} to publisher actor {}", logContext(), regMessage, publisherActor());
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.Props;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
+import java.util.Optional;
import java.util.function.Consumer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
RegisterListener(final YangInstanceIdentifier path, final DOMDataTreeChangeListener listener,
final Optional<DataTreeCandidate> initialState,
final Consumer<ListenerRegistration<DOMDataTreeChangeListener>> onRegistration) {
- this.path = Preconditions.checkNotNull(path);
- this.listener = Preconditions.checkNotNull(listener);
- this.initialState = Preconditions.checkNotNull(initialState);
- this.onRegistration = Preconditions.checkNotNull(onRegistration);
+ this.path = requireNonNull(path);
+ this.listener = requireNonNull(listener);
+ this.initialState = requireNonNull(initialState);
+ this.onRegistration = requireNonNull(onRegistration);
}
@Override
* 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.entityownership;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_OWNERS_PATH;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_OWNER_QNAME;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_QNAME;
-import com.google.common.base.Optional;
+import java.util.Optional;
import org.opendaylight.controller.cluster.datastore.ShardDataTree;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType;
.node(ENTITY_OWNER_QNAME).build();
void init(final ShardDataTree shardDataTree) {
- shardDataTree.registerTreeChangeListener(EOS_PATH, this, Optional.absent(), noop -> { /* NOOP */ });
+ shardDataTree.registerTreeChangeListener(EOS_PATH, this, Optional.empty(), noop -> { /* NOOP */ });
}
protected static String extractOwner(final LeafNode<?> ownerLeaf) {
* 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.entityownership;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NAME_QNAME;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_ID_QNAME;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_OWNERS_PATH;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_QNAME;
import akka.actor.ActorRef;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import org.opendaylight.controller.cluster.datastore.ShardDataTree;
import org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateAdded;
import org.opendaylight.controller.cluster.datastore.entityownership.messages.CandidateRemoved;
private final ActorRef shard;
private final Map<YangInstanceIdentifier, Collection<String>> currentCandidates = new HashMap<>();
- CandidateListChangeListener(ActorRef shard, String logId) {
- this.shard = Preconditions.checkNotNull(shard, "shard should not be null");
+ CandidateListChangeListener(final ActorRef shard, final String logId) {
+ this.shard = requireNonNull(shard, "shard should not be null");
this.logId = logId;
}
- void init(ShardDataTree shardDataTree) {
+ void init(final ShardDataTree shardDataTree) {
shardDataTree.registerTreeChangeListener(YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH)
.node(EntityType.QNAME).node(EntityType.QNAME).node(ENTITY_QNAME).node(ENTITY_QNAME)
- .node(Candidate.QNAME).node(Candidate.QNAME).build(), this, Optional.absent(), noop -> { /* NOOP */ });
+ .node(Candidate.QNAME).node(Candidate.QNAME).build(), this, Optional.empty(), noop -> { /* NOOP */ });
}
@Override
- public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
+ public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
for (DataTreeCandidate change: changes) {
DataTreeCandidateNode changeRoot = change.getRootNode();
ModificationType type = changeRoot.getModificationType();
}
}
- private Collection<String> addToCurrentCandidates(YangInstanceIdentifier entityId, String newCandidate) {
+ private Collection<String> addToCurrentCandidates(final YangInstanceIdentifier entityId,
+ final String newCandidate) {
Collection<String> candidates = currentCandidates.computeIfAbsent(entityId, k -> new LinkedHashSet<>());
-
candidates.add(newCandidate);
return candidates;
}
- private Collection<String> removeFromCurrentCandidates(YangInstanceIdentifier entityId, String candidateToRemove) {
+ private Collection<String> removeFromCurrentCandidates(final YangInstanceIdentifier entityId,
+ final String candidateToRemove) {
Collection<String> candidates = currentCandidates.get(entityId);
if (candidates != null) {
candidates.remove(candidateToRemove);
return Collections.emptyList();
}
- private static YangInstanceIdentifier extractEntityPath(YangInstanceIdentifier candidatePath) {
+ private static YangInstanceIdentifier extractEntityPath(final YangInstanceIdentifier candidatePath) {
List<PathArgument> newPathArgs = new ArrayList<>();
for (PathArgument pathArg: candidatePath.getPathArguments()) {
newPathArgs.add(pathArg);
import akka.cluster.Member;
import akka.cluster.MemberStatus;
import akka.pattern.Patterns;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
getSender().tell(SuccessReply.INSTANCE, getSelf());
searchForEntities((entityTypeNode, entityNode) -> {
- java.util.Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
+ Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
String entityType = possibleType.isPresent() ? possibleType.get().getValue().toString() : null;
if (registerListener.getEntityType().equals(entityType)) {
final boolean hasOwner;
final boolean isOwner;
- java.util.Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
+ Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
if (possibleOwner.isPresent()) {
isOwner = localMemberName.getName().equals(possibleOwner.get().getValue().toString());
hasOwner = true;
private void notifyAllListeners() {
searchForEntities((entityTypeNode, entityNode) -> {
- java.util.Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
+ Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
if (possibleType.isPresent()) {
final boolean hasOwner;
final boolean isOwner;
- java.util.Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
+ Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
if (possibleOwner.isPresent()) {
isOwner = localMemberName.getName().equals(possibleOwner.get().getValue().toString());
hasOwner = true;
.node(entityTypeNode.getIdentifier()).node(ENTITY_NODE_ID).node(entityNode.getIdentifier())
.node(ENTITY_OWNER_NODE_ID).build();
- java.util.Optional<String> possibleOwner =
+ Optional<String> possibleOwner =
entityNode.getChild(ENTITY_OWNER_NODE_ID).map(node -> node.getValue().toString());
String newOwner = newOwner(possibleOwner.orElse(null), getCandidateNames(entityNode),
getEntityOwnerElectionStrategy(entityPath));
}
private void initializeDownPeerMemberNamesFromClusterState() {
- java.util.Optional<Cluster> cluster = getRaftActorContext().getCluster();
+ Optional<Cluster> cluster = getRaftActorContext().getCluster();
if (!cluster.isPresent()) {
return;
}
LOG.debug("{}: Searching for entities owned by {}", persistenceId(), ownedBy);
searchForEntities((entityTypeNode, entityNode) -> {
- java.util.Optional<DataContainerChild<? extends PathArgument, ?>> possibleOwner =
+ Optional<DataContainerChild<? extends PathArgument, ?>> possibleOwner =
entityNode.getChild(ENTITY_OWNER_NODE_ID);
String currentOwner = possibleOwner.isPresent() ? possibleOwner.get().getValue().toString() : "";
if (ownedBy.contains(currentOwner)) {
return;
}
- for (MapEntryNode entityType: ((MapNode) possibleEntityTypes.get()).getValue()) {
- java.util.Optional<DataContainerChild<?, ?>> possibleEntities = entityType.getChild(ENTITY_NODE_ID);
+ for (MapEntryNode entityType : ((MapNode) possibleEntityTypes.get()).getValue()) {
+ Optional<DataContainerChild<?, ?>> possibleEntities = entityType.getChild(ENTITY_NODE_ID);
if (!possibleEntities.isPresent()) {
// shouldn't happen but handle anyway
continue;
}
private String getCurrentOwner(final YangInstanceIdentifier entityId) {
- Optional<NormalizedNode<?, ?>> optionalEntityOwner = getDataStore().readNode(entityId.node(ENTITY_OWNER_QNAME));
- if (optionalEntityOwner.isPresent()) {
- return optionalEntityOwner.get().getValue().toString();
- }
- return null;
+ return getDataStore().readNode(entityId.node(ENTITY_OWNER_QNAME))
+ .map(owner -> owner.getValue().toString())
+ .orElse(null);
}
@FunctionalInterface
tryReschedule(throwable);
} else {
final FindLeaderReply findLeader = (FindLeaderReply) findLeaderReply;
- final java.util.Optional<String> leaderActor = findLeader.getLeaderActor();
+ final Optional<String> leaderActor = findLeader.getLeaderActor();
if (leaderActor.isPresent()) {
// leader is found, backend seems ready, check if the frontend is ready
LOG.debug("{} - Leader for shard[{}] backend ready, starting frontend lookup..",
tryReschedule(throwable);
} else {
final FindLeaderReply findLeader = (FindLeaderReply) findLeaderReply;
- final java.util.Optional<String> leaderActor = findLeader.getLeaderActor();
+ final Optional<String> leaderActor = findLeader.getLeaderActor();
if (leaderActor.isPresent()) {
// leader is found, backend seems ready, check if the frontend is ready
LOG.debug("{} - Leader for config shard is ready. Ending lookup.",
public static NormalizedNode<?,?> readStore(final TestActorRef<? extends Shard> shard,
final YangInstanceIdentifier id) {
- return shard.underlyingActor().getDataStore().readNode(id).orNull();
+ return shard.underlyingActor().getDataStore().readNode(id).orElse(null);
}
public static NormalizedNode<?,?> readStore(final DataTree store, final YangInstanceIdentifier id) {
* 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 org.junit.Assert.assertEquals;
import akka.actor.AddressFromURIString;
import akka.cluster.Cluster;
import akka.testkit.javadsl.TestKit;
-import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.FluentFuture;
import com.typesafe.config.ConfigFactory;
import java.math.BigInteger;
import java.util.Collection;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
kit.testWriteTransaction(dataStore, TestModel.TEST_PATH, node);
verify(cohort).canCommit(any(Object.class), any(SchemaContext.class), candidateCapt.capture());
assertDataTreeCandidate((DOMDataTreeCandidate) candidateCapt.getValue().iterator().next(), TEST_ID,
- ModificationType.WRITE, Optional.of(node), Optional.absent());
+ ModificationType.WRITE, Optional.of(node), Optional.empty());
reset(cohort);
doReturn(PostCanCommitStep.NOOP_SUCCESSFUL_FUTURE).when(cohort).canCommit(any(Object.class),
verify(cohort).canCommit(any(Object.class), any(SchemaContext.class), candidateCapture.capture());
assertDataTreeCandidate((DOMDataTreeCandidate) candidateCapture.getValue().iterator().next(),
new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, optimaPath), ModificationType.WRITE,
- Optional.of(optimaNode), Optional.absent());
+ Optional.of(optimaNode), Optional.empty());
// Write replace the cars container with 2 new car entries. The cohort should get invoked with 3
// DOMDataTreeCandidates: once for each of the 2 new car entries (WRITE mod) and once for the deleted prior
assertDataTreeCandidate(findCandidate(candidateCapture, sportagePath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, sportagePath), ModificationType.WRITE,
- Optional.of(sportageNode), Optional.absent());
+ Optional.of(sportageNode), Optional.empty());
assertDataTreeCandidate(findCandidate(candidateCapture, soulPath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, soulPath), ModificationType.WRITE,
- Optional.of(soulNode), Optional.absent());
+ Optional.of(soulNode), Optional.empty());
assertDataTreeCandidate(findCandidate(candidateCapture, optimaPath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, optimaPath), ModificationType.DELETE,
- Optional.absent(), Optional.of(optimaNode));
+ Optional.empty(), Optional.of(optimaNode));
// Delete the cars container - cohort should be invoked for the 2 deleted car entries.
assertDataTreeCandidate(findCandidate(candidateCapture, sportagePath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, sportagePath), ModificationType.DELETE,
- Optional.absent(), Optional.of(sportageNode));
+ Optional.empty(), Optional.of(sportageNode));
assertDataTreeCandidate(findCandidate(candidateCapture, soulPath), new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, soulPath), ModificationType.DELETE,
- Optional.absent(), Optional.of(soulNode));
+ Optional.empty(), Optional.of(soulNode));
}
}
import static org.mockito.Mockito.verify;
import akka.actor.ActorSelection;
-import com.google.common.base.Optional;
import com.google.common.util.concurrent.SettableFuture;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Test
public void testReady() {
final LocalThreePhaseCommitCohort mockCohort = mock(LocalThreePhaseCommitCohort.class);
- doReturn(akka.dispatch.Futures.successful(null)).when(mockCohort).initiateCoordinatedCommit(
- java.util.Optional.empty());
+ doReturn(akka.dispatch.Futures.successful(null)).when(mockCohort).initiateCoordinatedCommit(Optional.empty());
doReturn(mockCohort).when(mockReadySupport).onTransactionReady(readWriteTransaction, null);
- Future<ActorSelection> future = localTransactionContext.readyTransaction(null, java.util.Optional.empty());
+ Future<ActorSelection> future = localTransactionContext.readyTransaction(null, Optional.empty());
assertTrue(future.isCompleted());
verify(mockReadySupport).onTransactionReady(readWriteTransaction, null);
private void doReadyWithExpectedError(final RuntimeException expError) {
LocalThreePhaseCommitCohort mockCohort = mock(LocalThreePhaseCommitCohort.class);
- doReturn(akka.dispatch.Futures.successful(null)).when(mockCohort).initiateCoordinatedCommit(
- java.util.Optional.empty());
+ doReturn(akka.dispatch.Futures.successful(null)).when(mockCohort).initiateCoordinatedCommit(Optional.empty());
doReturn(mockCohort).when(mockReadySupport).onTransactionReady(readWriteTransaction, expError);
- localTransactionContext.readyTransaction(null, java.util.Optional.empty());
+ localTransactionContext.readyTransaction(null, Optional.empty());
}
}
DOMDataTreeChangeListener listener = mock(DOMDataTreeChangeListener.class);
shardDataTree.registerTreeChangeListener(CarsModel.CAR_LIST_PATH.node(CarsModel.CAR_QNAME), listener,
- com.google.common.base.Optional.absent(), noop -> { });
+ Optional.empty(), noop -> { });
addCar(shardDataTree, "optima");
* 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 org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.google.common.base.Optional;
import java.io.IOException;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;