Merge "BUG-731: fix warnings from missing generic arguments"
authorTony Tkacik <ttkacik@cisco.com>
Tue, 20 May 2014 13:19:25 +0000 (13:19 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 20 May 2014 13:19:25 +0000 (13:19 +0000)
18 files changed:
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImpl.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/Context.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcClient.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RoutingTableProvider.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImpl.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandler.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/Message.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientImplTest.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ClientRequestHandlerTest.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/MockRoutingTable.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerImplTest.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/ServerRequestHandlerTest.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/MessagingUtil.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/test/java/org/opendaylight/controller/sal/connector/remoterpc/utils/RemoteServerTestClient.java

index ddc79ae..e08e9a4 100644 (file)
@@ -443,9 +443,6 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat
     }
 
     private static class BackwardsCompatibleConfigurationDataChangeInvoker implements BindingDataChangeListener, Delegator<DataChangeListener> {
-
-
-        @SuppressWarnings("rawtypes")
         private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener<?,?> delegate;
 
         public BackwardsCompatibleConfigurationDataChangeInvoker(final DataChangeListener listener) {
index f869254..a7c6b0c 100644 (file)
@@ -285,7 +285,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
 
         @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) {
+        protected NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(final CompositeNode compositeNode) {
             ImmutableMap.Builder<QName, Object> keys = ImmutableMap.builder();
             for (QName key : keyDefinition) {
 
@@ -325,7 +325,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
 
         @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) {
+        protected NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(final CompositeNode compositeNode) {
             return Builders.unkeyedListEntryBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -343,7 +343,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
 
         @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) {
+        protected NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(final CompositeNode compositeNode) {
             return Builders.containerBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -377,7 +377,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
 
         @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) {
+        protected NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(final CompositeNode compositeNode) {
             return Builders.orderedLeafSetBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -397,7 +397,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
 
         @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) {
+        protected NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(final CompositeNode compositeNode) {
             return Builders.leafSetBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -602,7 +602,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
 
         @Override
-        protected NormalizedNodeContainerBuilder createBuilder(final CompositeNode compositeNode) {
+        protected NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(final CompositeNode compositeNode) {
             return Builders.choiceBuilder().withNodeIdentifier(getIdentifier());
         }
 
index 9cbf428..357a516 100644 (file)
@@ -8,29 +8,22 @@
 package org.opendaylight.controller.sal.dom.broker
 
 import java.util.Hashtable
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
+import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry
 import org.opendaylight.controller.sal.core.api.data.DataBrokerService
 import org.opendaylight.controller.sal.core.api.data.DataProviderService
 import org.opendaylight.controller.sal.core.api.data.DataStore
 import org.opendaylight.controller.sal.core.api.model.SchemaService
-import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
 import org.opendaylight.controller.sal.core.api.mount.MountService
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener
 import org.osgi.framework.BundleContext
 import org.osgi.framework.ServiceRegistration
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry
-import org.opendaylight.controller.md.sal.dom.broker.impl.compat.BackwardsCompatibleDataBroker
-import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl
-import com.google.common.util.concurrent.MoreExecutors
-import com.google.common.collect.ImmutableMap
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType
-import org.opendaylight.controller.sal.core.spi.data.DOMStore
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore
-import java.util.concurrent.Executors
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
 
 class BrokerConfigActivator implements AutoCloseable {
 
index 8f95e73..e721084 100644 (file)
@@ -180,10 +180,10 @@ public class ClientImpl implements RemoteRpcClient {
    * @param  routeId route identifier
    * @return         remote network address
    */
-  private String lookupRemoteAddressForGlobalRpc(RpcRouter.RouteIdentifier routeId){
+  private String lookupRemoteAddressForGlobalRpc(RpcRouter.RouteIdentifier<?, ?, ?> routeId){
     checkNotNull(routeId, "route must not be null");
 
-    Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> routingTable = routingTableProvider.getRoutingTable();
+    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> routingTable = routingTableProvider.getRoutingTable();
     checkNotNull(routingTable.isPresent(), "Routing table is null");
 
     String address = null;
@@ -202,10 +202,10 @@ public class ClientImpl implements RemoteRpcClient {
    * @param  routeId route identifier
    * @return         remote network address
    */
-  private String lookupRemoteAddressForRpc(RpcRouter.RouteIdentifier routeId){
+  private String lookupRemoteAddressForRpc(RpcRouter.RouteIdentifier<?, ?, ?> routeId){
     checkNotNull(routeId, "route must not be null");
 
-    Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> routingTable = routingTableProvider.getRoutingTable();
+    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> routingTable = routingTableProvider.getRoutingTable();
     checkNotNull(routingTable.isPresent(), "Routing table is null");
 
     String address = routingTable.get().getLastAddedRoute(routeId);
@@ -230,7 +230,7 @@ public class ClientImpl implements RemoteRpcClient {
    */
   private void closeZmqContext() {
     ExecutorService exec = Executors.newSingleThreadExecutor();
-    FutureTask zmqTermination = new FutureTask(new Runnable() {
+    FutureTask<?> zmqTermination = new FutureTask<Void>(new Runnable() {
 
       @Override
       public void run() {
index 9e66c20..37bff7b 100644 (file)
@@ -7,19 +7,19 @@
 
 package org.opendaylight.controller.sal.connector.remoterpc;
 
-import org.zeromq.ZMQ;
-
 import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
 import java.net.SocketException;
 import java.util.Enumeration;
 
+import org.zeromq.ZMQ;
+
 /**
  * Provides a ZeroMQ Context object
  */
 public class Context {
-  private ZMQ.Context zmqContext = ZMQ.context(1);
+  private final ZMQ.Context zmqContext = ZMQ.context(1);
   private String uri;
   private final String DEFAULT_RPC_PORT = "5554";
 
@@ -69,7 +69,7 @@ public class Context {
    */
   private String findIpAddress() {
     String hostAddress = null;
-    Enumeration e = null;
+    Enumeration<?> e = null;
     try {
       e = NetworkInterface.getNetworkInterfaces();
     } catch (SocketException e1) {
@@ -79,7 +79,7 @@ public class Context {
 
       NetworkInterface n = (NetworkInterface) e.nextElement();
 
-      Enumeration ee = n.getInetAddresses();
+      Enumeration<?> ee = n.getInetAddresses();
       while (ee.hasMoreElements()) {
         InetAddress i = (InetAddress) ee.nextElement();
         if ((i instanceof Inet4Address) && (i.isSiteLocalAddress()))
index a564a0a..94e3232 100644 (file)
@@ -8,14 +8,11 @@
 
 package org.opendaylight.controller.sal.connector.remoterpc;
 
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation;
-
 public interface RemoteRpcClient extends AutoCloseable{
 
     void setRoutingTableProvider(RoutingTableProvider provider);
-    
+
     void stop();
-    
+
     void start();
 }
index 53fbb92..76df256 100644 (file)
@@ -58,7 +58,7 @@ public class RemoteRpcProvider implements
   private ProviderSession brokerSession;
   private RpcProvisionRegistry rpcProvisionRegistry;
   private BundleContext context;
-  private ServiceTracker clusterTracker;
+  private ServiceTracker<?, ?> clusterTracker;
 
   public RemoteRpcProvider(ServerImpl server, ClientImpl client) {
     this.server = server;
@@ -170,8 +170,8 @@ public class RemoteRpcProvider implements
 
   }
 
-  private RoutingTable<RpcRouter.RouteIdentifier, String> getRoutingTable(){
-    Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> routingTable =
+  private RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> getRoutingTable(){
+    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> routingTable =
         routingTableProvider.getRoutingTable();
 
     checkState(routingTable.isPresent(), "Routing table is null");
@@ -191,7 +191,7 @@ public class RemoteRpcProvider implements
       RouteIdentifierImpl routeId = new RouteIdentifierImpl();
       routeId.setType(rpc);
 
-      RoutingTable<RpcRouter.RouteIdentifier, String> routingTable = getRoutingTable();
+      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
 
       try {
         routingTable.addGlobalRoute(routeId, server.getServerAddress());
@@ -212,7 +212,7 @@ public class RemoteRpcProvider implements
       RouteIdentifierImpl routeId = new RouteIdentifierImpl();
       routeId.setType(rpc);
 
-      RoutingTable<RpcRouter.RouteIdentifier, String> routingTable = getRoutingTable();
+      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
 
       try {
         routingTable.removeGlobalRoute(routeId);
@@ -245,9 +245,9 @@ public class RemoteRpcProvider implements
      *
      * @param announcements
      */
-    private void announce(Set<RpcRouter.RouteIdentifier> announcements) {
+    private void announce(Set<RpcRouter.RouteIdentifier<?, ?, ?>> announcements) {
       _logger.debug("Announcing [{}]", announcements);
-      RoutingTable<RpcRouter.RouteIdentifier, String> routingTable = getRoutingTable();
+      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
       try {
         routingTable.addRoutes(announcements, server.getServerAddress());
       } catch (RoutingTableException | SystemException e) {
@@ -259,9 +259,9 @@ public class RemoteRpcProvider implements
      *
      * @param removals
      */
-    private void remove(Set<RpcRouter.RouteIdentifier> removals){
+    private void remove(Set<RpcRouter.RouteIdentifier<?, ?, ?>> removals){
       _logger.debug("Removing [{}]", removals);
-      RoutingTable<RpcRouter.RouteIdentifier, String> routingTable = getRoutingTable();
+      RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> routingTable = getRoutingTable();
       try {
         routingTable.removeRoutes(removals, server.getServerAddress());
       } catch (RoutingTableException | SystemException e) {
@@ -274,9 +274,9 @@ public class RemoteRpcProvider implements
      * @param changes
      * @return
      */
-    private Set<RpcRouter.RouteIdentifier> getRouteIdentifiers(Map<RpcRoutingContext, Set<InstanceIdentifier>> changes) {
+    private Set<RpcRouter.RouteIdentifier<?, ?, ?>> getRouteIdentifiers(Map<RpcRoutingContext, Set<InstanceIdentifier>> changes) {
       RouteIdentifierImpl routeId = null;
-      Set<RpcRouter.RouteIdentifier> routeIdSet = new HashSet<RpcRouter.RouteIdentifier>();
+      Set<RpcRouter.RouteIdentifier<?, ?, ?>> routeIdSet = new HashSet<>();
 
       for (RpcRoutingContext context : changes.keySet()){
         routeId = new RouteIdentifierImpl();
index 71bab28..d960303 100644 (file)
@@ -8,25 +8,24 @@
 
 package org.opendaylight.controller.sal.connector.remoterpc;
 
-import com.google.common.base.Optional;
 import org.opendaylight.controller.sal.connector.api.RpcRouter;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RouteChangeListener;
 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.RouteIdentifierImpl;
 import org.opendaylight.controller.sal.connector.remoterpc.impl.RoutingTableImpl;
 import org.osgi.framework.BundleContext;
 import org.osgi.util.tracker.ServiceTracker;
 
+import com.google.common.base.Optional;
+
 public class RoutingTableProvider implements AutoCloseable {
 
     @SuppressWarnings("rawtypes")
     final ServiceTracker<RoutingTable,RoutingTable> tracker;
 
-    private RoutingTableImpl routingTableImpl = null;
+    private RoutingTableImpl<?, ?> routingTableImpl = null;
 
     //final private RouteChangeListener routeChangeListener;
-    
-    
+
+
     public RoutingTableProvider(BundleContext ctx){//,RouteChangeListener rcl) {
         @SuppressWarnings("rawtypes")
         ServiceTracker<RoutingTable, RoutingTable> rawTracker = new ServiceTracker<>(ctx, RoutingTable.class, null);
@@ -35,14 +34,14 @@ public class RoutingTableProvider implements AutoCloseable {
 
         //routeChangeListener = rcl;
     }
-    
-    public Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> getRoutingTable() {
+
+    public Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> getRoutingTable() {
         @SuppressWarnings("unchecked")
-        RoutingTable<RpcRouter.RouteIdentifier,String> tracked = tracker.getService();
+        RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> tracked = tracker.getService();
 
         if(tracked instanceof RoutingTableImpl){
             if(routingTableImpl != tracked){
-             routingTableImpl= (RoutingTableImpl)tracked;
+             routingTableImpl= (RoutingTableImpl<?, ?>)tracked;
              //routingTableImpl.setRouteChangeListener(routeChangeListener);
             }
         }
index d256b99..3acea35 100644 (file)
@@ -7,48 +7,33 @@
  */
 package org.opendaylight.controller.sal.connector.remoterpc;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Sets;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RouteChangeListener;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
-import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
-import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.RouteIdentifierImpl;
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
-import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
-import org.opendaylight.controller.sal.core.api.RpcRoutingContext;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
 import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.net.NetworkInterface;
 import java.net.SocketException;
 import java.util.Enumeration;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.TimeUnit;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.zeromq.ZMQ;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 
 /**
  * ZeroMq based implementation of RpcRouter.
  */
 public class ServerImpl implements RemoteRpcServer {
 
-  private Logger _logger = LoggerFactory.getLogger(ServerImpl.class);
+  private final Logger _logger = LoggerFactory.getLogger(ServerImpl.class);
 
   private ExecutorService serverPool;
   protected ServerRequestHandler handler;
@@ -63,7 +48,7 @@ public class ServerImpl implements RemoteRpcServer {
   private volatile State status = State.STOPPED;
 
   private String serverAddress;
-  private int port;
+  private final int port;
 
   public static enum State {
     STARTING, STARTED, STOPPED;
@@ -167,7 +152,7 @@ public class ServerImpl implements RemoteRpcServer {
    */
   private void closeZmqContext() {
     ExecutorService exec = Executors.newSingleThreadExecutor();
-    FutureTask zmqTermination = new FutureTask(new Runnable() {
+    FutureTask<?> zmqTermination = new FutureTask<Void>(new Runnable() {
 
       @Override
       public void run() {
@@ -249,7 +234,7 @@ public class ServerImpl implements RemoteRpcServer {
    * @return
    */
   private String findIpAddress() {
-    Enumeration e = null;
+    Enumeration<?> e = null;
     try {
       e = NetworkInterface.getNetworkInterfaces();
     } catch (SocketException e1) {
@@ -260,7 +245,7 @@ public class ServerImpl implements RemoteRpcServer {
 
       NetworkInterface n = (NetworkInterface) e.nextElement();
 
-      Enumeration ee = n.getInetAddresses();
+      Enumeration<?> ee = n.getInetAddresses();
       while (ee.hasMoreElements()) {
         InetAddress i = (InetAddress) ee.nextElement();
         _logger.debug("Trying address {}", i);
index 2041f03..a25387d 100644 (file)
@@ -8,38 +8,39 @@
 
 package org.opendaylight.controller.sal.connector.remoterpc;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
 import org.opendaylight.controller.sal.connector.api.RpcRouter;
 import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.RouteIdentifierImpl;
 import org.opendaylight.controller.sal.connector.remoterpc.util.XmlUtils;
 import org.opendaylight.controller.sal.core.api.Broker;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.zeromq.ZMQ;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Collection;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
 /**
  *
  */
 public class ServerRequestHandler implements AutoCloseable{
 
-  private Logger _logger = LoggerFactory.getLogger(ServerRequestHandler.class);
+  private final Logger _logger = LoggerFactory.getLogger(ServerRequestHandler.class);
   private final String DEFAULT_NAME = "remote-rpc-worker";
-  private String dealerAddress;
-  private String serverAddress;
-  private int workerCount;
-  private ZMQ.Context context;
-  private Broker.ProviderSession broker;
+  private final String dealerAddress;
+  private final String serverAddress;
+  private final int workerCount;
+  private final ZMQ.Context context;
+  private final Broker.ProviderSession broker;
 
   private RequestHandlerThreadPool workerPool;
   private final AtomicInteger threadId = new AtomicInteger();
@@ -87,7 +88,7 @@ public class ServerRequestHandler implements AutoCloseable{
    * Worker to handles RPC request
    */
   private class Worker implements Runnable {
-    private String name;
+    private final String name;
 
     public Worker(int id){
       this.name = DEFAULT_NAME + "-" + id;
@@ -187,7 +188,7 @@ public class ServerRequestHandler implements AutoCloseable{
   }
 
   class MessageHandler{
-    private ZMQ.Socket socket;
+    private final ZMQ.Socket socket;
     private Message message;          //parsed message received on zmq server port
     private boolean messageForBroker = false; //if the message is valid and not a "ping" message
 
@@ -236,7 +237,7 @@ public class ServerRequestHandler implements AutoCloseable{
       CompositeNode payload = (result != null) ? result.getResult() : null;
 
       String recipient = null;
-      RpcRouter.RouteIdentifier routeId = null;
+      RpcRouter.RouteIdentifier<?, ?, ?> routeId = null;
 
       if (message != null) {
         recipient = message.getSender();
index 21d02be..cbcfe3e 100644 (file)
@@ -41,7 +41,7 @@ public class Message implements Serializable {
   private MessageType type;
   private String sender;
   private String recipient;
-  private RpcRouter.RouteIdentifier route;
+  private RpcRouter.RouteIdentifier<?, ?, ?> route;
   private Object payload;
 
   public MessageType getType() {
@@ -60,11 +60,11 @@ public class Message implements Serializable {
     this.sender = sender;
   }
 
-  public RpcRouter.RouteIdentifier getRoute() {
+  public RpcRouter.RouteIdentifier<?, ?, ?> getRoute() {
     return route;
   }
 
-  public void setRoute(RpcRouter.RouteIdentifier route) {
+  public void setRoute(RpcRouter.RouteIdentifier<?, ?, ?> route) {
     this.route = route;
   }
 
@@ -123,7 +123,7 @@ public class Message implements Serializable {
     return o.readObject();
   }
 
-  public static class Response extends Message implements RpcRouter.RpcReply {
+  public static class Response extends Message implements RpcRouter.RpcReply<Object> {
     private static final long serialVersionUID = 1L;
     private ResponseCode code; // response code
 
@@ -173,7 +173,7 @@ public class Message implements Serializable {
       return this;
     }
 
-    public MessageBuilder route(RpcRouter.RouteIdentifier route){
+    public MessageBuilder route(RpcRouter.RouteIdentifier<?, ?, ?> route){
       message.setRoute(route);
       return this;
     }
index 0fa12e3..f8d14ce 100644 (file)
@@ -40,8 +40,8 @@ public class ClientImplTest {
 
     //mock routing table
     routingTableProvider = mock(RoutingTableProvider.class);
-    RoutingTable<RpcRouter.RouteIdentifier, String> mockRoutingTable = new MockRoutingTable<String, String>();
-    Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> optionalRoutingTable = Optional.fromNullable(mockRoutingTable);
+    RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> mockRoutingTable = new MockRoutingTable<String, String>();
+    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> optionalRoutingTable = Optional.fromNullable(mockRoutingTable);
     when(routingTableProvider.getRoutingTable()).thenReturn(optionalRoutingTable);
 
     //mock ClientRequestHandler
index 1edd004..0918868 100644 (file)
@@ -99,7 +99,7 @@ public class ClientRequestHandlerTest {
   private Message handleMessageWithTimeout(final Message request) {
     Message response = null;
 
-    FutureTask task = new FutureTask(new Callable<Message>() {
+    FutureTask<?> task = new FutureTask<Message>(new Callable<Message>() {
 
       @Override
       public Message call() {
index 0fe0155..179051e 100644 (file)
@@ -7,16 +7,13 @@
  */
 package org.opendaylight.controller.sal.connector.remoterpc;
 
-import org.opendaylight.controller.sal.connector.remoterpc.api.RouteChangeListener;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTableException;
 import org.opendaylight.controller.sal.connector.remoterpc.api.SystemException;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * Mock implementation of routing table
  */
@@ -59,7 +56,7 @@ public class MockRoutingTable<K, V> implements RoutingTable {
   }
 
   @Override
-  public Set getRoutes(Object o) {
+  public Set<String> getRoutes(Object o) {
     Set<String> routes = new HashSet<String>();
     routes.add("localhost:5554");
     return routes;
index 886ff42..7ffdf17 100644 (file)
@@ -8,28 +8,34 @@
 package org.opendaylight.controller.sal.connector.remoterpc;
 
 
-import com.google.common.base.Optional;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ThreadPoolExecutor;
+
 import junit.framework.Assert;
-import org.junit.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 import org.opendaylight.controller.sal.connector.api.RpcRouter;
 import org.opendaylight.controller.sal.connector.remoterpc.api.RoutingTable;
 import org.opendaylight.controller.sal.connector.remoterpc.utils.MessagingUtil;
 import org.opendaylight.controller.sal.core.api.Broker;
 import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.zeromq.ZMQ;
+
 import zmq.Ctx;
 import zmq.SocketBase;
 
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import com.google.common.base.Optional;
 
 public class ServerImplTest {
 
@@ -68,12 +74,12 @@ public class ServerImplTest {
     server = new ServerImpl(port);
     server.setBrokerSession(brokerSession);
 
-    RoutingTable<RpcRouter.RouteIdentifier, String> mockRoutingTable = new MockRoutingTable<String, String>();
-    Optional<RoutingTable<RpcRouter.RouteIdentifier, String>> optionalRoutingTable = Optional.fromNullable(mockRoutingTable);
+    RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String> mockRoutingTable = new MockRoutingTable<String, String>();
+    Optional<RoutingTable<RpcRouter.RouteIdentifier<?, ?, ?>, String>> optionalRoutingTable = Optional.fromNullable(mockRoutingTable);
     when(routingTableProvider.getRoutingTable()).thenReturn(optionalRoutingTable);
 
     when(brokerSession.addRpcRegistrationListener(listener)).thenReturn(null);
-    when(brokerSession.getSupportedRpcs()).thenReturn(Collections.EMPTY_SET);
+    when(brokerSession.getSupportedRpcs()).thenReturn(Collections.<QName>emptySet());
     when(brokerSession.rpc(null, mock(CompositeNode.class))).thenReturn(null);
     server.start();
     Thread.sleep(5000);//wait for server to start
@@ -178,7 +184,7 @@ public class ServerImplTest {
     Thread[] threads = new Thread[Thread.activeCount()];
     Thread.enumerate(threads);
 
-    List<Thread> foundThreads = new ArrayList();
+    List<Thread> foundThreads = new ArrayList<Thread>();
     for (Thread t : threads) {
       if (t.getName().startsWith(name))
         foundThreads.add(t);
index 6e39867..e5fbc76 100644 (file)
@@ -7,7 +7,15 @@
 
 package org.opendaylight.controller.sal.connector.remoterpc;
 
+import static org.mockito.Mockito.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
 import junit.framework.Assert;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -15,22 +23,15 @@ import org.opendaylight.controller.sal.connector.remoterpc.utils.MessagingUtil;
 import org.opendaylight.controller.sal.core.api.Broker;
 import org.zeromq.ZMQ;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import static org.mockito.Mockito.mock;
-
 public class ServerRequestHandlerTest {
 
   ServerRequestHandler handler;
   ZMQ.Context context;
   ExecutorService executorService = Executors.newCachedThreadPool();
-  private int workerCount = 2;
-  private String mockDealerAddress = "inproc://rpc-request-handler";
-  private String mockServerIp = "localhost";
-  private int mockServerPort = 5554;
+  private final int workerCount = 2;
+  private final String mockDealerAddress = "inproc://rpc-request-handler";
+  private final String mockServerIp = "localhost";
+  private final int mockServerPort = 5554;
 
   @Before
   public void setUp() throws Exception {
@@ -98,7 +99,7 @@ public class ServerRequestHandlerTest {
     Thread[] threads = new Thread[Thread.activeCount()];
     Thread.enumerate(threads);
 
-    List<Thread> foundThreads = new ArrayList();
+    List<Thread> foundThreads = new ArrayList<Thread>();
     for (Thread t : threads) {
       if (t.getName().startsWith(name))
         foundThreads.add(t);
index a68ee57..883aa52 100644 (file)
@@ -7,12 +7,6 @@
 
 package org.opendaylight.controller.sal.connector.remoterpc.utils;
 
-import junit.framework.Assert;
-import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.zeromq.ZMQ;
-
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -21,6 +15,13 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.FutureTask;
 import java.util.concurrent.TimeUnit;
 
+import junit.framework.Assert;
+
+import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.zeromq.ZMQ;
+
 public class MessagingUtil {
 
   private static final Logger _logger = LoggerFactory.getLogger(MessagingUtil.class);
@@ -160,7 +161,7 @@ public class MessagingUtil {
     if (context == null) return;
 
     ExecutorService exec = Executors.newSingleThreadExecutor();
-    FutureTask zmqTermination = new FutureTask(new Runnable() {
+    FutureTask<?> zmqTermination = new FutureTask<Void>(new Runnable() {
 
       @Override
       public void run() {
index a71ab86..7a4f4a5 100644 (file)
@@ -1,14 +1,14 @@
 package org.opendaylight.controller.sal.connector.remoterpc.utils;
 
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
 import org.opendaylight.controller.sal.connector.api.RpcRouter;
 import org.opendaylight.controller.sal.connector.remoterpc.dto.Message;
 import org.opendaylight.controller.sal.connector.remoterpc.util.XmlUtils;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.zeromq.ZMQ;
 
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
 public class RemoteServerTestClient {
 
 
@@ -39,7 +39,7 @@ public class RemoteServerTestClient {
   }
   public Message createAddFlowMessage(String serverAddress ){
 
-    RpcRouter.RouteIdentifier routeIdentifier = getAddFlowRpcIdentifier();
+    RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier = getAddFlowRpcIdentifier();
 
     Message addFlow = new Message.MessageBuilder()
         .type(Message.MessageType.REQUEST)
@@ -52,7 +52,7 @@ public class RemoteServerTestClient {
     return addFlow;
   }
 
-  private RpcRouter.RouteIdentifier getAddFlowRpcIdentifier(){
+  private RpcRouter.RouteIdentifier<?, ?, ?> getAddFlowRpcIdentifier(){
     throw new UnsupportedOperationException();
   }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.