<propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
</plugins>
</build>
final List<Pair<ActorRef, Long>> routePairs = routes.getRouterWithUpdateTime();
if (routePairs == null || routePairs.isEmpty()) {
frontEndFuture.failNow(new DOMRpcImplementationNotAvailableException(
- "No local or remote implementation available for rpc %s", rpc.getType(), error));
+ "No local or remote implementation available for rpc %s", rpc.getType()));
} else {
final ActorRef remoteImplRef = new LatestEntryRoutingLogic(routePairs).select();
final Object executeRpcMessage = ExecuteRpc.from(rpc, input);
import akka.util.Timeout;
import com.typesafe.config.Config;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.cluster.common.actor.CommonConfig;
import scala.concurrent.duration.FiniteDuration;
/**
* This is called via blueprint xml as the builder pattern can't be used.
*/
+ @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE",
+ justification = "Findbugs flags this as an unconfirmed cast of return value but the build method clearly "
+ + "returns RemoteRpcProviderConfig. Perhaps it's confused b/c the build method is overloaded and "
+ + "and differs in return type from the base class.")
public static RemoteRpcProviderConfig newInstance(String actorSystemName, boolean metricCaptureEnabled,
int mailboxCapacity) {
return new Builder(actorSystemName).metricCaptureEnabled(metricCaptureEnabled)
import akka.actor.ActorRef;
import akka.actor.Props;
-import akka.japi.Creator;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import java.util.Arrays;
-import java.util.Collection;
import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc;
import org.opendaylight.controller.remote.rpc.messages.RpcResponse;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public static Props props(final DOMRpcService rpcService) {
Preconditions.checkNotNull(rpcService, "DOMRpcService can not be null");
- return Props.create(new RpcBrokerCreator(rpcService));
+ return Props.create(RpcBroker.class, rpcService);
}
@Override
Futures.addCallback(future, new FutureCallback<DOMRpcResult>() {
@Override
public void onSuccess(final DOMRpcResult result) {
- if (result.getErrors() != null && !result.getErrors().isEmpty()) {
- final String message = String.format("Execution of RPC %s failed", msg.getRpc());
- Collection<RpcError> errors = result.getErrors();
- if (errors == null || errors.size() == 0) {
- errors = Arrays.asList(RpcResultBuilder.newError(ErrorType.RPC, null, message));
- }
+ if (result == null) {
+ // This shouldn't happen but the FutureCallback annotates the result param with Nullable so
+ // handle null here to avoid FindBugs warning.
+ LOG.debug("Got null DOMRpcResult - sending null response for execute rpc : {}", msg.getRpc());
+ sender.tell(new RpcResponse(null), self);
+ return;
+ }
- sender.tell(new akka.actor.Status.Failure(new RpcErrorsException(message, errors)), self);
+ if (!result.getErrors().isEmpty()) {
+ final String message = String.format("Execution of RPC %s failed", msg.getRpc());
+ sender.tell(new akka.actor.Status.Failure(new RpcErrorsException(message,
+ result.getErrors())), self);
} else {
LOG.debug("Sending response for execute rpc : {}", msg.getRpc());
sender.tell(new akka.actor.Status.Failure(e), sender);
}
}
-
- private static class RpcBrokerCreator implements Creator<RpcBroker> {
- private static final long serialVersionUID = 1L;
-
- final DOMRpcService rpcService;
-
- RpcBrokerCreator(final DOMRpcService rpcService) {
- this.rpcService = rpcService;
- }
-
- @Override
- public RpcBroker create() throws Exception {
- return new RpcBroker(rpcService);
- }
- }
}
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
public class ExecuteRpc implements Serializable {
private static final long serialVersionUID = 1128904894827335676L;
+ @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+ + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+ + "aren't serialized. FindBugs does not recognize this.")
private final NormalizedNode<?, ?> inputNormalizedNode;
private final QName rpc;
*/
package org.opendaylight.controller.remote.rpc.messages;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
public class RpcResponse implements Serializable {
private static final long serialVersionUID = -4211279498688989245L;
+ @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+ + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+ + "aren't serialized. FindBugs does not recognize this.")
private final NormalizedNode<?, ?> resultNormalizedNode;
public RpcResponse(@Nullable final NormalizedNode<?, ?> inputNormalizedNode) {
import akka.actor.ActorRef;
import akka.actor.Cancellable;
import akka.actor.Props;
-import akka.japi.Creator;
import akka.japi.Option;
import akka.japi.Pair;
import com.google.common.base.Preconditions;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter;
import org.opendaylight.controller.remote.rpc.registry.gossip.Bucket;
import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore;
-import org.opendaylight.controller.remote.rpc.registry.mbeans.RemoteRpcRegistryMXBeanImpl;
import org.opendaylight.controller.sal.connector.api.RpcRouter;
import org.opendaylight.controller.sal.connector.api.RpcRouter.RouteIdentifier;
import scala.concurrent.duration.FiniteDuration;
}
public static Props props(RemoteRpcProviderConfig config) {
- return Props.create(new RpcRegistryCreator(config));
+ return Props.create(RpcRegistry.class, config);
}
@Override
}
}
}
-
- private static class RpcRegistryCreator implements Creator<RpcRegistry> {
- private static final long serialVersionUID = 1L;
- private final RemoteRpcProviderConfig config;
-
- private RpcRegistryCreator(RemoteRpcProviderConfig config) {
- this.config = config;
- }
-
- @Override
- public RpcRegistry create() throws Exception {
- RpcRegistry registry = new RpcRegistry(config);
- new RemoteRpcRegistryMXBeanImpl(registry);
- return registry;
- }
- }
}
localIsNewer.removeAll(remoteVersions.keySet());
- for (Address address : remoteVersions.keySet()) {
-
- if (localVersions.get(address) == null || remoteVersions.get(address) == null) {
+ for (Map.Entry<Address, Long> entry : remoteVersions.entrySet()) {
+ Address address = entry.getKey();
+ Long remoteVersion = entry.getValue();
+ Long localVersion = localVersions.get(address);
+ if (localVersion == null || remoteVersion == null) {
continue; //this condition is taken care of by above diffs
}
- if (localVersions.get(address) < remoteVersions.get(address)) {
+
+ if (localVersion < remoteVersion) {
localIsOlder.add(address);
- } else if (localVersions.get(address) > remoteVersions.get(address)) {
+ } else if (localVersion > remoteVersion) {
localIsNewer.add(address);
}
}
}
}
- public static class GetAllBucketsReply<T extends Copier<T>> extends ContainsBuckets<T> implements Serializable {
+ public static class GetAllBucketsReply<T extends Copier<T>> extends ContainsBuckets<T> {
private static final long serialVersionUID = 1L;
public GetAllBucketsReply(Map<Address, Bucket<T>> buckets) {
}
}
- public static class GetBucketsByMembersReply<T extends Copier<T>> extends ContainsBuckets<T>
- implements Serializable {
+ public static class GetBucketsByMembersReply<T extends Copier<T>> extends ContainsBuckets<T> {
private static final long serialVersionUID = 1L;
public GetBucketsByMembersReply(Map<Address, Bucket<T>> buckets) {
}
- public static class GetBucketVersionsReply extends ContainsBucketVersions implements Serializable {
+ public static class GetBucketVersionsReply extends ContainsBucketVersions {
private static final long serialVersionUID = 1L;
public GetBucketVersionsReply(Map<Address, Long> versions) {
}
}
- public static class UpdateRemoteBuckets<T extends Copier<T>> extends ContainsBuckets<T>
- implements Serializable {
+ public static class UpdateRemoteBuckets<T extends Copier<T>> extends ContainsBuckets<T> {
private static final long serialVersionUID = 1L;
public UpdateRemoteBuckets(Map<Address, Bucket<T>> buckets) {
private static final long serialVersionUID = 5803354404380026143L;
}
- public static final class GossipStatus extends ContainsBucketVersions implements Serializable {
+ public static final class GossipStatus extends ContainsBucketVersions {
private static final long serialVersionUID = -593037395143883265L;
private final Address from;
}
}
- public static final class GossipEnvelope<T extends Copier<T>> extends ContainsBuckets<T>
- implements Serializable {
+ public static final class GossipEnvelope<T extends Copier<T>> extends ContainsBuckets<T> {
private static final long serialVersionUID = 8346634072582438818L;
private final Address from;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean;
import org.opendaylight.controller.remote.rpc.registry.RoutingTable;
// Get all RPCs from remote bucket
Map<Address, Bucket<RoutingTable>> buckets = rpcRegistry.getRemoteBuckets();
- for (Address address : buckets.keySet()) {
- RoutingTable table = buckets.get(address).getData();
- rpcMap.putAll(getRpcMemberMapByName(table, name, address.toString()));
+ for (Entry<Address, Bucket<RoutingTable>> entry : buckets.entrySet()) {
+ RoutingTable table = entry.getValue().getData();
+ rpcMap.putAll(getRpcMemberMapByName(table, name, entry.getKey().toString()));
}
log.debug("list of RPCs {} searched by name {}", rpcMap, name);
Map<String, String> rpcMap = new HashMap<>(getRpcMemberMapByRoute(localTable, routeId, LOCAL_CONSTANT));
Map<Address, Bucket<RoutingTable>> buckets = rpcRegistry.getRemoteBuckets();
- for (Address address : buckets.keySet()) {
- RoutingTable table = buckets.get(address).getData();
- rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, address.toString()));
-
+ for (Entry<Address, Bucket<RoutingTable>> entry : buckets.entrySet()) {
+ RoutingTable table = entry.getValue().getData();
+ rpcMap.putAll(getRpcMemberMapByRoute(table, routeId, entry.getKey().toString()));
}
log.debug("list of RPCs {} searched by route {}", rpcMap, routeId);
import akka.actor.ActorRef;
import akka.japi.Pair;
import com.google.common.base.Preconditions;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Comparator;
import java.util.SortedSet;
return actorRefSet.last().first();
}
- private class LatestEntryComparator implements Comparator<Pair<ActorRef, Long>> {
+ private static class LatestEntryComparator implements Comparator<Pair<ActorRef, Long>>, Serializable {
+ private static final long serialVersionUID = 1L;
@Override
public int compare(Pair<ActorRef, Long> o1, Pair<ActorRef, Long> o2) {
if (o1 == null && o2 == null) {
return 0;
}
- if (o1 == null && o2 != null) {
+
+ if (o1 != null && o2 != null && o1.second() == null && o2.second() == null) {
+ return 0;
+ }
+
+ if ((o1 == null || o1.second() == null) && o2 != null) {
return -1;
}
- if (o1 != null && o2 == null) {
+
+ if (o2 == null || o2.second() == null) {
return 1;
}
return o1.second().compareTo(o2.second());
-
}
}
}