This fixes issues pointed out by Modernizer, which mostly boil
down to using Objects.requireNonNull() and direct java.util
collections.
Change-Id: Id32530a6722cd101f96c23f6a745f91b2f09e2f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
3859df9beca8f13f1ff2b2744ed3470a1715bec3)
190 files changed:
*/
package org.opendaylight.controller.blueprint;
*/
package org.opendaylight.controller.blueprint;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayDeque;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayDeque;
}
private void restartContainerAndDependentsInternal(final Bundle forBundle) {
}
private void restartContainerAndDependentsInternal(final Bundle forBundle) {
- Preconditions.checkNotNull(blueprintExtenderService);
- Preconditions.checkNotNull(quiesceParticipant);
+ requireNonNull(blueprintExtenderService);
+ requireNonNull(quiesceParticipant);
// We use a LinkedHashSet to preserve insertion order as we walk the service usage hierarchy.
Set<Bundle> containerBundlesSet = new LinkedHashSet<>();
// We use a LinkedHashSet to preserve insertion order as we walk the service usage hierarchy.
Set<Bundle> containerBundlesSet = new LinkedHashSet<>();
- private ServiceRegistration<?> registerEventHandler(final BundleContext bundleContext,
+ private static ServiceRegistration<?> registerEventHandler(final BundleContext bundleContext,
final BlueprintListener listener) {
return bundleContext.registerService(BlueprintListener.class.getName(), listener, new Hashtable<>());
}
final BlueprintListener listener) {
return bundleContext.registerService(BlueprintListener.class.getName(), listener, new Hashtable<>());
}
*/
package org.opendaylight.controller.blueprint.ext;
*/
package org.opendaylight.controller.blueprint.ext;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
private boolean stoppedServiceRecipes;
protected AbstractDependentComponentFactoryMetadata(final String id) {
private boolean stoppedServiceRecipes;
protected AbstractDependentComponentFactoryMetadata(final String id) {
- this.id = Preconditions.checkNotNull(id);
+ this.id = requireNonNull(id);
*/
package org.opendaylight.controller.blueprint.ext;
*/
package org.opendaylight.controller.blueprint.ext;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.Set;
AbstractInvokableServiceMetadata(final String id, final String interfaceName) {
super(id);
AbstractInvokableServiceMetadata(final String id, final String interfaceName) {
super(id);
- this.interfaceName = Preconditions.checkNotNull(interfaceName);
+ this.interfaceName = requireNonNull(interfaceName);
}
Class<RpcService> rpcInterface() {
}
Class<RpcService> rpcInterface() {
*/
package org.opendaylight.controller.blueprint.ext;
*/
package org.opendaylight.controller.blueprint.ext;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
private final String id;
MandatoryServiceReferenceMetadata(final String id, final String interfaceClass) {
private final String id;
MandatoryServiceReferenceMetadata(final String id, final String interfaceClass) {
- this.id = Preconditions.checkNotNull(id);
+ this.id = requireNonNull(id);
this.interfaceClass = interfaceClass;
}
this.interfaceClass = interfaceClass;
}
*/
package org.opendaylight.controller.blueprint.ext;
*/
package org.opendaylight.controller.blueprint.ext;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collections;
import java.util.function.Consumer;
import org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe;
import java.util.Collections;
import java.util.function.Consumer;
import org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe;
- Preconditions.checkNotNull(localTrackedServiceReference, "trackedServiceReference is null");
-
- trackedService = getServiceSecurely(localTrackedServiceReference);
+ trackedService = getServiceSecurely(requireNonNull(localTrackedServiceReference,
+ "trackedServiceReference is null"));
LOG.debug("{}: Returning service instance: {}", getName(), trackedService);
LOG.debug("{}: Returning service instance: {}", getName(), trackedService);
- Preconditions.checkNotNull(trackedService, "getService() returned null for %s", localTrackedServiceReference);
-
- return trackedService;
+ return checkNotNull(trackedService, "getService() returned null for %s", localTrackedServiceReference);
*/
package org.opendaylight.controller.cluster.access.commands;
*/
package org.opendaylight.controller.cluster.access.commands;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import com.google.common.annotations.Beta;
import akka.actor.ActorRef;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
private long sequence;
public ModifyTransactionRequestBuilder(final TransactionIdentifier identifier, final ActorRef replyTo) {
private long sequence;
public ModifyTransactionRequestBuilder(final TransactionIdentifier identifier, final ActorRef replyTo) {
- this.identifier = Preconditions.checkNotNull(identifier);
- this.replyTo = Preconditions.checkNotNull(replyTo);
+ this.identifier = requireNonNull(identifier);
+ this.replyTo = requireNonNull(replyTo);
}
private void checkNotFinished() {
}
private void checkNotFinished() {
- Preconditions.checkState(protocol == null, "Batch has already been finished");
+ checkState(protocol == null, "Batch has already been finished");
}
public void addModification(final TransactionModification modification) {
checkNotFinished();
}
public void addModification(final TransactionModification modification) {
checkNotFinished();
- modifications.add(Preconditions.checkNotNull(modification));
+ modifications.add(requireNonNull(modification));
}
public void setSequence(final long sequence) {
}
public void setSequence(final long sequence) {
- Preconditions.checkState(!haveSequence, "Sequence has already been set");
+ checkState(!haveSequence, "Sequence has already been set");
this.sequence = sequence;
haveSequence = true;
}
this.sequence = sequence;
haveSequence = true;
}
@Override
public ModifyTransactionRequest build() {
@Override
public ModifyTransactionRequest build() {
- Preconditions.checkState(haveSequence, "Request sequence has not been set");
+ checkState(haveSequence, "Request sequence has not been set");
final ModifyTransactionRequest ret = new ModifyTransactionRequest(identifier, sequence, replyTo, modifications,
protocol);
final ModifyTransactionRequest ret = new ModifyTransactionRequest(identifier, sequence, replyTo, modifications,
protocol);
*/
package org.opendaylight.controller.cluster.access.commands;
*/
package org.opendaylight.controller.cluster.access.commands;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
import org.opendaylight.controller.cluster.access.ABIVersion;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
import org.opendaylight.controller.cluster.access.ABIVersion;
public ReadTransactionSuccess(final TransactionIdentifier identifier, final long sequence,
final Optional<NormalizedNode<?, ?>> data) {
super(identifier, sequence);
public ReadTransactionSuccess(final TransactionIdentifier identifier, final long sequence,
final Optional<NormalizedNode<?, ?>> data) {
super(identifier, sequence);
- this.data = Preconditions.checkNotNull(data);
+ this.data = requireNonNull(data);
}
public Optional<NormalizedNode<?, ?>> getData() {
}
public Optional<NormalizedNode<?, ?>> getData() {
*/
package org.opendaylight.controller.cluster.access.commands;
*/
package org.opendaylight.controller.cluster.access.commands;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import java.io.IOException;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import java.io.IOException;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
TransactionDataModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
super(path);
TransactionDataModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
super(path);
- this.data = Preconditions.checkNotNull(data);
+ this.data = requireNonNull(data);
}
public final NormalizedNode<?, ?> getData() {
}
public final NormalizedNode<?, ?> getData() {
*/
package org.opendaylight.controller.cluster.access.commands;
*/
package org.opendaylight.controller.cluster.access.commands;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.io.IOException;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
import java.io.IOException;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
private final YangInstanceIdentifier path;
TransactionModification(final YangInstanceIdentifier path) {
private final YangInstanceIdentifier path;
TransactionModification(final YangInstanceIdentifier path) {
- this.path = Preconditions.checkNotNull(path);
+ this.path = requireNonNull(path);
}
public final YangInstanceIdentifier getPath() {
}
public final YangInstanceIdentifier getPath() {
*/
package org.opendaylight.controller.cluster.access.concepts;
*/
package org.opendaylight.controller.cluster.access.concepts;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
}
Proxy(final FrontendIdentifier frontendId, final long generation) {
}
Proxy(final FrontendIdentifier frontendId, final long generation) {
- this.frontendId = Preconditions.checkNotNull(frontendId);
+ this.frontendId = requireNonNull(frontendId);
this.generation = generation;
}
this.generation = generation;
}
private final long generation;
ClientIdentifier(final FrontendIdentifier frontendId, final long generation) {
private final long generation;
ClientIdentifier(final FrontendIdentifier frontendId, final long generation) {
- this.frontendId = Preconditions.checkNotNull(frontendId);
+ this.frontendId = requireNonNull(frontendId);
this.generation = generation;
}
this.generation = generation;
}
*/
package org.opendaylight.controller.cluster.access.concepts;
*/
package org.opendaylight.controller.cluster.access.concepts;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.io.Serializable;
import org.opendaylight.yangtools.concepts.Immutable;
import java.io.Serializable;
import org.opendaylight.yangtools.concepts.Immutable;
private final long sessionId;
Envelope(final T message, final long sessionId, final long txSequence) {
private final long sessionId;
Envelope(final T message, final long sessionId, final long txSequence) {
- this.message = Preconditions.checkNotNull(message);
+ this.message = requireNonNull(message);
this.sessionId = sessionId;
this.txSequence = txSequence;
}
this.sessionId = sessionId;
this.txSequence = txSequence;
}
*/
package org.opendaylight.controller.cluster.access.concepts;
*/
package org.opendaylight.controller.cluster.access.concepts;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
}
Proxy(final MemberName memberName, final FrontendType clientType) {
}
Proxy(final MemberName memberName, final FrontendType clientType) {
- this.memberName = Preconditions.checkNotNull(memberName);
- this.clientType = Preconditions.checkNotNull(clientType);
+ this.memberName = requireNonNull(memberName);
+ this.clientType = requireNonNull(clientType);
private final FrontendType clientType;
FrontendIdentifier(final MemberName memberName, final FrontendType clientType) {
private final FrontendType clientType;
FrontendIdentifier(final MemberName memberName, final FrontendType clientType) {
- this.clientType = Preconditions.checkNotNull(clientType);
- this.memberName = Preconditions.checkNotNull(memberName);
+ this.clientType = requireNonNull(clientType);
+ this.memberName = requireNonNull(memberName);
}
public static FrontendIdentifier create(final MemberName memberName, final FrontendType clientType) {
}
public static FrontendIdentifier create(final MemberName memberName, final FrontendType clientType) {
*/
package org.opendaylight.controller.cluster.access.concepts;
*/
package org.opendaylight.controller.cluster.access.concepts;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
}
Proxy(final ClientIdentifier frontendId, final long historyId, final long cookie) {
}
Proxy(final ClientIdentifier frontendId, final long historyId, final long cookie) {
- this.clientId = Preconditions.checkNotNull(frontendId);
+ this.clientId = requireNonNull(frontendId);
this.historyId = historyId;
this.cookie = cookie;
}
this.historyId = historyId;
this.cookie = cookie;
}
}
public LocalHistoryIdentifier(final ClientIdentifier frontendId, final long historyId, final long cookie) {
}
public LocalHistoryIdentifier(final ClientIdentifier frontendId, final long historyId, final long cookie) {
- this.clientId = Preconditions.checkNotNull(frontendId);
+ this.clientId = requireNonNull(frontendId);
this.historyId = historyId;
this.cookie = cookie;
}
this.historyId = historyId;
this.cookie = cookie;
}
*/
package org.opendaylight.controller.cluster.access.concepts;
*/
package org.opendaylight.controller.cluster.access.concepts;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.base.Strings;
-import com.google.common.base.Verify;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.DataInput;
import java.io.DataOutput;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.DataInput;
import java.io.DataOutput;
}
Proxy(final byte[] serialized) {
}
Proxy(final byte[] serialized) {
- this.serialized = Preconditions.checkNotNull(serialized);
+ this.serialized = requireNonNull(serialized);
private volatile byte[] serialized;
private MemberName(final String name) {
private volatile byte[] serialized;
private MemberName(final String name) {
- this.name = Preconditions.checkNotNull(name);
+ this.name = requireNonNull(name);
}
MemberName(final String name, final byte[] serialized) {
this(name);
}
MemberName(final String name, final byte[] serialized) {
this(name);
- this.serialized = Verify.verifyNotNull(serialized);
+ this.serialized = verifyNotNull(serialized);
}
public static MemberName forName(final String name) {
}
public static MemberName forName(final String name) {
- Preconditions.checkArgument(!Strings.isNullOrEmpty(name));
+ checkArgument(!Strings.isNullOrEmpty(name));
// TODO: consider caching instances here
return new MemberName(name);
}
// TODO: consider caching instances here
return new MemberName(name);
}
*/
package org.opendaylight.controller.cluster.access.concepts;
*/
package org.opendaylight.controller.cluster.access.concepts;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
/**
import com.google.common.base.Strings;
/**
private static final long serialVersionUID = 1L;
public RuntimeRequestException(final String message, final Throwable cause) {
private static final long serialVersionUID = 1L;
public RuntimeRequestException(final String message, final Throwable cause) {
- super(message, Preconditions.checkNotNull(cause));
- Preconditions.checkArgument(!Strings.isNullOrEmpty(message), "Exception message is mandatory");
+ super(message, requireNonNull(cause));
+ checkArgument(!Strings.isNullOrEmpty(message), "Exception message is mandatory");
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import akka.actor.ActorRef;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.access.ABIVersion;
/**
import org.opendaylight.controller.cluster.access.ABIVersion;
/**
protected BackendInfo(final ActorRef actor, final String name, final long sessionId, final ABIVersion version,
final int maxMessages) {
protected BackendInfo(final ActorRef actor, final String name, final long sessionId, final ABIVersion version,
final int maxMessages) {
- this.version = Preconditions.checkNotNull(version);
- this.actor = Preconditions.checkNotNull(actor);
- this.name = Preconditions.checkNotNull(name);
- Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
+ this.version = requireNonNull(version);
+ this.actor = requireNonNull(actor);
+ this.name = requireNonNull(name);
+ checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
this.maxMessages = maxMessages;
this.sessionId = sessionId;
}
this.maxMessages = maxMessages;
this.sessionId = sessionId;
}
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
import java.util.function.Consumer;
import org.opendaylight.controller.cluster.access.concepts.Request;
import org.opendaylight.controller.cluster.access.concepts.Response;
import java.util.function.Consumer;
import org.opendaylight.controller.cluster.access.concepts.Request;
import org.opendaylight.controller.cluster.access.concepts.Response;
private final long enqueuedTicks;
ConnectionEntry(final Request<?, ?> request, final Consumer<Response<?, ?>> callback, final long now) {
private final long enqueuedTicks;
ConnectionEntry(final Request<?, ?> request, final Consumer<Response<?, ?>> callback, final long now) {
- this.request = Preconditions.checkNotNull(request);
- this.callback = Preconditions.checkNotNull(callback);
+ this.request = requireNonNull(request);
+ this.callback = requireNonNull(callback);
this.enqueuedTicks = now;
}
this.enqueuedTicks = now;
}
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorSystem;
import akka.persistence.SnapshotSelectionCriteria;
import akka.actor.ActorSystem;
import akka.persistence.SnapshotSelectionCriteria;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
/**
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
/**
InitialClientActorContext(final AbstractClientActor actor, final String persistenceId) {
super(actor.self(), persistenceId);
InitialClientActorContext(final AbstractClientActor actor, final String persistenceId) {
super(actor.self(), persistenceId);
- this.actor = Preconditions.checkNotNull(actor);
+ this.actor = requireNonNull(actor);
}
void saveSnapshot(final ClientIdentifier snapshot) {
}
void saveSnapshot(final ClientIdentifier snapshot) {
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import java.util.concurrent.CountDownLatch;
/**
import java.util.concurrent.CountDownLatch;
/**
private final transient CountDownLatch latch;
InversibleLockException(final CountDownLatch latch) {
private final transient CountDownLatch latch;
InversibleLockException(final CountDownLatch latch) {
- this.latch = Preconditions.checkNotNull(latch);
+ this.latch = requireNonNull(latch);
}
public void awaitResolution() {
}
public void awaitResolution() {
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
/**
* Forwarder class responsible for routing requests from the previous connection incarnation back to the originator,
/**
* Forwarder class responsible for routing requests from the previous connection incarnation back to the originator,
private final AbstractReceivingClientConnection<?> successor;
protected ReconnectForwarder(final AbstractReceivingClientConnection<?> successor) {
private final AbstractReceivingClientConnection<?> successor;
protected ReconnectForwarder(final AbstractReceivingClientConnection<?> successor) {
- this.successor = Preconditions.checkNotNull(successor);
+ this.successor = requireNonNull(successor);
}
protected final void sendToSuccessor(final ConnectionEntry entry) {
}
protected final void sendToSuccessor(final ConnectionEntry entry) {
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.cluster.access.concepts.RequestException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.controller.cluster.access.concepts.RequestException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection, final RequestException cause) {
super(oldConnection);
ReconnectingClientConnection(final ConnectedClientConnection<T> oldConnection, final RequestException cause) {
super(oldConnection);
- this.cause = Preconditions.checkNotNull(cause);
+ this.cause = requireNonNull(cause);
@Override
@SuppressWarnings("checkstyle:hiddenField")
ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
@Override
@SuppressWarnings("checkstyle:hiddenField")
ClientActorBehavior<T> lockedReconnect(final ClientActorBehavior<T> current, final RequestException cause) {
- this.cause = Preconditions.checkNotNull(cause);
+ this.cause = requireNonNull(cause);
LOG.warn("Skipping reconnect of already-reconnecting connection {}", this);
return current;
}
LOG.warn("Skipping reconnect of already-reconnecting connection {}", this);
return current;
}
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static java.util.Objects.requireNonNull;
+
import akka.persistence.RecoveryCompleted;
import akka.persistence.SnapshotOffer;
import akka.persistence.RecoveryCompleted;
import akka.persistence.SnapshotOffer;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
import org.slf4j.Logger;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
import org.slf4j.Logger;
RecoveringClientActorBehavior(final InitialClientActorContext context, final FrontendIdentifier frontendId) {
super(context);
RecoveringClientActorBehavior(final InitialClientActorContext context, final FrontendIdentifier frontendId) {
super(context);
- currentFrontend = Preconditions.checkNotNull(frontendId);
+ currentFrontend = requireNonNull(frontendId);
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static java.util.Objects.requireNonNull;
+
import akka.persistence.DeleteSnapshotsFailure;
import akka.persistence.DeleteSnapshotsSuccess;
import akka.persistence.SaveSnapshotFailure;
import akka.persistence.SaveSnapshotSuccess;
import akka.persistence.SnapshotSelectionCriteria;
import akka.persistence.DeleteSnapshotsFailure;
import akka.persistence.DeleteSnapshotsSuccess;
import akka.persistence.SaveSnapshotFailure;
import akka.persistence.SaveSnapshotSuccess;
import akka.persistence.SnapshotSelectionCriteria;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
SavingClientActorBehavior(final InitialClientActorContext context, final ClientIdentifier nextId) {
super(context);
SavingClientActorBehavior(final InitialClientActorContext context, final ClientIdentifier nextId) {
super(context);
- this.myId = Preconditions.checkNotNull(nextId);
+ this.myId = requireNonNull(nextId);
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import com.google.common.annotations.VisibleForTesting;
import akka.actor.ActorRef;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayDeque;
import java.util.ArrayList;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayDeque;
import java.util.ArrayList;
Transmitting(final TransmitQueue oldQueue, final int targetDepth, final BackendInfo backend, final long now,
final MessageSlicer messageSlicer) {
super(oldQueue, targetDepth, now);
Transmitting(final TransmitQueue oldQueue, final int targetDepth, final BackendInfo backend, final long now,
final MessageSlicer messageSlicer) {
super(oldQueue, targetDepth, now);
- this.backend = Preconditions.checkNotNull(backend);
- this.messageSlicer = Preconditions.checkNotNull(messageSlicer);
+ this.backend = requireNonNull(backend);
+ this.messageSlicer = requireNonNull(messageSlicer);
}
final void setForwarder(final ReconnectForwarder forwarder, final long now) {
}
final void setForwarder(final ReconnectForwarder forwarder, final long now) {
- Verify.verify(successor == null, "Successor %s already set on connection %s", successor, this);
- successor = Preconditions.checkNotNull(forwarder);
+ verify(successor == null, "Successor %s already set on connection %s", successor, this);
+ successor = requireNonNull(forwarder);
LOG.debug("Connection {} superseded by {}, splicing queue", this, successor);
/*
LOG.debug("Connection {} superseded by {}, splicing queue", this, successor);
/*
*/
package org.opendaylight.controller.cluster.access.client;
*/
package org.opendaylight.controller.cluster.access.client;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.actor.ActorRef;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.persistence.SnapshotMetadata;
import akka.persistence.SnapshotSelectionCriteria;
import akka.persistence.snapshot.japi.SnapshotStore;
import akka.persistence.SnapshotMetadata;
import akka.persistence.SnapshotSelectionCriteria;
import akka.persistence.snapshot.japi.SnapshotStore;
-import com.google.common.base.Preconditions;
import java.util.Optional;
import scala.concurrent.Future;
import scala.concurrent.Promise;
import java.util.Optional;
import scala.concurrent.Future;
import scala.concurrent.Promise;
}
private <T> Future<T> askDelegate(final MockedSnapshotStoreMessage message) {
}
private <T> Future<T> askDelegate(final MockedSnapshotStoreMessage message) {
- Preconditions.checkNotNull(delegate, "Delegate ref wasn't sent");
- final Future<Object> ask = Patterns.ask(delegate, message, TIMEOUT);
- return transform(ask);
+ return transform(Patterns.ask(requireNonNull(delegate, "Delegate ref was not sent"), message, TIMEOUT));
}
private <T> Future<T> transform(final Future<Object> future) {
}
private <T> Future<T> transform(final Future<Object> future) {
*/
package org.opendaylight.controller.messagebus.app.impl;
*/
package org.opendaylight.controller.messagebus.app.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.messagebus.spi.EventSource;
import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.controller.messagebus.spi.EventSource;
import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
*/
EventSourceRegistrationImpl(T instance, EventSourceTopology eventSourceTopology) {
super(instance);
*/
EventSourceRegistrationImpl(T instance, EventSourceTopology eventSourceTopology) {
super(instance);
- this.eventSourceTopology = Preconditions.checkNotNull(eventSourceTopology);
+ this.eventSourceTopology = requireNonNull(eventSourceTopology);
*/
package org.opendaylight.controller.cluster.raft;
*/
package org.opendaylight.controller.cluster.raft;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.ReceiveTimeout;
import akka.actor.UntypedAbstractActor;
import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.ReceiveTimeout;
import akka.actor.UntypedAbstractActor;
-import com.google.common.base.Preconditions;
import java.util.concurrent.TimeoutException;
import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
import java.util.concurrent.TimeoutException;
import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply;
Params(final CaptureSnapshot captureSnapshot, final ElectionTerm electionTerm, final ActorRef replyToActor,
final FiniteDuration receiveTimeout, final String id, final ServerConfigurationPayload peerInfo) {
Params(final CaptureSnapshot captureSnapshot, final ElectionTerm electionTerm, final ActorRef replyToActor,
final FiniteDuration receiveTimeout, final String id, final ServerConfigurationPayload peerInfo) {
- this.captureSnapshot = Preconditions.checkNotNull(captureSnapshot);
- this.electionTerm = Preconditions.checkNotNull(electionTerm);
- this.replyToActor = Preconditions.checkNotNull(replyToActor);
- this.receiveTimeout = Preconditions.checkNotNull(receiveTimeout);
- this.id = Preconditions.checkNotNull(id);
+ this.captureSnapshot = requireNonNull(captureSnapshot);
+ this.electionTerm = requireNonNull(electionTerm);
+ this.replyToActor = requireNonNull(replyToActor);
+ this.receiveTimeout = requireNonNull(receiveTimeout);
+ this.id = requireNonNull(id);
this.peerInformation = peerInfo;
}
}
this.peerInformation = peerInfo;
}
}
import akka.actor.PoisonPill;
import akka.actor.Status;
import com.google.common.annotations.VisibleForTesting;
import akka.actor.PoisonPill;
import akka.actor.Status;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
if (getCurrentBehavior() instanceof AbstractLeader) {
AbstractLeader leader = (AbstractLeader)getCurrentBehavior();
Collection<String> followerIds = leader.getFollowerIds();
if (getCurrentBehavior() instanceof AbstractLeader) {
AbstractLeader leader = (AbstractLeader)getCurrentBehavior();
Collection<String> followerIds = leader.getFollowerIds();
- List<FollowerInfo> followerInfoList = Lists.newArrayListWithCapacity(followerIds.size());
+ List<FollowerInfo> followerInfoList = new ArrayList<>(followerIds.size());
for (String id: followerIds) {
final FollowerLogInformation info = leader.getFollower(id);
followerInfoList.add(new FollowerInfo(id, info.getNextIndex(), info.getMatchIndex(),
for (String id: followerIds) {
final FollowerLogInformation info = leader.getFollower(id);
followerInfoList.add(new FollowerInfo(id, info.getNextIndex(), info.getMatchIndex(),
*/
package org.opendaylight.controller.cluster.raft;
*/
package org.opendaylight.controller.cluster.raft;
+import static java.util.Objects.requireNonNull;
+
import akka.japi.Procedure;
import akka.japi.Procedure;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.DataPersistenceProvider;
import org.opendaylight.controller.cluster.DelegatingPersistentDataProvider;
import org.opendaylight.controller.cluster.PersistentDataProvider;
import org.opendaylight.controller.cluster.DataPersistenceProvider;
import org.opendaylight.controller.cluster.DelegatingPersistentDataProvider;
import org.opendaylight.controller.cluster.PersistentDataProvider;
class RaftActorDelegatingPersistentDataProvider extends DelegatingPersistentDataProvider {
private final PersistentDataProvider persistentProvider;
class RaftActorDelegatingPersistentDataProvider extends DelegatingPersistentDataProvider {
private final PersistentDataProvider persistentProvider;
- RaftActorDelegatingPersistentDataProvider(DataPersistenceProvider delegate,
- PersistentDataProvider persistentProvider) {
+ RaftActorDelegatingPersistentDataProvider(final DataPersistenceProvider delegate,
+ final PersistentDataProvider persistentProvider) {
- this.persistentProvider = Preconditions.checkNotNull(persistentProvider);
+ this.persistentProvider = requireNonNull(persistentProvider);
- public <T> void persistAsync(T entry, Procedure<T> procedure) {
+ public <T> void persistAsync(final T entry, final Procedure<T> procedure) {
doPersist(entry, procedure, true);
}
doPersist(entry, procedure, true);
}
private CaptureSnapshot captureSnapshot;
private long lastSequenceNumber = -1;
private CaptureSnapshot captureSnapshot;
private long lastSequenceNumber = -1;
- private Consumer<Optional<OutputStream>> createSnapshotProcedure;
+ private Consumer<Optional<OutputStream>> createSnapshotProcedure = null;
private ApplySnapshot applySnapshot;
private RaftActorSnapshotCohort snapshotCohort = NoopRaftActorSnapshotCohort.INSTANCE;
private ApplySnapshot applySnapshot;
private RaftActorSnapshotCohort snapshotCohort = NoopRaftActorSnapshotCohort.INSTANCE;
*/
package org.opendaylight.controller.cluster.raft;
*/
package org.opendaylight.controller.cluster.raft;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.Cancellable;
import akka.actor.Cancellable;
-import com.google.common.base.Preconditions;
import scala.concurrent.duration.FiniteDuration;
/**
import scala.concurrent.duration.FiniteDuration;
/**
private final Cancellable cancelTimer;
private boolean canRun = true;
private final Cancellable cancelTimer;
private boolean canRun = true;
- TimedRunnable(FiniteDuration timeout, RaftActor actor) {
- Preconditions.checkNotNull(timeout);
- Preconditions.checkNotNull(actor);
- cancelTimer = actor.getContext().system().scheduler().scheduleOnce(timeout, actor.self(),
- (Runnable) this::cancel, actor.getContext().system().dispatcher(), actor.self());
+ TimedRunnable(final FiniteDuration timeout, final RaftActor actor) {
+ cancelTimer = requireNonNull(actor).getContext().system().scheduler()
+ .scheduleOnce(requireNonNull(timeout), actor.self(), (Runnable) this::cancel,
+ actor.getContext().system().dispatcher(), actor.self());
*/
package org.opendaylight.controller.cluster.raft.base.messages;
*/
package org.opendaylight.controller.cluster.raft.base.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Externalizable;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Externalizable;
import java.io.ObjectInput;
import java.io.ObjectOutput;
private final Object readResolveTo;
private final Object readResolveTo;
- protected EmptyExternalizableProxy(Object readResolveTo) {
- this.readResolveTo = Preconditions.checkNotNull(readResolveTo);
+ protected EmptyExternalizableProxy(final Object readResolveTo) {
+ this.readResolveTo = requireNonNull(readResolveTo);
- public void writeExternal(ObjectOutput out) {
+ public void writeExternal(final ObjectOutput out) {
- public void readExternal(ObjectInput in) {
+ public void readExternal(final ObjectInput in) {
}
protected Object readResolve() {
}
protected Object readResolve() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.raft.behaviors;
package org.opendaylight.controller.cluster.raft.behaviors;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.actor.ActorRef;
import akka.actor.Cancellable;
-import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Random;
import java.util.concurrent.TimeUnit;
private long replicatedToAllIndex = -1;
AbstractRaftActorBehavior(final RaftActorContext context, final RaftState state) {
private long replicatedToAllIndex = -1;
AbstractRaftActorBehavior(final RaftActorContext context, final RaftState state) {
- this.context = Preconditions.checkNotNull(context);
- this.state = Preconditions.checkNotNull(state);
+ this.context = requireNonNull(context);
+ this.state = requireNonNull(state);
this.log = context.getLogger();
logName = String.format("%s (%s)", context.getId(), state);
this.log = context.getLogger();
logName = String.format("%s (%s)", context.getId(), state);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.raft.behaviors;
package org.opendaylight.controller.cluster.raft.behaviors;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final String leaderId;
LeaderInfo(final String leaderId, final long minimumCommitIndex) {
final String leaderId;
LeaderInfo(final String leaderId, final long minimumCommitIndex) {
- this.leaderId = Preconditions.checkNotNull(leaderId);
+ this.leaderId = requireNonNull(leaderId);
this.minimumCommitIndex = minimumCommitIndex;
}
}
this.minimumCommitIndex = minimumCommitIndex;
}
}
private boolean syncStatus;
public SyncStatusTracker(final ActorRef actor, final String id, final long syncThreshold) {
private boolean syncStatus;
public SyncStatusTracker(final ActorRef actor, final String id, final long syncThreshold) {
- this.actor = Preconditions.checkNotNull(actor, "actor should not be null");
- this.id = Preconditions.checkNotNull(id, "id should not be null");
- Preconditions.checkArgument(syncThreshold >= 0, "syncThreshold should be greater than or equal to 0");
+ this.actor = requireNonNull(actor, "actor should not be null");
+ this.id = requireNonNull(id, "id should not be null");
+ checkArgument(syncThreshold >= 0, "syncThreshold should be greater than or equal to 0");
this.syncThreshold = syncThreshold;
}
public void update(final String leaderId, final long leaderCommit, final long commitIndex) {
this.syncThreshold = syncThreshold;
}
public void update(final String leaderId, final long leaderCommit, final long commitIndex) {
- Preconditions.checkNotNull(leaderId, "leaderId should not be null");
+ requireNonNull(leaderId, "leaderId should not be null");
if (syncTarget == null || !leaderId.equals(syncTarget.leaderId)) {
LOG.debug("{}: Last sync leader does not match current leader {}, need to catch up to {}", id,
if (syncTarget == null || !leaderId.equals(syncTarget.leaderId)) {
LOG.debug("{}: Last sync leader does not match current leader {}, need to catch up to {}", 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
*/
* 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.raft.messages;
package org.opendaylight.controller.cluster.raft.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Serializable;
/**
import java.io.Serializable;
/**
private final String serverId;
private final String serverId;
- public RemoveServer(String serverId) {
- this.serverId = Preconditions.checkNotNull(serverId);
+ public RemoveServer(final String serverId) {
+ this.serverId = requireNonNull(serverId);
}
public String getServerId() {
}
public String getServerId() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.raft.messages;
package org.opendaylight.controller.cluster.raft.messages;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
import java.io.Serializable;
/**
import java.io.Serializable;
/**
private final ActorRef replyTo;
public RequestLeadership(final String requestedFollowerId, final ActorRef replyTo) {
private final ActorRef replyTo;
public RequestLeadership(final String requestedFollowerId, final ActorRef replyTo) {
- this.requestedFollowerId = Preconditions.checkNotNull(requestedFollowerId);
- this.replyTo = Preconditions.checkNotNull(replyTo);
+ this.requestedFollowerId = requireNonNull(requestedFollowerId);
+ this.replyTo = requireNonNull(replyTo);
}
public String getRequestedFollowerId() {
}
public String getRequestedFollowerId() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.raft.messages;
package org.opendaylight.controller.cluster.raft.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Serializable;
/**
import java.io.Serializable;
/**
private final String serverId;
private final String serverId;
- public ServerRemoved(String serverId) {
- this.serverId = Preconditions.checkNotNull(serverId);
+ public ServerRemoved(final String serverId) {
+ this.serverId = requireNonNull(serverId);
}
public String getServerId() {
}
public String getServerId() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.raft.persisted;
package org.opendaylight.controller.cluster.raft.persisted;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
this.replicatedLogEntry = replicatedLogEntry;
}
this.replicatedLogEntry = replicatedLogEntry;
}
- static int estimatedSerializedSize(ReplicatedLogEntry replicatedLogEntry) {
+ static int estimatedSerializedSize(final ReplicatedLogEntry replicatedLogEntry) {
return 8 /* index */ + 8 /* term */ + replicatedLogEntry.getData().size()
+ 400 /* estimated extra padding for class info */;
}
return 8 /* index */ + 8 /* term */ + replicatedLogEntry.getData().size()
+ 400 /* estimated extra padding for class info */;
}
* @param term the term
* @param payload the payload
*/
* @param term the term
* @param payload the payload
*/
- public SimpleReplicatedLogEntry(long index, long term, Payload payload) {
+ public SimpleReplicatedLogEntry(final long index, final long term, final Payload payload) {
this.index = index;
this.term = term;
this.index = index;
this.term = term;
- this.payload = Preconditions.checkNotNull(payload);
+ this.payload = requireNonNull(payload);
- public void setPersistencePending(boolean pending) {
+ public void setPersistencePending(final boolean pending) {
persistencePending = pending;
}
persistencePending = pending;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (this == obj) {
return true;
}
import akka.actor.Props;
import akka.testkit.TestActorRef;
import com.google.common.collect.ImmutableMap;
import akka.actor.Props;
import akka.testkit.TestActorRef;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Arrays;
import java.util.HashMap;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Arrays;
import java.util.HashMap;
DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
"test", new ElectionTermImpl(createProvider(), "test", LOG), -1, -1,
DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
"test", new ElectionTermImpl(createProvider(), "test", LOG), -1, -1,
- Maps.newHashMap(ImmutableMap.<String, String>of("peer1", "peerAddress1")), configParams,
+ new HashMap<>(ImmutableMap.of("peer1", "peerAddress1")), configParams,
createProvider(), applyState -> { }, LOG, MoreExecutors.directExecutor());
context.setPeerAddress("peer1", "peerAddress1_1");
createProvider(), applyState -> { }, LOG, MoreExecutors.directExecutor());
context.setPeerAddress("peer1", "peerAddress1_1");
public void testUpdatePeerIds() {
RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
"self", new ElectionTermImpl(createProvider(), "test", LOG), -1, -1,
public void testUpdatePeerIds() {
RaftActorContextImpl context = new RaftActorContextImpl(actor, actor.underlyingActor().getContext(),
"self", new ElectionTermImpl(createProvider(), "test", LOG), -1, -1,
- Maps.newHashMap(ImmutableMap.<String, String>of("peer1", "peerAddress1")),
+ new HashMap<>(ImmutableMap.of("peer1", "peerAddress1")),
new DefaultConfigParamsImpl(), createProvider(), applyState -> { }, LOG,
MoreExecutors.directExecutor());
new DefaultConfigParamsImpl(), createProvider(), applyState -> { }, LOG,
MoreExecutors.directExecutor());
import akka.testkit.javadsl.TestKit;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableMap;
import akka.testkit.javadsl.TestKit;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
import com.google.common.io.ByteSource;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.OutputStream;
import com.google.common.io.ByteSource;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.List;
import java.util.Map;
import java.util.Optional;
// Verify new server config was applied in both followers
// Verify new server config was applied in both followers
- assertEquals("Follower peers", Sets.newHashSet(LEADER_ID, NEW_SERVER_ID), followerActorContext.getPeerIds());
+ assertEquals("Follower peers", ImmutableSet.of(LEADER_ID, NEW_SERVER_ID), followerActorContext.getPeerIds());
- assertEquals("New follower peers", Sets.newHashSet(LEADER_ID, FOLLOWER_ID),
+ assertEquals("New follower peers", ImmutableSet.of(LEADER_ID, FOLLOWER_ID),
newFollowerActorContext.getPeerIds());
assertEquals("Follower commit index", 3, followerActorContext.getCommitIndex());
newFollowerActorContext.getPeerIds());
assertEquals("Follower commit index", 3, followerActorContext.getCommitIndex());
// Verify new server config was applied in the new follower
// Verify new server config was applied in the new follower
- assertEquals("New follower peers", Sets.newHashSet(LEADER_ID), newFollowerActorContext.getPeerIds());
+ assertEquals("New follower peers", ImmutableSet.of(LEADER_ID), newFollowerActorContext.getPeerIds());
LOG.info("testAddServerWithNoExistingFollower ending");
}
LOG.info("testAddServerWithNoExistingFollower ending");
}
// Verify new server config was applied in the new follower
// Verify new server config was applied in the new follower
- assertEquals("New follower peers", Sets.newHashSet(LEADER_ID), newFollowerActorContext.getPeerIds());
+ assertEquals("New follower peers", ImmutableSet.of(LEADER_ID), newFollowerActorContext.getPeerIds());
assertNoneMatching(newFollowerCollectorActor, InstallSnapshot.class, 500);
assertNoneMatching(newFollowerCollectorActor, InstallSnapshot.class, 500);
// Verify ServerConfigurationPayload entry in the new follower
expectMatching(newFollowerCollectorActor, ApplyState.class, 2);
// Verify ServerConfigurationPayload entry in the new follower
expectMatching(newFollowerCollectorActor, ApplyState.class, 2);
- assertEquals("New follower peers", Sets.newHashSet(LEADER_ID, NEW_SERVER_ID2),
+ assertEquals("New follower peers", ImmutableSet.of(LEADER_ID, NEW_SERVER_ID2),
newFollowerActorContext.getPeerIds());
LOG.info("testAddServerWithOperationInProgress ending");
newFollowerActorContext.getPeerIds());
LOG.info("testAddServerWithOperationInProgress ending");
ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
assertEquals("getStatus", ServerChangeStatus.NO_LEADER, reply.getStatus());
ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
assertEquals("getStatus", ServerChangeStatus.NO_LEADER, reply.getStatus());
- assertEquals("Server config", Sets.newHashSet(nonVotingServer(node1ID), votingServer(node2ID)),
- Sets.newHashSet(node1RaftActor.getRaftActorContext().getPeerServerInfo(true).getServerConfig()));
+ assertEquals("Server config", ImmutableSet.of(nonVotingServer(node1ID), votingServer(node2ID)),
+ new HashSet<>(node1RaftActor.getRaftActorContext().getPeerServerInfo(true).getServerConfig()));
assertEquals("getRaftState", RaftState.Follower, node1RaftActor.getRaftState());
LOG.info("testChangeToVotingWithNoLeaderAndElectionTimeout ending");
assertEquals("getRaftState", RaftState.Follower, node1RaftActor.getRaftState());
LOG.info("testChangeToVotingWithNoLeaderAndElectionTimeout ending");
ReplicatedLogEntry logEntry = log.get(log.lastIndex());
assertEquals("Last log entry payload class", ServerConfigurationPayload.class, logEntry.getData().getClass());
ServerConfigurationPayload payload = (ServerConfigurationPayload)logEntry.getData();
ReplicatedLogEntry logEntry = log.get(log.lastIndex());
assertEquals("Last log entry payload class", ServerConfigurationPayload.class, logEntry.getData().getClass());
ServerConfigurationPayload payload = (ServerConfigurationPayload)logEntry.getData();
- assertEquals("Server config", Sets.newHashSet(expected), Sets.newHashSet(payload.getServerConfig()));
+ assertEquals("Server config", ImmutableSet.copyOf(expected), new HashSet<>(payload.getServerConfig()));
}
private static RaftActorContextImpl newFollowerContext(final String id,
}
private static RaftActorContextImpl newFollowerContext(final String id,
public static class MockNewFollowerRaftActor extends AbstractMockRaftActor {
public MockNewFollowerRaftActor(final ConfigParams config, final ActorRef collectorActor) {
public static class MockNewFollowerRaftActor extends AbstractMockRaftActor {
public MockNewFollowerRaftActor(final ConfigParams config, final ActorRef collectorActor) {
- super(NEW_SERVER_ID, Maps.<String, String>newHashMap(), Optional.of(config), NO_PERSISTENCE,
- collectorActor);
+ super(NEW_SERVER_ID, new HashMap<>(), Optional.of(config), NO_PERSISTENCE, collectorActor);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.raft.utils;
import akka.dispatch.Futures;
package org.opendaylight.controller.cluster.raft.utils;
import akka.dispatch.Futures;
import akka.persistence.SnapshotMetadata;
import akka.persistence.SnapshotSelectionCriteria;
import akka.persistence.snapshot.japi.SnapshotStore;
import akka.persistence.SnapshotMetadata;
import akka.persistence.SnapshotSelectionCriteria;
import akka.persistence.snapshot.japi.SnapshotStore;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.ArrayList;
import java.util.Collections;
import com.google.common.util.concurrent.Uninterruptibles;
import java.util.ArrayList;
import java.util.Collections;
List<T> retList;
synchronized (stored) {
List<T> retList;
synchronized (stored) {
- retList = Lists.newArrayListWithCapacity(stored.size());
+ retList = new ArrayList<>(stored.size());
for (StoredSnapshot s: stored) {
if (type.isInstance(s.data)) {
retList.add((T) s.data);
for (StoredSnapshot s: stored) {
if (type.isInstance(s.data)) {
retList.add((T) s.data);
*/
package org.opendaylight.controller.md.sal.binding.compat;
*/
package org.opendaylight.controller.md.sal.binding.compat;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.yang.binding.Notification;
protected AbstractNotificationListenerRegistration(final Class<? extends Notification> type,
final NotificationListener<T> listener) {
super(listener);
protected AbstractNotificationListenerRegistration(final Class<? extends Notification> type,
final NotificationListener<T> listener) {
super(listener);
- this.type = Preconditions.checkNotNull(type);
+ this.type = requireNonNull(type);
*/
package org.opendaylight.controller.md.sal.binding.compat;
*/
package org.opendaylight.controller.md.sal.binding.compat;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.yangtools.yang.binding.Notification;
protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type,
final NotificationListener<N> listener, final A aggregator) {
super(type, listener);
protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type,
final NotificationListener<N> listener, final A aggregator) {
super(type, listener);
- this.aggregator = Preconditions.checkNotNull(aggregator);
+ this.aggregator = requireNonNull(aggregator);
}
protected A getAggregator() {
}
protected A getAggregator() {
*/
package org.opendaylight.controller.md.sal.binding.impl;
*/
package org.opendaylight.controller.md.sal.binding.impl;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
private final BindingToNormalizedNodeCodec codec;
AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
private final BindingToNormalizedNodeCodec codec;
AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
- this.delegate = Preconditions.checkNotNull(delegateTx, "Delegate must not be null");
- this.codec = Preconditions.checkNotNull(codec, "Codec must not be null");
+ this.delegate = requireNonNull(delegateTx, "Delegate must not be null");
+ this.codec = requireNonNull(codec, "Codec must not be null");
@Override
public final Object getIdentifier() {
return delegate.getIdentifier();
@Override
public final Object getIdentifier() {
return delegate.getIdentifier();
*/
package org.opendaylight.controller.md.sal.binding.impl;
*/
package org.opendaylight.controller.md.sal.binding.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import java.util.Collection;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
*/
@Deprecated
class BindingDOMDataTreeChangeListenerAdapter<T extends DataObject> implements DOMDataTreeChangeListener {
*/
@Deprecated
class BindingDOMDataTreeChangeListenerAdapter<T extends DataObject> implements DOMDataTreeChangeListener {
private final BindingToNormalizedNodeCodec codec;
private final DataTreeChangeListener<T> listener;
private final LogicalDatastoreType store;
BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
private final BindingToNormalizedNodeCodec codec;
private final DataTreeChangeListener<T> listener;
private final LogicalDatastoreType store;
BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
- this.codec = Preconditions.checkNotNull(codec);
- this.listener = Preconditions.checkNotNull(listener);
- this.store = Preconditions.checkNotNull(store);
+ this.codec = requireNonNull(codec);
+ this.listener = requireNonNull(listener);
+ this.store = requireNonNull(store);
*/
package org.opendaylight.controller.md.sal.binding.impl;
*/
package org.opendaylight.controller.md.sal.binding.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService;
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
/**
* Adapter exposing Binding {@link DataTreeChangeService} and wrapping
* {@link DOMDataTreeChangeService} and is responsible for translation
/**
* Adapter exposing Binding {@link DataTreeChangeService} and wrapping
* {@link DOMDataTreeChangeService} and is responsible for translation
private BindingDOMDataTreeChangeServiceAdapter(final BindingToNormalizedNodeCodec codec,
final DOMDataTreeChangeService dataTreeChangeService) {
private BindingDOMDataTreeChangeServiceAdapter(final BindingToNormalizedNodeCodec codec,
final DOMDataTreeChangeService dataTreeChangeService) {
- this.codec = Preconditions.checkNotNull(codec);
- this.dataTreeChangeService = Preconditions.checkNotNull(dataTreeChangeService);
+ this.codec = requireNonNull(codec);
+ this.dataTreeChangeService = requireNonNull(dataTreeChangeService);
}
static DataTreeChangeService create(final BindingToNormalizedNodeCodec codec,
}
static DataTreeChangeService create(final BindingToNormalizedNodeCodec codec,
*/
package org.opendaylight.controller.md.sal.binding.impl;
*/
package org.opendaylight.controller.md.sal.binding.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
- Preconditions.checkNotNull(chainFactory, "DOM Transaction chain factory must not be null");
this.domListener = new DelegateChainListener();
this.bindingListener = listener;
this.domListener = new DelegateChainListener();
this.bindingListener = listener;
- this.delegate = chainFactory.createTransactionChain(domListener);
+ this.delegate = requireNonNull(chainFactory, "DOM Transaction chain factory must not be null")
+ .createTransactionChain(domListener);
}
private final class DelegateChainListener implements TransactionChainListener {
}
private final class DelegateChainListener implements TransactionChainListener {
@Override
public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
final AsyncTransaction<?, ?> transaction, final Throwable cause) {
@Override
public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
final AsyncTransaction<?, ?> transaction, final Throwable cause) {
- Preconditions.checkState(delegate.equals(chain),
- "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
/*
* Intentionally NOOP, callback for failure, since we
* are also listening on each transaction future for failure,
/*
* Intentionally NOOP, callback for failure, since we
* are also listening on each transaction future for failure,
* of this transaction chain), instead of DOM transaction
* which is known only to this chain, binding transaction implementation
* and underlying transaction chain.
* of this transaction chain), instead of DOM transaction
* which is known only to this chain, binding transaction implementation
* and underlying transaction chain.
*/
LOG.debug("Transaction chain {} failed. Failed DOM Transaction {}",this,transaction,cause);
}
@Override
public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
*/
LOG.debug("Transaction chain {} failed. Failed DOM Transaction {}",this,transaction,cause);
}
@Override
public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- Preconditions.checkState(delegate.equals(chain),
- "Illegal state - listener for %s was invoked for incorrect chain %s.", delegate, chain);
bindingListener.onTransactionChainSuccessful(BindingDOMTransactionChainAdapter.this);
}
bindingListener.onTransactionChainSuccessful(BindingDOMTransactionChainAdapter.this);
}
+
+ private void checkChain(final TransactionChain<?, ?> chain) {
+ checkState(delegate.equals(chain), "Illegal state - listener for %s was invoked for incorrect chain %s.",
+ delegate, chain);
+ }
*/
package org.opendaylight.controller.md.sal.binding.impl;
*/
package org.opendaylight.controller.md.sal.binding.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
BindingDataTreeChangeListenerRegistration(final L listener, final ListenerRegistration<?> domReg) {
super(listener);
BindingDataTreeChangeListenerRegistration(final L listener, final ListenerRegistration<?> domReg) {
super(listener);
- this.domReg = Preconditions.checkNotNull(domReg);
+ this.domReg = requireNonNull(domReg);
*/
package org.opendaylight.controller.md.sal.binding.impl;
*/
package org.opendaylight.controller.md.sal.binding.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
private LazyDOMRpcResultFuture(final ListenableFuture<RpcResult<?>> delegate,
final BindingNormalizedNodeSerializer codec) {
private LazyDOMRpcResultFuture(final ListenableFuture<RpcResult<?>> delegate,
final BindingNormalizedNodeSerializer codec) {
- this.bindingFuture = Preconditions.checkNotNull(delegate, "delegate");
- this.codec = Preconditions.checkNotNull(codec, "codec");
+ this.bindingFuture = requireNonNull(delegate, "delegate");
+ this.codec = requireNonNull(codec, "codec");
}
static CheckedFuture<DOMRpcResult, DOMRpcException> create(final BindingNormalizedNodeSerializer codec,
}
static CheckedFuture<DOMRpcResult, DOMRpcException> create(final BindingNormalizedNodeSerializer codec,
*/
package org.opendaylight.controller.md.sal.binding.impl;
*/
package org.opendaylight.controller.md.sal.binding.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
RpcServiceAdapter(final Class<? extends RpcService> type, final BindingToNormalizedNodeCodec codec,
final DOMRpcService domService) {
RpcServiceAdapter(final Class<? extends RpcService> type, final BindingToNormalizedNodeCodec codec,
final DOMRpcService domService) {
- this.type = Preconditions.checkNotNull(type);
- this.codec = Preconditions.checkNotNull(codec);
- this.delegate = Preconditions.checkNotNull(domService);
+ this.type = requireNonNull(type);
+ this.codec = requireNonNull(codec);
+ this.delegate = requireNonNull(domService);
final ImmutableMap.Builder<Method, RpcInvocationStrategy> rpcBuilder = ImmutableMap.builder();
for (final Entry<Method, RpcDefinition> rpc : codec.getRpcMethodToSchema(type).entrySet()) {
rpcBuilder.put(rpc.getKey(), createStrategy(rpc.getKey(), rpc.getValue()));
final ImmutableMap.Builder<Method, RpcInvocationStrategy> rpcBuilder = ImmutableMap.builder();
for (final Entry<Method, RpcDefinition> rpc : codec.getRpcMethodToSchema(type).entrySet()) {
rpcBuilder.put(rpc.getKey(), createStrategy(rpc.getKey(), rpc.getValue()));
*/
package org.opendaylight.controller.md.sal.binding.util;
*/
package org.opendaylight.controller.md.sal.binding.util;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap;
private BindingContextUtils() {
}
private BindingContextUtils() {
}
- public static ConsumerContext createConsumerContext(BindingAwareConsumer consumer,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
- checkNotNull(consumer,"Consumer should not be null");
- checkNotNull(serviceProvider,"Service map should not be null");
- return new SingleConsumerContextImpl(serviceProvider);
+ public static ConsumerContext createConsumerContext(final BindingAwareConsumer consumer,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ requireNonNull(consumer, "Consumer should not be null");
+ return new SingleConsumerContextImpl(requireNonNull(serviceProvider, "Service map should not be null"));
- public static ProviderContext createProviderContext(BindingAwareProvider provider,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
- checkNotNull(provider,"Provider should not be null");
- checkNotNull(serviceProvider,"Service map should not be null");
- return new SingleProviderContextImpl(serviceProvider);
+ public static ProviderContext createProviderContext(final BindingAwareProvider provider,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ requireNonNull(provider, "Provider should not be null");
+ return new SingleProviderContextImpl(requireNonNull(serviceProvider, "Service map should not be null"));
- public static ConsumerContext createConsumerContextAndInitialize(BindingAwareConsumer consumer,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ public static ConsumerContext createConsumerContextAndInitialize(final BindingAwareConsumer consumer,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
ConsumerContext context = createConsumerContext(consumer, serviceProvider);
consumer.onSessionInitialized(context);
return context;
}
ConsumerContext context = createConsumerContext(consumer, serviceProvider);
consumer.onSessionInitialized(context);
return context;
}
- public static ProviderContext createProviderContextAndInitialize(BindingAwareProvider provider,
- ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ public static ProviderContext createProviderContextAndInitialize(final BindingAwareProvider provider,
+ final ClassToInstanceMap<BindingAwareService> serviceProvider) {
ProviderContext context = createProviderContext(provider, serviceProvider);
provider.onSessionInitiated(context);
return context;
}
ProviderContext context = createProviderContext(provider, serviceProvider);
provider.onSessionInitiated(context);
return context;
}
- public static <T extends BindingAwareService> T createContextProxyOrReturnService(Class<T> service, T instance) {
+ public static <T extends BindingAwareService> T createContextProxyOrReturnService(final Class<T> service,
+ final T instance) {
// FIXME: Create Proxy
return instance;
}
// FIXME: Create Proxy
return instance;
}
private ClassToInstanceMap<BindingAwareService> alreadyRetrievedServices;
private ClassToInstanceMap<BindingAwareService> serviceProvider;
private ClassToInstanceMap<BindingAwareService> alreadyRetrievedServices;
private ClassToInstanceMap<BindingAwareService> serviceProvider;
- SingleConsumerContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ SingleConsumerContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
this.serviceProvider = serviceProvider;
}
@Override
this.alreadyRetrievedServices = MutableClassToInstanceMap.create();
this.serviceProvider = serviceProvider;
}
@Override
- public final <T extends RpcService> T getRpcService(Class<T> module) {
+ public final <T extends RpcService> T getRpcService(final Class<T> module) {
return getSALService(RpcConsumerRegistry.class).getRpcService(module);
}
@Override
return getSALService(RpcConsumerRegistry.class).getRpcService(module);
}
@Override
- public final <T extends BindingAwareService> T getSALService(Class<T> service) {
- checkNotNull(service,"Service class should not be null.");
- T potential = alreadyRetrievedServices.getInstance(service);
+ public final <T extends BindingAwareService> T getSALService(final Class<T> service) {
+ T potential = alreadyRetrievedServices.getInstance(requireNonNull(service,
+ "Service class should not be null."));
if (potential != null) {
return potential;
}
return tryToRetrieveSalService(service);
}
if (potential != null) {
return potential;
}
return tryToRetrieveSalService(service);
}
- private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(Class<T> service) {
+ private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(final Class<T> service) {
final T potential = alreadyRetrievedServices.getInstance(service);
if (potential != null) {
return potential;
final T potential = alreadyRetrievedServices.getInstance(service);
if (potential != null) {
return potential;
}
private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext {
}
private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext {
-
- SingleProviderContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
+ SingleProviderContextImpl(final ClassToInstanceMap<BindingAwareService> serviceProvider) {
super(serviceProvider);
}
@Override
public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
super(serviceProvider);
}
@Override
public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
- registerRouteChangeListener(L listener) {
+ registerRouteChangeListener(final L listener) {
return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener);
}
@Override
return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener);
}
@Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type,
- T implementation) throws IllegalStateException {
+ public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(final Class<T> type,
+ final T implementation) {
return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation);
}
@Override
return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation);
}
@Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
- throws IllegalStateException {
+ public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> type,
+ final T implementation) {
return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation);
}
}
return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation);
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.common.actor;
package org.opendaylight.controller.cluster.common.actor;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import scala.concurrent.ExecutionContext;
public class Dispatchers {
import scala.concurrent.ExecutionContext;
public class Dispatchers {
}
public Dispatchers(final akka.dispatch.Dispatchers dispatchers) {
}
public Dispatchers(final akka.dispatch.Dispatchers dispatchers) {
- Preconditions.checkNotNull(dispatchers, "dispatchers should not be null");
- this.dispatchers = dispatchers;
+ this.dispatchers = requireNonNull(dispatchers, "dispatchers should not be null");
}
public ExecutionContext getDispatcher(final DispatcherType dispatcherType) {
}
public ExecutionContext getDispatcher(final DispatcherType dispatcherType) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.node.utils;
package org.opendaylight.controller.cluster.datastore.node.utils;
-import com.google.common.base.Preconditions;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MixinNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MixinNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*/
public class NormalizedNodeNavigator {
*/
public class NormalizedNodeNavigator {
- private final org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor visitor;
+ private final NormalizedNodeVisitor visitor;
- public NormalizedNodeNavigator(
- org.opendaylight.controller.cluster.datastore.node.utils.NormalizedNodeVisitor visitor) {
- Preconditions.checkNotNull(visitor, "visitor should not be null");
- this.visitor = visitor;
+ public NormalizedNodeNavigator(final NormalizedNodeVisitor visitor) {
+ this.visitor = requireNonNull(visitor, "visitor should not be null");
- public void navigate(String parentPath, NormalizedNode<?, ?> normalizedNode) {
+ public void navigate(String parentPath, final NormalizedNode<?, ?> normalizedNode) {
if (parentPath == null) {
parentPath = "";
}
navigateNormalizedNode(0, parentPath, normalizedNode);
}
if (parentPath == null) {
parentPath = "";
}
navigateNormalizedNode(0, parentPath, normalizedNode);
}
- private void navigateDataContainerNode(int level, final String parentPath,
+ private void navigateDataContainerNode(final int level, final String parentPath,
final DataContainerNode<?> dataContainerNode) {
visitor.visitNode(level, parentPath, dataContainerNode);
String newParentPath = parentPath + "/" + dataContainerNode.getIdentifier().toString();
final DataContainerNode<?> dataContainerNode) {
visitor.visitNode(level, parentPath, dataContainerNode);
String newParentPath = parentPath + "/" + dataContainerNode.getIdentifier().toString();
- final Iterable<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> value = dataContainerNode
- .getValue();
- for (NormalizedNode<?, ?> node : value) {
+ for (NormalizedNode<?, ?> node : dataContainerNode.getValue()) {
if (node instanceof MixinNode && node instanceof NormalizedNodeContainer) {
navigateNormalizedNodeContainerMixin(level, newParentPath, (NormalizedNodeContainer<?, ?, ?>) node);
} else {
if (node instanceof MixinNode && node instanceof NormalizedNodeContainer) {
navigateNormalizedNodeContainerMixin(level, newParentPath, (NormalizedNodeContainer<?, ?, ?>) node);
} else {
- private void navigateNormalizedNodeContainerMixin(int level, final String parentPath,
- NormalizedNodeContainer<?, ?, ?> node) {
+ private void navigateNormalizedNodeContainerMixin(final int level, final String parentPath,
+ final NormalizedNodeContainer<?, ?, ?> node) {
visitor.visitNode(level, parentPath, node);
String newParentPath = parentPath + "/" + node.getIdentifier().toString();
visitor.visitNode(level, parentPath, node);
String newParentPath = parentPath + "/" + node.getIdentifier().toString();
- final Iterable<? extends NormalizedNode<?, ?>> value = node.getValue();
- for (NormalizedNode<?, ?> normalizedNode : value) {
+ for (NormalizedNode<?, ?> normalizedNode : node.getValue()) {
if (normalizedNode instanceof MixinNode && normalizedNode instanceof NormalizedNodeContainer) {
navigateNormalizedNodeContainerMixin(level + 1, newParentPath,
(NormalizedNodeContainer<?, ?, ?>) normalizedNode);
if (normalizedNode instanceof MixinNode && normalizedNode instanceof NormalizedNodeContainer) {
navigateNormalizedNodeContainerMixin(level + 1, newParentPath,
(NormalizedNodeContainer<?, ?, ?>) normalizedNode);
- private void navigateNormalizedNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
+ private void navigateNormalizedNode(final int level, final String parentPath,
+ final NormalizedNode<?, ?> normalizedNode) {
if (normalizedNode instanceof DataContainerNode) {
final DataContainerNode<?> dataContainerNode = (DataContainerNode<?>) normalizedNode;
if (normalizedNode instanceof DataContainerNode) {
final DataContainerNode<?> dataContainerNode = (DataContainerNode<?>) normalizedNode;
*/
package org.opendaylight.controller.cluster.datastore.node.utils.stream;
*/
package org.opendaylight.controller.cluster.datastore.node.utils.stream;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.DataOutput;
import java.io.IOException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.DataOutput;
import java.io.IOException;
private boolean inSimple;
AbstractNormalizedNodeDataOutput(final DataOutput output) {
private boolean inSimple;
AbstractNormalizedNodeDataOutput(final DataOutput output) {
- this.output = Preconditions.checkNotNull(output);
+ this.output = requireNonNull(output);
}
private void ensureHeaderWritten() throws IOException {
}
private void ensureHeaderWritten() throws IOException {
@Override
public void startLeafNode(final NodeIdentifier name) throws IOException {
@Override
public void startLeafNode(final NodeIdentifier name) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new leaf node");
startNode(name.getNodeType(), NodeTypes.LEAF_NODE);
inSimple = true;
LOG.trace("Starting a new leaf node");
startNode(name.getNodeType(), NodeTypes.LEAF_NODE);
inSimple = true;
@Override
public void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new leaf set");
lastLeafSetQName = name.getNodeType();
LOG.trace("Starting a new leaf set");
lastLeafSetQName = name.getNodeType();
@Override
public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new ordered leaf set");
lastLeafSetQName = name.getNodeType();
LOG.trace("Starting a new ordered leaf set");
lastLeafSetQName = name.getNodeType();
@Override
public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new container node");
LOG.trace("Starting a new container node");
@Override
public void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new yang modeled anyXml node");
LOG.trace("Starting a new yang modeled anyXml node");
@Override
public void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new unkeyed list");
startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST);
LOG.trace("Starting a new unkeyed list");
startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST);
@Override
public void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new unkeyed list item");
startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST_ITEM);
LOG.trace("Starting a new unkeyed list item");
startNode(name.getNodeType(), NodeTypes.UNKEYED_LIST_ITEM);
@Override
public void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new map node");
startNode(name.getNodeType(), NodeTypes.MAP_NODE);
LOG.trace("Starting a new map node");
startNode(name.getNodeType(), NodeTypes.MAP_NODE);
@Override
public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
throws IOException {
@Override
public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
throws IOException {
- Preconditions.checkNotNull(identifier, "Node identifier should not be null");
+ requireNonNull(identifier, "Node identifier should not be null");
LOG.trace("Starting a new map entry node");
startNode(identifier.getNodeType(), NodeTypes.MAP_ENTRY_NODE);
LOG.trace("Starting a new map entry node");
startNode(identifier.getNodeType(), NodeTypes.MAP_ENTRY_NODE);
@Override
public void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new ordered map node");
startNode(name.getNodeType(), NodeTypes.ORDERED_MAP_NODE);
LOG.trace("Starting a new ordered map node");
startNode(name.getNodeType(), NodeTypes.ORDERED_MAP_NODE);
@Override
public void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
@Override
public void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting a new choice node");
startNode(name.getNodeType(), NodeTypes.CHOICE_NODE);
LOG.trace("Starting a new choice node");
startNode(name.getNodeType(), NodeTypes.CHOICE_NODE);
@Override
public void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
@Override
public void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
- Preconditions.checkNotNull(identifier, "Node identifier should not be null");
+ requireNonNull(identifier, "Node identifier should not be null");
LOG.trace("Starting a new augmentation node");
output.writeByte(NodeTypes.AUGMENTATION_NODE);
LOG.trace("Starting a new augmentation node");
output.writeByte(NodeTypes.AUGMENTATION_NODE);
@Override
public void startAnyxmlNode(final NodeIdentifier name) throws IOException {
@Override
public void startAnyxmlNode(final NodeIdentifier name) throws IOException {
- Preconditions.checkNotNull(name, "Node identifier should not be null");
+ requireNonNull(name, "Node identifier should not be null");
LOG.trace("Starting any xml node");
startNode(name.getNodeType(), NodeTypes.ANY_XML_NODE);
inSimple = true;
LOG.trace("Starting any xml node");
startNode(name.getNodeType(), NodeTypes.ANY_XML_NODE);
inSimple = true;
}
private void startNode(final QName qname, final byte nodeType) throws IOException {
}
private void startNode(final QName qname, final byte nodeType) throws IOException {
- Preconditions.checkNotNull(qname, "QName of node identifier should not be null.");
- Preconditions.checkState(!inSimple, "Attempted to start a child in a simple node");
+ requireNonNull(qname, "QName of node identifier should not be null.");
+ checkState(!inSimple, "Attempted to start a child in a simple node");
private void writeObjSet(final Set<?> set) throws IOException {
output.writeInt(set.size());
for (Object o : set) {
private void writeObjSet(final Set<?> set) throws IOException {
output.writeInt(set.size());
for (Object o : set) {
- Preconditions.checkArgument(o instanceof String, "Expected value type to be String but was %s (%s)",
- o.getClass(), o);
-
+ checkArgument(o instanceof String, "Expected value type to be String but was %s (%s)", o.getClass(), o);
writeString((String) o);
}
}
writeString((String) o);
}
}
*/
package org.opendaylight.controller.cluster.messaging;
*/
package org.opendaylight.controller.cluster.messaging;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
private final Identifier identifier;
AbortSlicing(final Identifier identifier) {
private final Identifier identifier;
AbortSlicing(final Identifier identifier) {
- this.identifier = Preconditions.checkNotNull(identifier);
+ this.identifier = requireNonNull(identifier);
}
Identifier getIdentifier() {
}
Identifier getIdentifier() {
- Proxy(AbortSlicing abortSlicing) {
+ Proxy(final AbortSlicing abortSlicing) {
this.abortSlicing = abortSlicing;
}
@Override
this.abortSlicing = abortSlicing;
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
out.writeObject(abortSlicing.identifier);
}
@Override
out.writeObject(abortSlicing.identifier);
}
@Override
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
abortSlicing = new AbortSlicing((Identifier) in.readObject());
}
abortSlicing = new AbortSlicing((Identifier) in.readObject());
}
*/
package org.opendaylight.controller.cluster.messaging;
*/
package org.opendaylight.controller.cluster.messaging;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.serialization.JavaSerializer;
import akka.serialization.Serialization;
import akka.actor.ActorRef;
import akka.serialization.JavaSerializer;
import akka.serialization.Serialization;
-import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
private final int lastSliceHashCode;
private final ActorRef replyTo;
private final int lastSliceHashCode;
private final ActorRef replyTo;
- MessageSlice(Identifier identifier, byte[] data, int sliceIndex, int totalSlices, int lastSliceHashCode,
- final ActorRef replyTo) {
- this.identifier = Preconditions.checkNotNull(identifier);
- this.data = Preconditions.checkNotNull(data);
+ MessageSlice(final Identifier identifier, final byte[] data, final int sliceIndex, final int totalSlices,
+ final int lastSliceHashCode, final ActorRef replyTo) {
+ this.identifier = requireNonNull(identifier);
+ this.data = requireNonNull(data);
this.sliceIndex = sliceIndex;
this.totalSlices = totalSlices;
this.lastSliceHashCode = lastSliceHashCode;
this.sliceIndex = sliceIndex;
this.totalSlices = totalSlices;
this.lastSliceHashCode = lastSliceHashCode;
- this.replyTo = Preconditions.checkNotNull(replyTo);
+ this.replyTo = requireNonNull(replyTo);
}
public Identifier getIdentifier() {
}
public Identifier getIdentifier() {
- Proxy(MessageSlice messageSlice) {
+ Proxy(final MessageSlice messageSlice) {
this.messageSlice = messageSlice;
}
@Override
this.messageSlice = messageSlice;
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
out.writeObject(messageSlice.identifier);
out.writeInt(messageSlice.sliceIndex);
out.writeInt(messageSlice.totalSlices);
out.writeObject(messageSlice.identifier);
out.writeInt(messageSlice.sliceIndex);
out.writeInt(messageSlice.totalSlices);
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
Identifier identifier = (Identifier) in.readObject();
int sliceIndex = in.readInt();
int totalSlices = in.readInt();
Identifier identifier = (Identifier) in.readObject();
int sliceIndex = in.readInt();
int totalSlices = in.readInt();
*/
package org.opendaylight.controller.cluster.messaging;
*/
package org.opendaylight.controller.cluster.messaging;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
}
private MessageSliceIdentifier(final Identifier clientIdentifier, final long slicerId, final long messageId) {
}
private MessageSliceIdentifier(final Identifier clientIdentifier, final long slicerId, final long messageId) {
- this.clientIdentifier = Preconditions.checkNotNull(clientIdentifier);
+ this.clientIdentifier = requireNonNull(clientIdentifier);
this.messageId = messageId;
this.slicerId = slicerId;
}
this.messageId = messageId;
this.slicerId = slicerId;
}
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (this == obj) {
return true;
}
- Proxy(MessageSliceIdentifier messageSliceId) {
+ Proxy(final MessageSliceIdentifier messageSliceId) {
this.messageSliceId = messageSliceId;
}
@Override
this.messageSliceId = messageSliceId;
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
out.writeObject(messageSliceId.clientIdentifier);
WritableObjects.writeLongs(out, messageSliceId.slicerId, messageSliceId.messageId);
}
@Override
out.writeObject(messageSliceId.clientIdentifier);
WritableObjects.writeLongs(out, messageSliceId.slicerId, messageSliceId.messageId);
}
@Override
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
final Identifier clientIdentifier = (Identifier) in.readObject();
final byte header = WritableObjects.readLongHeader(in);
final long slicerId = WritableObjects.readFirstLong(in, header);
final Identifier clientIdentifier = (Identifier) in.readObject();
final byte header = WritableObjects.readLongHeader(in);
final long slicerId = WritableObjects.readFirstLong(in, header);
*/
package org.opendaylight.controller.cluster.messaging;
*/
package org.opendaylight.controller.cluster.messaging;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.serialization.JavaSerializer;
import akka.serialization.Serialization;
import akka.actor.ActorRef;
import akka.serialization.JavaSerializer;
import akka.serialization.Serialization;
-import com.google.common.base.Preconditions;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
private MessageSliceReply(final Identifier identifier, final int sliceIndex, final MessageSliceException failure,
final ActorRef sendTo) {
private MessageSliceReply(final Identifier identifier, final int sliceIndex, final MessageSliceException failure,
final ActorRef sendTo) {
- this.identifier = Preconditions.checkNotNull(identifier);
+ this.identifier = requireNonNull(identifier);
this.sliceIndex = sliceIndex;
this.sliceIndex = sliceIndex;
- this.sendTo = Preconditions.checkNotNull(sendTo);
+ this.sendTo = requireNonNull(sendTo);
this.failure = failure;
}
this.failure = failure;
}
*/
package org.opendaylight.controller.cluster.messaging;
*/
package org.opendaylight.controller.cluster.messaging;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
-import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.function.Consumer;
import org.opendaylight.controller.cluster.io.FileBackedOutputStream;
import java.io.Serializable;
import java.util.function.Consumer;
import org.opendaylight.controller.cluster.io.FileBackedOutputStream;
public SliceOptions build() {
sealed = true;
public SliceOptions build() {
sealed = true;
- Preconditions.checkNotNull(identifier, "identifier must be set");
- Preconditions.checkNotNull(replyTo, "replyTo must be set");
- Preconditions.checkNotNull(onFailureCallback, "onFailureCallback must be set");
- Preconditions.checkState(fileBackedStream == null || message == null,
+ requireNonNull(identifier, "identifier must be set");
+ requireNonNull(replyTo, "replyTo must be set");
+ requireNonNull(onFailureCallback, "onFailureCallback must be set");
+ checkState(fileBackedStream == null || message == null,
"Only one of message and fileBackedStream can be set");
"Only one of message and fileBackedStream can be set");
- Preconditions.checkState(!(fileBackedStream == null && message == null),
+ checkState(!(fileBackedStream == null && message == null),
"One of message and fileBackedStream must be set");
"One of message and fileBackedStream must be set");
- Preconditions.checkState(sendToRef == null || sendToSelection == null,
+ checkState(sendToRef == null || sendToSelection == null,
"Only one of sendToRef and sendToSelection can be set");
"Only one of sendToRef and sendToSelection can be set");
- Preconditions.checkState(!(sendToRef == null && sendToSelection == null),
+ checkState(!(sendToRef == null && sendToSelection == null),
"One of sendToRef and sendToSelection must be set");
return new SliceOptions(this);
}
protected void checkSealed() {
"One of sendToRef and sendToSelection must be set");
return new SliceOptions(this);
}
protected void checkSealed() {
- Preconditions.checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
+ checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.notifications;
import akka.actor.ActorPath;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.serialization.Serialization;
package org.opendaylight.controller.cluster.notifications;
import akka.actor.ActorPath;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.serialization.Serialization;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import java.util.Map;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
public class RoleChangeNotifier extends AbstractUntypedActor implements AutoCloseable {
private final String memberId;
public class RoleChangeNotifier extends AbstractUntypedActor implements AutoCloseable {
private final String memberId;
- private final Map<ActorPath, ActorRef> registeredListeners = Maps.newHashMap();
+ private final Map<ActorPath, ActorRef> registeredListeners = new HashMap<>();
private RoleChangeNotification latestRoleChangeNotification = null;
private LeaderStateChanged latestLeaderStateChanged;
private RoleChangeNotification latestRoleChangeNotification = null;
private LeaderStateChanged latestLeaderStateChanged;
- public RoleChangeNotifier(String memberId) {
+ public RoleChangeNotifier(final String memberId) {
this.memberId = memberId;
}
this.memberId = memberId;
}
- protected void handleReceive(Object message) {
+ protected void handleReceive(final Object message) {
if (message instanceof RegisterRoleChangeListener) {
// register listeners for this shard
if (message instanceof RegisterRoleChangeListener) {
// register listeners for this shard
*/
package org.opendaylight.controller.md.sal.common.api.data;
*/
package org.opendaylight.controller.md.sal.common.api.data;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.yangtools.concepts.Path;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.yangtools.concepts.Path;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
final String message, final Throwable cause) {
super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "invalid-value", message, null,
path != null ? path.toString() : null, cause));
final String message, final Throwable cause) {
super(message, cause, RpcResultBuilder.newError(ErrorType.APPLICATION, "invalid-value", message, null,
path != null ? path.toString() : null, cause));
- this.pathType = Preconditions.checkNotNull(pathType, "path type must not be null");
- this.path = Preconditions.checkNotNull(path,"path must not be null.");
+ this.pathType = requireNonNull(pathType, "path type must not be null");
+ this.path = requireNonNull(path,"path must not be null.");
- public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
- final String message) {
+ public <P extends Path<P>> DataValidationFailedException(final Class<P> pathType,final P path,
+ final String message) {
this(pathType, path, message, null);
}
this(pathType, path, message, null);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.databroker;
package org.opendaylight.controller.cluster.databroker;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import java.util.ArrayList;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import java.util.ArrayList;
final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories,
final AbstractDOMTransactionFactory<?> commitImpl) {
super(identifier, storeTxFactories);
final Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories,
final AbstractDOMTransactionFactory<?> commitImpl) {
super(identifier, storeTxFactories);
- this.commitImpl = Preconditions.checkNotNull(commitImpl, "commitImpl must not be null.");
+ this.commitImpl = requireNonNull(commitImpl, "commitImpl must not be null.");
private static void checkInstanceIdentifierReferencesData(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
private static void checkInstanceIdentifierReferencesData(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
- Preconditions.checkArgument(data != null, "Attempted to store null data at %s", path);
+ checkArgument(data != null, "Attempted to store null data at %s", path);
final PathArgument lastArg = path.getLastPathArgument();
final PathArgument lastArg = path.getLastPathArgument();
- Preconditions.checkArgument(
- lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()),
+ checkArgument(lastArg == data.getIdentifier() || lastArg != null && lastArg.equals(data.getIdentifier()),
"Instance identifier references %s but data identifier is %s", lastArg, data);
}
"Instance identifier references %s but data identifier is %s", lastArg, data);
}
}
private void checkRunning(final AbstractDOMTransactionFactory<?> impl) {
}
private void checkRunning(final AbstractDOMTransactionFactory<?> impl) {
- Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
+ checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
*/
package org.opendaylight.controller.cluster.databroker;
*/
package org.opendaylight.controller.cluster.databroker;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction;
private final ClientTransaction tx;
AbstractShardedTransaction(final ClientTransaction tx) {
private final ClientTransaction tx;
AbstractShardedTransaction(final ClientTransaction tx) {
- this.tx = Preconditions.checkNotNull(tx);
+ this.tx = requireNonNull(tx);
*/
package org.opendaylight.controller.cluster.databroker;
*/
package org.opendaylight.controller.cluster.databroker;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER;
import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER;
import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER;
import com.google.common.annotations.Beta;
import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.CAN_COMMIT_ERROR_MAPPER;
import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER;
import static org.opendaylight.mdsal.dom.broker.TransactionCommitFailedExceptionMapper.PRE_COMMIT_MAPPER;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.AbstractFuture;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.AbstractFuture;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores,
final Executor listenableFutureExecutor, final DurationStatisticsTracker commitStatsTracker) {
super(datastores);
public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores,
final Executor listenableFutureExecutor, final DurationStatisticsTracker commitStatsTracker) {
super(datastores);
- this.clientFutureCallbackExecutor = Preconditions.checkNotNull(listenableFutureExecutor);
- this.commitStatsTracker = Preconditions.checkNotNull(commitStatsTracker);
+ this.clientFutureCallbackExecutor = requireNonNull(listenableFutureExecutor);
+ this.commitStatsTracker = requireNonNull(commitStatsTracker);
}
public DurationStatisticsTracker getCommitStatsTracker() {
}
public DurationStatisticsTracker getCommitStatsTracker() {
- protected FluentFuture<? extends CommitInfo> commit(
- final DOMDataTreeWriteTransaction transaction, final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
+ protected FluentFuture<? extends CommitInfo> commit(final DOMDataTreeWriteTransaction transaction,
+ final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
- Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
- Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
+ checkArgument(transaction != null, "Transaction must not be null.");
+ checkArgument(cohorts != null, "Cohorts must not be null.");
LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
if (cohorts.isEmpty()) {
LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
if (cohorts.isEmpty()) {
private final Executor listenerExecutor;
AsyncNotifyingSettableFuture(final Executor listenerExecutor) {
private final Executor listenerExecutor;
AsyncNotifyingSettableFuture(final Executor listenerExecutor) {
- this.listenerExecutor = Preconditions.checkNotNull(listenerExecutor);
+ this.listenerExecutor = requireNonNull(listenerExecutor);
private final Executor executor;
DelegatingRunnable(final Runnable delegate, final Executor executor) {
private final Executor executor;
DelegatingRunnable(final Runnable delegate, final Executor executor) {
- this.delegate = Preconditions.checkNotNull(delegate);
- this.executor = Preconditions.checkNotNull(executor);
+ this.delegate = requireNonNull(delegate);
+ this.executor = requireNonNull(executor);
package org.opendaylight.controller.cluster.databroker;
package org.opendaylight.controller.cluster.databroker;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
final AbstractDOMBroker broker, final DOMTransactionChainListener listener) {
super(chains);
this.chainId = chainId;
final AbstractDOMBroker broker, final DOMTransactionChainListener listener) {
super(chains);
this.chainId = chainId;
- this.broker = Preconditions.checkNotNull(broker);
- this.listener = Preconditions.checkNotNull(listener);
+ this.broker = requireNonNull(broker);
+ this.listener = requireNonNull(listener);
}
private void checkNotFailed() {
}
private void checkNotFailed() {
- Preconditions.checkState(state != State.FAILED, "Transaction chain has failed");
+ checkState(state != State.FAILED, "Transaction chain has failed");
*/
package org.opendaylight.controller.cluster.databroker;
*/
package org.opendaylight.controller.cluster.databroker;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ForwardingObject;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
import com.google.common.collect.ForwardingObject;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
DOMStoreThreePhaseCommitCohortAdaptor(
final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate) {
DOMStoreThreePhaseCommitCohortAdaptor(
final org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort delegate) {
- this.delegate = Preconditions.checkNotNull(delegate);
+ this.delegate = requireNonNull(delegate);
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
// Hidden to prevent outside instantiation
AbstractClientHandle(final AbstractClientHistory parent, final TransactionIdentifier transactionId) {
// Hidden to prevent outside instantiation
AbstractClientHandle(final AbstractClientHistory parent, final TransactionIdentifier transactionId) {
- this.transactionId = Preconditions.checkNotNull(transactionId);
- this.parent = Preconditions.checkNotNull(parent);
+ this.transactionId = requireNonNull(transactionId);
+ this.parent = requireNonNull(parent);
private State<T> getState() {
final State<T> local = state;
private State<T> getState() {
final State<T> local = state;
- Preconditions.checkState(local != null, "Transaction %s is closed", transactionId);
+ checkState(local != null, "Transaction %s is closed", transactionId);
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
private final TransactionIdentifier txId;
AbstractTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId) {
private final TransactionIdentifier txId;
AbstractTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId) {
- this.parent = Preconditions.checkNotNull(parent);
- this.txId = Preconditions.checkNotNull(txId);
+ this.parent = requireNonNull(parent);
+ this.txId = requireNonNull(txId);
}
final void complete() {
}
final void complete() {
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.Collections2;
import com.google.common.collect.Maps;
import java.util.Collection;
import com.google.common.collect.Collections2;
import com.google.common.collect.Maps;
import java.util.Collection;
private BouncingReconnectForwarder(final ConnectedClientConnection<?> successor,
final Map<LocalHistoryIdentifier, ProxyReconnectCohort> cohorts) {
super(successor);
private BouncingReconnectForwarder(final ConnectedClientConnection<?> successor,
final Map<LocalHistoryIdentifier, ProxyReconnectCohort> cohorts) {
super(successor);
- this.cohorts = Preconditions.checkNotNull(cohorts);
+ this.cohorts = requireNonNull(cohorts);
}
static ReconnectForwarder forCohorts(final ConnectedClientConnection<?> successor,
}
static ReconnectForwarder forCohorts(final ConnectedClientConnection<?> successor,
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import java.util.Arrays;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import java.util.Arrays;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
private final ClientTransaction parent;
ClientTransactionCursor(final ClientTransaction parent) {
private final ClientTransaction parent;
ClientTransactionCursor(final ClientTransaction parent) {
- this.parent = Preconditions.checkNotNull(parent);
+ this.parent = requireNonNull(parent);
@Override
public void exit() {
final YangInstanceIdentifier currentParent = current.getParent();
@Override
public void exit() {
final YangInstanceIdentifier currentParent = current.getParent();
- Preconditions.checkState(currentParent != null);
+ checkState(currentParent != null);
current = currentParent;
}
current = currentParent;
}
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
DirectTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId,
final AbstractProxyTransaction proxy) {
super(parent, txId);
DirectTransactionCommitCohort(final AbstractClientHistory parent, final TransactionIdentifier txId,
final AbstractProxyTransaction proxy) {
super(parent, txId);
- this.proxy = Preconditions.checkNotNull(proxy);
+ this.proxy = requireNonNull(proxy);
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
*/
package org.opendaylight.controller.cluster.databroker.actors.dds;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
/**
* Request the ClientIdentifier from a particular actor. Response is an instance of {@link DataStoreClient}.
/**
* Request the ClientIdentifier from a particular actor. Response is an instance of {@link DataStoreClient}.
private final ActorRef replyTo;
GetClientRequest(final ActorRef replyTo) {
private final ActorRef replyTo;
GetClientRequest(final ActorRef replyTo) {
- this.replyTo = Preconditions.checkNotNull(replyTo);
+ this.replyTo = requireNonNull(replyTo);
}
ActorRef getReplyTo() {
}
ActorRef getReplyTo() {
import static java.util.Objects.requireNonNull;
import static java.util.Objects.requireNonNull;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FluentFuture;
import java.util.Optional;
import java.util.function.Consumer;
import com.google.common.util.concurrent.FluentFuture;
import java.util.Optional;
import java.util.function.Consumer;
final Optional<NormalizedNode<?, ?>> result = readOnlyView().readNode(path);
if (callback != null) {
// XXX: FB does not see that callback is final, on stack and has be check for non-null.
final Optional<NormalizedNode<?, ?>> result = readOnlyView().readNode(path);
if (callback != null) {
// XXX: FB does not see that callback is final, on stack and has be check for non-null.
- final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
+ final Consumer<Response<?, ?>> fbIsStupid = requireNonNull(callback);
executeInActor(() -> fbIsStupid.accept(new ReadTransactionSuccess(request.getTarget(),
request.getSequence(), result)));
}
executeInActor(() -> fbIsStupid.accept(new ReadTransactionSuccess(request.getTarget(),
request.getSequence(), result)));
}
final boolean result = readOnlyView().readNode(path).isPresent();
if (callback != null) {
// XXX: FB does not see that callback is final, on stack and has be check for non-null.
final boolean result = readOnlyView().readNode(path).isPresent();
if (callback != null) {
// XXX: FB does not see that callback is final, on stack and has be check for non-null.
- final Consumer<Response<?, ?>> fbIsStupid = Preconditions.checkNotNull(callback);
+ final Consumer<Response<?, ?>> fbIsStupid = requireNonNull(callback);
executeInActor(() -> fbIsStupid.accept(new ExistsTransactionSuccess(request.getTarget(),
request.getSequence(), result)));
}
executeInActor(() -> fbIsStupid.accept(new ExistsTransactionSuccess(request.getTarget(),
request.getSequence(), result)));
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
AbstractFrontendHistory(final String persistenceId, final ShardDataTree tree,
final Map<UnsignedLong, Boolean> closedTransactions, final RangeSet<UnsignedLong> purgedTransactions) {
AbstractFrontendHistory(final String persistenceId, final ShardDataTree tree,
final Map<UnsignedLong, Boolean> closedTransactions, final RangeSet<UnsignedLong> purgedTransactions) {
- this.persistenceId = Preconditions.checkNotNull(persistenceId);
- this.tree = Preconditions.checkNotNull(tree);
- this.closedTransactions = Preconditions.checkNotNull(closedTransactions);
- this.purgedTransactions = Preconditions.checkNotNull(purgedTransactions);
+ this.persistenceId = requireNonNull(persistenceId);
+ this.tree = requireNonNull(tree);
+ this.closedTransactions = requireNonNull(closedTransactions);
+ this.purgedTransactions = requireNonNull(purgedTransactions);
}
final String persistenceId() {
}
final String persistenceId() {
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.AbortTransactionPayload;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.AbortTransactionPayload;
import org.opendaylight.yangtools.concepts.Identifiable;
AbstractShardDataTreeTransaction(final ShardDataTreeTransactionParent parent, final TransactionIdentifier id,
final T snapshot) {
AbstractShardDataTreeTransaction(final ShardDataTreeTransactionParent parent, final TransactionIdentifier id,
final T snapshot) {
- this.parent = Preconditions.checkNotNull(parent);
- this.snapshot = Preconditions.checkNotNull(snapshot);
- this.id = Preconditions.checkNotNull(id);
+ this.parent = requireNonNull(parent);
+ this.snapshot = requireNonNull(snapshot);
+ this.id = requireNonNull(id);
}
final void abort(final Runnable callback) {
}
final void abort(final Runnable callback) {
- Preconditions.checkState(close(), "Transaction is already closed");
+ checkState(close(), "Transaction is already closed");
parent.abortTransaction(this, callback);
}
parent.abortTransaction(this, callback);
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.util.Optional;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.util.Optional;
ChainedCommitCohort(final ShardDataTreeTransactionChain chain, final ReadWriteShardDataTreeTransaction transaction,
final ShardDataTreeCohort delegate) {
ChainedCommitCohort(final ShardDataTreeTransactionChain chain, final ReadWriteShardDataTreeTransaction transaction,
final ShardDataTreeCohort delegate) {
- this.transaction = Preconditions.checkNotNull(transaction);
- this.delegate = Preconditions.checkNotNull(delegate);
- this.chain = Preconditions.checkNotNull(chain);
+ this.transaction = requireNonNull(transaction);
+ this.delegate = requireNonNull(delegate);
+ this.chain = requireNonNull(chain);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Address;
import akka.cluster.Cluster;
import akka.cluster.ClusterEvent;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Address;
import akka.cluster.Cluster;
import akka.cluster.ClusterEvent;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
public class ClusterWrapperImpl implements ClusterWrapper {
import org.opendaylight.controller.cluster.access.concepts.MemberName;
public class ClusterWrapperImpl implements ClusterWrapper {
private final MemberName currentMemberName;
private final Address selfAddress;
private final MemberName currentMemberName;
private final Address selfAddress;
- public ClusterWrapperImpl(ActorSystem actorSystem) {
- Preconditions.checkNotNull(actorSystem, "actorSystem should not be null");
+ public ClusterWrapperImpl(final ActorSystem actorSystem) {
+ cluster = Cluster.get(requireNonNull(actorSystem, "actorSystem should not be null"));
- cluster = Cluster.get(actorSystem);
-
- Preconditions.checkState(cluster.getSelfRoles().size() > 0,
+ checkState(cluster.getSelfRoles().size() > 0,
"No akka roles were specified.\n"
+ "One way to specify the member name is to pass a property on the command line like so\n"
+ " -Dakka.cluster.roles.0=member-3\n"
"No akka roles were specified.\n"
+ "One way to specify the member name is to pass a property on the command line like so\n"
+ " -Dakka.cluster.roles.0=member-3\n"
- public void subscribeToMemberEvents(ActorRef actorRef) {
- Preconditions.checkNotNull(actorRef, "actorRef should not be null");
-
- cluster.subscribe(actorRef, ClusterEvent.initialStateAsEvents(),
+ public void subscribeToMemberEvents(final ActorRef actorRef) {
+ cluster.subscribe(requireNonNull(actorRef, "actorRef should not be null"), ClusterEvent.initialStateAsEvents(),
ClusterEvent.MemberEvent.class,
ClusterEvent.UnreachableMember.class,
ClusterEvent.ReachableMember.class);
ClusterEvent.MemberEvent.class,
ClusterEvent.UnreachableMember.class,
ClusterEvent.ReachableMember.class);
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.util.List;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.util.List;
private CohortEntry(final ReadWriteShardDataTreeTransaction transaction, final short clientVersion) {
this.cohort = null;
private CohortEntry(final ReadWriteShardDataTreeTransaction transaction, final short clientVersion) {
this.cohort = null;
- this.transaction = Preconditions.checkNotNull(transaction);
+ this.transaction = requireNonNull(transaction);
this.transactionId = transaction.getIdentifier();
this.clientVersion = clientVersion;
}
private CohortEntry(final ShardDataTreeCohort cohort, final short clientVersion) {
this.transactionId = transaction.getIdentifier();
this.clientVersion = clientVersion;
}
private CohortEntry(final ShardDataTreeCohort cohort, final short clientVersion) {
- this.cohort = Preconditions.checkNotNull(cohort);
+ this.cohort = requireNonNull(cohort);
this.transactionId = cohort.getIdentifier();
this.transaction = null;
this.clientVersion = clientVersion;
this.transactionId = cohort.getIdentifier();
this.transaction = null;
this.clientVersion = clientVersion;
}
void ready(final Optional<SortedSet<String>> participatingShardNames, final CohortDecorator cohortDecorator) {
}
void ready(final Optional<SortedSet<String>> participatingShardNames, final CohortDecorator cohortDecorator) {
- Preconditions.checkState(cohort == null, "cohort was already set");
+ checkState(cohort == null, "cohort was already set");
cohort = transaction.ready(participatingShardNames);
cohort = transaction.ready(participatingShardNames);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Status;
import akka.actor.Status.Failure;
import akka.actor.ActorRef;
import akka.actor.Status;
import akka.actor.Status.Failure;
import akka.dispatch.Recover;
import akka.pattern.Patterns;
import akka.util.Timeout;
import akka.dispatch.Recover;
import akka.pattern.Patterns;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.AbstractMap.SimpleImmutableEntry;
import com.google.common.collect.Lists;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.AbstractMap.SimpleImmutableEntry;
CompositeDataTreeCohort(final DataTreeCohortActorRegistry registry, final TransactionIdentifier transactionID,
final SchemaContext schema, final Executor callbackExecutor, final Timeout timeout) {
CompositeDataTreeCohort(final DataTreeCohortActorRegistry registry, final TransactionIdentifier transactionID,
final SchemaContext schema, final Executor callbackExecutor, final Timeout timeout) {
- this.registry = Preconditions.checkNotNull(registry);
- this.txId = Preconditions.checkNotNull(transactionID);
- this.schema = Preconditions.checkNotNull(schema);
- this.callbackExecutor = Preconditions.checkNotNull(callbackExecutor);
- this.timeout = Preconditions.checkNotNull(timeout);
+ this.registry = requireNonNull(registry);
+ this.txId = requireNonNull(transactionID);
+ this.schema = requireNonNull(schema);
+ this.callbackExecutor = requireNonNull(callbackExecutor);
+ this.timeout = requireNonNull(timeout);
}
void changeStateFrom(final State expected, final State followup) {
}
void changeStateFrom(final State expected, final State followup) {
- Preconditions.checkState(state == expected);
+ checkState(state == expected);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCandidate;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
private final DOMDataTreeIdentifier rootPath;
private final DataTreeCandidateNode rootNode;
private final DOMDataTreeIdentifier rootPath;
private final DataTreeCandidateNode rootNode;
- private DOMDataTreeCandidateTO(DOMDataTreeIdentifier rootPath, DataTreeCandidateNode rootNode) {
- this.rootPath = Preconditions.checkNotNull(rootPath);
- this.rootNode = Preconditions.checkNotNull(rootNode);
+ private DOMDataTreeCandidateTO(final DOMDataTreeIdentifier rootPath, final DataTreeCandidateNode rootNode) {
+ this.rootPath = requireNonNull(rootPath);
+ this.rootNode = requireNonNull(rootNode);
- static DOMDataTreeCandidate create(DOMDataTreeIdentifier path, DataTreeCandidateNode node) {
+ static DOMDataTreeCandidate create(final DOMDataTreeIdentifier path, final DataTreeCandidateNode node) {
return new DOMDataTreeCandidateTO(path, node);
}
return new DOMDataTreeCandidateTO(path, node);
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
import org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
import org.opendaylight.controller.cluster.datastore.messages.DataTreeChangedReply;
private DataTreeChangeListenerActor(final DOMDataTreeChangeListener listener,
final YangInstanceIdentifier registeredPath) {
private DataTreeChangeListenerActor(final DOMDataTreeChangeListener listener,
final YangInstanceIdentifier registeredPath) {
- this.listener = Preconditions.checkNotNull(listener);
- this.registeredPath = Preconditions.checkNotNull(registeredPath);
+ this.listener = requireNonNull(listener);
+ this.registeredPath = requireNonNull(registeredPath);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Status;
import akka.util.Timeout;
import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Status;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
}
abstract static class CohortRegistryCommand {
}
abstract static class CohortRegistryCommand {
private final ActorRef cohort;
CohortRegistryCommand(final ActorRef cohort) {
private final ActorRef cohort;
CohortRegistryCommand(final ActorRef cohort) {
- this.cohort = Preconditions.checkNotNull(cohort);
+ this.cohort = requireNonNull(cohort);
}
static class RegisterCohort extends CohortRegistryCommand {
}
static class RegisterCohort extends CohortRegistryCommand {
private final DOMDataTreeIdentifier path;
RegisterCohort(final DOMDataTreeIdentifier path, final ActorRef cohort) {
super(cohort);
this.path = path;
private final DOMDataTreeIdentifier path;
RegisterCohort(final DOMDataTreeIdentifier path, final ActorRef cohort) {
super(cohort);
this.path = path;
}
public DOMDataTreeIdentifier getPath() {
return path;
}
}
public DOMDataTreeIdentifier getPath() {
return path;
}
}
static class RemoveCohort extends CohortRegistryCommand {
}
static class RemoveCohort extends CohortRegistryCommand {
RemoveCohort(final ActorRef cohort) {
super(cohort);
}
RemoveCohort(final ActorRef cohort) {
super(cohort);
}
}
private static class CanCommitMessageBuilder {
}
private static class CanCommitMessageBuilder {
+ private final Multimap<ActorRef, DOMDataTreeCandidate> actorToCandidates = ArrayListMultimap.create();
private final TransactionIdentifier txId;
private final DataTreeCandidate candidate;
private final SchemaContext schema;
private final TransactionIdentifier txId;
private final DataTreeCandidate candidate;
private final SchemaContext schema;
- private final Multimap<ActorRef, DOMDataTreeCandidate> actorToCandidates = ArrayListMultimap.create();
CanCommitMessageBuilder(final TransactionIdentifier txId, final DataTreeCandidate candidate,
final SchemaContext schema) {
CanCommitMessageBuilder(final TransactionIdentifier txId, final DataTreeCandidate candidate,
final SchemaContext schema) {
- this.txId = Preconditions.checkNotNull(txId);
- this.candidate = Preconditions.checkNotNull(candidate);
+ this.txId = requireNonNull(txId);
+ this.candidate = requireNonNull(candidate);
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
}
private void setSnapshotDataThresholdPercentage(final int shardSnapshotDataThresholdPercentage) {
}
private void setSnapshotDataThresholdPercentage(final int shardSnapshotDataThresholdPercentage) {
- Preconditions.checkArgument(shardSnapshotDataThresholdPercentage >= 0
- && shardSnapshotDataThresholdPercentage <= 100);
+ checkArgument(shardSnapshotDataThresholdPercentage >= 0 && shardSnapshotDataThresholdPercentage <= 100);
raftConfig.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
}
raftConfig.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
}
}
public Builder logicalStoreType(final LogicalDatastoreType logicalStoreType) {
}
public Builder logicalStoreType(final LogicalDatastoreType logicalStoreType) {
- datastoreContext.logicalStoreType = Preconditions.checkNotNull(logicalStoreType);
+ datastoreContext.logicalStoreType = requireNonNull(logicalStoreType);
// Retain compatible naming
switch (logicalStoreType) {
// Retain compatible naming
switch (logicalStoreType) {
}
public Builder dataStoreName(final String dataStoreName) {
}
public Builder dataStoreName(final String dataStoreName) {
- datastoreContext.dataStoreName = Preconditions.checkNotNull(dataStoreName);
+ datastoreContext.dataStoreName = requireNonNull(dataStoreName);
datastoreContext.dataStoreMXBeanType = "Distributed" + WordUtils.capitalize(dataStoreName) + "Datastore";
return this;
}
datastoreContext.dataStoreMXBeanType = "Distributed" + WordUtils.capitalize(dataStoreName) + "Datastore";
return this;
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
}
private DatastoreSnapshotRestore(final String restoreDirectoryPath) {
}
private DatastoreSnapshotRestore(final String restoreDirectoryPath) {
- this.restoreDirectoryPath = Preconditions.checkNotNull(restoreDirectoryPath);
+ this.restoreDirectoryPath = requireNonNull(restoreDirectoryPath);
}
// synchronize this method so that, in case of concurrent access to getAndRemove(),
}
// synchronize this method so that, in case of concurrent access to getAndRemove(),
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
DebugThreePhaseCommitCohort(final TransactionIdentifier transactionId,
final AbstractThreePhaseCommitCohort<?> delegate, final Throwable debugContext) {
DebugThreePhaseCommitCohort(final TransactionIdentifier transactionId,
final AbstractThreePhaseCommitCohort<?> delegate, final Throwable debugContext) {
- this.delegate = Preconditions.checkNotNull(delegate);
- this.debugContext = Preconditions.checkNotNull(debugContext);
- this.transactionId = Preconditions.checkNotNull(transactionId);
+ this.delegate = requireNonNull(delegate);
+ this.debugContext = requireNonNull(debugContext);
+ this.transactionId = requireNonNull(transactionId);
}
private <V> ListenableFuture<V> addFutureCallback(final ListenableFuture<V> future) {
}
private <V> ListenableFuture<V> addFutureCallback(final ListenableFuture<V> future) {
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
-import com.google.common.base.Preconditions;
import java.util.Collection;
import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
import org.opendaylight.controller.cluster.datastore.messages.OnInitialData;
import java.util.Collection;
import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
import org.opendaylight.controller.cluster.datastore.messages.OnInitialData;
private final ActorSelection actor;
ForwardingDataTreeChangeListener(final ActorSelection actor) {
private final ActorSelection actor;
ForwardingDataTreeChangeListener(final ActorSelection actor) {
- this.actor = Preconditions.checkNotNull(actor, "actor should not be null");
+ this.actor = requireNonNull(actor, "actor should not be null");
- public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
+ public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
LOG.debug("Sending DataTreeChanged to {}", actor);
actor.tell(new DataTreeChanged(changes), ActorRef.noSender());
}
LOG.debug("Sending DataTreeChanged to {}", actor);
actor.tell(new DataTreeChanged(changes), ActorRef.noSender());
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
import com.google.common.collect.TreeRangeSet;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
import com.google.common.collect.TreeRangeSet;
private boolean closed;
FrontendHistoryMetadataBuilder(final LocalHistoryIdentifier identifier) {
private boolean closed;
FrontendHistoryMetadataBuilder(final LocalHistoryIdentifier identifier) {
- this.identifier = Preconditions.checkNotNull(identifier);
+ this.identifier = requireNonNull(identifier);
this.purgedTransactions = TreeRangeSet.create();
this.closedTransactions = new HashMap<>(2);
}
this.purgedTransactions = TreeRangeSet.create();
this.closedTransactions = new HashMap<>(2);
}
}
void onHistoryClosed() {
}
void onHistoryClosed() {
- Preconditions.checkState(identifier.getHistoryId() != 0);
+ checkState(identifier.getHistoryId() != 0);
package org.opendaylight.controller.cluster.datastore;
import static com.google.common.base.Verify.verify;
package org.opendaylight.controller.cluster.datastore;
import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
import com.google.common.collect.Maps;
import java.util.HashMap;
import com.google.common.collect.Collections2;
import com.google.common.collect.Maps;
import java.util.HashMap;
private final String shardName;
FrontendMetadata(final String shardName) {
private final String shardName;
FrontendMetadata(final String shardName) {
- this.shardName = Preconditions.checkNotNull(shardName);
+ this.shardName = requireNonNull(shardName);
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import java.util.ArrayDeque;
import java.util.Optional;
import com.google.common.base.Verify;
import java.util.ArrayDeque;
import java.util.Optional;
private RequestException previousFailure;
FrontendTransaction(final AbstractFrontendHistory history, final TransactionIdentifier id) {
private RequestException previousFailure;
FrontendTransaction(final AbstractFrontendHistory history, final TransactionIdentifier id) {
- this.history = Preconditions.checkNotNull(history);
- this.id = Preconditions.checkNotNull(id);
+ this.history = requireNonNull(history);
+ this.id = requireNonNull(id);
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorPath;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.Props;
import akka.actor.ActorPath;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.Props;
-import com.google.common.base.Preconditions;
/**
* Base class for factories instantiating delegates which are local to the
/**
* Base class for factories instantiating delegates which are local to the
private final Shard shard;
protected LeaderLocalDelegateFactory(final Shard shard) {
private final Shard shard;
protected LeaderLocalDelegateFactory(final Shard shard) {
- this.shard = Preconditions.checkNotNull(shard);
+ this.shard = requireNonNull(shard);
}
protected final ActorRef getSelf() {
}
protected final ActorRef getSelf() {
return shard.getContext().actorOf(props);
}
return shard.getContext().actorOf(props);
}
- protected final ActorSelection selectActor(ActorRef ref) {
+ protected final ActorSelection selectActor(final ActorRef ref) {
return shard.getContext().system().actorSelection(ref.path());
}
return shard.getContext().system().actorSelection(ref.path());
}
- protected final ActorSelection selectActor(ActorPath path) {
+ protected final ActorSelection selectActor(final ActorPath path) {
return shard.getContext().system().actorSelection(path);
}
return shard.getContext().system().actorSelection(path);
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.RangeSet;
import com.google.common.collect.TreeRangeSet;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.RangeSet;
import com.google.common.collect.TreeRangeSet;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
/**
* Chained transaction specialization of {@link AbstractFrontendHistory}. It prevents concurrent open transactions.
*
/**
* Chained transaction specialization of {@link AbstractFrontendHistory}. It prevents concurrent open transactions.
*
final ShardDataTreeTransactionChain chain, final Map<UnsignedLong, Boolean> closedTransactions,
final RangeSet<UnsignedLong> purgedTransactions) {
super(persistenceId, tree, closedTransactions, purgedTransactions);
final ShardDataTreeTransactionChain chain, final Map<UnsignedLong, Boolean> closedTransactions,
final RangeSet<UnsignedLong> purgedTransactions) {
super(persistenceId, tree, closedTransactions, purgedTransactions);
- this.chain = Preconditions.checkNotNull(chain);
+ this.chain = requireNonNull(chain);
}
static LocalFrontendHistory create(final String persistenceId, final ShardDataTree tree,
}
static LocalFrontendHistory create(final String persistenceId, final ShardDataTree tree,
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorSelection;
import akka.actor.ActorSelection;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
LocalTransactionContext(final DOMStoreTransaction txDelegate, final TransactionIdentifier identifier,
final LocalTransactionReadySupport readySupport) {
super(identifier);
LocalTransactionContext(final DOMStoreTransaction txDelegate, final TransactionIdentifier identifier,
final LocalTransactionReadySupport readySupport) {
super(identifier);
- this.txDelegate = Preconditions.checkNotNull(txDelegate);
+ this.txDelegate = requireNonNull(txDelegate);
this.readySupport = readySupport;
}
this.readySupport = readySupport;
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
private final int maxPermits;
OperationLimiter(final TransactionIdentifier identifier, final int maxPermits, final long acquireTimeoutSeconds) {
private final int maxPermits;
OperationLimiter(final TransactionIdentifier identifier, final int maxPermits, final long acquireTimeoutSeconds) {
- this.identifier = Preconditions.checkNotNull(identifier);
+ this.identifier = requireNonNull(identifier);
- Preconditions.checkArgument(acquireTimeoutSeconds >= 0);
+ checkArgument(acquireTimeoutSeconds >= 0);
this.acquireTimeout = TimeUnit.SECONDS.toNanos(acquireTimeoutSeconds);
this.acquireTimeout = TimeUnit.SECONDS.toNanos(acquireTimeoutSeconds);
- Preconditions.checkArgument(maxPermits >= 0);
+ checkArgument(maxPermits >= 0);
this.maxPermits = maxPermits;
this.semaphore = new Semaphore(maxPermits);
}
this.maxPermits = maxPermits;
this.semaphore = new Semaphore(maxPermits);
}
- void release(int permits) {
+ void release(final int permits) {
this.semaphore.release(permits);
}
this.semaphore.release(permits);
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorSelection;
import akka.dispatch.OnComplete;
import akka.pattern.AskTimeoutException;
import akka.util.Timeout;
import akka.actor.ActorSelection;
import akka.dispatch.OnComplete;
import akka.pattern.AskTimeoutException;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
RemoteTransactionContextSupport(final TransactionContextWrapper transactionContextWrapper,
final TransactionProxy parent, final String shardName) {
RemoteTransactionContextSupport(final TransactionContextWrapper transactionContextWrapper,
final TransactionProxy parent, final String shardName) {
- this.parent = Preconditions.checkNotNull(parent);
+ this.parent = requireNonNull(parent);
this.shardName = shardName;
this.transactionContextWrapper = transactionContextWrapper;
this.shardName = shardName;
this.transactionContextWrapper = transactionContextWrapper;
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.serialization.JavaSerializer;
import akka.serialization.Serialization;
import com.google.common.annotations.VisibleForTesting;
import akka.serialization.JavaSerializer;
import akka.serialization.Serialization;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.base.Ticker;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.common.base.Ticker;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
}
protected void checkSealed() {
}
protected void checkSealed() {
- Preconditions.checkState(!sealed, "Builder isalready sealed - further modifications are not allowed");
+ checkState(!sealed, "Builder isalready sealed - further modifications are not allowed");
}
@SuppressWarnings("unchecked")
}
@SuppressWarnings("unchecked")
public T schemaContextProvider(final SchemaContextProvider newSchemaContextProvider) {
checkSealed();
public T schemaContextProvider(final SchemaContextProvider newSchemaContextProvider) {
checkSealed();
- this.schemaContextProvider = Preconditions.checkNotNull(newSchemaContextProvider);
+ this.schemaContextProvider = requireNonNull(newSchemaContextProvider);
}
protected void verify() {
}
protected void verify() {
- Preconditions.checkNotNull(id, "id should not be null");
- Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null");
- Preconditions.checkNotNull(datastoreContext, "dataStoreContext should not be null");
- Preconditions.checkNotNull(schemaContextProvider, "schemaContextProvider should not be null");
+ requireNonNull(id, "id should not be null");
+ requireNonNull(peerAddresses, "peerAddresses should not be null");
+ requireNonNull(datastoreContext, "dataStoreContext should not be null");
+ requireNonNull(schemaContextProvider, "schemaContextProvider should not be null");
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Status.Failure;
import akka.serialization.Serialization;
import com.google.common.annotations.VisibleForTesting;
import akka.actor.ActorRef;
import akka.actor.Status.Failure;
import akka.serialization.Serialization;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.util.ArrayDeque;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.util.ArrayDeque;
ShardCommitCoordinator(final ShardDataTree dataTree, final Logger log, final String name) {
this.log = log;
this.name = name;
ShardCommitCoordinator(final ShardDataTree dataTree, final Logger log, final String name) {
this.log = log;
this.name = name;
- this.dataTree = Preconditions.checkNotNull(dataTree);
+ this.dataTree = requireNonNull(dataTree);
}
int getCohortCacheSize() {
}
int getCohortCacheSize() {
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verify;
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import akka.actor.ActorRef;
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.base.Stopwatch;
-import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
long lastAccess;
CommitEntry(final SimpleShardDataTreeCohort cohort, final long now) {
long lastAccess;
CommitEntry(final SimpleShardDataTreeCohort cohort, final long now) {
- this.cohort = Preconditions.checkNotNull(cohort);
+ this.cohort = requireNonNull(cohort);
final ShardDataTreeChangeListenerPublisher treeChangeListenerPublisher,
final String logContext,
final ShardDataTreeMetadata<?>... metadata) {
final ShardDataTreeChangeListenerPublisher treeChangeListenerPublisher,
final String logContext,
final ShardDataTreeMetadata<?>... metadata) {
- this.dataTree = Preconditions.checkNotNull(dataTree);
+ this.dataTree = requireNonNull(dataTree);
updateSchemaContext(schemaContext);
updateSchemaContext(schemaContext);
- this.shard = Preconditions.checkNotNull(shard);
- this.treeChangeListenerPublisher = Preconditions.checkNotNull(treeChangeListenerPublisher);
- this.logContext = Preconditions.checkNotNull(logContext);
+ this.shard = requireNonNull(shard);
+ this.treeChangeListenerPublisher = requireNonNull(treeChangeListenerPublisher);
+ this.logContext = requireNonNull(logContext);
this.metadata = ImmutableList.copyOf(metadata);
tip = dataTree;
}
this.metadata = ImmutableList.copyOf(metadata);
tip = dataTree;
}
void updateSchemaContext(final SchemaContext newSchemaContext) {
dataTree.setSchemaContext(newSchemaContext);
void updateSchemaContext(final SchemaContext newSchemaContext) {
dataTree.setSchemaContext(newSchemaContext);
- this.schemaContext = Preconditions.checkNotNull(newSchemaContext);
+ this.schemaContext = requireNonNull(newSchemaContext);
this.dataSchemaContext = DataSchemaContextTree.from(newSchemaContext);
}
this.dataSchemaContext = DataSchemaContextTree.from(newSchemaContext);
}
((CommitTransactionPayload) payload).getCandidate();
applyReplicatedCandidate(e.getKey(), e.getValue());
} else {
((CommitTransactionPayload) payload).getCandidate();
applyReplicatedCandidate(e.getKey(), e.getValue());
} else {
- Verify.verify(identifier instanceof TransactionIdentifier);
+ verify(identifier instanceof TransactionIdentifier);
payloadReplicationComplete((TransactionIdentifier) identifier);
}
} else if (payload instanceof AbortTransactionPayload) {
payloadReplicationComplete((TransactionIdentifier) identifier);
}
} else if (payload instanceof AbortTransactionPayload) {
final boolean closed) {
final ShardDataTreeTransactionChain ret = new ShardDataTreeTransactionChain(historyId, this);
final ShardDataTreeTransactionChain existing = transactionChains.putIfAbsent(historyId, ret);
final boolean closed) {
final ShardDataTreeTransactionChain ret = new ShardDataTreeTransactionChain(historyId, this);
final ShardDataTreeTransactionChain existing = transactionChains.putIfAbsent(historyId, ret);
- Preconditions.checkState(existing == null, "Attempted to recreate chain %s, but %s already exists", historyId,
- existing);
+ checkState(existing == null, "Attempted to recreate chain %s, but %s already exists", historyId, existing);
@SuppressWarnings("checkstyle:IllegalCatch")
void startPreCommit(final SimpleShardDataTreeCohort cohort) {
final CommitEntry entry = pendingTransactions.peek();
@SuppressWarnings("checkstyle:IllegalCatch")
void startPreCommit(final SimpleShardDataTreeCohort cohort) {
final CommitEntry entry = pendingTransactions.peek();
- Preconditions.checkState(entry != null, "Attempted to pre-commit of %s when no transactions pending", cohort);
+ checkState(entry != null, "Attempted to pre-commit of %s when no transactions pending", cohort);
final SimpleShardDataTreeCohort current = entry.cohort;
final SimpleShardDataTreeCohort current = entry.cohort;
- Verify.verify(cohort.equals(current), "Attempted to pre-commit %s while %s is pending", cohort, current);
+ verify(cohort.equals(current), "Attempted to pre-commit %s while %s is pending", cohort, current);
final TransactionIdentifier currentId = current.getIdentifier();
LOG.debug("{}: Preparing transaction {}", logContext, currentId);
final TransactionIdentifier currentId = current.getIdentifier();
LOG.debug("{}: Preparing transaction {}", logContext, currentId);
@Override
public void onSuccess(final Void noop) {
// Set the tip of the data tree.
@Override
public void onSuccess(final Void noop) {
// Set the tip of the data tree.
- tip = Verify.verifyNotNull(candidate);
+ tip = verifyNotNull(candidate);
entry.lastAccess = readTime();
entry.lastAccess = readTime();
void startCommit(final SimpleShardDataTreeCohort cohort, final DataTreeCandidate candidate) {
final CommitEntry entry = pendingCommits.peek();
void startCommit(final SimpleShardDataTreeCohort cohort, final DataTreeCandidate candidate) {
final CommitEntry entry = pendingCommits.peek();
- Preconditions.checkState(entry != null, "Attempted to start commit of %s when no transactions pending", cohort);
+ checkState(entry != null, "Attempted to start commit of %s when no transactions pending", cohort);
final SimpleShardDataTreeCohort current = entry.cohort;
if (!cohort.equals(current)) {
final SimpleShardDataTreeCohort current = entry.cohort;
if (!cohort.equals(current)) {
@SuppressWarnings("checkstyle:IllegalCatch")
private void rebaseTransactions(final Iterator<CommitEntry> iter, final @NonNull DataTreeTip newTip) {
@SuppressWarnings("checkstyle:IllegalCatch")
private void rebaseTransactions(final Iterator<CommitEntry> iter, final @NonNull DataTreeTip newTip) {
- tip = Preconditions.checkNotNull(newTip);
+ tip = requireNonNull(newTip);
while (iter.hasNext()) {
final SimpleShardDataTreeCohort cohort = iter.next().cohort;
if (cohort.getState() == State.CAN_COMMIT_COMPLETE) {
while (iter.hasNext()) {
final SimpleShardDataTreeCohort cohort = iter.next().cohort;
if (cohort.getState() == State.CAN_COMMIT_COMPLETE) {
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.util.Optional;
import java.util.SortedSet;
import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
import java.util.Optional;
import java.util.SortedSet;
import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
private boolean closed;
ShardDataTreeTransactionChain(final LocalHistoryIdentifier localHistoryIdentifier, final ShardDataTree dataTree) {
private boolean closed;
ShardDataTreeTransactionChain(final LocalHistoryIdentifier localHistoryIdentifier, final ShardDataTree dataTree) {
- this.chainId = Preconditions.checkNotNull(localHistoryIdentifier);
- this.dataTree = Preconditions.checkNotNull(dataTree);
+ this.chainId = requireNonNull(localHistoryIdentifier);
+ this.dataTree = requireNonNull(dataTree);
}
private DataTreeSnapshot getSnapshot() {
}
private DataTreeSnapshot getSnapshot() {
- Preconditions.checkState(!closed, "TransactionChain %s has been closed", this);
- Preconditions.checkState(openTransaction == null, "Transaction %s is open", openTransaction);
+ checkState(!closed, "TransactionChain %s has been closed", this);
+ checkState(openTransaction == null, "Transaction %s is open", openTransaction);
if (previousTx == null) {
LOG.debug("Opening an unchained snapshot in {}", chainId);
if (previousTx == null) {
LOG.debug("Opening an unchained snapshot in {}", chainId);
@Override
void abortFromTransactionActor(final AbstractShardDataTreeTransaction<?> transaction) {
if (transaction instanceof ReadWriteShardDataTreeTransaction) {
@Override
void abortFromTransactionActor(final AbstractShardDataTreeTransaction<?> transaction) {
if (transaction instanceof ReadWriteShardDataTreeTransaction) {
- Preconditions.checkState(openTransaction != null,
- "Attempted to abort transaction %s while none is outstanding", transaction);
+ checkState(openTransaction != null, "Attempted to abort transaction %s while none is outstanding",
+ transaction);
LOG.debug("Aborted open transaction {}", transaction);
openTransaction = null;
}
LOG.debug("Aborted open transaction {}", transaction);
openTransaction = null;
}
@Override
ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction,
final Optional<SortedSet<String>> participatingShardNames) {
@Override
ShardDataTreeCohort finishTransaction(final ReadWriteShardDataTreeTransaction transaction,
final Optional<SortedSet<String>> participatingShardNames) {
- Preconditions.checkState(openTransaction != null,
- "Attempted to finish transaction %s while none is outstanding", transaction);
+ checkState(openTransaction != null, "Attempted to finish transaction %s while none is outstanding",
+ transaction);
// dataTree is finalizing ready the transaction, we just record it for the next
// transaction in chain
// dataTree is finalizing ready the transaction, we just record it for the next
// transaction in chain
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.ReadData;
import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
import org.opendaylight.controller.cluster.datastore.messages.DataExists;
import org.opendaylight.controller.cluster.datastore.messages.ReadData;
public class ShardReadTransaction extends ShardTransaction {
private final AbstractShardDataTreeTransaction<?> transaction;
public class ShardReadTransaction extends ShardTransaction {
private final AbstractShardDataTreeTransaction<?> transaction;
- public ShardReadTransaction(AbstractShardDataTreeTransaction<?> transaction, ActorRef shardActor,
- ShardStats shardStats) {
+ public ShardReadTransaction(final AbstractShardDataTreeTransaction<?> transaction, final ActorRef shardActor,
+ final ShardStats shardStats) {
super(shardActor, shardStats, transaction.getIdentifier());
super(shardActor, shardStats, transaction.getIdentifier());
- this.transaction = Preconditions.checkNotNull(transaction);
+ this.transaction = requireNonNull(transaction);
- public void handleReceive(Object message) {
+ public void handleReceive(final Object message) {
if (ReadData.isSerializedType(message)) {
readData(transaction, ReadData.fromSerializable(message));
} else if (DataExists.isSerializedType(message)) {
if (ReadData.isSerializedType(message)) {
readData(transaction, ReadData.fromSerializable(message));
} else if (DataExists.isSerializedType(message)) {
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import java.io.File;
import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
import java.io.File;
import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshot;
import org.opendaylight.controller.cluster.datastore.persisted.ShardSnapshotState;
WithSnapshot(final ShardDataTree store, final String shardName, final Logger log, final Snapshot snapshot) {
super(store, shardName, log);
WithSnapshot(final ShardDataTree store, final String shardName, final Logger log, final Snapshot snapshot) {
super(store, shardName, log);
- this.restoreFromSnapshot = Preconditions.checkNotNull(snapshot);
+ this.restoreFromSnapshot = requireNonNull(snapshot);
private boolean open;
ShardRecoveryCoordinator(final ShardDataTree store, final String shardName, final Logger log) {
private boolean open;
ShardRecoveryCoordinator(final ShardDataTree store, final String shardName, final Logger log) {
- this.store = Preconditions.checkNotNull(store);
- this.shardName = Preconditions.checkNotNull(shardName);
- this.log = Preconditions.checkNotNull(log);
+ this.store = requireNonNull(store);
+ this.shardName = requireNonNull(shardName);
+ this.log = requireNonNull(log);
}
static ShardRecoveryCoordinator create(final ShardDataTree store, final String shardName, final Logger log) {
}
static ShardRecoveryCoordinator create(final ShardDataTree store, final String shardName, final Logger log) {
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void appendRecoveredLogEntry(final Payload payload) {
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void appendRecoveredLogEntry(final Payload payload) {
- Preconditions.checkState(open, "call startLogRecovery before calling appendRecoveredLogEntry");
+ checkState(open, "call startLogRecovery before calling appendRecoveredLogEntry");
try {
store.applyRecoveryPayload(payload);
try {
store.applyRecoveryPayload(payload);
*/
@Override
public void applyCurrentLogRecoveryBatch() {
*/
@Override
public void applyCurrentLogRecoveryBatch() {
- Preconditions.checkState(open, "call startLogRecovery before calling applyCurrentLogRecoveryBatch");
+ checkState(open, "call startLogRecovery before calling applyCurrentLogRecoveryBatch");
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorContext;
import akka.actor.ActorRef;
import akka.actor.ActorContext;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
import com.google.common.io.ByteSource;
import java.io.IOException;
import java.io.ObjectInputStream;
import com.google.common.io.ByteSource;
import java.io.IOException;
import java.io.ObjectInputStream;
private ShardSnapshotCohort(final LocalHistoryIdentifier applyHistoryId, final ActorRef snapshotActor,
final ShardDataTree store, final Logger log, final String logId) {
private ShardSnapshotCohort(final LocalHistoryIdentifier applyHistoryId, final ActorRef snapshotActor,
final ShardDataTree store, final Logger log, final String logId) {
- this.snapshotActor = Preconditions.checkNotNull(snapshotActor);
- this.store = Preconditions.checkNotNull(store);
+ this.snapshotActor = requireNonNull(snapshotActor);
+ this.store = requireNonNull(store);
this.log = log;
this.logId = logId;
}
this.log = log;
this.logId = logId;
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.ReceiveTimeout;
import akka.japi.Creator;
import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.ReceiveTimeout;
import akka.japi.Creator;
-import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActorWithMetering;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActorWithMetering;
super("shard-tx");
this.shardActor = shardActor;
this.shardStats = shardStats;
super("shard-tx");
this.shardActor = shardActor;
this.shardStats = shardStats;
- this.transactionId = Preconditions.checkNotNull(transactionId);
+ this.transactionId = requireNonNull(transactionId);
}
public static Props props(final TransactionType type, final AbstractShardDataTreeTransaction<?> transaction,
}
public static Props props(final TransactionType type, final AbstractShardDataTreeTransaction<?> transaction,
ShardTransactionCreator(final TransactionType type, final AbstractShardDataTreeTransaction<?> transaction,
final ActorRef shardActor, final DatastoreContext datastoreContext, final ShardStats shardStats) {
ShardTransactionCreator(final TransactionType type, final AbstractShardDataTreeTransaction<?> transaction,
final ActorRef shardActor, final DatastoreContext datastoreContext, final ShardStats shardStats) {
- this.transaction = Preconditions.checkNotNull(transaction);
+ this.transaction = requireNonNull(transaction);
this.shardActor = shardActor;
this.shardStats = shardStats;
this.datastoreContext = datastoreContext;
this.shardActor = shardActor;
this.shardStats = shardStats;
this.datastoreContext = datastoreContext;
import akka.actor.ActorSelection;
import akka.dispatch.OnComplete;
import com.google.common.base.Supplier;
import akka.actor.ActorSelection;
import akka.dispatch.OnComplete;
import com.google.common.base.Supplier;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
}
private Future<Iterable<Object>> invokeCohorts(final MessageSupplier messageSupplier) {
}
private Future<Iterable<Object>> invokeCohorts(final MessageSupplier messageSupplier) {
- List<Future<Object>> futureList = Lists.newArrayListWithCapacity(cohorts.size());
+ List<Future<Object>> futureList = new ArrayList<>(cohorts.size());
for (CohortInfo cohort : cohorts) {
Object message = messageSupplier.newMessage(transactionId, cohort.getActorVersion());
for (CohortInfo cohort : cohorts) {
Object message = messageSupplier.newMessage(transactionId, cohort.getActorVersion());
*/
package org.opendaylight.controller.cluster.datastore;
*/
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 akka.actor.ActorSelection;
import akka.dispatch.Futures;
import akka.dispatch.OnComplete;
-import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Pending(final TransactionIdentifier transaction, final Future<?> previousFuture) {
this.previousFuture = previousFuture;
Pending(final TransactionIdentifier transaction, final Future<?> previousFuture) {
this.previousFuture = previousFuture;
- this.transaction = Preconditions.checkNotNull(transaction);
+ this.transaction = requireNonNull(transaction);
protected <T> void onTransactionReady(final TransactionIdentifier transaction,
final Collection<Future<T>> cohortFutures) {
final State localState = currentState;
protected <T> void onTransactionReady(final TransactionIdentifier transaction,
final Collection<Future<T>> cohortFutures) {
final State localState = currentState;
- Preconditions.checkState(localState instanceof Allocated, "Readying transaction %s while state is %s",
- transaction, localState);
+ checkState(localState instanceof Allocated, "Readying transaction %s while state is %s", transaction,
+ localState);
final TransactionIdentifier currentTx = ((Allocated)localState).getIdentifier();
final TransactionIdentifier currentTx = ((Allocated)localState).getIdentifier();
- Preconditions.checkState(transaction.equals(currentTx), "Readying transaction %s while %s is allocated",
- transaction, currentTx);
+ checkState(transaction.equals(currentTx), "Readying transaction %s while %s is allocated", transaction,
+ currentTx);
// Transaction ready and we are not waiting for futures -- go to idle
if (cohortFutures.isEmpty()) {
// Transaction ready and we are not waiting for futures -- go to idle
if (cohortFutures.isEmpty()) {
- protected void onTransactionContextCreated(TransactionIdentifier transactionId) {
+ protected void onTransactionContextCreated(final TransactionIdentifier transactionId) {
Promise<Object> promise = priorReadOnlyTxPromises.remove(transactionId);
if (promise != null) {
promise.success(null);
Promise<Object> promise = priorReadOnlyTxPromises.remove(transactionId);
if (promise != null) {
promise.success(null);
*/
package org.opendaylight.controller.cluster.datastore;
*/
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 com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import akka.actor.ActorSelection;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.FluentFuture;
super(txContextFactory.nextIdentifier(), txContextFactory.getActorUtils().getDatastoreContext()
.isTransactionDebugContextEnabled());
this.txContextFactory = txContextFactory;
super(txContextFactory.nextIdentifier(), txContextFactory.getActorUtils().getDatastoreContext()
.isTransactionDebugContextEnabled());
this.txContextFactory = txContextFactory;
- this.type = Preconditions.checkNotNull(type);
+ this.type = requireNonNull(type);
LOG.debug("New {} Tx - {}", type, getIdentifier());
}
LOG.debug("New {} Tx - {}", type, getIdentifier());
}
}
private <T> FluentFuture<T> executeRead(final String shardName, final AbstractRead<T> readCmd) {
}
private <T> FluentFuture<T> executeRead(final String shardName, final AbstractRead<T> readCmd) {
- Preconditions.checkState(type != TransactionType.WRITE_ONLY,
- "Reads from write-only transactions are not allowed");
+ checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed");
LOG.trace("Tx {} {} {}", getIdentifier(), readCmd.getClass().getSimpleName(), readCmd.getPath());
LOG.trace("Tx {} {} {}", getIdentifier(), readCmd.getClass().getSimpleName(), readCmd.getPath());
@Override
public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
@Override
public FluentFuture<Optional<NormalizedNode<?, ?>>> read(final YangInstanceIdentifier path) {
- Preconditions.checkState(type != TransactionType.WRITE_ONLY,
- "Reads from write-only transactions are not allowed");
- Preconditions.checkNotNull(path, "path should not be null");
+ checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed");
+ requireNonNull(path, "path should not be null");
LOG.trace("Tx {} read {}", getIdentifier(), path);
return path.isEmpty() ? readAllData() : singleShardRead(shardNameFromIdentifier(path), path);
LOG.trace("Tx {} read {}", getIdentifier(), path);
return path.isEmpty() ? readAllData() : singleShardRead(shardNameFromIdentifier(path), path);
}
private void checkModificationState() {
}
private void checkModificationState() {
- Preconditions.checkState(type != TransactionType.READ_ONLY,
- "Modification operation on read-only transaction is not allowed");
- Preconditions.checkState(state == TransactionState.OPEN,
- "Transaction is sealed - further modifications are not allowed");
+ checkState(type != TransactionType.READ_ONLY, "Modification operation on read-only transaction is not allowed");
+ checkState(state == TransactionState.OPEN, "Transaction is sealed - further modifications are not allowed");
}
private boolean seal(final TransactionState newState) {
}
private boolean seal(final TransactionState newState) {
@Override
public final void close() {
if (!seal(TransactionState.CLOSED)) {
@Override
public final void close() {
if (!seal(TransactionState.CLOSED)) {
- Preconditions.checkState(state == TransactionState.CLOSED, "Transaction %s is ready, it cannot be closed",
+ checkState(state == TransactionState.CLOSED, "Transaction %s is ready, it cannot be closed",
getIdentifier());
// Idempotent no-op as per AutoCloseable recommendation
return;
getIdentifier());
// Idempotent no-op as per AutoCloseable recommendation
return;
@Override
public final AbstractThreePhaseCommitCohort<?> ready() {
@Override
public final AbstractThreePhaseCommitCohort<?> ready() {
- Preconditions.checkState(type != TransactionType.READ_ONLY, "Read-only transactions cannot be readied");
+ checkState(type != TransactionType.READ_ONLY, "Read-only transactions cannot be readied");
final boolean success = seal(TransactionState.READY);
final boolean success = seal(TransactionState.READY);
- Preconditions.checkState(success, "Transaction %s is %s, it cannot be readied", getIdentifier(), state);
+ checkState(success, "Transaction %s is %s, it cannot be readied", getIdentifier(), state);
LOG.debug("Tx {} Readying {} components for commit", getIdentifier(), txContextWrappers.size());
LOG.debug("Tx {} Readying {} components for commit", getIdentifier(), txContextWrappers.size());
*/
package org.opendaylight.controller.cluster.datastore.actors;
*/
package org.opendaylight.controller.cluster.datastore.actors;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.actor.PoisonPill;
import akka.actor.Props;
import com.google.common.annotations.VisibleForTesting;
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.actor.PoisonPill;
import akka.actor.Props;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration;
private Cancellable killSchedule;
@Override
private Cancellable killSchedule;
@Override
- protected void handleReceive(Object message) {
+ protected void handleReceive(final Object message) {
if (message instanceof CloseDataTreeNotificationListenerRegistration) {
closeListenerRegistration();
if (isValidSender(getSender())) {
if (message instanceof CloseDataTreeNotificationListenerRegistration) {
closeListenerRegistration();
if (isValidSender(getSender())) {
private final Runnable onClose;
public SetRegistration(final ListenerRegistration<?> registration, final Runnable onClose) {
private final Runnable onClose;
public SetRegistration(final ListenerRegistration<?> registration, final Runnable onClose) {
- this.registration = Preconditions.checkNotNull(registration);
- this.onClose = Preconditions.checkNotNull(onClose);
+ this.registration = requireNonNull(registration);
+ this.onClose = requireNonNull(onClose);
*/
package org.opendaylight.controller.cluster.datastore.actors;
*/
package org.opendaylight.controller.cluster.datastore.actors;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.ActorRef;
import akka.actor.Props;
-import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
SerializeSnapshot(final ShardDataTreeSnapshot snapshot, final Optional<OutputStream> installSnapshotStream,
final ActorRef replyTo) {
SerializeSnapshot(final ShardDataTreeSnapshot snapshot, final Optional<OutputStream> installSnapshotStream,
final ActorRef replyTo) {
- this.snapshot = Preconditions.checkNotNull(snapshot);
- this.installSnapshotStream = Preconditions.checkNotNull(installSnapshotStream);
- this.replyTo = Preconditions.checkNotNull(replyTo);
+ this.snapshot = requireNonNull(snapshot);
+ this.installSnapshotStream = requireNonNull(installSnapshotStream);
+ this.replyTo = requireNonNull(replyTo);
}
ShardDataTreeSnapshot getSnapshot() {
}
ShardDataTreeSnapshot getSnapshot() {
*/
package org.opendaylight.controller.cluster.datastore.config;
*/
package org.opendaylight.controller.cluster.datastore.config;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.AbstractMap.SimpleEntry;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.AbstractMap.SimpleEntry;
this.namespaceToModuleName = createNamespaceToModuleName(moduleConfigMap.values());
}
this.namespaceToModuleName = createNamespaceToModuleName(moduleConfigMap.values());
}
- private static Set<String> createAllShardNames(Iterable<ModuleConfig> moduleConfigs) {
+ private static Set<String> createAllShardNames(final Iterable<ModuleConfig> moduleConfigs) {
final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
for (ModuleConfig moduleConfig : moduleConfigs) {
builder.addAll(moduleConfig.getShardNames());
final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
for (ModuleConfig moduleConfig : moduleConfigs) {
builder.addAll(moduleConfig.getShardNames());
return builder.build();
}
return builder.build();
}
- private static Map<String, String> createNamespaceToModuleName(Iterable<ModuleConfig> moduleConfigs) {
+ private static Map<String, String> createNamespaceToModuleName(final Iterable<ModuleConfig> moduleConfigs) {
final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (ModuleConfig moduleConfig : moduleConfigs) {
if (moduleConfig.getNamespace() != null) {
final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
for (ModuleConfig moduleConfig : moduleConfigs) {
if (moduleConfig.getNamespace() != null) {
@Override
public Collection<String> getMemberShardNames(final MemberName memberName) {
@Override
public Collection<String> getMemberShardNames(final MemberName memberName) {
- Preconditions.checkNotNull(memberName, "memberName should not be null");
+ requireNonNull(memberName, "memberName should not be null");
List<String> shards = new ArrayList<>();
for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
List<String> shards = new ArrayList<>();
for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
@Override
public String getModuleNameFromNameSpace(final String nameSpace) {
@Override
public String getModuleNameFromNameSpace(final String nameSpace) {
- Preconditions.checkNotNull(nameSpace, "nameSpace should not be null");
+ requireNonNull(nameSpace, "nameSpace should not be null");
return namespaceToModuleName.get(nameSpace);
}
@Override
return namespaceToModuleName.get(nameSpace);
}
@Override
- public ShardStrategy getStrategyForModule(String moduleName) {
- Preconditions.checkNotNull(moduleName, "moduleName should not be null");
+ public ShardStrategy getStrategyForModule(final String moduleName) {
+ requireNonNull(moduleName, "moduleName should not be null");
ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
return moduleConfig != null ? moduleConfig.getShardStrategy() : null;
ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
return moduleConfig != null ? moduleConfig.getShardStrategy() : null;
@Override
public String getShardNameForModule(final String moduleName) {
@Override
public String getShardNameForModule(final String moduleName) {
- Preconditions.checkNotNull(moduleName, "moduleName should not be null");
+ requireNonNull(moduleName, "moduleName should not be null");
ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
Collection<ShardConfig> shardConfigs = moduleConfig != null ? moduleConfig.getShardConfigs() :
ModuleConfig moduleConfig = moduleConfigMap.get(moduleName);
Collection<ShardConfig> shardConfigs = moduleConfig != null ? moduleConfig.getShardConfigs() :
@Override
public String getShardNameForPrefix(final DOMDataTreeIdentifier prefix) {
@Override
public String getShardNameForPrefix(final DOMDataTreeIdentifier prefix) {
- Preconditions.checkNotNull(prefix, "prefix should not be null");
+ requireNonNull(prefix, "prefix should not be null");
- Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry =
- new SimpleEntry<>(
- new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
+ Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry = new SimpleEntry<>(
+ new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
for (Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> entry : prefixConfigMap.entrySet()) {
if (entry.getKey().contains(prefix) && entry.getKey().getRootIdentifier().getPathArguments().size()
for (Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> entry : prefixConfigMap.entrySet()) {
if (entry.getKey().contains(prefix) && entry.getKey().getRootIdentifier().getPathArguments().size()
}
private static void checkNotNullShardName(final String shardName) {
}
private static void checkNotNullShardName(final String shardName) {
- Preconditions.checkNotNull(shardName, "shardName should not be null");
+ requireNonNull(shardName, "shardName should not be null");
- public synchronized void addModuleShardConfiguration(ModuleShardConfiguration config) {
- Preconditions.checkNotNull(config, "ModuleShardConfiguration should not be null");
+ public synchronized void addModuleShardConfiguration(final ModuleShardConfiguration config) {
+ requireNonNull(config, "ModuleShardConfiguration should not be null");
ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName())
.nameSpace(config.getNamespace().toASCIIString())
ModuleConfig moduleConfig = ModuleConfig.builder(config.getModuleName())
.nameSpace(config.getNamespace().toASCIIString())
@Override
public void addPrefixShardConfiguration(final PrefixShardConfiguration config) {
@Override
public void addPrefixShardConfiguration(final PrefixShardConfiguration config) {
- Preconditions.checkNotNull(config, "PrefixShardConfiguration cannot be null");
- addPrefixConfig(config);
+ addPrefixConfig(requireNonNull(config, "PrefixShardConfiguration cannot be null"));
allShardNames = ImmutableSet.<String>builder().addAll(allShardNames)
.add(ClusterUtils.getCleanShardName(config.getPrefix().getRootIdentifier())).build();
}
@Override
public void removePrefixShardConfiguration(final DOMDataTreeIdentifier prefix) {
allShardNames = ImmutableSet.<String>builder().addAll(allShardNames)
.add(ClusterUtils.getCleanShardName(config.getPrefix().getRootIdentifier())).build();
}
@Override
public void removePrefixShardConfiguration(final DOMDataTreeIdentifier prefix) {
- Preconditions.checkNotNull(prefix, "Prefix cannot be null");
-
- removePrefixConfig(prefix);
+ removePrefixConfig(requireNonNull(prefix, "Prefix cannot be null"));
final HashSet<String> temp = new HashSet<>(allShardNames);
temp.remove(ClusterUtils.getCleanShardName(prefix.getRootIdentifier()));
final HashSet<String> temp = new HashSet<>(allShardNames);
temp.remove(ClusterUtils.getCleanShardName(prefix.getRootIdentifier()));
prefixConfigMap = ImmutableMap.copyOf(newPrefixConfigMap);
}
prefixConfigMap = ImmutableMap.copyOf(newPrefixConfigMap);
}
- private ShardStrategy createShardStrategy(String moduleName, String shardStrategyName) {
+ private ShardStrategy createShardStrategy(final String moduleName, final String shardStrategyName) {
return ShardStrategyFactory.newShardStrategyInstance(moduleName, shardStrategyName, this);
}
@Override
return ShardStrategyFactory.newShardStrategyInstance(moduleName, shardStrategyName, this);
}
@Override
- public boolean isShardConfigured(String shardName) {
+ public boolean isShardConfigured(final String shardName) {
checkNotNullShardName(shardName);
return allShardNames.contains(shardName);
}
@Override
checkNotNullShardName(shardName);
return allShardNames.contains(shardName);
}
@Override
- public void addMemberReplicaForShard(String shardName, MemberName newMemberName) {
+ public void addMemberReplicaForShard(final String shardName, final MemberName newMemberName) {
checkNotNullShardName(shardName);
checkNotNullShardName(shardName);
- Preconditions.checkNotNull(newMemberName, "MemberName should not be null");
+ requireNonNull(newMemberName, "MemberName should not be null");
for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
- public void removeMemberReplicaForShard(String shardName, MemberName newMemberName) {
+ public void removeMemberReplicaForShard(final String shardName, final MemberName newMemberName) {
checkNotNullShardName(shardName);
checkNotNullShardName(shardName);
- Preconditions.checkNotNull(newMemberName, "MemberName should not be null");
+ requireNonNull(newMemberName, "MemberName should not be null");
for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
for (ModuleConfig moduleConfig: moduleConfigMap.values()) {
ShardConfig shardConfig = moduleConfig.getShardConfig(shardName);
@Override
public ShardStrategy getStrategyForPrefix(final DOMDataTreeIdentifier prefix) {
@Override
public ShardStrategy getStrategyForPrefix(final DOMDataTreeIdentifier prefix) {
- Preconditions.checkNotNull(prefix, "Prefix cannot be null");
+ requireNonNull(prefix, "Prefix cannot be null");
// FIXME using prefix tables like in mdsal will be better
// FIXME using prefix tables like in mdsal will be better
- Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry =
- new SimpleEntry<>(
- new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
+ Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry = new SimpleEntry<>(
+ new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
for (Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> entry : prefixConfigMap.entrySet()) {
if (entry.getKey().contains(prefix) && entry.getKey().getRootIdentifier().getPathArguments().size()
for (Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> entry : prefixConfigMap.entrySet()) {
if (entry.getKey().contains(prefix) && entry.getKey().getRootIdentifier().getPathArguments().size()
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.config;
package org.opendaylight.controller.cluster.datastore.config;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableSet;
import java.io.Externalizable;
import java.io.IOException;
import com.google.common.collect.ImmutableSet;
import java.io.Externalizable;
import java.io.IOException;
public PrefixShardConfiguration(final DOMDataTreeIdentifier prefix,
final String shardStrategyName,
final Collection<MemberName> shardMemberNames) {
public PrefixShardConfiguration(final DOMDataTreeIdentifier prefix,
final String shardStrategyName,
final Collection<MemberName> shardMemberNames) {
- this.prefix = Preconditions.checkNotNull(prefix);
- this.shardStrategyName = Preconditions.checkNotNull(shardStrategyName);
+ this.prefix = requireNonNull(prefix);
+ this.shardStrategyName = requireNonNull(shardStrategyName);
this.shardMemberNames = ImmutableSet.copyOf(shardMemberNames);
}
this.shardMemberNames = ImmutableSet.copyOf(shardMemberNames);
}
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
DistributedEntityOwnershipListenerRegistration(final DOMEntityOwnershipListener listener, final String entityType,
final DistributedEntityOwnershipService service) {
super(listener);
DistributedEntityOwnershipListenerRegistration(final DOMEntityOwnershipListener listener, final String entityType,
final DistributedEntityOwnershipService service) {
super(listener);
- this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null");
- this.service = Preconditions.checkNotNull(service, "DOMEntityOwnershipListener cannot be null");
+ this.entityType = requireNonNull(entityType, "entityType cannot be null");
+ this.service = requireNonNull(service, "DOMEntityOwnershipListener cannot be null");
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.createEntity;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.createEntity;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.base.Strings;
-import com.google.common.base.Verify;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
private final EntityOwnershipChangePublisher publisher;
EntityOwnerChangeListener(final MemberName localMemberName, final EntityOwnershipChangePublisher publisher) {
private final EntityOwnershipChangePublisher publisher;
EntityOwnerChangeListener(final MemberName localMemberName, final EntityOwnershipChangePublisher publisher) {
- this.localMemberName = Verify.verifyNotNull(localMemberName.getName());
- this.publisher = Preconditions.checkNotNull(publisher);
+ this.localMemberName = verifyNotNull(localMemberName.getName());
+ this.publisher = requireNonNull(publisher);
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.Props;
import akka.japi.Creator;
import akka.actor.Props;
import akka.japi.Creator;
-import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipChange;
private final DOMEntityOwnershipListener listener;
EntityOwnershipListenerCreator(final DOMEntityOwnershipListener listener) {
private final DOMEntityOwnershipListener listener;
EntityOwnershipListenerCreator(final DOMEntityOwnershipListener listener) {
- this.listener = Preconditions.checkNotNull(listener);
+ this.listener = requireNonNull(listener);
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NAME_NODE_ID;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NODE_ID;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_ID_NODE_ID;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NAME_NODE_ID;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NODE_ID;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_ID_NODE_ID;
import akka.cluster.Member;
import akka.cluster.MemberStatus;
import akka.pattern.Patterns;
import akka.cluster.Member;
import akka.cluster.MemberStatus;
import akka.pattern.Patterns;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@Override
protected void verify() {
super.verify();
@Override
protected void verify() {
super.verify();
- Preconditions.checkNotNull(localMemberName, "localMemberName should not be null");
- Preconditions.checkNotNull(ownerSelectionStrategyConfig, "ownerSelectionStrategyConfig should not be null");
+ requireNonNull(localMemberName, "localMemberName should not be null");
+ requireNonNull(ownerSelectionStrategyConfig, "ownerSelectionStrategyConfig should not be null");
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
*/
package org.opendaylight.controller.cluster.datastore.entityownership;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_OWNER_QNAME;
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.actor.Status.Failure;
import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_OWNER_QNAME;
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.actor.Status.Failure;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.Iterator;
import java.util.LinkedList;
import com.google.common.collect.ImmutableList;
import java.util.Iterator;
import java.util.LinkedList;
private Cancellable retryCommitSchedule;
private long transactionIDCounter = 0;
private Cancellable retryCommitSchedule;
private long transactionIDCounter = 0;
- EntityOwnershipShardCommitCoordinator(MemberName localMemberName, Logger log) {
- this.log = Preconditions.checkNotNull(log);
+ EntityOwnershipShardCommitCoordinator(final MemberName localMemberName, final Logger log) {
+ this.log = requireNonNull(log);
historyId = new LocalHistoryIdentifier(
ClientIdentifier.create(FrontendIdentifier.create(localMemberName, FRONTEND_TYPE), 0), 0);
}
historyId = new LocalHistoryIdentifier(
ClientIdentifier.create(FrontendIdentifier.create(localMemberName, FRONTEND_TYPE), 0), 0);
}
- boolean handleMessage(Object message, EntityOwnershipShard shard) {
+ boolean handleMessage(final Object message, final EntityOwnershipShard shard) {
boolean handled = true;
if (CommitTransactionReply.isSerializedType(message)) {
// Successful reply from a local commit.
boolean handled = true;
if (CommitTransactionReply.isSerializedType(message)) {
// Successful reply from a local commit.
- private void retryInflightCommit(EntityOwnershipShard shard) {
+ private void retryInflightCommit(final EntityOwnershipShard shard) {
// Shouldn't be null happen but verify anyway
if (inflightCommit == null) {
return;
// Shouldn't be null happen but verify anyway
if (inflightCommit == null) {
return;
- void inflightCommitFailure(Throwable cause, EntityOwnershipShard shard) {
+ void inflightCommitFailure(final Throwable cause, final EntityOwnershipShard shard) {
// This should've originated from a failed inflight commit but verify anyway
if (inflightCommit == null) {
return;
// This should've originated from a failed inflight commit but verify anyway
if (inflightCommit == null) {
return;
scheduleInflightCommitRetry(shard);
}
scheduleInflightCommitRetry(shard);
}
- private void scheduleInflightCommitRetry(EntityOwnershipShard shard) {
+ private void scheduleInflightCommitRetry(final EntityOwnershipShard shard) {
FiniteDuration duration = shard.getDatastoreContext().getShardRaftConfig().getElectionTimeOutInterval();
log.debug("Scheduling retry for BatchedModifications commit {} in {}",
FiniteDuration duration = shard.getDatastoreContext().getShardRaftConfig().getElectionTimeOutInterval();
log.debug("Scheduling retry for BatchedModifications commit {} in {}",
COMMIT_RETRY_MESSAGE, shard.getContext().dispatcher(), ActorRef.noSender());
}
COMMIT_RETRY_MESSAGE, shard.getContext().dispatcher(), ActorRef.noSender());
}
- void inflightCommitSucceeded(EntityOwnershipShard shard) {
+ void inflightCommitSucceeded(final EntityOwnershipShard shard) {
// Shouldn't be null but verify anyway
if (inflightCommit == null) {
return;
// Shouldn't be null but verify anyway
if (inflightCommit == null) {
return;
commitNextBatch(shard);
}
commitNextBatch(shard);
}
- void commitNextBatch(EntityOwnershipShard shard) {
+ void commitNextBatch(final EntityOwnershipShard shard) {
if (inflightCommit != null || pendingModifications.isEmpty() || !shard.hasLeader()) {
return;
}
if (inflightCommit != null || pendingModifications.isEmpty() || !shard.hasLeader()) {
return;
}
shard.tryCommitModifications(inflightCommit);
}
shard.tryCommitModifications(inflightCommit);
}
- void commitModification(Modification modification, EntityOwnershipShard shard) {
+ void commitModification(final Modification modification, final EntityOwnershipShard shard) {
commitModifications(ImmutableList.of(modification), shard);
}
commitModifications(ImmutableList.of(modification), shard);
}
- void commitModifications(List<Modification> modifications, EntityOwnershipShard shard) {
+ void commitModifications(final List<Modification> modifications, final EntityOwnershipShard shard) {
if (modifications.isEmpty()) {
return;
}
if (modifications.isEmpty()) {
return;
}
- void onStateChanged(EntityOwnershipShard shard, boolean isLeader) {
+ void onStateChanged(final EntityOwnershipShard shard, final boolean isLeader) {
shard.possiblyRemoveAllInitialCandidates(shard.getLeader());
possiblyPrunePendingCommits(shard, isLeader);
shard.possiblyRemoveAllInitialCandidates(shard.getLeader());
possiblyPrunePendingCommits(shard, isLeader);
- private void possiblyPrunePendingCommits(EntityOwnershipShard shard, boolean isLeader) {
+ private void possiblyPrunePendingCommits(final EntityOwnershipShard shard, final boolean isLeader) {
// If we were the leader and transitioned to follower, we'll try to forward pending commits to the new leader.
// However certain commits, e.g. entity owner changes, should only be committed by a valid leader as the
// criteria used to determine the commit may be stale. Since we're no longer a valid leader, we should not
// If we were the leader and transitioned to follower, we'll try to forward pending commits to the new leader.
// However certain commits, e.g. entity owner changes, should only be committed by a valid leader as the
// criteria used to determine the commit may be stale. Since we're no longer a valid leader, we should not
- private @Nullable BatchedModifications pruneModifications(BatchedModifications toPrune) {
+ private @Nullable BatchedModifications pruneModifications(final BatchedModifications toPrune) {
BatchedModifications prunedModifications = new BatchedModifications(toPrune.getTransactionId(),
toPrune.getVersion());
prunedModifications.setDoCommitOnReady(toPrune.isDoCommitOnReady());
BatchedModifications prunedModifications = new BatchedModifications(toPrune.getTransactionId(),
toPrune.getVersion());
prunedModifications.setDoCommitOnReady(toPrune.isDoCommitOnReady());
return !prunedModifications.getModifications().isEmpty() ? prunedModifications : null;
}
return !prunedModifications.getModifications().isEmpty() ? prunedModifications : null;
}
- private boolean canForwardModificationToNewLeader(Modification mod) {
+ private boolean canForwardModificationToNewLeader(final Modification mod) {
// If this is a WRITE of entity owner we don't want to forward it to a new leader since the criteria used
// to determine the new owner might be stale.
if (mod instanceof WriteModification) {
// If this is a WRITE of entity owner we don't want to forward it to a new leader since the criteria used
// to determine the new owner might be stale.
if (mod instanceof WriteModification) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.messages;
package org.opendaylight.controller.cluster.datastore.entityownership.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import org.opendaylight.controller.cluster.datastore.entityownership.selectionstrategy.EntityOwnerSelectionStrategy;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import java.util.Collection;
import org.opendaylight.controller.cluster.datastore.entityownership.selectionstrategy.EntityOwnerSelectionStrategy;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
private final Collection<String> allCandidates;
private final EntityOwnerSelectionStrategy ownerSelectionStrategy;
private final Collection<String> allCandidates;
private final EntityOwnerSelectionStrategy ownerSelectionStrategy;
- public SelectOwner(YangInstanceIdentifier entityPath, Collection<String> allCandidates,
- EntityOwnerSelectionStrategy ownerSelectionStrategy) {
-
- this.entityPath = Preconditions.checkNotNull(entityPath, "entityPath should not be null");
- this.allCandidates = Preconditions.checkNotNull(allCandidates, "allCandidates should not be null");
- this.ownerSelectionStrategy = Preconditions.checkNotNull(ownerSelectionStrategy,
- "ownerSelectionStrategy should not be null");
+ public SelectOwner(final YangInstanceIdentifier entityPath, final Collection<String> allCandidates,
+ final EntityOwnerSelectionStrategy ownerSelectionStrategy) {
+ this.entityPath = requireNonNull(entityPath, "entityPath should not be null");
+ this.allCandidates = requireNonNull(allCandidates, "allCandidates should not be null");
+ this.ownerSelectionStrategy = requireNonNull(ownerSelectionStrategy,
+ "ownerSelectionStrategy should not be null");
}
public YangInstanceIdentifier getEntityPath() {
}
public YangInstanceIdentifier getEntityPath() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.identifiers;
package org.opendaylight.controller.cluster.datastore.identifiers;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
private final String fullName;
ShardIdentifier(final String shardName, final MemberName memberName, final String type) {
private final String fullName;
ShardIdentifier(final String shardName, final MemberName memberName, final String type) {
- this.shardName = Preconditions.checkNotNull(shardName, "shardName should not be null");
- this.memberName = Preconditions.checkNotNull(memberName, "memberName should not be null");
- this.type = Preconditions.checkNotNull(type, "type should not be null");
+ this.shardName = requireNonNull(shardName, "shardName should not be null");
+ this.memberName = requireNonNull(memberName, "memberName should not be null");
+ this.type = requireNonNull(type, "type should not be null");
fullName = memberName.getName() + "-shard-" + shardName + "-" + type;
}
fullName = memberName.getName() + "-shard-" + shardName + "-" + type;
}
public static ShardIdentifier fromShardIdString(final String shardIdString) {
final Matcher matcher = PATTERN.matcher(shardIdString);
public static ShardIdentifier fromShardIdString(final String shardIdString) {
final Matcher matcher = PATTERN.matcher(shardIdString);
- Preconditions.checkArgument(matcher.matches(), "Invalid shard id \"%s\"", shardIdString);
+ checkArgument(matcher.matches(), "Invalid shard id \"%s\"", shardIdString);
return new ShardIdentifier(matcher.group(2), MemberName.forName(matcher.group(1)), matcher.group(3));
}
return new ShardIdentifier(matcher.group(2), MemberName.forName(matcher.group(1)), matcher.group(3));
}
*/
package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
*/
package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.pattern.Patterns;
import akka.util.Timeout;
import akka.actor.ActorRef;
import akka.pattern.Patterns;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.base.Stopwatch;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
private volatile String stateRetrievalTime;
OnDemandShardStateCache(final String shardName, final ActorRef shardActor) {
private volatile String stateRetrievalTime;
OnDemandShardStateCache(final String shardName, final ActorRef shardActor) {
- this.shardName = Preconditions.checkNotNull(shardName);
+ this.shardName = requireNonNull(shardName);
this.shardActor = shardActor;
}
this.shardActor = shardActor;
}
*/
package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
*/
package org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.dispatch.Futures;
import akka.pattern.Patterns;
import akka.util.Timeout;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.dispatch.Futures;
import akka.pattern.Patterns;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import java.util.ArrayList;
import java.util.Collection;
import com.google.common.base.Throwables;
import java.util.ArrayList;
import java.util.Collection;
public ShardDataTreeListenerInfoMXBeanImpl(final String shardName, final String mxBeanType,
final ActorRef shardActor) {
super(shardName, mxBeanType, JMX_CATEGORY);
public ShardDataTreeListenerInfoMXBeanImpl(final String shardName, final String mxBeanType,
final ActorRef shardActor) {
super(shardName, mxBeanType, JMX_CATEGORY);
- stateCache = new OnDemandShardStateCache(shardName, Preconditions.checkNotNull(shardActor));
+ stateCache = new OnDemandShardStateCache(shardName, requireNonNull(shardActor));
*/
package org.opendaylight.controller.cluster.datastore.messages;
*/
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
protected AbstractThreePhaseCommitMessage(final TransactionIdentifier transactionId, final short version) {
super(version);
protected AbstractThreePhaseCommitMessage(final TransactionIdentifier transactionId, final short version) {
super(version);
- this.transactionId = Preconditions.checkNotNull(transactionId);
+ this.transactionId = requireNonNull(transactionId);
}
public TransactionIdentifier getTransactionId() {
}
public TransactionIdentifier getTransactionId() {
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
transactionId = TransactionIdentifier.readFrom(in);
}
@Override
super.readExternal(in);
transactionId = TransactionIdentifier.readFrom(in);
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
super.writeExternal(out);
transactionId.writeTo(out);
}
super.writeExternal(out);
transactionId.writeTo(out);
}
*/
package org.opendaylight.controller.cluster.datastore.messages;
*/
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
private final String shardName;
private final Map<String, Boolean> meberVotingStatusMap;
private final String shardName;
private final Map<String, Boolean> meberVotingStatusMap;
- public ChangeShardMembersVotingStatus(String shardName, Map<String, Boolean> meberVotingStatusMap) {
- this.shardName = Preconditions.checkNotNull(shardName);
+ public ChangeShardMembersVotingStatus(final String shardName, final Map<String, Boolean> meberVotingStatusMap) {
+ this.shardName = requireNonNull(shardName);
this.meberVotingStatusMap = ImmutableMap.copyOf(meberVotingStatusMap);
}
this.meberVotingStatusMap = ImmutableMap.copyOf(meberVotingStatusMap);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.messages;
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
public CloseTransactionChain(final LocalHistoryIdentifier transactionChainId, final short version) {
super(version);
public CloseTransactionChain(final LocalHistoryIdentifier transactionChainId, final short version) {
super(version);
- this.transactionChainId = Preconditions.checkNotNull(transactionChainId);
+ this.transactionChainId = requireNonNull(transactionChainId);
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
transactionChainId = LocalHistoryIdentifier.readFrom(in);
}
@Override
super.readExternal(in);
transactionChainId = LocalHistoryIdentifier.readFrom(in);
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
super.writeExternal(out);
transactionChainId.writeTo(out);
}
public static CloseTransactionChain fromSerializable(final Object serializable) {
super.writeExternal(out);
transactionChainId.writeTo(out);
}
public static CloseTransactionChain fromSerializable(final Object serializable) {
- Preconditions.checkArgument(serializable instanceof CloseTransactionChain);
+ checkArgument(serializable instanceof CloseTransactionChain);
return (CloseTransactionChain)serializable;
}
return (CloseTransactionChain)serializable;
}
- public static boolean isSerializedType(Object message) {
+ public static boolean isSerializedType(final Object message) {
return message instanceof CloseTransactionChain;
}
}
return message instanceof CloseTransactionChain;
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.messages;
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
public CreateTransaction() {
}
public CreateTransaction() {
}
- public CreateTransaction(TransactionIdentifier transactionId, int transactionType, short version) {
+ public CreateTransaction(final TransactionIdentifier transactionId, final int transactionType,
+ final short version) {
- this.transactionId = Preconditions.checkNotNull(transactionId);
+ this.transactionId = requireNonNull(transactionId);
this.transactionType = transactionType;
}
this.transactionType = transactionType;
}
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
transactionId = TransactionIdentifier.readFrom(in);
transactionType = in.readInt();
}
@Override
super.readExternal(in);
transactionId = TransactionIdentifier.readFrom(in);
transactionType = in.readInt();
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
super.writeExternal(out);
transactionId.writeTo(out);
out.writeInt(transactionType);
super.writeExternal(out);
transactionId.writeTo(out);
out.writeInt(transactionType);
return "CreateTransaction [transactionId=" + transactionId + ", transactionType=" + transactionType + "]";
}
return "CreateTransaction [transactionId=" + transactionId + ", transactionType=" + transactionType + "]";
}
- public static CreateTransaction fromSerializable(Object message) {
- Preconditions.checkArgument(message instanceof CreateTransaction);
+ public static CreateTransaction fromSerializable(final Object message) {
+ checkArgument(message instanceof CreateTransaction);
return (CreateTransaction)message;
}
return (CreateTransaction)message;
}
- public static boolean isSerializedType(Object message) {
+ public static boolean isSerializedType(final Object message) {
return message instanceof CreateTransaction;
}
}
return message instanceof CreateTransaction;
}
}
*/
package org.opendaylight.controller.cluster.datastore.messages;
*/
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
import java.util.Collection;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
private final Collection<DataTreeCandidate> changes;
public DataTreeChanged(final Collection<DataTreeCandidate> changes) {
private final Collection<DataTreeCandidate> changes;
public DataTreeChanged(final Collection<DataTreeCandidate> changes) {
- this.changes = Preconditions.checkNotNull(changes);
+ this.changes = requireNonNull(changes);
*/
package org.opendaylight.controller.cluster.datastore.messages;
*/
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.beans.ConstructorProperties;
/**
import java.beans.ConstructorProperties;
/**
@ConstructorProperties({"listener","registeredPath", "isEnabled", "notificationCount"})
public DataTreeListenerInfo(final String listener, final String registeredPath, final boolean isEnabled,
final long notificationCount) {
@ConstructorProperties({"listener","registeredPath", "isEnabled", "notificationCount"})
public DataTreeListenerInfo(final String listener, final String registeredPath, final boolean isEnabled,
final long notificationCount) {
- this.listener = Preconditions.checkNotNull(listener);
- this.registeredPath = Preconditions.checkNotNull(registeredPath);
+ this.listener = requireNonNull(listener);
+ this.registeredPath = requireNonNull(registeredPath);
this.isEnabled = isEnabled;
this.notificationCount = notificationCount;
}
this.isEnabled = isEnabled;
this.notificationCount = notificationCount;
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.messages;
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Serializable;
/**
import java.io.Serializable;
/**
private final String shardName;
private final boolean waitUntilReady;
private final String shardName;
private final boolean waitUntilReady;
- public FindPrimary(String shardName, boolean waitUntilReady) {
-
- Preconditions.checkNotNull(shardName, "shardName should not be null");
-
- this.shardName = shardName;
+ public FindPrimary(final String shardName, final boolean waitUntilReady) {
+ this.shardName = requireNonNull(shardName, "shardName should not be null");
this.waitUntilReady = waitUntilReady;
}
this.waitUntilReady = waitUntilReady;
}
*/
package org.opendaylight.controller.cluster.datastore.messages;
*/
package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
/**
* A local message sent to the ShardManager to flip the raft voting states for members of a shard.
/**
* A local message sent to the ShardManager to flip the raft voting states for members of a shard.
public class FlipShardMembersVotingStatus {
private final String shardName;
public class FlipShardMembersVotingStatus {
private final String shardName;
- public FlipShardMembersVotingStatus(String shardName) {
- this.shardName = Preconditions.checkNotNull(shardName);
+ public FlipShardMembersVotingStatus(final String shardName) {
+ this.shardName = requireNonNull(shardName);
}
public String getShardName() {
}
public String getShardName() {
*/
package org.opendaylight.controller.cluster.datastore.messages;
*/
package org.opendaylight.controller.cluster.datastore.messages;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ExtendedActorSystem;
import akka.serialization.JSerializer;
import akka.util.ClassLoaderObjectInputStream;
import akka.actor.ExtendedActorSystem;
import akka.serialization.JSerializer;
import akka.util.ClassLoaderObjectInputStream;
-import com.google.common.base.Preconditions;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.apache.commons.lang3.SerializationUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.apache.commons.lang3.SerializationUtils;
private final ExtendedActorSystem system;
public ReadyLocalTransactionSerializer(final ExtendedActorSystem system) {
private final ExtendedActorSystem system;
public ReadyLocalTransactionSerializer(final ExtendedActorSystem system) {
- this.system = Preconditions.checkNotNull(system);
+ this.system = requireNonNull(system);
@Override
public byte[] toBinary(final Object obj) {
@Override
public byte[] toBinary(final Object obj) {
- Preconditions.checkArgument(obj instanceof ReadyLocalTransaction, "Unsupported object type %s", obj.getClass());
+ checkArgument(obj instanceof ReadyLocalTransaction, "Unsupported object type %s", obj.getClass());
final ReadyLocalTransaction readyLocal = (ReadyLocalTransaction) obj;
final BatchedModifications batched = new BatchedModifications(readyLocal.getTransactionId(),
readyLocal.getRemoteVersion());
final ReadyLocalTransaction readyLocal = (ReadyLocalTransaction) obj;
final BatchedModifications batched = new BatchedModifications(readyLocal.getTransactionId(),
readyLocal.getRemoteVersion());
private final BatchedModifications message;
BatchedCursor(final BatchedModifications message) {
private final BatchedModifications message;
BatchedCursor(final BatchedModifications message) {
- this.message = Preconditions.checkNotNull(message);
+ this.message = requireNonNull(message);
*/
package org.opendaylight.controller.cluster.datastore.messages;
*/
package org.opendaylight.controller.cluster.datastore.messages;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorPath;
import akka.actor.ActorRef;
import akka.actor.ActorPath;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
import java.io.Serializable;
/**
import java.io.Serializable;
/**
private final ActorRef listenerRegistrationPath;
public RegisterDataTreeNotificationListenerReply(final ActorRef listenerRegistrationPath) {
private final ActorRef listenerRegistrationPath;
public RegisterDataTreeNotificationListenerReply(final ActorRef listenerRegistrationPath) {
- this.listenerRegistrationPath = Preconditions.checkNotNull(listenerRegistrationPath);
+ this.listenerRegistrationPath = requireNonNull(listenerRegistrationPath);
}
public ActorPath getListenerRegistrationPath() {
}
public ActorPath getListenerRegistrationPath() {
*/
package org.opendaylight.controller.cluster.datastore.persisted;
*/
package org.opendaylight.controller.cluster.datastore.persisted;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import java.util.Collection;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
private final ModificationType type;
protected AbstractDataTreeCandidateNode(final ModificationType type) {
private final ModificationType type;
protected AbstractDataTreeCandidateNode(final ModificationType type) {
- this.type = Preconditions.checkNotNull(type);
+ this.type = requireNonNull(type);
import static java.util.Objects.requireNonNull;
import static java.util.Objects.requireNonNull;
-import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.io.ByteStreams;
import java.io.DataInput;
import com.google.common.base.Verify;
import com.google.common.io.ByteStreams;
import java.io.DataInput;
}
protected AbstractProxy(final byte[] serialized) {
}
protected AbstractProxy(final byte[] serialized) {
- this.serialized = Preconditions.checkNotNull(serialized);
+ this.serialized = requireNonNull(serialized);
*/
package org.opendaylight.controller.cluster.datastore.persisted;
*/
package org.opendaylight.controller.cluster.datastore.persisted;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import java.io.DataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import java.io.DataInput;
}
Proxy(final byte[] serialized) {
}
Proxy(final byte[] serialized) {
- this.serialized = Preconditions.checkNotNull(serialized);
+ this.serialized = requireNonNull(serialized);
private final byte[] serialized;
CommitTransactionPayload(final byte[] serialized) {
private final byte[] serialized;
CommitTransactionPayload(final byte[] serialized) {
- this.serialized = Preconditions.checkNotNull(serialized);
+ this.serialized = requireNonNull(serialized);
}
public static CommitTransactionPayload create(final TransactionIdentifier transactionId,
}
public static CommitTransactionPayload create(final TransactionIdentifier transactionId,
*/
package org.opendaylight.controller.cluster.datastore.persisted;
*/
package org.opendaylight.controller.cluster.datastore.persisted;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.ImmutableRangeSet.Builder;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.ImmutableRangeSet.Builder;
public FrontendClientMetadata(final ClientIdentifier identifier, final RangeSet<UnsignedLong> purgedHistories,
final Collection<FrontendHistoryMetadata> currentHistories) {
public FrontendClientMetadata(final ClientIdentifier identifier, final RangeSet<UnsignedLong> purgedHistories,
final Collection<FrontendHistoryMetadata> currentHistories) {
- this.identifier = Preconditions.checkNotNull(identifier);
+ this.identifier = requireNonNull(identifier);
this.purgedHistories = ImmutableRangeSet.copyOf(purgedHistories);
this.currentHistories = ImmutableList.copyOf(currentHistories);
}
this.purgedHistories = ImmutableRangeSet.copyOf(purgedHistories);
this.currentHistories = ImmutableList.copyOf(currentHistories);
}
*/
package org.opendaylight.controller.cluster.datastore.persisted;
*/
package org.opendaylight.controller.cluster.datastore.persisted;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import java.util.Collection;
import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
private ModifiedDataTreeCandidateNode(final ModificationType type,
final Collection<DataTreeCandidateNode> children) {
super(type);
private ModifiedDataTreeCandidateNode(final ModificationType type,
final Collection<DataTreeCandidateNode> children) {
super(type);
- this.children = Preconditions.checkNotNull(children);
+ this.children = requireNonNull(children);
}
static DataTreeCandidateNode create(final ModificationType type, final Collection<DataTreeCandidateNode> children) {
}
static DataTreeCandidateNode create(final ModificationType type, final Collection<DataTreeCandidateNode> children) {
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
-import com.google.common.base.Preconditions;
import java.util.concurrent.CountDownLatch;
import org.opendaylight.controller.cluster.datastore.AbstractDataStore;
import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
import java.util.concurrent.CountDownLatch;
import org.opendaylight.controller.cluster.datastore.AbstractDataStore;
import org.opendaylight.controller.cluster.datastore.ClusterWrapper;
}
protected final void checkSealed() {
}
protected final void checkSealed() {
- Preconditions.checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
+ checkState(!sealed, "Builder is already sealed - further modifications are not allowed");
}
ClusterWrapper getCluster() {
return cluster;
}
}
ClusterWrapper getCluster() {
return cluster;
}
- public T cluster(ClusterWrapper newCluster) {
+ public T cluster(final ClusterWrapper newCluster) {
checkSealed();
this.cluster = newCluster;
return self();
checkSealed();
this.cluster = newCluster;
return self();
- public T configuration(Configuration newConfiguration) {
+ public T configuration(final Configuration newConfiguration) {
checkSealed();
this.configuration = newConfiguration;
return self();
checkSealed();
this.configuration = newConfiguration;
return self();
public T datastoreContextFactory(final DatastoreContextFactory newDatastoreContextFactory) {
checkSealed();
public T datastoreContextFactory(final DatastoreContextFactory newDatastoreContextFactory) {
checkSealed();
- this.datastoreContextFactory = Preconditions.checkNotNull(newDatastoreContextFactory);
+ this.datastoreContextFactory = requireNonNull(newDatastoreContextFactory);
return waitTillReadyCountDownLatch;
}
return waitTillReadyCountDownLatch;
}
- public T waitTillReadyCountDownLatch(CountDownLatch newWaitTillReadyCountDownLatch) {
+ public T waitTillReadyCountDownLatch(final CountDownLatch newWaitTillReadyCountDownLatch) {
checkSealed();
this.waitTillReadyCountDownLatch = newWaitTillReadyCountDownLatch;
return self();
checkSealed();
this.waitTillReadyCountDownLatch = newWaitTillReadyCountDownLatch;
return self();
return primaryShardInfoCache;
}
return primaryShardInfoCache;
}
- public T primaryShardInfoCache(PrimaryShardInfoFutureCache newPrimaryShardInfoCache) {
+ public T primaryShardInfoCache(final PrimaryShardInfoFutureCache newPrimaryShardInfoCache) {
checkSealed();
this.primaryShardInfoCache = newPrimaryShardInfoCache;
return self();
checkSealed();
this.primaryShardInfoCache = newPrimaryShardInfoCache;
return self();
return restoreFromSnapshot;
}
return restoreFromSnapshot;
}
- public T restoreFromSnapshot(DatastoreSnapshot newRestoreFromSnapshot) {
+ public T restoreFromSnapshot(final DatastoreSnapshot newRestoreFromSnapshot) {
checkSealed();
this.restoreFromSnapshot = newRestoreFromSnapshot;
return self();
checkSealed();
this.restoreFromSnapshot = newRestoreFromSnapshot;
return self();
protected void verify() {
sealed = true;
protected void verify() {
sealed = true;
- Preconditions.checkNotNull(cluster, "cluster should not be null");
- Preconditions.checkNotNull(configuration, "configuration should not be null");
- Preconditions.checkNotNull(datastoreContextFactory, "datastoreContextFactory should not be null");
- Preconditions.checkNotNull(distributedDataStore, "distributedDataStore should not be null");
- Preconditions.checkNotNull(waitTillReadyCountDownLatch, "waitTillReadyCountdownLatch should not be null");
- Preconditions.checkNotNull(primaryShardInfoCache, "primaryShardInfoCache should not be null");
+ requireNonNull(cluster, "cluster should not be null");
+ requireNonNull(configuration, "configuration should not be null");
+ requireNonNull(datastoreContextFactory, "datastoreContextFactory should not be null");
+ requireNonNull(distributedDataStore, "distributedDataStore should not be null");
+ requireNonNull(waitTillReadyCountDownLatch, "waitTillReadyCountdownLatch should not be null");
+ requireNonNull(primaryShardInfoCache, "primaryShardInfoCache should not be null");
import akka.actor.Props;
import akka.serialization.Serialization;
import com.google.common.annotations.VisibleForTesting;
import akka.actor.Props;
import akka.serialization.Serialization;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import java.util.HashSet;
import java.util.Iterator;
import com.google.common.base.Strings;
import java.util.HashSet;
import java.util.Iterator;
}
void setSchemaContext(final SchemaContext schemaContext) {
}
void setSchemaContext(final SchemaContext schemaContext) {
- schemaContextProvider.set(Preconditions.checkNotNull(schemaContext));
+ schemaContextProvider.set(requireNonNull(schemaContext));
package org.opendaylight.controller.cluster.datastore.shardmanager;
import static akka.pattern.Patterns.ask;
package org.opendaylight.controller.cluster.datastore.shardmanager;
import static akka.pattern.Patterns.ask;
+import static java.util.Objects.requireNonNull;
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.persistence.SnapshotSelectionCriteria;
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
import akka.persistence.SnapshotSelectionCriteria;
import akka.util.Timeout;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
*/
protected AutoFindPrimaryFailureResponseHandler(final ActorRef targetActor, final String shardName,
final String persistenceId, final ActorRef shardManagerActor) {
*/
protected AutoFindPrimaryFailureResponseHandler(final ActorRef targetActor, final String shardName,
final String persistenceId, final ActorRef shardManagerActor) {
- this.targetActor = Preconditions.checkNotNull(targetActor);
- this.shardName = Preconditions.checkNotNull(shardName);
- this.persistenceId = Preconditions.checkNotNull(persistenceId);
- this.shardManagerActor = Preconditions.checkNotNull(shardManagerActor);
+ this.targetActor = requireNonNull(targetActor);
+ this.shardName = requireNonNull(shardName);
+ this.persistenceId = requireNonNull(persistenceId);
+ this.shardManagerActor = requireNonNull(shardManagerActor);
}
public ActorRef getTargetActor() {
}
public ActorRef getTargetActor() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.shardmanager;
package org.opendaylight.controller.cluster.datastore.shardmanager;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.pattern.Patterns;
import akka.actor.ActorRef;
import akka.pattern.Patterns;
-import com.google.common.base.Preconditions;
import java.util.List;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import java.util.List;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
ShardManagerInfo(final ActorRef shardManager, final MemberName memberName, final String name,
final String mxBeanType) {
super(name, mxBeanType, JMX_CATEGORY_SHARD_MANAGER);
ShardManagerInfo(final ActorRef shardManager, final MemberName memberName, final String name,
final String mxBeanType) {
super(name, mxBeanType, JMX_CATEGORY_SHARD_MANAGER);
- this.shardManager = Preconditions.checkNotNull(shardManager);
- this.memberName = Preconditions.checkNotNull(memberName);
+ this.shardManager = requireNonNull(shardManager);
+ this.memberName = requireNonNull(memberName);
}
@SuppressWarnings({"unchecked", "checkstyle:IllegalCatch"})
}
@SuppressWarnings({"unchecked", "checkstyle:IllegalCatch"})
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
*/
package org.opendaylight.controller.cluster.datastore.shardmanager;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.Address;
import akka.actor.AddressFromURIString;
import akka.actor.Address;
import akka.actor.AddressFromURIString;
-import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
private final String shardManagerType;
private final MemberName localMemberName;
private final String shardManagerType;
private final MemberName localMemberName;
- ShardPeerAddressResolver(String shardManagerType, MemberName localMemberName) {
+ ShardPeerAddressResolver(final String shardManagerType, final MemberName localMemberName) {
this.shardManagerIdentifier = ShardManagerIdentifier.builder().type(shardManagerType).build().toString();
this.shardManagerType = shardManagerType;
this.shardManagerIdentifier = ShardManagerIdentifier.builder().type(shardManagerType).build().toString();
this.shardManagerType = shardManagerType;
- this.localMemberName = Preconditions.checkNotNull(localMemberName);
+ this.localMemberName = requireNonNull(localMemberName);
- void addPeerAddress(MemberName memberName, Address address) {
+ void addPeerAddress(final MemberName memberName, final Address address) {
memberNameToAddress.put(memberName, address);
}
memberNameToAddress.put(memberName, address);
}
- void removePeerAddress(MemberName memberName) {
+ void removePeerAddress(final MemberName memberName) {
memberNameToAddress.remove(memberName);
}
memberNameToAddress.remove(memberName);
}
return this.memberNameToAddress.keySet();
}
return this.memberNameToAddress.keySet();
}
- Address getPeerAddress(MemberName memberName) {
+ Address getPeerAddress(final MemberName memberName) {
return memberNameToAddress.get(memberName);
}
return memberNameToAddress.get(memberName);
}
- ShardIdentifier getShardIdentifier(MemberName memberName, String shardName) {
+ ShardIdentifier getShardIdentifier(final MemberName memberName, final String shardName) {
return ShardIdentifier.create(shardName, memberName, shardManagerType);
}
return ShardIdentifier.create(shardName, memberName, shardManagerType);
}
- String getShardActorAddress(String shardName, MemberName memberName) {
+ String getShardActorAddress(final String shardName, final MemberName memberName) {
Address memberAddress = memberNameToAddress.get(memberName);
if (memberAddress != null) {
return getShardManagerActorPathBuilder(memberAddress).append("/").append(
Address memberAddress = memberNameToAddress.get(memberName);
if (memberAddress != null) {
return getShardManagerActorPathBuilder(memberAddress).append("/").append(
- StringBuilder getShardManagerActorPathBuilder(Address address) {
+ StringBuilder getShardManagerActorPathBuilder(final Address address) {
return new StringBuilder().append(address.toString()).append("/user/").append(shardManagerIdentifier);
}
@Override
return new StringBuilder().append(address.toString()).append("/user/").append(shardManagerIdentifier);
}
@Override
- public String resolve(String peerId) {
+ public String resolve(final String peerId) {
if (peerId == null) {
return null;
}
if (peerId == null) {
return null;
}
- public void setResolved(String peerId, String address) {
+ public void setResolved(final String peerId, final String address) {
memberNameToAddress.put(ShardIdentifier.fromShardIdString(peerId).getMemberName(),
AddressFromURIString.parse(address));
}
memberNameToAddress.put(ShardIdentifier.fromShardIdString(peerId).getMemberName(),
AddressFromURIString.parse(address));
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.shardstrategy;
package org.opendaylight.controller.cluster.datastore.shardstrategy;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.cluster.datastore.config.Configuration;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
private final LogicalDatastoreType logicalStoreType;
public ShardStrategyFactory(final Configuration configuration, final LogicalDatastoreType logicalStoreType) {
private final LogicalDatastoreType logicalStoreType;
public ShardStrategyFactory(final Configuration configuration, final LogicalDatastoreType logicalStoreType) {
- Preconditions.checkState(configuration != null, "configuration should not be missing");
+ checkState(configuration != null, "configuration should not be missing");
this.configuration = configuration;
this.configuration = configuration;
- this.logicalStoreType = Preconditions.checkNotNull(logicalStoreType);
+ this.logicalStoreType = requireNonNull(logicalStoreType);
}
public ShardStrategy getStrategy(final YangInstanceIdentifier path) {
}
public ShardStrategy getStrategy(final YangInstanceIdentifier path) {
- Preconditions.checkNotNull(path, "path should not be null");
-
// try with the legacy module based shard mapping
// try with the legacy module based shard mapping
- final String moduleName = getModuleName(path);
+ final String moduleName = getModuleName(requireNonNull(path, "path should not be null"));
final ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName);
if (shardStrategy == null) {
// retry with prefix based sharding
final ShardStrategy shardStrategy = configuration.getStrategyForModule(moduleName);
if (shardStrategy == null) {
// retry with prefix based sharding
*/
package org.opendaylight.controller.cluster.datastore.utils;
*/
package org.opendaylight.controller.cluster.datastore.utils;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
private final RangeSet<UnsignedLong> rangeset;
private UnsignedLongRangeSet(final RangeSet<UnsignedLong> rangeset) {
private final RangeSet<UnsignedLong> rangeset;
private UnsignedLongRangeSet(final RangeSet<UnsignedLong> rangeset) {
- this.rangeset = Preconditions.checkNotNull(rangeset);
+ this.rangeset = requireNonNull(rangeset);
}
public static UnsignedLongRangeSet create() {
}
public static UnsignedLongRangeSet create() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding;
package org.opendaylight.controller.cluster.sharding;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Map;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
import java.util.Map;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
final Map<PathArgument, WriteableModificationNode> subshards,
final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) {
super(subshards);
final Map<PathArgument, WriteableModificationNode> subshards,
final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) {
super(subshards);
- this.context = Preconditions.checkNotNull(context);
- this.childShards = Preconditions.checkNotNull(childShards);
+ this.context = requireNonNull(context);
+ this.childShards = requireNonNull(childShards);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding;
package org.opendaylight.controller.cluster.sharding;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
DistributedShardModificationFactory(final DOMDataTreeIdentifier root,
final Map<PathArgument, WriteableModificationNode> children,
final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) {
DistributedShardModificationFactory(final DOMDataTreeIdentifier root,
final Map<PathArgument, WriteableModificationNode> children,
final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) {
- this.root = Preconditions.checkNotNull(root);
+ this.root = requireNonNull(root);
this.children = ImmutableMap.copyOf(children);
this.childShards = ImmutableMap.copyOf(childShards);
}
this.children = ImmutableMap.copyOf(children);
this.childShards = ImmutableMap.copyOf(childShards);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding;
import static akka.actor.ActorRef.noSender;
package org.opendaylight.controller.cluster.sharding;
import static akka.actor.ActorRef.noSender;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_PREFIX_QNAME;
import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_REPLICAS_QNAME;
import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_REPLICA_QNAME;
import akka.actor.ActorRef;
import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_PREFIX_QNAME;
import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_REPLICAS_QNAME;
import static org.opendaylight.controller.cluster.datastore.utils.ClusterUtils.SHARD_REPLICA_QNAME;
import akka.actor.ActorRef;
-import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
import java.util.Collection;
import java.util.EnumMap;
import java.util.List;
new EnumMap<>(LogicalDatastoreType.class);
public PrefixedShardConfigUpdateHandler(final ActorRef handlingActor, final MemberName memberName) {
new EnumMap<>(LogicalDatastoreType.class);
public PrefixedShardConfigUpdateHandler(final ActorRef handlingActor, final MemberName memberName) {
- this.handlingActor = Preconditions.checkNotNull(handlingActor);
- this.memberName = Preconditions.checkNotNull(memberName);
+ this.handlingActor = requireNonNull(handlingActor);
+ this.memberName = requireNonNull(memberName);
}
public void initListener(final AbstractDataStore dataStore, final LogicalDatastoreType type) {
}
public void initListener(final AbstractDataStore dataStore, final LogicalDatastoreType type) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding;
package org.opendaylight.controller.cluster.sharding;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.ActorRef;
import akka.actor.Props;
-import com.google.common.base.Preconditions;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.cluster.dom.api.LeaderLocation;
import org.opendaylight.controller.cluster.dom.api.LeaderLocationListener;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.cluster.dom.api.LeaderLocation;
import org.opendaylight.controller.cluster.dom.api.LeaderLocationListener;
private final ActorRef roleChangeNotifier;
private RoleChangeListenerActor(final ActorRef roleChangeNotifier, final LeaderLocationListener listener) {
private final ActorRef roleChangeNotifier;
private RoleChangeListenerActor(final ActorRef roleChangeNotifier, final LeaderLocationListener listener) {
- this.roleChangeNotifier = Preconditions.checkNotNull(roleChangeNotifier);
- this.leaderLocationListener = Preconditions.checkNotNull(listener);
+ this.roleChangeNotifier = requireNonNull(roleChangeNotifier);
+ this.leaderLocationListener = requireNonNull(listener);
*/
package org.opendaylight.controller.cluster.sharding;
*/
package org.opendaylight.controller.cluster.sharding;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import static java.util.Objects.requireNonNull;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
private YangInstanceIdentifier toRelative(final YangInstanceIdentifier path) {
final Optional<YangInstanceIdentifier> relative =
path.relativeTo(modification.getPrefix().getRootIdentifier());
private YangInstanceIdentifier toRelative(final YangInstanceIdentifier path) {
final Optional<YangInstanceIdentifier> relative =
path.relativeTo(modification.getPrefix().getRootIdentifier());
- Preconditions.checkArgument(relative.isPresent());
+ checkArgument(relative.isPresent());
public void ready() {
LOG.debug("Readying transaction for shard {}", shardRoot);
public void ready() {
LOG.debug("Readying transaction for shard {}", shardRoot);
- Preconditions.checkNotNull(modification, "Attempting to ready an empty transaction.");
+ requireNonNull(modification, "Attempting to ready an empty transaction.");
cohorts.add(modification.seal());
for (Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry
cohorts.add(modification.seal());
for (Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry
}
private void checkTransactionReadied() {
}
private void checkTransactionReadied() {
- Preconditions.checkState(!cohorts.isEmpty(), "Transaction not readied yet");
+ checkState(!cohorts.isEmpty(), "Transaction not readied yet");
*/
package org.opendaylight.controller.cluster.sharding;
*/
package org.opendaylight.controller.cluster.sharding;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.util.Timeout;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
}
private void verify() {
}
private void verify() {
- Preconditions.checkNotNull(shardingService);
- Preconditions.checkNotNull(actorSystem);
- Preconditions.checkNotNull(cluster);
- Preconditions.checkNotNull(distributedConfigDatastore);
- Preconditions.checkNotNull(distributedOperDatastore);
+ requireNonNull(shardingService);
+ requireNonNull(actorSystem);
+ requireNonNull(cluster);
+ requireNonNull(distributedConfigDatastore);
+ requireNonNull(distributedOperDatastore);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding;
package org.opendaylight.controller.cluster.sharding;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.Address;
import akka.actor.Address;
-import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
}
public String resolve(final MemberName memberName) {
}
public String resolve(final MemberName memberName) {
- Preconditions.checkNotNull(memberName);
- final Address address = memberNameToAddress.get(memberName);
- Preconditions.checkNotNull(address, "Requested member[%s] is not present in the resolver ",
- memberName.toString());
-
+ final Address address = memberNameToAddress.get(requireNonNull(memberName));
+ checkNotNull(address, "Requested member[%s] is not present in the resolver", memberName);
return getActorPathBuilder(address).toString();
}
}
return getActorPathBuilder(address).toString();
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding.messages;
package org.opendaylight.controller.cluster.sharding.messages;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import java.io.Serializable;
import org.opendaylight.controller.cluster.sharding.ShardedDataTreeActor;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import java.io.Serializable;
import org.opendaylight.controller.cluster.sharding.ShardedDataTreeActor;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
private final DOMDataTreeIdentifier prefix;
public LookupPrefixShard(final DOMDataTreeIdentifier prefix) {
private final DOMDataTreeIdentifier prefix;
public LookupPrefixShard(final DOMDataTreeIdentifier prefix) {
- this.prefix = Preconditions.checkNotNull(prefix);
+ this.prefix = requireNonNull(prefix);
}
public DOMDataTreeIdentifier getPrefix() {
}
public DOMDataTreeIdentifier getPrefix() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding.messages;
import com.google.common.annotations.Beta;
package org.opendaylight.controller.cluster.sharding.messages;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.io.Serializable;
import java.util.Collection;
import com.google.common.collect.ImmutableList;
import java.io.Serializable;
import java.util.Collection;
private final Collection<DOMDataTreeIdentifier> subtrees;
public NotifyProducerCreated(final Collection<DOMDataTreeIdentifier> subtrees) {
private final Collection<DOMDataTreeIdentifier> subtrees;
public NotifyProducerCreated(final Collection<DOMDataTreeIdentifier> subtrees) {
- this.subtrees = ImmutableList.copyOf(Preconditions.checkNotNull(subtrees));
+ this.subtrees = ImmutableList.copyOf(subtrees);
}
public Collection<DOMDataTreeIdentifier> getSubtrees() {
}
public Collection<DOMDataTreeIdentifier> getSubtrees() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding.messages;
import com.google.common.annotations.Beta;
package org.opendaylight.controller.cluster.sharding.messages;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.io.Serializable;
import java.util.Collection;
import com.google.common.collect.ImmutableList;
import java.io.Serializable;
import java.util.Collection;
private final Collection<DOMDataTreeIdentifier> subtrees;
public NotifyProducerRemoved(final Collection<DOMDataTreeIdentifier> subtrees) {
private final Collection<DOMDataTreeIdentifier> subtrees;
public NotifyProducerRemoved(final Collection<DOMDataTreeIdentifier> subtrees) {
- this.subtrees = ImmutableList.copyOf(Preconditions.checkNotNull(subtrees));
+ this.subtrees = ImmutableList.copyOf(subtrees);
}
public Collection<DOMDataTreeIdentifier> getSubtrees() {
}
public Collection<DOMDataTreeIdentifier> getSubtrees() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.sharding.messages;
package org.opendaylight.controller.cluster.sharding.messages;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.controller.cluster.sharding.ShardedDataTreeActor;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.controller.cluster.sharding.ShardedDataTreeActor;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
* the system entirely the actor responds with a success.
*/
public class PrefixShardRemovalLookup {
* the system entirely the actor responds with a success.
*/
public class PrefixShardRemovalLookup {
private final DOMDataTreeIdentifier prefix;
public PrefixShardRemovalLookup(final DOMDataTreeIdentifier prefix) {
private final DOMDataTreeIdentifier prefix;
public PrefixShardRemovalLookup(final DOMDataTreeIdentifier prefix) {
-
- this.prefix = Preconditions.checkNotNull(prefix);
+ this.prefix = requireNonNull(prefix);
}
public DOMDataTreeIdentifier getPrefix() {
}
public DOMDataTreeIdentifier getPrefix() {
@Override
public String toString() {
@Override
public String toString() {
- return "PrefixShardRemovalLookup{"
- + "prefix=" + prefix
- + '}';
+ return "PrefixShardRemovalLookup{" + "prefix=" + prefix + '}';
import java.util.Arrays;
import java.util.HashMap;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.Map;
import org.junit.Test;
import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
import java.util.Map;
import org.junit.Test;
import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
updated = introspector.update(null);
assertFalse("updated", updated);
updated = introspector.update(null);
assertFalse("updated", updated);
- updated = introspector.update(new Hashtable<>());
+ updated = introspector.update(new HashMap<>());
assertFalse("updated", updated);
}
assertFalse("updated", updated);
}
*/
package org.opendaylight.controller.cluster.datastore;
*/
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import akka.cluster.ClusterEvent.CurrentClusterState;
import akka.cluster.Member;
import akka.cluster.MemberStatus;
import akka.cluster.ClusterEvent.CurrentClusterState;
import akka.cluster.Member;
import akka.cluster.MemberStatus;
-import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.base.Stopwatch;
-import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Uninterruptibles;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.google.common.util.concurrent.Uninterruptibles;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public static void verifyRaftPeersPresent(final AbstractDataStore datastore, final String shardName,
final String... peerMemberNames) throws Exception {
public static void verifyRaftPeersPresent(final AbstractDataStore datastore, final String shardName,
final String... peerMemberNames) throws Exception {
- final Set<String> peerIds = Sets.newHashSet();
+ final Set<String> peerIds = new HashSet<>();
for (String p: peerMemberNames) {
peerIds.add(ShardIdentifier.create(shardName, MemberName.forName(p),
datastore.getActorUtils().getDataStoreName()).toString());
for (String p: peerMemberNames) {
peerIds.add(ShardIdentifier.create(shardName, MemberName.forName(p),
datastore.getActorUtils().getDataStoreName()).toString());
}
public MemberNode build() throws Exception {
}
public MemberNode build() throws Exception {
- Preconditions.checkNotNull(moduleShardsConfig, "moduleShardsConfig must be specified");
- Preconditions.checkNotNull(akkaConfig, "akkaConfig must be specified");
- Preconditions.checkNotNull(testName, "testName must be specified");
+ requireNonNull(moduleShardsConfig, "moduleShardsConfig must be specified");
+ requireNonNull(akkaConfig, "akkaConfig must be specified");
+ requireNonNull(testName, "testName must be specified");
if (schemaContext == null) {
schemaContext = SchemaContextHelper.full();
if (schemaContext == null) {
schemaContext = SchemaContextHelper.full();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
import static org.junit.Assert.assertEquals;
import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.immediatePreCommit;
import com.google.common.base.Ticker;
import static org.opendaylight.controller.cluster.datastore.ShardDataTreeMocking.immediatePreCommit;
import com.google.common.base.Ticker;
-import com.google.common.collect.Maps;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import com.google.common.primitives.UnsignedLong;
import com.google.common.util.concurrent.FutureCallback;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.List;
import java.util.Map;
import java.util.Optional;
shardDataTree.applySnapshot(newDataTree.takeStateSnapshot());
shardDataTree.applySnapshot(newDataTree.takeStateSnapshot());
- Map<YangInstanceIdentifier, ModificationType> expChanges = Maps.newHashMap();
+ Map<YangInstanceIdentifier, ModificationType> expChanges = new HashMap<>();
expChanges.put(CarsModel.newCarPath("optima"), ModificationType.WRITE);
expChanges.put(CarsModel.newCarPath("murano"), ModificationType.WRITE);
expChanges.put(CarsModel.newCarPath("sportage"), ModificationType.DELETE);
expChanges.put(CarsModel.newCarPath("optima"), ModificationType.WRITE);
expChanges.put(CarsModel.newCarPath("murano"), ModificationType.WRITE);
expChanges.put(CarsModel.newCarPath("sportage"), ModificationType.DELETE);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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;
package org.opendaylight.controller.cluster.datastore;
+import static java.util.Objects.requireNonNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import akka.testkit.TestActorRef;
import com.codahale.metrics.Snapshot;
import com.codahale.metrics.Timer;
import akka.testkit.TestActorRef;
import com.codahale.metrics.Snapshot;
import com.codahale.metrics.Timer;
-import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
private final TransactionIdentifier transactionId;
Builder(final TransactionIdentifier transactionId) {
private final TransactionIdentifier transactionId;
Builder(final TransactionIdentifier transactionId) {
- this.transactionId = Preconditions.checkNotNull(transactionId);
+ this.transactionId = requireNonNull(transactionId);
}
Builder expectCanCommit(final Class<?> newExpCanCommitType, final Object newCanCommitReply) {
}
Builder expectCanCommit(final Class<?> newExpCanCommitType, final Object newCanCommitReply) {
import akka.testkit.TestActorRef;
import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
import akka.testkit.TestActorRef;
import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
-import com.google.common.base.Function;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
+import java.util.function.Function;
import java.util.stream.Collectors;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import java.util.stream.Collectors;
import org.junit.AfterClass;
import org.junit.BeforeClass;
assertEquals("getType", shardMrgIDSuffix, datastoreSnapshot.getType());
assertNull("Expected null ShardManagerSnapshot", datastoreSnapshot.getShardManagerSnapshot());
assertEquals("getType", shardMrgIDSuffix, datastoreSnapshot.getType());
assertNull("Expected null ShardManagerSnapshot", datastoreSnapshot.getShardManagerSnapshot());
- Function<ShardSnapshot, String> shardNameTransformer = ShardSnapshot::getName;
-
assertEquals("Shard names", Sets.newHashSet("shard1", "shard2"), Sets.newHashSet(
assertEquals("Shard names", Sets.newHashSet("shard1", "shard2"), Sets.newHashSet(
- datastoreSnapshot.getShardSnapshots().stream().map(shardNameTransformer).collect(Collectors.toSet())));
+ datastoreSnapshot.getShardSnapshots().stream().map(ShardSnapshot::getName).collect(Collectors.toSet())));
datastoreSnapshot = expectMsgClassOrFailure(DatastoreSnapshot.class, kit, "GetSnapshot");
assertEquals("Shard names", Sets.newHashSet("shard1", "shard2", "astronauts"), Sets.newHashSet(
datastoreSnapshot = expectMsgClassOrFailure(DatastoreSnapshot.class, kit, "GetSnapshot");
assertEquals("Shard names", Sets.newHashSet("shard1", "shard2", "astronauts"), Sets.newHashSet(
- Lists.transform(datastoreSnapshot.getShardSnapshots(), shardNameTransformer)));
+ Lists.transform(datastoreSnapshot.getShardSnapshots(), ShardSnapshot::getName)));
ShardManagerSnapshot snapshot = datastoreSnapshot.getShardManagerSnapshot();
assertNotNull("Expected ShardManagerSnapshot", snapshot);
ShardManagerSnapshot snapshot = datastoreSnapshot.getShardManagerSnapshot();
assertNotNull("Expected ShardManagerSnapshot", snapshot);
import akka.testkit.TestActorRef;
import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
import akka.testkit.TestActorRef;
import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.typesafe.config.ConfigFactory;
import java.time.Duration;
import java.util.Arrays;
import com.google.common.collect.Sets;
import com.typesafe.config.ConfigFactory;
import java.time.Duration;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
}
private static final class MockShardManager extends UntypedAbstractActor {
}
private static final class MockShardManager extends UntypedAbstractActor {
+ private final Map<String,Object> findPrimaryResponses = new HashMap<>();
private final boolean found;
private final ActorRef actorRef;
private final boolean found;
private final ActorRef actorRef;
- private final Map<String,Object> findPrimaryResponses = Maps.newHashMap();
private MockShardManager(final boolean found, final ActorRef actorRef) {
private MockShardManager(final boolean found, final ActorRef actorRef) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.md.sal.dom.broker.impl;
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import java.util.Map;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
import java.util.Collection;
import java.util.Map;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
* Key,value map of backing transactions.
*/
protected AbstractDOMForwardedCompositeTransaction(final Object identifier, final Map<K, T> backingTxs) {
* Key,value map of backing transactions.
*/
protected AbstractDOMForwardedCompositeTransaction(final Object identifier, final Map<K, T> backingTxs) {
- this.identifier = Preconditions.checkNotNull(identifier, "Identifier should not be null");
- this.backingTxs = Preconditions.checkNotNull(backingTxs, "Backing transactions should not be null");
+ this.identifier = requireNonNull(identifier, "Identifier should not be null");
+ this.backingTxs = requireNonNull(backingTxs, "Backing transactions should not be null");
* if no subtransaction is associated with key.
*/
protected final T getSubtransaction(final K key) {
* if no subtransaction is associated with key.
*/
protected final T getSubtransaction(final K key) {
- Preconditions.checkNotNull(key, "key must not be null.");
-
- final T ret = backingTxs.get(key);
- Preconditions.checkArgument(ret != null, "No subtransaction associated with %s", key);
+ final T ret = backingTxs.get(requireNonNull(key, "key must not be null."));
+ checkArgument(ret != null, "No subtransaction associated with %s", key);
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Maps;
AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations) {
- this.schemaPath = Preconditions.checkNotNull(schemaPath);
- this.implementations = Preconditions.checkNotNull(implementations);
+ this.schemaPath = requireNonNull(schemaPath);
+ this.implementations = requireNonNull(implementations);
}
final SchemaPath getSchemaPath() {
}
final SchemaPath getSchemaPath() {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.md.sal.dom.broker.impl;
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.Futures;
import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.Futures;
final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
final DurationStatisticsTracker commitStatTracker,
final Supplier<T> futureValueSupplier) {
final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
final DurationStatisticsTracker commitStatTracker,
final Supplier<T> futureValueSupplier) {
- this.tx = Preconditions.checkNotNull(transaction, "transaction must not be null");
- this.cohorts = Preconditions.checkNotNull(cohorts, "cohorts must not be null");
+ this.tx = requireNonNull(transaction, "transaction must not be null");
+ this.cohorts = requireNonNull(cohorts, "cohorts must not be null");
this.commitStatTracker = commitStatTracker;
this.futureValueSupplier = futureValueSupplier;
}
this.commitStatTracker = commitStatTracker;
this.futureValueSupplier = futureValueSupplier;
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.md.sal.dom.broker.impl;
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
final TransactionChainListener listener) {
super(chains);
this.chainId = chainId;
final TransactionChainListener listener) {
super(chains);
this.chainId = chainId;
- this.broker = Preconditions.checkNotNull(broker);
- this.listener = Preconditions.checkNotNull(listener);
+ this.broker = requireNonNull(broker);
+ this.listener = requireNonNull(listener);
}
private void checkNotFailed() {
}
private void checkNotFailed() {
- Preconditions.checkState(state != State.FAILED, "Transaction chain has failed");
+ checkState(state != State.FAILED, "Transaction chain has failed");
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
protected DOMForwardedWriteTransaction(final Object identifier, final Map<LogicalDatastoreType, T> backingTxs,
final AbstractDOMForwardedTransactionFactory<?> commitImpl) {
super(identifier, backingTxs);
protected DOMForwardedWriteTransaction(final Object identifier, final Map<LogicalDatastoreType, T> backingTxs,
final AbstractDOMForwardedTransactionFactory<?> commitImpl) {
super(identifier, backingTxs);
- this.commitImpl = Preconditions.checkNotNull(commitImpl, "commitImpl must not be null.");
+ this.commitImpl = requireNonNull(commitImpl, "commitImpl must not be null.");
}
@SuppressWarnings("checkstyle:IllegalCatch")
}
@SuppressWarnings("checkstyle:IllegalCatch")
- private <V> ListenableFuture<V> doCommit(Supplier<V> futureValueSupplier) {
+ private <V> ListenableFuture<V> doCommit(final Supplier<V> futureValueSupplier) {
final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
checkRunning(impl);
final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
checkRunning(impl);
}
private void checkRunning(final AbstractDOMForwardedTransactionFactory<?> impl) {
}
private void checkRunning(final AbstractDOMForwardedTransactionFactory<?> impl) {
- Preconditions.checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
+ checkState(impl != null, "Transaction %s is no longer running", getIdentifier());
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import com.lmax.disruptor.EventFactory;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import com.lmax.disruptor.EventFactory;
ListenableFuture<Void> initialize(final DOMNotification notification,
final Collection<ListenerRegistration<? extends DOMNotificationListener>>
subscribers) {
ListenableFuture<Void> initialize(final DOMNotification notification,
final Collection<ListenerRegistration<? extends DOMNotificationListener>>
subscribers) {
- this.notification = Preconditions.checkNotNull(notification);
- this.subscribers = Preconditions.checkNotNull(subscribers);
+ this.notification = requireNonNull(notification);
+ this.subscribers = requireNonNull(subscribers);
this.future = SettableFuture.create();
return this.future;
}
this.future = SettableFuture.create();
return this.future;
}
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.LinkedListMultimap;
private DOMRpcRoutingTable(final Map<SchemaPath, AbstractDOMRpcRoutingTableEntry> rpcs,
final SchemaContext schemaContext) {
private DOMRpcRoutingTable(final Map<SchemaPath, AbstractDOMRpcRoutingTableEntry> rpcs,
final SchemaContext schemaContext) {
- this.rpcs = Preconditions.checkNotNull(rpcs);
+ this.rpcs = requireNonNull(rpcs);
this.schemaContext = schemaContext;
}
this.schemaContext = schemaContext;
}
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.CheckedFuture;
import java.util.List;
import java.util.Map;
import com.google.common.util.concurrent.CheckedFuture;
import java.util.List;
import java.util.Map;
private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
super(rpcId.getType(), impls);
private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
super(rpcId.getType(), impls);
- this.rpcId = Preconditions.checkNotNull(rpcId);
+ this.rpcId = requireNonNull(rpcId);
}
// We do not need the RpcDefinition, but this makes sure we do not
}
// We do not need the RpcDefinition, but this makes sure we do not
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
private DOMDataReadWriteTransaction frontendTransaction;
PingPongTransaction(final DOMDataReadWriteTransaction delegate) {
private DOMDataReadWriteTransaction frontendTransaction;
PingPongTransaction(final DOMDataReadWriteTransaction delegate) {
- this.delegate = Preconditions.checkNotNull(delegate);
+ this.delegate = requireNonNull(delegate);
future = SettableFuture.create();
}
future = SettableFuture.create();
}
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import java.util.List;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import java.util.List;
private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, final YangInstanceIdentifier keyId,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
super(globalRpcId.getType(), impls);
private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, final YangInstanceIdentifier keyId,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
super(globalRpcId.getType(), impls);
- this.keyId = Preconditions.checkNotNull(keyId);
- this.globalRpcId = Preconditions.checkNotNull(globalRpcId);
+ this.keyId = requireNonNull(keyId);
+ this.globalRpcId = requireNonNull(globalRpcId);
}
RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
super(def.getPath(), impls);
}
RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId,
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
super(def.getPath(), impls);
- this.keyId = Preconditions.checkNotNull(keyId);
+ this.keyId = requireNonNull(keyId);
this.globalRpcId = DOMRpcIdentifier.create(def.getPath());
}
this.globalRpcId = DOMRpcIdentifier.create(def.getPath());
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.md.sal.dom.broker.impl;
package org.opendaylight.controller.md.sal.dom.broker.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.base.Supplier;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
public SerializedDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores,
final ListeningExecutorService executor) {
super(datastores);
public SerializedDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores,
final ListeningExecutorService executor) {
super(datastores);
- this.executor = Preconditions.checkNotNull(executor, "executor must not be null.");
+ this.executor = requireNonNull(executor, "executor must not be null.");
}
public DurationStatisticsTracker getCommitStatsTracker() {
}
public DurationStatisticsTracker getCommitStatsTracker() {
@Override
protected <T> ListenableFuture<T> commit(final DOMDataWriteTransaction transaction,
final Collection<DOMStoreThreePhaseCommitCohort> cohorts, final Supplier<T> futureValueSupplier) {
@Override
protected <T> ListenableFuture<T> commit(final DOMDataWriteTransaction transaction,
final Collection<DOMStoreThreePhaseCommitCohort> cohorts, final Supplier<T> futureValueSupplier) {
- Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
- Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
+ checkArgument(transaction != null, "Transaction must not be null.");
+ checkArgument(cohorts != null, "Cohorts must not be null.");
LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
ListenableFuture<T> commitFuture;
LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
ListenableFuture<T> commitFuture;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import java.util.Collections;
import java.util.Map;
import java.util.Collections;
import java.util.Map;
public LegacyShardedDOMDataBrokerAdapter(final ShardedDOMDataBrokerAdapter delegateDataBroker,
final DOMSchemaService schemaService) {
public LegacyShardedDOMDataBrokerAdapter(final ShardedDOMDataBrokerAdapter delegateDataBroker,
final DOMSchemaService schemaService) {
- this.delegateDataBroker = checkNotNull(delegateDataBroker);
- this.schemaService = checkNotNull(schemaService);
+ this.delegateDataBroker = requireNonNull(delegateDataBroker);
+ this.schemaService = requireNonNull(schemaService);
*/
package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
*/
package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
ShardedDOMDataBrokerDelegatingReadTransaction(final Object txIdentifier,
final DOMDataTreeReadTransaction delegateTx) {
ShardedDOMDataBrokerDelegatingReadTransaction(final Object txIdentifier,
final DOMDataTreeReadTransaction delegateTx) {
- this.delegateTx = checkNotNull(delegateTx);
- this.txIdentifier = checkNotNull(txIdentifier);
+ this.delegateTx = requireNonNull(delegateTx);
+ this.txIdentifier = requireNonNull(txIdentifier);
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
+import java.util.EnumMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import java.util.Map;
import java.util.Queue;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
this.readTxDelegate = requireNonNull(readTxDelegate);
this.writeTxDelegate = requireNonNull(writeTxDelegate);
this.txIdentifier = requireNonNull(readWriteTxId);
this.readTxDelegate = requireNonNull(readTxDelegate);
this.writeTxDelegate = requireNonNull(writeTxDelegate);
this.txIdentifier = requireNonNull(readWriteTxId);
- this.initialReadMap = Maps.newEnumMap(LogicalDatastoreType.class);
+ this.initialReadMap = new EnumMap<>(LogicalDatastoreType.class);
final InMemoryDataTreeFactory treeFactory = new InMemoryDataTreeFactory();
final ImmutableMap.Builder<LogicalDatastoreType, DataTreeSnapshot> snapshotMapBuilder = ImmutableMap.builder();
final InMemoryDataTreeFactory treeFactory = new InMemoryDataTreeFactory();
final ImmutableMap.Builder<LogicalDatastoreType, DataTreeSnapshot> snapshotMapBuilder = ImmutableMap.builder();
tree.setSchemaContext(ctx);
snapshotMapBuilder.put(store, tree.takeSnapshot());
tree.setSchemaContext(ctx);
snapshotMapBuilder.put(store, tree.takeSnapshot());
- modificationHistoryMapBuilder.put(store, Lists.newLinkedList());
+ modificationHistoryMapBuilder.put(store, new LinkedList<>());
}
modificationHistoryMap = modificationHistoryMapBuilder.build();
}
modificationHistoryMap = modificationHistoryMapBuilder.build();
import static java.util.Objects.requireNonNull;
import com.google.common.base.Preconditions;
import static java.util.Objects.requireNonNull;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
@Deprecated
class ShardedDOMDataBrokerDelegatingTransactionChain implements DOMTransactionChain, DOMTransactionChainListener {
@Deprecated
class ShardedDOMDataBrokerDelegatingTransactionChain implements DOMTransactionChain, DOMTransactionChainListener {
+ private final Map<Object, AsyncTransaction<?, ?>> transactionMap = new HashMap<>();
private final org.opendaylight.mdsal.dom.api.DOMTransactionChain txChainDelegate;
private final SchemaContext schemaContext;
private final TransactionChainListener txChainListener;
private final Object txChainIdentifier;
private final AtomicLong txNum = new AtomicLong();
private final org.opendaylight.mdsal.dom.api.DOMTransactionChain txChainDelegate;
private final SchemaContext schemaContext;
private final TransactionChainListener txChainListener;
private final Object txChainIdentifier;
private final AtomicLong txNum = new AtomicLong();
- private final Map<Object, AsyncTransaction<?, ?>> transactionMap;
-
ShardedDOMDataBrokerDelegatingTransactionChain(final Object txChainIdentifier,
final SchemaContext schemaContext,
final org.opendaylight.mdsal.dom.api.DOMDataBroker
ShardedDOMDataBrokerDelegatingTransactionChain(final Object txChainIdentifier,
final SchemaContext schemaContext,
final org.opendaylight.mdsal.dom.api.DOMDataBroker
this.txChainIdentifier = requireNonNull(txChainIdentifier);
this.txChainListener = requireNonNull(txChainListener);
this.txChainDelegate = brokerDelegate.createTransactionChain(this);
this.txChainIdentifier = requireNonNull(txChainIdentifier);
this.txChainListener = requireNonNull(txChainListener);
this.txChainDelegate = brokerDelegate.createTransactionChain(this);
- transactionMap = Maps.newHashMap();
- public void onTransactionChainFailed(org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
- DOMDataTreeTransaction transaction, Throwable cause) {
+ public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
+ final DOMDataTreeTransaction transaction, final Throwable cause) {
txChainListener.onTransactionChainFailed(this, transactionFromDelegate(transaction.getIdentifier()), cause);
}
@Override
txChainListener.onTransactionChainFailed(this, transactionFromDelegate(transaction.getIdentifier()), cause);
}
@Override
- public void onTransactionChainSuccessful(org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
+ public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
txChainListener.onTransactionChainSuccessful(this);
}
txChainListener.onTransactionChainSuccessful(this);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.md.sal.dom.broker.impl.legacy.sharded.adapter;
package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.util.concurrent.FluentFuture;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import com.google.common.util.concurrent.FluentFuture;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
private final Object txIdentifier;
ShardedDOMDataBrokerDelegatingWriteTransaction(final Object txIdentifier,
private final Object txIdentifier;
ShardedDOMDataBrokerDelegatingWriteTransaction(final Object txIdentifier,
- final DOMDataTreeWriteTransaction delegateTx) {
- this.delegateTx = checkNotNull(delegateTx);
- this.txIdentifier = checkNotNull(txIdentifier);
+ final DOMDataTreeWriteTransaction delegateTx) {
+ this.delegateTx = requireNonNull(delegateTx);
+ this.txIdentifier = requireNonNull(txIdentifier);
*/
package org.opendaylight.controller.md.sal.dom.broker.spi.rpc;
*/
package org.opendaylight.controller.md.sal.dom.broker.spi.rpc;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Optional;
import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@Deprecated
public abstract class RpcRoutingStrategy implements Identifiable<QName> {
@Deprecated
public abstract class RpcRoutingStrategy implements Identifiable<QName> {
private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext",
"2013-07-09", "context-reference").intern();
private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext",
"2013-07-09", "context-reference").intern();
private final QName identifier;
private RpcRoutingStrategy(final QName identifier) {
private final QName identifier;
private RpcRoutingStrategy(final QName identifier) {
- this.identifier = Preconditions.checkNotNull(identifier);
+ this.identifier = requireNonNull(identifier);
private RoutedRpcStrategy(final QName identifier, final QName ctx, final QName leaf) {
super(identifier);
private RoutedRpcStrategy(final QName identifier, final QName ctx, final QName leaf) {
super(identifier);
- this.context = Preconditions.checkNotNull(ctx);
- this.leaf = Preconditions.checkNotNull(leaf);
+ this.context = requireNonNull(ctx);
+ this.leaf = requireNonNull(leaf);
*/
package org.opendaylight.controller.sal.core.spi.data;
*/
package org.opendaylight.controller.sal.core.spi.data;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.Beta;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
private final AbstractSnapshotBackedTransactionChain<?> chain;
Idle(final AbstractSnapshotBackedTransactionChain<?> chain) {
private final AbstractSnapshotBackedTransactionChain<?> chain;
Idle(final AbstractSnapshotBackedTransactionChain<?> chain) {
- this.chain = Preconditions.checkNotNull(chain);
+ this.chain = requireNonNull(chain);
- protected DataTreeSnapshot getSnapshot(Object transactionId) {
+ protected DataTreeSnapshot getSnapshot(final Object transactionId) {
return chain.takeSnapshot();
}
}
return chain.takeSnapshot();
}
}
private volatile DataTreeSnapshot snapshot;
Allocated(final DOMStoreWriteTransaction transaction) {
private volatile DataTreeSnapshot snapshot;
Allocated(final DOMStoreWriteTransaction transaction) {
- this.transaction = Preconditions.checkNotNull(transaction);
+ this.transaction = requireNonNull(transaction);
}
public DOMStoreWriteTransaction getTransaction() {
}
public DOMStoreWriteTransaction getTransaction() {
- protected DataTreeSnapshot getSnapshot(Object transactionId) {
+ protected DataTreeSnapshot getSnapshot(final Object transactionId) {
final DataTreeSnapshot ret = snapshot;
final DataTreeSnapshot ret = snapshot;
- Preconditions.checkState(ret != null,
+ checkState(ret != null,
"Could not get snapshot for transaction %s - previous transaction %s is not ready yet",
transactionId, transaction.getIdentifier());
return ret;
"Could not get snapshot for transaction %s - previous transaction %s is not ready yet",
transactionId, transaction.getIdentifier());
return ret;
void setSnapshot(final DataTreeSnapshot snapshot) {
final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot);
void setSnapshot(final DataTreeSnapshot snapshot) {
final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot);
- Preconditions.checkState(success, "Transaction %s has already been marked as ready",
- transaction.getIdentifier());
+ checkState(success, "Transaction %s has already been marked as ready", transaction.getIdentifier());
private final String message;
Shutdown(final String message) {
private final String message;
Shutdown(final String message) {
- this.message = Preconditions.checkNotNull(message);
+ this.message = requireNonNull(message);
- protected DataTreeSnapshot getSnapshot(Object transactionId) {
+ protected DataTreeSnapshot getSnapshot(final Object transactionId) {
throw new IllegalStateException(message);
}
}
throw new IllegalStateException(message);
}
}
- private Entry<State, DataTreeSnapshot> getSnapshot(T transactionId) {
+ private Entry<State, DataTreeSnapshot> getSnapshot(final T transactionId) {
final State localState = state;
return new SimpleEntry<>(localState, localState.getSnapshot(transactionId));
}
final State localState = state;
return new SimpleEntry<>(localState, localState.getSnapshot(transactionId));
}
return newReadOnlyTransaction(nextTransactionIdentifier());
}
return newReadOnlyTransaction(nextTransactionIdentifier());
}
- protected DOMStoreReadTransaction newReadOnlyTransaction(T transactionId) {
+ protected DOMStoreReadTransaction newReadOnlyTransaction(final T transactionId) {
final Entry<State, DataTreeSnapshot> entry = getSnapshot(transactionId);
return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue(),
this);
final Entry<State, DataTreeSnapshot> entry = getSnapshot(transactionId);
return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue(),
this);
return newReadWriteTransaction(nextTransactionIdentifier());
}
return newReadWriteTransaction(nextTransactionIdentifier());
}
- protected DOMStoreReadWriteTransaction newReadWriteTransaction(T transactionId) {
+ protected DOMStoreReadWriteTransaction newReadWriteTransaction(final T transactionId) {
Entry<State, DataTreeSnapshot> entry;
DOMStoreReadWriteTransaction ret;
Entry<State, DataTreeSnapshot> entry;
DOMStoreReadWriteTransaction ret;
return newWriteOnlyTransaction(nextTransactionIdentifier());
}
return newWriteOnlyTransaction(nextTransactionIdentifier());
}
- protected DOMStoreWriteTransaction newWriteOnlyTransaction(T transactionId) {
+ protected DOMStoreWriteTransaction newWriteOnlyTransaction(final T transactionId) {
Entry<State, DataTreeSnapshot> entry;
DOMStoreWriteTransaction ret;
Entry<State, DataTreeSnapshot> entry;
DOMStoreWriteTransaction ret;
if (localState instanceof Allocated) {
final Allocated allocated = (Allocated)localState;
final DOMStoreWriteTransaction transaction = allocated.getTransaction();
if (localState instanceof Allocated) {
final Allocated allocated = (Allocated)localState;
final DOMStoreWriteTransaction transaction = allocated.getTransaction();
- Preconditions.checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s",
- tx, transaction);
+ checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx,
+ transaction);
allocated.setSnapshot(tree);
} else {
LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState);
allocated.setSnapshot(tree);
} else {
LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState);
final State localState = state;
do {
final State localState = state;
do {
- Preconditions.checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this);
-
+ checkState(!CLOSED.equals(localState), "Transaction chain %s has been closed", this);
if (FAILED.equals(localState)) {
LOG.debug("Ignoring user close in failed state");
return;
if (FAILED.equals(localState)) {
LOG.debug("Ignoring user close in failed state");
return;
*/
package org.opendaylight.controller.sal.core.spi.data;
*/
package org.opendaylight.controller.sal.core.spi.data;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
SnapshotBackedReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot,
final TransactionClosePrototype<T> closeImpl) {
super(identifier, debug);
SnapshotBackedReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot,
final TransactionClosePrototype<T> closeImpl) {
super(identifier, debug);
- this.stableSnapshot = Preconditions.checkNotNull(snapshot);
+ this.stableSnapshot = requireNonNull(snapshot);
this.closeImpl = closeImpl;
LOG.debug("ReadOnly Tx: {} allocated with snapshot {}", identifier, snapshot);
}
this.closeImpl = closeImpl;
LOG.debug("ReadOnly Tx: {} allocated with snapshot {}", identifier, snapshot);
}
@SuppressWarnings("checkstyle:IllegalCatch")
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
@SuppressWarnings("checkstyle:IllegalCatch")
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
- checkNotNull(path, "Path must not be null.");
+ requireNonNull(path, "Path must not be null.");
final DataTreeSnapshot snapshot = stableSnapshot;
if (snapshot == null) {
final DataTreeSnapshot snapshot = stableSnapshot;
if (snapshot == null) {
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Exists: {}", getIdentifier(), path);
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Exists: {}", getIdentifier(), path);
- checkNotNull(path, "Path must not be null.");
+ requireNonNull(path, "Path must not be null.");
try {
return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent());
try {
return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent());
*/
package org.opendaylight.controller.sal.core.spi.data;
*/
package org.opendaylight.controller.sal.core.spi.data;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
@SuppressWarnings("checkstyle:IllegalCatch")
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
@SuppressWarnings("checkstyle:IllegalCatch")
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
- checkNotNull(path, "Path must not be null.");
+ requireNonNull(path, "Path must not be null.");
final Optional<NormalizedNode<?, ?>> result;
try {
final Optional<NormalizedNode<?, ?>> result;
try {
package org.opendaylight.controller.sal.core.spi.data;
import static com.google.common.base.Preconditions.checkState;
package org.opendaylight.controller.sal.core.spi.data;
import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import org.eclipse.jdt.annotation.Nullable;
import com.google.common.base.Throwables;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import org.eclipse.jdt.annotation.Nullable;
SnapshotBackedWriteTransaction(final T identifier, final boolean debug,
final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
super(identifier, debug);
SnapshotBackedWriteTransaction(final T identifier, final boolean debug,
final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
super(identifier, debug);
- this.readyImpl = Preconditions.checkNotNull(readyImpl, "readyImpl must not be null.");
+ this.readyImpl = requireNonNull(readyImpl, "readyImpl must not be null.");
mutableTree = snapshot.newModification();
LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot);
}
mutableTree = snapshot.newModification();
LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot);
}
*/
package org.opendaylight.controller.remote.rpc.registry;
*/
package org.opendaylight.controller.remote.rpc.registry;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.actor.Props;
import com.google.common.annotations.VisibleForTesting;
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.actor.Props;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
public ActionRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker,
final ActorRef rpcRegistrar) {
super(config, config.getRpcRegistryPersistenceId(), new ActionRoutingTable(rpcInvoker, ImmutableSet.of()));
public ActionRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker,
final ActorRef rpcRegistrar) {
super(config, config.getRpcRegistryPersistenceId(), new ActionRoutingTable(rpcInvoker, ImmutableSet.of()));
- this.rpcRegistrar = Preconditions.checkNotNull(rpcRegistrar);
+ this.rpcRegistrar = requireNonNull(rpcRegistrar);
this.mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
config.getAskDuration()), config.getAskDuration());
}
this.mxBean = new RemoteActionRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
config.getAskDuration()), config.getAskDuration());
}
@VisibleForTesting
public RemoteActionEndpoint(final ActorRef router, final Collection<DOMActionInstance> actions) {
@VisibleForTesting
public RemoteActionEndpoint(final ActorRef router, final Collection<DOMActionInstance> actions) {
- this.router = Preconditions.checkNotNull(router);
+ this.router = requireNonNull(router);
this.actions = ImmutableSet.copyOf(actions);
}
this.actions = ImmutableSet.copyOf(actions);
}
*/
package org.opendaylight.controller.remote.rpc.registry;
*/
package org.opendaylight.controller.remote.rpc.registry;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.actor.Props;
import com.google.common.annotations.VisibleForTesting;
import akka.actor.ActorRef;
import akka.actor.Address;
import akka.actor.Props;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
public RpcRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker, final ActorRef rpcRegistrar) {
super(config, config.getRpcRegistryPersistenceId(), new RoutingTable(rpcInvoker, ImmutableSet.of()));
public RpcRegistry(final RemoteOpsProviderConfig config, final ActorRef rpcInvoker, final ActorRef rpcRegistrar) {
super(config, config.getRpcRegistryPersistenceId(), new RoutingTable(rpcInvoker, ImmutableSet.of()));
- this.rpcRegistrar = Preconditions.checkNotNull(rpcRegistrar);
+ this.rpcRegistrar = requireNonNull(rpcRegistrar);
this.mxBean = new RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
config.getAskDuration()), config.getAskDuration());
}
this.mxBean = new RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(self(), getContext().dispatcher(),
config.getAskDuration()), config.getAskDuration());
}
@VisibleForTesting
public RemoteRpcEndpoint(final ActorRef router, final Collection<DOMRpcIdentifier> rpcs) {
@VisibleForTesting
public RemoteRpcEndpoint(final ActorRef router, final Collection<DOMRpcIdentifier> rpcs) {
- this.router = Preconditions.checkNotNull(router);
+ this.router = requireNonNull(router);
this.rpcs = ImmutableSet.copyOf(rpcs);
}
this.rpcs = ImmutableSet.copyOf(rpcs);
}
final List<DOMRpcIdentifier> rpcRouteIdentifiers;
AbstractRouteMessage(final Collection<DOMRpcIdentifier> rpcRouteIdentifiers) {
final List<DOMRpcIdentifier> rpcRouteIdentifiers;
AbstractRouteMessage(final Collection<DOMRpcIdentifier> rpcRouteIdentifiers) {
- Preconditions.checkArgument(rpcRouteIdentifiers != null && !rpcRouteIdentifiers.isEmpty(),
+ checkArgument(rpcRouteIdentifiers != null && !rpcRouteIdentifiers.isEmpty(),
"Route Identifiers must be supplied");
this.rpcRouteIdentifiers = ImmutableList.copyOf(rpcRouteIdentifiers);
}
"Route Identifiers must be supplied");
this.rpcRouteIdentifiers = ImmutableList.copyOf(rpcRouteIdentifiers);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.remote.rpc.registry.gossip;
package org.opendaylight.controller.remote.rpc.registry.gossip;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_ALL_BUCKETS;
import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_BUCKET_VERSIONS;
import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_ALL_BUCKETS;
import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_BUCKET_VERSIONS;
import akka.persistence.SnapshotOffer;
import akka.persistence.SnapshotSelectionCriteria;
import com.google.common.annotations.VisibleForTesting;
import akka.persistence.SnapshotOffer;
import akka.persistence.SnapshotSelectionCriteria;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.SetMultimap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.SetMultimap;
private boolean persisting;
protected BucketStoreActor(final RemoteOpsProviderConfig config, final String persistenceId, final T initialData) {
private boolean persisting;
protected BucketStoreActor(final RemoteOpsProviderConfig config, final String persistenceId, final T initialData) {
- this.config = Preconditions.checkNotNull(config);
- this.initialData = Preconditions.checkNotNull(initialData);
- this.persistenceId = Preconditions.checkNotNull(persistenceId);
+ this.config = requireNonNull(config);
+ this.initialData = requireNonNull(initialData);
+ this.persistenceId = requireNonNull(persistenceId);
}
static ExecuteInActor getBucketsByMembersMessage(final Collection<Address> members) {
}
static ExecuteInActor getBucketsByMembersMessage(final Collection<Address> members) {
if (bumpIncarnation) {
LOG.debug("Version wrapped. incrementing incarnation");
if (bumpIncarnation) {
LOG.debug("Version wrapped. incrementing incarnation");
- Verify.verify(incarnation < Integer.MAX_VALUE, "Ran out of incarnations, cannot continue");
+ verify(incarnation < Integer.MAX_VALUE, "Ran out of incarnations, cannot continue");
incarnation = incarnation + 1;
persisting = true;
incarnation = incarnation + 1;
persisting = true;
}
private LocalBucket<T> getLocalBucket() {
}
private LocalBucket<T> getLocalBucket() {
- Preconditions.checkState(localBucket != null, "Attempted to access local bucket before recovery completed");
+ checkState(localBucket != null, "Attempted to access local bucket before recovery completed");
*/
package org.opendaylight.controller.remote.rpc.registry.gossip;
*/
package org.opendaylight.controller.remote.rpc.registry.gossip;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.Address;
import akka.actor.Address;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import java.io.Serializable;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import java.io.Serializable;
import java.util.Map;
private final Address to;
GossipEnvelope(final Address from, final Address to, final Map<Address, ? extends Bucket<?>> buckets) {
private final Address to;
GossipEnvelope(final Address from, final Address to, final Map<Address, ? extends Bucket<?>> buckets) {
- this.to = Preconditions.checkNotNull(to);
+ this.to = requireNonNull(to);
this.buckets = ImmutableMap.copyOf(buckets);
this.from = from;
}
this.buckets = ImmutableMap.copyOf(buckets);
this.from = from;
}
*/
package org.opendaylight.controller.remote.rpc.registry.gossip;
*/
package org.opendaylight.controller.remote.rpc.registry.gossip;
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorRefProvider;
import akka.actor.ActorSelection;
import akka.actor.ActorRef;
import akka.actor.ActorRefProvider;
import akka.actor.ActorSelection;
import akka.cluster.ClusterEvent;
import akka.cluster.Member;
import com.google.common.annotations.VisibleForTesting;
import akka.cluster.ClusterEvent;
import akka.cluster.Member;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.HashMap;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.HashMap;
private BucketStoreAccess bucketStore;
Gossiper(final RemoteOpsProviderConfig config, final Boolean autoStartGossipTicks) {
private BucketStoreAccess bucketStore;
Gossiper(final RemoteOpsProviderConfig config, final Boolean autoStartGossipTicks) {
- this.config = Preconditions.checkNotNull(config);
+ this.config = requireNonNull(config);
this.autoStartGossipTicks = autoStartGossipTicks.booleanValue();
}
this.autoStartGossipTicks = autoStartGossipTicks.booleanValue();
}
}
LOG.trace("Gossiping to [{}]", address);
}
LOG.trace("Gossiping to [{}]", address);
- getLocalStatusAndSendTo(Verify.verifyNotNull(peers.get(address)));
+ getLocalStatusAndSendTo(verifyNotNull(peers.get(address)));
*/
package org.opendaylight.controller.remote.rpc.registry.gossip;
*/
package org.opendaylight.controller.remote.rpc.registry.gossip;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
/**
* Local bucket implementation. Unlike a full-blown {@link Bucket}, this class is mutable and tracks when it has been
/**
* Local bucket implementation. Unlike a full-blown {@link Bucket}, this class is mutable and tracks when it has been
private boolean bumpVersion;
LocalBucket(final int incarnation, final T data) {
private boolean bumpVersion;
LocalBucket(final int incarnation, final T data) {
- Preconditions.checkArgument(incarnation >= 0);
- this.version = ((long)incarnation) << Integer.SIZE;
- this.data = Preconditions.checkNotNull(data);
+ checkArgument(incarnation >= 0);
+ this.version = (long)incarnation << Integer.SIZE;
+ this.data = requireNonNull(data);
}
boolean setData(final T newData) {
}
boolean setData(final T newData) {
- this.data = Preconditions.checkNotNull(newData);
+ this.data = requireNonNull(newData);
if (!bumpVersion) {
return false;
}
if (!bumpVersion) {
return false;
}
*/
package org.opendaylight.controller.remote.rpc.registry.mbeans;
*/
package org.opendaylight.controller.remote.rpc.registry.mbeans;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.remote.rpc.RemoteOpsProviderConfig;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.remote.rpc.RemoteOpsProviderConfig;
public void testGetGlobalRpcEmptyBuckets() {
final Set<String> globalRpc = mxBean.getGlobalRpc();
public void testGetGlobalRpcEmptyBuckets() {
final Set<String> globalRpc = mxBean.getGlobalRpc();
- Assert.assertNotNull(globalRpc);
- Assert.assertTrue(globalRpc.isEmpty());
+ assertNotNull(globalRpc);
+ assertTrue(globalRpc.isEmpty());
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Set<String> globalRpc = mxBean.getGlobalRpc();
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Set<String> globalRpc = mxBean.getGlobalRpc();
- Assert.assertNotNull(globalRpc);
- Assert.assertEquals(1, globalRpc.size());
+ assertNotNull(globalRpc);
+ assertEquals(1, globalRpc.size());
final String rpc = globalRpc.iterator().next();
final String rpc = globalRpc.iterator().next();
- Assert.assertEquals(EMPTY_SCHEMA_PATH.toString(), rpc);
+ assertEquals(EMPTY_SCHEMA_PATH.toString(), rpc);
}
@Test
public void testGetLocalRegisteredRoutedRpcEmptyBuckets() {
final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
}
@Test
public void testGetLocalRegisteredRoutedRpcEmptyBuckets() {
final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
- Assert.assertNotNull(localRegisteredRoutedRpc);
- Assert.assertTrue(localRegisteredRoutedRpc.isEmpty());
+ assertNotNull(localRegisteredRoutedRpc);
+ assertTrue(localRegisteredRoutedRpc.isEmpty());
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
- Assert.assertNotNull(localRegisteredRoutedRpc);
- Assert.assertEquals(1, localRegisteredRoutedRpc.size());
+ assertNotNull(localRegisteredRoutedRpc);
+ assertEquals(1, localRegisteredRoutedRpc.size());
final String localRpc = localRegisteredRoutedRpc.iterator().next();
final String localRpc = localRegisteredRoutedRpc.iterator().next();
- Assert.assertTrue(localRpc.contains(LOCAL_QNAME.toString()));
- Assert.assertTrue(localRpc.contains(LOCAL_SCHEMA_PATH.toString()));
+ assertTrue(localRpc.contains(LOCAL_QNAME.toString()));
+ assertTrue(localRpc.contains(LOCAL_SCHEMA_PATH.toString()));
}
@Test
public void testFindRpcByNameEmptyBuckets() {
final Map<String, String> rpcByName = mxBean.findRpcByName("");
}
@Test
public void testFindRpcByNameEmptyBuckets() {
final Map<String, String> rpcByName = mxBean.findRpcByName("");
- Assert.assertNotNull(rpcByName);
- Assert.assertTrue(rpcByName.isEmpty());
+ assertNotNull(rpcByName);
+ assertTrue(rpcByName.isEmpty());
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Map<String, String> rpcByName = mxBean.findRpcByName("");
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Map<String, String> rpcByName = mxBean.findRpcByName("");
- Assert.assertNotNull(rpcByName);
- Assert.assertEquals(1, rpcByName.size());
- Assert.assertTrue(rpcByName.containsValue(LOCAL_QNAME.getLocalName()));
+ assertNotNull(rpcByName);
+ assertEquals(1, rpcByName.size());
+ assertTrue(rpcByName.containsValue(LOCAL_QNAME.getLocalName()));
}
@Test
public void testFindRpcByRouteEmptyBuckets() {
final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
}
@Test
public void testFindRpcByRouteEmptyBuckets() {
final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
- Assert.assertNotNull(rpcByRoute);
- Assert.assertTrue(rpcByRoute.isEmpty());
+ assertNotNull(rpcByRoute);
+ assertTrue(rpcByRoute.isEmpty());
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
- Assert.assertNotNull(rpcByRoute);
- Assert.assertEquals(1, rpcByRoute.size());
- Assert.assertTrue(rpcByRoute.containsValue(LOCAL_QNAME.getLocalName()));
+ assertNotNull(rpcByRoute);
+ assertEquals(1, rpcByRoute.size());
+ assertTrue(rpcByRoute.containsValue(LOCAL_QNAME.getLocalName()));
}
@Test
public void testGetBucketVersionsEmptyBuckets() {
final String bucketVersions = mxBean.getBucketVersions();
}
@Test
public void testGetBucketVersionsEmptyBuckets() {
final String bucketVersions = mxBean.getBucketVersions();
- Assert.assertEquals(Collections.EMPTY_MAP.toString(), bucketVersions);
+ assertEquals(Collections.emptyMap().toString(), bucketVersions);
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final String bucketVersions = mxBean.getBucketVersions();
testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
final String bucketVersions = mxBean.getBucketVersions();
- Assert.assertTrue(bucketVersions.contains(testActor.provider().getDefaultAddress().toString()));
+ assertTrue(bucketVersions.contains(testActor.provider().getDefaultAddress().toString()));
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.clustering.it.provider.impl;
package org.opendaylight.controller.clustering.it.provider.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
private ProduceTransactionsHandler(final DOMDataTreeProducer producer, final DOMDataTreeIdentifier idListItem,
final ProduceTransactionsInput input) {
super(input);
private ProduceTransactionsHandler(final DOMDataTreeProducer producer, final DOMDataTreeIdentifier idListItem,
final ProduceTransactionsInput input) {
super(input);
- this.itemProducer = Preconditions.checkNotNull(producer);
- this.idListItem = Preconditions.checkNotNull(idListItem);
+ this.itemProducer = requireNonNull(producer);
+ this.idListItem = requireNonNull(idListItem);
}
public static ListenableFuture<RpcResult<ProduceTransactionsOutput>> start(
}
public static ListenableFuture<RpcResult<ProduceTransactionsOutput>> start(
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.clustering.it.provider.impl;
package org.opendaylight.controller.clustering.it.provider.impl;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
public PublishNotificationsTask(final NotificationPublishService notificationPublishService,
final String notificationId, final long secondsToTake, final long maxPerSecond) {
public PublishNotificationsTask(final NotificationPublishService notificationPublishService,
final String notificationId, final long secondsToTake, final long maxPerSecond) {
- Preconditions.checkNotNull(notificationPublishService);
- Preconditions.checkNotNull(notificationId);
- Preconditions.checkArgument(secondsToTake > 0);
- Preconditions.checkArgument(maxPerSecond > 0);
- this.notificationPublishService = notificationPublishService;
- this.notificationId = notificationId;
+ this.notificationPublishService = requireNonNull(notificationPublishService);
+ this.notificationId = requireNonNull(notificationId);
+ checkArgument(secondsToTake > 0);
this.timeToTake = secondsToTake * SECOND_AS_NANO;
this.timeToTake = secondsToTake * SECOND_AS_NANO;
+ checkArgument(maxPerSecond > 0);
this.delay = SECOND_AS_NANO / maxPerSecond;
LOG.debug("Delay : {}", delay);
this.delay = SECOND_AS_NANO / maxPerSecond;
LOG.debug("Delay : {}", delay);
LOG.debug("current {}, starttime: {}, timetotake: {}, current-start = {}",
current, startTime, timeToTake, current - startTime);
LOG.debug("current {}, starttime: {}, timetotake: {}, current-start = {}",
current, startTime, timeToTake, current - startTime);
- if ((current - startTime) > timeToTake) {
+ if (current - startTime > timeToTake) {
LOG.debug("Sequence number: {}", sequenceNumber);
scheduledFuture.cancel(false);
executor.shutdown();
LOG.debug("Sequence number: {}", sequenceNumber);
scheduledFuture.cancel(false);
executor.shutdown();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.clustering.it.provider.impl;
package org.opendaylight.controller.clustering.it.provider.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.LinkedHashSet;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.LinkedHashSet;
Simple(final DOMDataBroker dataBroker, final YangInstanceIdentifier idListItem,
final WriteTransactionsInput input) {
super(idListItem, input);
Simple(final DOMDataBroker dataBroker, final YangInstanceIdentifier idListItem,
final WriteTransactionsInput input) {
super(idListItem, input);
- this.dataBroker = Preconditions.checkNotNull(dataBroker);
+ this.dataBroker = requireNonNull(dataBroker);
WriteTransactionsHandler(final YangInstanceIdentifier idListItem, final WriteTransactionsInput input) {
super(input);
WriteTransactionsHandler(final YangInstanceIdentifier idListItem, final WriteTransactionsInput input) {
super(input);
- this.idListItem = Preconditions.checkNotNull(idListItem);
+ this.idListItem = requireNonNull(idListItem);
}
public static ListenableFuture<RpcResult<WriteTransactionsOutput>> start(final DOMDataBroker domDataBroker,
}
public static ListenableFuture<RpcResult<WriteTransactionsOutput>> start(final DOMDataBroker domDataBroker,
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* 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.clustering.it.provider.impl;
package org.opendaylight.controller.clustering.it.provider.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutputBuilder;
import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutputBuilder;
import org.slf4j.LoggerFactory;
public class YnlListener implements OdlMdsalLowlevelTargetListener {
import org.slf4j.LoggerFactory;
public class YnlListener implements OdlMdsalLowlevelTargetListener {
private static final Logger LOG = LoggerFactory.getLogger(YnlListener.class);
private final String id;
private static final Logger LOG = LoggerFactory.getLogger(YnlListener.class);
private final String id;
private final AtomicLong errNot = new AtomicLong();
public YnlListener(final String id) {
private final AtomicLong errNot = new AtomicLong();
public YnlListener(final String id) {
- Preconditions.checkNotNull(id);
- this.id = id;
+ this.id = requireNonNull(id);
*/
package org.opendaylight.controller.sample.toaster.provider;
*/
package org.opendaylight.controller.sample.toaster.provider;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.DELETE;
import static org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType.WRITE;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.yangtools.yang.common.RpcError.ErrorType.APPLICATION;
import com.google.common.base.Function;
import static org.opendaylight.yangtools.yang.common.RpcError.ErrorType.APPLICATION;
import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
public void init() {
LOG.info("Initializing...");
public void init() {
LOG.info("Initializing...");
- Preconditions.checkNotNull(dataBroker, "dataBroker must be set");
- dataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(CONFIGURATION, TOASTER_IID), this);
+ dataTreeChangeListenerRegistration = requireNonNull(dataBroker, "dataBroker must be set")
+ .registerDataTreeChangeListener(DataTreeIdentifier.create(CONFIGURATION, TOASTER_IID), this);
setToasterStatusUp(null);
// Register our MXBean.
setToasterStatusUp(null);
// Register our MXBean.