Cleaned formatting (per ODL standards) and whitespace. 65/17665/3
authorKeith Burns (alagalah) <alagalah@gmail.com>
Thu, 2 Apr 2015 17:31:09 +0000 (10:31 -0700)
committerKeith Burns (alagalah) <alagalah@gmail.com>
Thu, 2 Apr 2015 17:53:32 +0000 (10:53 -0700)
See https://git.opendaylight.org/gerrit/#/c/17575/ for
eclipse-java-clean-code-style.xml.

Only did this for files associated with https://git.opendaylight.org/gerrit/#/c/17391/

Change-Id: I430c5ef0a409bc6dc8b59c966ffd9e6ca6e57873
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
16 files changed:
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/endpoint/EndpointRpcRegistry.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/endpoint/EpRendererAugmentation.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/SfcManager.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/resolver/InheritanceUtils.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/resolver/MatcherUtils.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/resolver/PolicyResolver.java
groupbasedpolicy/src/main/yang/model/common.yang
groupbasedpolicy/src/main/yang/model/endpoint-provider.yang
groupbasedpolicy/src/main/yang/model/endpoint.yang
groupbasedpolicy/src/main/yang/model/policy-provider.yang
groupbasedpolicy/src/main/yang/model/policy.yang
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/util/SingletonTaskTest.java
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/EndpointManager.java
renderers/ofoverlay/src/main/yang/ofoverlay.yang
renderers/opflex/src/main/java/org/opendaylight/groupbasedpolicy/renderer/opflex/EndpointManager.java
renderers/opflex/src/main/yang/opflex.yang

index 4808061db313cb9d8f5d134dea82ce2a428baf7b..f5c4a58ea38658abc50a6d5c803b8b26cc7952e6 100644 (file)
@@ -58,12 +58,11 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 
 /**
- * Endpoint registry provides a scalable store for accessing and 
- * updating information about endpoints.
- * @author readamsO
+ * Endpoint registry provides a scalable store for accessing and updating
+ * information about endpoints.
  */
 public class EndpointRpcRegistry implements EndpointService {
-    private static final Logger LOG = 
+    private static final Logger LOG =
             LoggerFactory.getLogger(EndpointRpcRegistry.class);
 
     private final DataBroker dataProvider;
@@ -75,7 +74,6 @@ public class EndpointRpcRegistry implements EndpointService {
 
     private final static ConcurrentMap<String, EpRendererAugmentation> registeredRenderers = new ConcurrentHashMap<String, EpRendererAugmentation>();
 
-
     /**
      * This method registers a renderer for endpoint RPC API. This method
      * ensures single RPC registration for all renderers since a single RPC
@@ -88,7 +86,8 @@ public class EndpointRpcRegistry implements EndpointService {
      * @param executor
      *            - thread pool executor
      * @param epRendererAugmentation
-     *            - specific implementation RPC augmentation, if any. Otherwise NULL
+     *            - specific implementation RPC augmentation, if any. Otherwise
+     *            NULL
      */
     public static void register(DataBroker dataProvider,
             RpcProviderRegistry rpcRegistry, ScheduledExecutorService executor,
@@ -146,8 +145,8 @@ public class EndpointRpcRegistry implements EndpointService {
      * @param executor
      */
     private EndpointRpcRegistry(DataBroker dataProvider,
-                                    RpcProviderRegistry rpcRegistry,
-                                    ScheduledExecutorService executor) {
+            RpcProviderRegistry rpcRegistry,
+            ScheduledExecutorService executor) {
         this.dataProvider = dataProvider;
         this.executor = executor;
         this.rpcRegistry = rpcRegistry;
@@ -158,13 +157,13 @@ public class EndpointRpcRegistry implements EndpointService {
             LOG.debug("Added RPC Implementation Correctly");
         } else
             rpcRegistration = null;
-        
+
         if (dataProvider != null) {
-            InstanceIdentifier<Endpoints> iid = 
+            InstanceIdentifier<Endpoints> iid =
                     InstanceIdentifier.builder(Endpoints.class).build();
             WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
-            t.put(LogicalDatastoreType.OPERATIONAL, 
-                  iid, new EndpointsBuilder().build());
+            t.put(LogicalDatastoreType.OPERATIONAL,
+                    iid, new EndpointsBuilder().build());
             CheckedFuture<Void, TransactionCommitFailedException> f = t.submit();
             Futures.addCallback(f, new FutureCallback<Void>() {
                 @Override
@@ -174,19 +173,22 @@ public class EndpointRpcRegistry implements EndpointService {
 
                 @Override
                 public void onSuccess(Void result) {
-                    
+
                 }
             });
         }
 
-        // XXX TODO - age out endpoint data and remove 
+        // XXX TODO - age out endpoint data and remove
         // endpoint group/condition mappings with no conditions
     }
-  
+
     /**
-     * Construct an endpoint with the appropriate augmentations from the 
-     * endpoint input.  Each concrete implementation can provides its specifics earlier.
-     * @param input the input object
+     * Construct an endpoint with the appropriate augmentations from the
+     * endpoint input. Each concrete implementation can provides its specifics
+     * earlier.
+     *
+     * @param input
+     *            the input object
      */
     private EndpointBuilder buildEndpoint(RegisterEndpointInput input) {
         EndpointBuilder eb = new EndpointBuilder(input);
@@ -203,9 +205,12 @@ public class EndpointRpcRegistry implements EndpointService {
     }
 
     /**
-     * Construct an L3 endpoint with the appropriate augmentations from the 
-     * endpoint input.  Each concrete implementation can provides its specifics earlier.
-     * @param input the input object
+     * Construct an L3 endpoint with the appropriate augmentations from the
+     * endpoint input. Each concrete implementation can provides its specifics
+     * earlier.
+     *
+     * @param input
+     *            the input object
      */
     private EndpointL3Builder buildEndpointL3(RegisterEndpointInput input) {
         EndpointL3Builder eb = new EndpointL3Builder(input);
@@ -222,9 +227,12 @@ public class EndpointRpcRegistry implements EndpointService {
     }
 
     /**
-     * Construct an L3 endpoint with the appropriate augmentations from the 
-     * endpoint input.  Each concrete implementation can provides its specifics earlier.
-     * @param input the input object
+     * Construct an L3 endpoint with the appropriate augmentations from the
+     * endpoint input. Each concrete implementation can provides its specifics
+     * earlier.
+     *
+     * @param input
+     *            the input object
      */
     private EndpointL3PrefixBuilder buildL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) {
         EndpointL3PrefixBuilder eb = new EndpointL3PrefixBuilder(input);
@@ -242,39 +250,40 @@ public class EndpointRpcRegistry implements EndpointService {
 
     @Override
     public Future<RpcResult<Void>>
-        registerEndpoint(RegisterEndpointInput input) {
+            registerEndpoint(RegisterEndpointInput input) {
         long timestamp = System.currentTimeMillis();
 
-        //TODO: Replicate RPC feedback implemented in L3Prefix register for unmet requirements.
+        // TODO: Replicate RPC feedback implemented in L3Prefix register for
+        // unmet requirements.
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
 
         if (input.getL2Context() != null &&
-            input.getMacAddress() != null) {
+                input.getMacAddress() != null) {
             Endpoint ep = buildEndpoint(input)
                     .setTimestamp(timestamp)
                     .build();
 
-            EndpointKey key = 
+            EndpointKey key =
                     new EndpointKey(ep.getL2Context(), ep.getMacAddress());
-            InstanceIdentifier<Endpoint> iid = 
+            InstanceIdentifier<Endpoint> iid =
                     InstanceIdentifier.builder(Endpoints.class)
-                    .child(Endpoint.class, key)
-                    .build();
+                            .child(Endpoint.class, key)
+                            .build();
             t.put(LogicalDatastoreType.OPERATIONAL, iid, ep);
         }
         if (input.getL3Address() != null) {
             for (L3Address l3addr : input.getL3Address()) {
-                EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(), 
-                                                       l3addr.getL3Context());
+                EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(),
+                        l3addr.getL3Context());
                 EndpointL3 ep3 = buildEndpointL3(input)
-                    .setIpAddress(key3.getIpAddress())
-                    .setL3Context(key3.getL3Context())
-                    .setTimestamp(timestamp)
-                    .build();
-                InstanceIdentifier<EndpointL3> iid_l3 = 
+                        .setIpAddress(key3.getIpAddress())
+                        .setL3Context(key3.getL3Context())
+                        .setTimestamp(timestamp)
+                        .build();
+                InstanceIdentifier<EndpointL3> iid_l3 =
                         InstanceIdentifier.builder(Endpoints.class)
-                            .child(EndpointL3.class, key3)
-                            .build();
+                                .child(EndpointL3.class, key3)
+                                .build();
                 t.put(LogicalDatastoreType.OPERATIONAL, iid_l3, ep3);
             }
         }
@@ -299,76 +308,75 @@ public class EndpointRpcRegistry implements EndpointService {
                     .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.").build());
         }
 
-
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
 
         long timestamp = System.currentTimeMillis();
 
-        //TODO: Convert IPPrefix into it's IPv4/IPv6 canonical form. 
+        // TODO: Convert IPPrefix into it's IPv4/IPv6 canonical form.
         // See org.apache.commons.net.util.SubnetUtils.SubnetInfo
-            
-        EndpointL3PrefixKey epL3PrefixKey = new EndpointL3PrefixKey(input.getIpPrefix(),input.getL3Context());
-            
+
+        EndpointL3PrefixKey epL3PrefixKey = new EndpointL3PrefixKey(input.getIpPrefix(), input.getL3Context());
+
         EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build();
-        InstanceIdentifier<EndpointL3Prefix> iid_l3prefix = 
+        InstanceIdentifier<EndpointL3Prefix> iid_l3prefix =
                 InstanceIdentifier.builder(Endpoints.class)
                         .child(EndpointL3Prefix.class, epL3PrefixKey)
                         .build();
         t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix);
 
         ListenableFuture<Void> r = t.submit();
-        return Futures.transform(r, futureTrans, executor);    
+        return Futures.transform(r, futureTrans, executor);
     }
-    
+
     @Override
     public Future<RpcResult<Void>>
-        unregisterEndpoint(UnregisterEndpointInput input) {
+            unregisterEndpoint(UnregisterEndpointInput input) {
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
         if (input.getL2() != null) {
             for (L2 l2a : input.getL2()) {
-                EndpointKey key = 
-                        new EndpointKey(l2a.getL2Context(), 
-                                        l2a.getMacAddress());
-                InstanceIdentifier<Endpoint> iid = 
+                EndpointKey key =
+                        new EndpointKey(l2a.getL2Context(),
+                                l2a.getMacAddress());
+                InstanceIdentifier<Endpoint> iid =
                         InstanceIdentifier.builder(Endpoints.class)
-                        .child(Endpoint.class, key).build();
+                                .child(Endpoint.class, key).build();
                 t.delete(LogicalDatastoreType.OPERATIONAL, iid);
             }
         }
         if (input.getL3() != null) {
             for (L3 l3addr : input.getL3()) {
-                EndpointL3Key key3 = 
-                        new EndpointL3Key(l3addr.getIpAddress(), 
-                                          l3addr.getL3Context());
-                InstanceIdentifier<EndpointL3> iid_l3 = 
+                EndpointL3Key key3 =
+                        new EndpointL3Key(l3addr.getIpAddress(),
+                                l3addr.getL3Context());
+                InstanceIdentifier<EndpointL3> iid_l3 =
                         InstanceIdentifier.builder(Endpoints.class)
-                        .child(EndpointL3.class, key3)
-                        .build();
+                                .child(EndpointL3.class, key3)
+                                .build();
                 t.delete(LogicalDatastoreType.OPERATIONAL, iid_l3);
             }
         }
-        //TODO: Implement L3Prefix
+        // TODO: Implement L3Prefix
 
         ListenableFuture<Void> r = t.submit();
         return Futures.transform(r, futureTrans, executor);
     }
 
     @Override
-    public Future<RpcResult<Void>> 
-        setEndpointGroupConditions(SetEndpointGroupConditionsInput input) {
+    public Future<RpcResult<Void>>
+            setEndpointGroupConditions(SetEndpointGroupConditionsInput input) {
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
 
-        ConditionMappingKey key = 
+        ConditionMappingKey key =
                 new ConditionMappingKey(input.getEndpointGroup());
-        
-        for (EndpointGroupCondition condition: input.getEndpointGroupCondition()) {
-            EndpointGroupConditionKey ckey = 
+
+        for (EndpointGroupCondition condition : input.getEndpointGroupCondition()) {
+            EndpointGroupConditionKey ckey =
                     new EndpointGroupConditionKey(condition.getCondition());
-            InstanceIdentifier<EndpointGroupCondition> iid = 
+            InstanceIdentifier<EndpointGroupCondition> iid =
                     InstanceIdentifier.builder(Endpoints.class)
-                        .child(ConditionMapping.class, key)
-                        .child(EndpointGroupCondition.class, ckey)
-                        .build();
+                            .child(ConditionMapping.class, key)
+                            .child(EndpointGroupCondition.class, ckey)
+                            .build();
             t.put(LogicalDatastoreType.OPERATIONAL, iid, condition);
         }
 
@@ -377,21 +385,21 @@ public class EndpointRpcRegistry implements EndpointService {
     }
 
     @Override
-    public Future<RpcResult<Void>> 
-        unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input) {
+    public Future<RpcResult<Void>>
+            unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input) {
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
 
-        ConditionMappingKey key = 
+        ConditionMappingKey key =
                 new ConditionMappingKey(input.getEndpointGroup());
-        
-        for (EndpointGroupCondition condition: input.getEndpointGroupCondition()) {
-            EndpointGroupConditionKey ckey = 
+
+        for (EndpointGroupCondition condition : input.getEndpointGroupCondition()) {
+            EndpointGroupConditionKey ckey =
                     new EndpointGroupConditionKey(condition.getCondition());
-            InstanceIdentifier<EndpointGroupCondition> iid = 
+            InstanceIdentifier<EndpointGroupCondition> iid =
                     InstanceIdentifier.builder(Endpoints.class)
-                        .child(ConditionMapping.class, key)
-                        .child(EndpointGroupCondition.class, ckey)
-                        .build();
+                            .child(ConditionMapping.class, key)
+                            .child(EndpointGroupCondition.class, ckey)
+                            .build();
 
             t.delete(LogicalDatastoreType.OPERATIONAL, iid);
         }
@@ -401,13 +409,11 @@ public class EndpointRpcRegistry implements EndpointService {
     }
 
     Function<Void, RpcResult<Void>> futureTrans =
-            new Function<Void,RpcResult<Void>>() {
-        @Override
-        public RpcResult<Void> apply(Void input) {
-            return RpcResultBuilder.<Void>success().build();
-        }
-    };
-
-
+            new Function<Void, RpcResult<Void>>() {
+                @Override
+                public RpcResult<Void> apply(Void input) {
+                    return RpcResultBuilder.<Void> success().build();
+                }
+            };
 
 }
index 13faebb42199438e53f179a540c473b1a897afcc..1562a85ecdf71f833b2bd11c6f82fb4495d55842 100644 (file)
@@ -13,11 +13,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3PrefixBuilder;
 
-/**
- *
- * @author Khal
- *
- */
 public interface EpRendererAugmentation {
 
     void buildEndpointAugmentation(EndpointBuilder eb,
index 760a2008effff550bf5bc86e1c0650b8b869d379..53341c03029341dd023f376995a76a507b183286 100644 (file)
@@ -49,14 +49,12 @@ import java.util.concurrent.ScheduledExecutorService;
 /**
  * Manage all things SFC
  *
- * This is a bit of a place-holder for functionality
- * that we'll need to add for SFC integration. This
- * will likely change a lot.
+ * This is a bit of a place-holder for functionality that we'll need to add for
+ * SFC integration. This will likely change a lot.
  *
- * TODO Move SfcManager out of ofoverlay renderer -- should be something
- *       that's shared by renderers, not specific to ofoverlay
+ * TODO Move SfcManager out of ofoverlay renderer -- should be something that's
+ * shared by renderers, not specific to ofoverlay
  *
- * @author tbachman
  */
 public class SfcManager implements AutoCloseable, DataChangeListener {
     private static final Logger LOG =
@@ -77,9 +75,9 @@ public class SfcManager implements AutoCloseable, DataChangeListener {
     private final String SFC_RSP_NAME = "rsp-sfc-gbp";
 
     public SfcManager(DataBroker dataBroker,
-                      PolicyResolver policyResolver,
-                      RpcProviderRegistry rpcRegistry,
-                      ScheduledExecutorService executor) {
+            PolicyResolver policyResolver,
+            RpcProviderRegistry rpcRegistry,
+            ScheduledExecutorService executor) {
         this.dataBroker = dataBroker;
         this.policyResolver = policyResolver;
         this.rpcRegistry = rpcRegistry;
@@ -90,11 +88,11 @@ public class SfcManager implements AutoCloseable, DataChangeListener {
          */
         allActionInstancesIid =
                 InstanceIdentifier.builder(Tenants.class)
-                    .child(Tenant.class)
-                    .child(SubjectFeatureInstances.class)
-                    .child(ActionInstance.class)
-                    .build();
-        actionListener = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, 
+                        .child(Tenant.class)
+                        .child(SubjectFeatureInstances.class)
+                        .child(ActionInstance.class)
+                        .build();
+        actionListener = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
                 allActionInstancesIid, this, DataChangeScope.ONE);
         LOG.debug("SfcManager: Started");
     }
@@ -105,41 +103,39 @@ public class SfcManager implements AutoCloseable, DataChangeListener {
 
         for (DataObject dao : change.getCreatedData().values()) {
             if (dao instanceof ActionInstance) {
-                ActionInstance ai = (ActionInstance)dao;
+                ActionInstance ai = (ActionInstance) dao;
                 LOG.debug("New ActionInstance created");
                 executor.execute(new MatchActionDefTask(ai));
             }
         }
 
         // TODO: how to handle deletes (comment out for now)
-//        for (InstanceIdentifier<?> iid : change.getRemovedPaths()) {
-//            DataObject old = change.getOriginalData().get(iid);
-//            if (old != null && old instanceof ActionInstance) {
-//
-//            }
-//        }
+        // for (InstanceIdentifier<?> iid : change.getRemovedPaths()) {
+        // DataObject old = change.getOriginalData().get(iid);
+        // if (old != null && old instanceof ActionInstance) {
+        //
+        // }
+        // }
 
         for (DataObject dao : change.getUpdatedData().values()) {
             if (dao instanceof ActionInstance) {
-                ActionInstance ai = (ActionInstance)dao;
+                ActionInstance ai = (ActionInstance) dao;
                 executor.execute(new MatchActionDefTask(ai));
             }
         }
     }
 
     /**
-     * Private internal class that gets the action definition
-     * referenced by the instance. If the definition has an
-     * action of "chain" (or whatever we decide to use
-     * here), then we need to invoke the SFC API to go
-     * get the chain information, which we'll eventually
-     * use during policy resolution.
+     * Private internal class that gets the action definition referenced by the
+     * instance. If the definition has an action of "chain" (or whatever we
+     * decide to use here), then we need to invoke the SFC API to go get the
+     * chain information, which we'll eventually use during policy resolution.
      *
      * @author tbachman
      *
      */
     private class MatchActionDefTask implements Runnable,
-                     FutureCallback<Optional<ActionDefinition>> {
+            FutureCallback<Optional<ActionDefinition>> {
         private final ActionInstance actionInstance;
         private final InstanceIdentifier<ActionDefinition> adIid;
         private final ActionDefinitionId id;
@@ -149,9 +145,9 @@ public class SfcManager implements AutoCloseable, DataChangeListener {
             this.id = actionInstance.getActionDefinitionId();
 
             adIid = InstanceIdentifier.builder(SubjectFeatureDefinitions.class)
-                                      .child(ActionDefinition.class,
-                                             new ActionDefinitionKey(this.id))
-                                      .build();
+                    .child(ActionDefinition.class,
+                            new ActionDefinitionKey(this.id))
+                    .build();
 
         }
 
@@ -176,12 +172,11 @@ public class SfcManager implements AutoCloseable, DataChangeListener {
         public void onSuccess(Optional<ActionDefinition> dao) {
             LOG.debug("Found ActionDefinition {}", id.getValue());
             if (dao instanceof ActionDefinition) {
-                ActionDefinition ad = (ActionDefinition)dao;
+                ActionDefinition ad = (ActionDefinition) dao;
                 if (ad.getName().getValue().equals(SFC_CHAIN_ACTION)) {
                     /*
-                     * We have the state we need:
-                     *  1) it's a "CHAIN" action
-                     *  2) the name is defined in the ActionInstance
+                     * We have the state we need: 1) it's a "CHAIN" action 2)
+                     * the name is defined in the ActionInstance
                      */
                     if (actionInstance.getParameterValue() != null) {
                         getSfcRsp();
@@ -193,43 +188,42 @@ public class SfcManager implements AutoCloseable, DataChangeListener {
         /**
          * Go get the RenderedServicePath from SFC
          *
-         * TBD: what to do with this once we have it - who to
-         * give it to
+         * TBD: what to do with this once we have it - who to give it to
          */
         private void getSfcRsp() {
-            for (ParameterValue pv: actionInstance.getParameterValue()) {
+            for (ParameterValue pv : actionInstance.getParameterValue()) {
                 if (pv.getName().getValue().equals(SFC_CHAIN_NAME)) {
                     // TODO: check for rspFirstHop.getTransportType()
                     ReadRenderedServicePathFirstHopInputBuilder builder =
-                        new ReadRenderedServicePathFirstHopInputBuilder();
+                            new ReadRenderedServicePathFirstHopInputBuilder();
                     builder.setName(SFC_CHAIN_NAME);
                     Future<RpcResult<ReadRenderedServicePathFirstHopOutput>> result =
-                        SfcProviderRpc.getSfcProviderRpc().readRenderedServicePathFirstHop(builder.build());
+                            SfcProviderRpc.getSfcProviderRpc().readRenderedServicePathFirstHop(builder.build());
                     try {
                         RpcResult<ReadRenderedServicePathFirstHopOutput> output = result.get();
                         if (output.isSuccessful()) {
                             RenderedServicePathFirstHop rspFirstHop =
-                                output.getResult().getRenderedServicePathFirstHop();
+                                    output.getResult().getRenderedServicePathFirstHop();
                             IpAddress ip = rspFirstHop.getIp();
                             PortNumber pn = rspFirstHop.getPort();
                             // TODO: use NSI, NSP, SPI
-                            //Short nsi = rspFirstHop.getStartingIndex();
-                            //Long nsp = rspFirstHop.getPathId();
-                            //Long spi = rspFirstHop.getSymmetricPathId();
+                            // Short nsi = rspFirstHop.getStartingIndex();
+                            // Long nsp = rspFirstHop.getPathId();
+                            // Long spi = rspFirstHop.getSymmetricPathId();
                         }
                     } catch (Exception e) {
-                       // TODO: proper exception handling
+                        // TODO: proper exception handling
                     }
                 }
             }
         }
 
-
     }
 
     @Override
     public void close() throws Exception {
-        if (actionListener != null) actionListener.close();
+        if (actionListener != null)
+            actionListener.close();
 
     }
 }
index 281fb8cc65c3020e0a4193a9fae41a8a10fe9d44..47e5d2ff74129acfe06b38b0a2624bc27ca6e819 100644 (file)
@@ -85,22 +85,23 @@ import com.google.common.collect.ImmutableList;
 /**
  * Utilities useful for resolving the inheritance rules for the various objects
  * in the system
- * @author readams
  *
  */
 public class InheritanceUtils {
     /**
-     * Fully resolve the specified {@link Tenant}, returning a tenant with all 
-     * items fully normalized.  This means that no items will have parent/child 
+     * Fully resolve the specified {@link Tenant}, returning a tenant with all
+     * items fully normalized. This means that no items will have parent/child
      * relationships and can be interpreted simply without regard to inheritance
-     * rules 
-     * @param unresolvedTenant the {@link Tenant} unresolved tenant to resolve
+     * rules
+     *
+     * @param unresolvedTenant
+     *            the {@link Tenant} unresolved tenant to resolve
      * @return the fully-resolved {@link Tenant}
      */
     public static Tenant resolveTenant(Tenant unresolvedTenant) {
         HashMap<EndpointGroupId, EndpointGroup> resolvedEgs = new HashMap<>();
         HashMap<ContractId, Contract> resolvedContracts = new HashMap<>();
-        
+
         if (unresolvedTenant.getEndpointGroup() != null) {
             for (EndpointGroup eg : unresolvedTenant.getEndpointGroup()) {
                 resolveEndpointGroup(unresolvedTenant, eg, resolvedEgs);
@@ -113,52 +114,52 @@ public class InheritanceUtils {
         }
 
         // XXX TODO - inherit from common tenant
-        
+
         return new TenantBuilder()
-            .setId(unresolvedTenant.getId())
-            .setName(unresolvedTenant.getName())
-            .setDescription(unresolvedTenant.getDescription())
-            .setEndpointGroup(ImmutableList.copyOf(resolvedEgs.values()))
-            .setContract(ImmutableList.copyOf(resolvedContracts.values()))
-            .setContractRef(unresolvedTenant.getContractRef())
-            .setSubjectFeatureInstances(unresolvedTenant.getSubjectFeatureInstances())
-            .setL3Context(unresolvedTenant.getL3Context())
-            .setL2BridgeDomain(unresolvedTenant.getL2BridgeDomain())
-            .setL2FloodDomain(unresolvedTenant.getL2FloodDomain())
-            .setSubnet(unresolvedTenant.getSubnet())
-            .build();
+                .setId(unresolvedTenant.getId())
+                .setName(unresolvedTenant.getName())
+                .setDescription(unresolvedTenant.getDescription())
+                .setEndpointGroup(ImmutableList.copyOf(resolvedEgs.values()))
+                .setContract(ImmutableList.copyOf(resolvedContracts.values()))
+                .setContractRef(unresolvedTenant.getContractRef())
+                .setSubjectFeatureInstances(unresolvedTenant.getSubjectFeatureInstances())
+                .setL3Context(unresolvedTenant.getL3Context())
+                .setL2BridgeDomain(unresolvedTenant.getL2BridgeDomain())
+                .setL2FloodDomain(unresolvedTenant.getL2FloodDomain())
+                .setSubnet(unresolvedTenant.getSubnet())
+                .build();
     }
 
     // ****************
     // Helper functions
     // ****************
-    
+
     private static void resolveEndpointGroup(Tenant unresolvedTenant,
-                                             EndpointGroup unresolvedEg,
-                                             HashMap<EndpointGroupId, 
-                                                     EndpointGroup> resolvedEgs) {
+            EndpointGroup unresolvedEg,
+            HashMap<EndpointGroupId,
+            EndpointGroup> resolvedEgs) {
         // put the unresolved object into the data structure to avoid loops
         resolvedEgs.put(unresolvedEg.getId(), unresolvedEg);
-        
+
         // resolve parent if it hasn't been resolved already
         EndpointGroup parent = null;
         if (unresolvedEg.getParent() != null) {
             if (!resolvedEgs.containsKey(unresolvedEg.getParent())) {
-                parent = TenantUtils.findEndpointGroup(unresolvedTenant, 
-                                                       unresolvedEg.getParent());
+                parent = TenantUtils.findEndpointGroup(unresolvedTenant,
+                        unresolvedEg.getParent());
                 if (parent != null)
                     resolveEndpointGroup(unresolvedTenant, parent, resolvedEgs);
             }
             parent = resolvedEgs.get(unresolvedEg.getParent());
         }
 
-        HashMap<SelectorName, ConsumerTargetSelector> resolvedCts = 
+        HashMap<SelectorName, ConsumerTargetSelector> resolvedCts =
                 new HashMap<>();
-        HashMap<SelectorName, ConsumerNamedSelector> resolvedCns = 
+        HashMap<SelectorName, ConsumerNamedSelector> resolvedCns =
                 new HashMap<>();
-        HashMap<SelectorName, ProviderTargetSelector> resolvedPts = 
+        HashMap<SelectorName, ProviderTargetSelector> resolvedPts =
                 new HashMap<>();
-        HashMap<SelectorName, ProviderNamedSelector> resolvedPns = 
+        HashMap<SelectorName, ProviderNamedSelector> resolvedPns =
                 new HashMap<>();
         NetworkDomainId domain = unresolvedEg.getNetworkDomain();
 
@@ -182,7 +183,6 @@ public class InheritanceUtils {
                 resolvePns(unresolvedTenant, unresolvedEg, s, resolvedPns);
             }
         }
-        
 
         if (parent != null) {
             if (parent.getConsumerTargetSelector() != null) {
@@ -217,216 +217,228 @@ public class InheritanceUtils {
         // Note: do not set parent, or any of the values that only exist
         // for inheritance
         EndpointGroup resolvedEg = new EndpointGroupBuilder()
-            .setId(unresolvedEg.getId())
-            .setDescription(unresolvedEg.getDescription())
-            .setConsumerTargetSelector(ImmutableList.copyOf(resolvedCts.values()))
-            .setConsumerNamedSelector(ImmutableList.copyOf(resolvedCns.values()))
-            .setProviderTargetSelector(ImmutableList.copyOf(resolvedPts.values()))
-            .setProviderNamedSelector(ImmutableList.copyOf(resolvedPns.values()))
-            .setNetworkDomain(domain)
-            .build();
+                .setId(unresolvedEg.getId())
+                .setDescription(unresolvedEg.getDescription())
+                .setConsumerTargetSelector(ImmutableList.copyOf(resolvedCts.values()))
+                .setConsumerNamedSelector(ImmutableList.copyOf(resolvedCns.values()))
+                .setProviderTargetSelector(ImmutableList.copyOf(resolvedPts.values()))
+                .setProviderNamedSelector(ImmutableList.copyOf(resolvedPns.values()))
+                .setNetworkDomain(domain)
+                .build();
         resolvedEgs.put(resolvedEg.getId(), resolvedEg);
     }
-    
+
     private static void resolveCts(Tenant unresolvedTenant,
-                                   EndpointGroup unresolvedEg,
-                                   ConsumerTargetSelector unresolvedTs,
-                                   HashMap<SelectorName, 
-                                           ConsumerTargetSelector> resolvedCts) {
+            EndpointGroup unresolvedEg,
+            ConsumerTargetSelector unresolvedTs,
+            HashMap<SelectorName,
+            ConsumerTargetSelector> resolvedCts) {
         HashMap<QualityMatcherName, QualityMatcher> matchers = new HashMap<>();
         HashMap<RequirementName, Requirement> requirements = new HashMap<>();
         HashSet<EndpointGroupId> visited = new HashSet<>();
 
-        resolveCtsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(), 
-                       matchers, requirements, visited);
-        
+        resolveCtsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(),
+                matchers, requirements, visited);
+
         ConsumerTargetSelector resolved = new ConsumerTargetSelectorBuilder()
-            .setName(unresolvedTs.getName())
-            .setQualityMatcher(ImmutableList.copyOf(matchers.values()))
-            .setRequirement(ImmutableList.copyOf(requirements.values()))
-            .build();
+                .setName(unresolvedTs.getName())
+                .setQualityMatcher(ImmutableList.copyOf(matchers.values()))
+                .setRequirement(ImmutableList.copyOf(requirements.values()))
+                .build();
         resolvedCts.put(resolved.getName(), resolved);
     }
-    
+
     private static void resolveCtsAttr(Tenant unresolvedTenant,
-                                       EndpointGroup unresolvedEg,
-                                       SelectorName name,
-                                       HashMap<QualityMatcherName, 
-                                               QualityMatcher> matchers,
-                                       HashMap<RequirementName, 
-                                               Requirement> requirements,
-                                       HashSet<EndpointGroupId> visited) {
-        if (unresolvedEg == null) return;
-        if (visited.contains(unresolvedEg.getId())) return;
+            EndpointGroup unresolvedEg,
+            SelectorName name,
+            HashMap<QualityMatcherName,
+            QualityMatcher> matchers,
+            HashMap<RequirementName,
+            Requirement> requirements,
+            HashSet<EndpointGroupId> visited) {
+        if (unresolvedEg == null)
+            return;
+        if (visited.contains(unresolvedEg.getId()))
+            return;
         visited.add(unresolvedEg.getId());
         if (unresolvedEg.getParent() != null) {
-            resolveCtsAttr(unresolvedTenant, 
-                           TenantUtils.findEndpointGroup(unresolvedTenant, 
-                                                         unresolvedEg.getParent()),
-                           name, 
-                           matchers,
-                           requirements,
-                           visited);
+            resolveCtsAttr(unresolvedTenant,
+                    TenantUtils.findEndpointGroup(unresolvedTenant,
+                            unresolvedEg.getParent()),
+                    name,
+                    matchers,
+                    requirements,
+                    visited);
         }
-        resolveLabels(unresolvedEg.getRequirement(), requirements, 
-                      MatcherUtils.getRequirementName);
-        ConsumerTargetSelector unresolvedSelector = 
+        resolveLabels(unresolvedEg.getRequirement(), requirements,
+                MatcherUtils.getRequirementName);
+        ConsumerTargetSelector unresolvedSelector =
                 TenantUtils.findCts(unresolvedEg, name);
-        if (unresolvedSelector == null) return;
-        resolveLabels(unresolvedSelector.getRequirement(), requirements, 
-                      MatcherUtils.getRequirementName);
+        if (unresolvedSelector == null)
+            return;
+        resolveLabels(unresolvedSelector.getRequirement(), requirements,
+                MatcherUtils.getRequirementName);
         resolveQualityMatcher(unresolvedSelector.getQualityMatcher(), matchers);
     }
-    
+
     private static void resolveCns(Tenant unresolvedTenant,
-                                   EndpointGroup unresolvedEg,
-                                   ConsumerNamedSelector unresolvedTs,
-                                   HashMap<SelectorName, 
-                                           ConsumerNamedSelector> resolvedCns) {
+            EndpointGroup unresolvedEg,
+            ConsumerNamedSelector unresolvedTs,
+            HashMap<SelectorName,
+            ConsumerNamedSelector> resolvedCns) {
         HashMap<RequirementName, Requirement> requirements = new HashMap<>();
         HashSet<ContractId> contracts = new HashSet<>();
         HashSet<EndpointGroupId> visited = new HashSet<>();
 
-        resolveCnsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(), 
-                       requirements, contracts, visited);
-        
+        resolveCnsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(),
+                requirements, contracts, visited);
+
         ConsumerNamedSelector resolved = new ConsumerNamedSelectorBuilder()
-            .setName(unresolvedTs.getName())
-            .setRequirement(ImmutableList.copyOf(requirements.values()))
-            .setContract(ImmutableList.copyOf(contracts))
-            .build();
+                .setName(unresolvedTs.getName())
+                .setRequirement(ImmutableList.copyOf(requirements.values()))
+                .setContract(ImmutableList.copyOf(contracts))
+                .build();
         resolvedCns.put(resolved.getName(), resolved);
     }
-    
+
     private static void resolveCnsAttr(Tenant unresolvedTenant,
-                                       EndpointGroup unresolvedEg,
-                                       SelectorName name,
-                                       HashMap<RequirementName, 
-                                               Requirement> requirements,
-                                       HashSet<ContractId> contracts,
-                                       HashSet<EndpointGroupId> visited) {
-        if (unresolvedEg == null) return;
-        if (visited.contains(unresolvedEg.getId())) return;
+            EndpointGroup unresolvedEg,
+            SelectorName name,
+            HashMap<RequirementName,
+            Requirement> requirements,
+            HashSet<ContractId> contracts,
+            HashSet<EndpointGroupId> visited) {
+        if (unresolvedEg == null)
+            return;
+        if (visited.contains(unresolvedEg.getId()))
+            return;
         visited.add(unresolvedEg.getId());
         if (unresolvedEg.getParent() != null) {
-            resolveCnsAttr(unresolvedTenant, 
-                           TenantUtils.findEndpointGroup(unresolvedTenant, 
-                                                         unresolvedEg.getParent()),
-                           name, requirements, contracts, visited);
+            resolveCnsAttr(unresolvedTenant,
+                    TenantUtils.findEndpointGroup(unresolvedTenant,
+                            unresolvedEg.getParent()),
+                    name, requirements, contracts, visited);
         }
-        resolveLabels(unresolvedEg.getRequirement(), requirements, 
-                      MatcherUtils.getRequirementName);
+        resolveLabels(unresolvedEg.getRequirement(), requirements,
+                MatcherUtils.getRequirementName);
         ConsumerNamedSelector unresolvedSelector =
                 TenantUtils.findCns(unresolvedEg, name);
-        if (unresolvedSelector == null) return;
+        if (unresolvedSelector == null)
+            return;
         resolveLabels(unresolvedSelector.getRequirement(), requirements,
-                      MatcherUtils.getRequirementName);
+                MatcherUtils.getRequirementName);
         if (unresolvedSelector.getContract() != null) {
             contracts.addAll(unresolvedSelector.getContract());
         }
     }
 
     private static void resolvePts(Tenant unresolvedTenant,
-                                   EndpointGroup unresolvedEg,
-                                   ProviderTargetSelector unresolvedTs,
-                                   HashMap<SelectorName, 
-                                           ProviderTargetSelector> resolvedCts) {
+            EndpointGroup unresolvedEg,
+            ProviderTargetSelector unresolvedTs,
+            HashMap<SelectorName,
+            ProviderTargetSelector> resolvedCts) {
         HashMap<QualityMatcherName, QualityMatcher> matchers = new HashMap<>();
         HashMap<CapabilityName, Capability> capabilities = new HashMap<>();
         HashSet<EndpointGroupId> visited = new HashSet<>();
 
-        resolvePtsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(), 
-                       matchers, capabilities, visited);
-        
+        resolvePtsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(),
+                matchers, capabilities, visited);
+
         ProviderTargetSelector resolved = new ProviderTargetSelectorBuilder()
-            .setName(unresolvedTs.getName())
-            .setQualityMatcher(ImmutableList.copyOf(matchers.values()))
-            .setCapability(ImmutableList.copyOf(capabilities.values()))
-            .build();
+                .setName(unresolvedTs.getName())
+                .setQualityMatcher(ImmutableList.copyOf(matchers.values()))
+                .setCapability(ImmutableList.copyOf(capabilities.values()))
+                .build();
         resolvedCts.put(resolved.getName(), resolved);
     }
-    
+
     private static void resolvePtsAttr(Tenant unresolvedTenant,
-                                       EndpointGroup unresolvedEg,
-                                       SelectorName name,
-                                       HashMap<QualityMatcherName, 
-                                               QualityMatcher> matchers,
-                                       HashMap<CapabilityName, 
-                                               Capability> capabilities,
-                                       HashSet<EndpointGroupId> visited) {
-        if (unresolvedEg == null) return;
-        if (visited.contains(unresolvedEg.getId())) return;
+            EndpointGroup unresolvedEg,
+            SelectorName name,
+            HashMap<QualityMatcherName,
+            QualityMatcher> matchers,
+            HashMap<CapabilityName,
+            Capability> capabilities,
+            HashSet<EndpointGroupId> visited) {
+        if (unresolvedEg == null)
+            return;
+        if (visited.contains(unresolvedEg.getId()))
+            return;
         visited.add(unresolvedEg.getId());
         if (unresolvedEg.getParent() != null) {
-           resolvePtsAttr(unresolvedTenant, 
-                           TenantUtils.findEndpointGroup(unresolvedTenant, 
-                                                         unresolvedEg.getParent()),
-                           name, 
-                           matchers,
-                           capabilities, visited);
+            resolvePtsAttr(unresolvedTenant,
+                    TenantUtils.findEndpointGroup(unresolvedTenant,
+                            unresolvedEg.getParent()),
+                    name,
+                    matchers,
+                    capabilities, visited);
         }
-        resolveLabels(unresolvedEg.getCapability(), capabilities, 
-                      MatcherUtils.getCapabilityName);
-        ProviderTargetSelector unresolvedSelector = 
+        resolveLabels(unresolvedEg.getCapability(), capabilities,
+                MatcherUtils.getCapabilityName);
+        ProviderTargetSelector unresolvedSelector =
                 TenantUtils.findPts(unresolvedEg, name);
-        if (unresolvedSelector == null) return;
-        resolveLabels(unresolvedSelector.getCapability(), capabilities, 
-                      MatcherUtils.getCapabilityName);
+        if (unresolvedSelector == null)
+            return;
+        resolveLabels(unresolvedSelector.getCapability(), capabilities,
+                MatcherUtils.getCapabilityName);
         resolveQualityMatcher(unresolvedSelector.getQualityMatcher(), matchers);
     }
-    
+
     private static void resolvePns(Tenant unresolvedTenant,
-                                   EndpointGroup unresolvedEg,
-                                   ProviderNamedSelector unresolvedTs,
-                                   HashMap<SelectorName, 
-                                           ProviderNamedSelector> resolvedCns) {
+            EndpointGroup unresolvedEg,
+            ProviderNamedSelector unresolvedTs,
+            HashMap<SelectorName,
+            ProviderNamedSelector> resolvedCns) {
         HashMap<CapabilityName, Capability> capabilities = new HashMap<>();
         HashSet<ContractId> contracts = new HashSet<>();
         HashSet<EndpointGroupId> visited = new HashSet<>();
-        
-        resolvePnsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(), 
-                       capabilities, contracts, visited);
-        
+
+        resolvePnsAttr(unresolvedTenant, unresolvedEg, unresolvedTs.getName(),
+                capabilities, contracts, visited);
+
         ProviderNamedSelector resolved = new ProviderNamedSelectorBuilder()
-            .setName(unresolvedTs.getName())
-            .setCapability(ImmutableList.copyOf(capabilities.values()))
-            .setContract(ImmutableList.copyOf(contracts))
-            .build();
+                .setName(unresolvedTs.getName())
+                .setCapability(ImmutableList.copyOf(capabilities.values()))
+                .setContract(ImmutableList.copyOf(contracts))
+                .build();
         resolvedCns.put(resolved.getName(), resolved);
     }
-    
+
     private static void resolvePnsAttr(Tenant unresolvedTenant,
-                                       EndpointGroup unresolvedEg,
-                                       SelectorName name,
-                                       HashMap<CapabilityName, 
-                                               Capability> capabilities,
-                                       HashSet<ContractId> contracts,
-                                       HashSet<EndpointGroupId> visited) {
-        if (unresolvedEg == null) return;
-        if (visited.contains(unresolvedEg.getId())) return;
+            EndpointGroup unresolvedEg,
+            SelectorName name,
+            HashMap<CapabilityName,
+            Capability> capabilities,
+            HashSet<ContractId> contracts,
+            HashSet<EndpointGroupId> visited) {
+        if (unresolvedEg == null)
+            return;
+        if (visited.contains(unresolvedEg.getId()))
+            return;
         visited.add(unresolvedEg.getId());
         if (unresolvedEg.getParent() != null) {
-            resolvePnsAttr(unresolvedTenant, 
-                           TenantUtils.findEndpointGroup(unresolvedTenant, 
-                                                         unresolvedEg.getParent()),
-                           name, capabilities, contracts, visited);
+            resolvePnsAttr(unresolvedTenant,
+                    TenantUtils.findEndpointGroup(unresolvedTenant,
+                            unresolvedEg.getParent()),
+                    name, capabilities, contracts, visited);
         }
-        resolveLabels(unresolvedEg.getCapability(), capabilities, 
-                      MatcherUtils.getCapabilityName);
+        resolveLabels(unresolvedEg.getCapability(), capabilities,
+                MatcherUtils.getCapabilityName);
         ProviderNamedSelector unresolvedSelector =
                 TenantUtils.findPns(unresolvedEg, name);
-        if (unresolvedSelector == null) return;
+        if (unresolvedSelector == null)
+            return;
         resolveLabels(unresolvedSelector.getCapability(), capabilities,
-                      MatcherUtils.getCapabilityName);
+                MatcherUtils.getCapabilityName);
         if (unresolvedSelector.getContract() != null) {
             contracts.addAll(unresolvedSelector.getContract());
         }
     }
-   
+
     private static void resolveContract(Tenant unresolvedTenant,
-                                        Contract unresolvedContract,
-                                        HashMap<ContractId, 
-                                                Contract> resolvedContracts) {
+            Contract unresolvedContract,
+            HashMap<ContractId,
+            Contract> resolvedContracts) {
         // put the unresolved object into the data structure to avoid loops
         resolvedContracts.put(unresolvedContract.getId(), unresolvedContract);
 
@@ -435,35 +447,35 @@ public class InheritanceUtils {
         if (unresolvedContract.getParent() != null) {
             if (!resolvedContracts.containsKey(unresolvedContract.getParent())) {
                 parent = TenantUtils.findContract(unresolvedTenant,
-                                                  unresolvedContract.getParent());
+                        unresolvedContract.getParent());
                 if (parent != null)
-                    resolveContract(unresolvedTenant, 
-                                    parent, 
-                                    resolvedContracts);
+                    resolveContract(unresolvedTenant,
+                            parent,
+                            resolvedContracts);
             }
             parent = resolvedContracts.get(unresolvedContract.getParent());
         }
-        
+
         HashMap<TargetName, Target> resolvedTargets = new HashMap<>();
         HashMap<ClauseName, Clause> resolvedClauses = new HashMap<>();
         HashMap<SubjectName, Subject> resolvedSubjects = new HashMap<>();
 
         if (unresolvedContract.getTarget() != null) {
             for (Target t : unresolvedContract.getTarget()) {
-                resolveTarget(unresolvedTenant, unresolvedContract, 
-                              t, resolvedTargets);
+                resolveTarget(unresolvedTenant, unresolvedContract,
+                        t, resolvedTargets);
             }
         }
         if (unresolvedContract.getClause() != null) {
             for (Clause c : unresolvedContract.getClause()) {
-                resolveClause(unresolvedTenant, unresolvedContract, 
-                              c, resolvedClauses);
+                resolveClause(unresolvedTenant, unresolvedContract,
+                        c, resolvedClauses);
             }
         }
-        if (unresolvedContract.getSubject() != null ) {
+        if (unresolvedContract.getSubject() != null) {
             for (Subject s : unresolvedContract.getSubject()) {
                 resolveSubject(unresolvedTenant, unresolvedContract,
-                               s, resolvedSubjects);
+                        s, resolvedSubjects);
             }
         }
 
@@ -489,62 +501,65 @@ public class InheritanceUtils {
         }
 
         Contract resolvedContract = new ContractBuilder()
-            .setId(unresolvedContract.getId())
-            .setDescription(unresolvedContract.getDescription())
-            .setTarget(ImmutableList.copyOf(resolvedTargets.values()))
-            .setClause(ImmutableList.copyOf(resolvedClauses.values()))
-            .setSubject(ImmutableList.copyOf(resolvedSubjects.values()))
-            .build();
+                .setId(unresolvedContract.getId())
+                .setDescription(unresolvedContract.getDescription())
+                .setTarget(ImmutableList.copyOf(resolvedTargets.values()))
+                .setClause(ImmutableList.copyOf(resolvedClauses.values()))
+                .setSubject(ImmutableList.copyOf(resolvedSubjects.values()))
+                .build();
         resolvedContracts.put(resolvedContract.getId(), resolvedContract);
     }
-    
+
     private static void resolveTarget(Tenant unresolvedTenant,
-                                      Contract unresolvedContract,
-                                      Target unresolvedTarget,
-                                      HashMap<TargetName, Target> resolvedTargets) {
+            Contract unresolvedContract,
+            Target unresolvedTarget,
+            HashMap<TargetName, Target> resolvedTargets) {
         HashMap<QualityName, Quality> qualities = new HashMap<>();
         HashSet<ContractId> visited = new HashSet<>();
 
-        resolveTargetAttrs(unresolvedTenant, 
-                           unresolvedContract, 
-                           unresolvedTarget.getName(), 
-                           qualities, visited);
+        resolveTargetAttrs(unresolvedTenant,
+                unresolvedContract,
+                unresolvedTarget.getName(),
+                qualities, visited);
 
         Target resolved = new TargetBuilder()
-            .setName(unresolvedTarget.getName())
-            .setQuality(ImmutableList.copyOf(qualities.values()))
-            .build();
+                .setName(unresolvedTarget.getName())
+                .setQuality(ImmutableList.copyOf(qualities.values()))
+                .build();
         resolvedTargets.put(resolved.getName(), resolved);
     }
-    
+
     private static void resolveTargetAttrs(Tenant unresolvedTenant,
-                                           Contract unresolvedContract,
-                                           TargetName targetName,
-                                           HashMap<QualityName, Quality> qualities,
-                                           HashSet<ContractId> visited) {
-        if (unresolvedContract == null) return;
-        if (visited.contains(unresolvedContract.getId())) return;
+            Contract unresolvedContract,
+            TargetName targetName,
+            HashMap<QualityName, Quality> qualities,
+            HashSet<ContractId> visited) {
+        if (unresolvedContract == null)
+            return;
+        if (visited.contains(unresolvedContract.getId()))
+            return;
         visited.add(unresolvedContract.getId());
         if (unresolvedContract.getParent() != null) {
-            resolveTargetAttrs(unresolvedTenant, 
-                               TenantUtils.findContract(unresolvedTenant, 
-                                                        unresolvedContract.getParent()),
-                               targetName, 
-                               qualities, visited);
+            resolveTargetAttrs(unresolvedTenant,
+                    TenantUtils.findContract(unresolvedTenant,
+                            unresolvedContract.getParent()),
+                    targetName,
+                    qualities, visited);
         }
-        resolveLabels(unresolvedContract.getQuality(), qualities, 
-                      MatcherUtils.getQualityName);
-        Target unresolvedTarget = 
+        resolveLabels(unresolvedContract.getQuality(), qualities,
+                MatcherUtils.getQualityName);
+        Target unresolvedTarget =
                 TenantUtils.findTarget(unresolvedContract, targetName);
-        resolveLabels(unresolvedTarget.getQuality(), qualities, 
-                      MatcherUtils.getQualityName);        
+        resolveLabels(unresolvedTarget.getQuality(), qualities,
+                MatcherUtils.getQualityName);
     }
 
-    private static void 
-        resolveQualityMatcher(Collection<QualityMatcher> toResolve,
-                              HashMap<QualityMatcherName,
-                                      QualityMatcher> matchers) {
-        if (toResolve == null) return;
+    private static void
+            resolveQualityMatcher(Collection<QualityMatcher> toResolve,
+                    HashMap<QualityMatcherName,
+                    QualityMatcher> matchers) {
+        if (toResolve == null)
+            return;
         for (QualityMatcher qm : toResolve) {
             if (matchers.containsKey(qm.getName())) {
                 QualityMatcher oqm = matchers.get(qm.getName());
@@ -554,13 +569,13 @@ public class InheritanceUtils {
                 if (qm.getMatchType() != null)
                     qmb.setMatchType(qm.getMatchType());
 
-                HashMap<QualityName, MatcherQuality> qualities = 
+                HashMap<QualityName, MatcherQuality> qualities =
                         new HashMap<>();
-                resolveLabels(oqm.getMatcherQuality(), qualities, 
-                              MatcherUtils.getMatcherQualityName);
-                resolveLabels(qm.getMatcherQuality(), qualities, 
-                              MatcherUtils.getMatcherQualityName);
-                
+                resolveLabels(oqm.getMatcherQuality(), qualities,
+                        MatcherUtils.getMatcherQualityName);
+                resolveLabels(qm.getMatcherQuality(), qualities,
+                        MatcherUtils.getMatcherQualityName);
+
                 qmb.setMatcherQuality(ImmutableList.copyOf(qualities.values()));
                 matchers.put(qm.getName(), qmb.build());
             } else {
@@ -569,11 +584,12 @@ public class InheritanceUtils {
         }
     }
 
-    private static void 
-        resolveCapabilityMatcher(Collection<CapabilityMatcher> toResolve,
-                                 HashMap<CapabilityMatcherName,
-                                         CapabilityMatcher> matchers) {
-        if (toResolve == null) return;
+    private static void
+            resolveCapabilityMatcher(Collection<CapabilityMatcher> toResolve,
+                    HashMap<CapabilityMatcherName,
+                    CapabilityMatcher> matchers) {
+        if (toResolve == null)
+            return;
         for (CapabilityMatcher m : toResolve) {
             if (matchers.containsKey(m.getName())) {
                 CapabilityMatcher om = matchers.get(m.getName());
@@ -583,13 +599,13 @@ public class InheritanceUtils {
                 if (m.getMatchType() != null)
                     mb.setMatchType(m.getMatchType());
 
-                HashMap<CapabilityName, MatcherCapability> labels = 
+                HashMap<CapabilityName, MatcherCapability> labels =
                         new HashMap<>();
-                resolveLabels(om.getMatcherCapability(), labels, 
-                              MatcherUtils.getMatcherCapabilityName);
-                resolveLabels(m.getMatcherCapability(), labels, 
-                              MatcherUtils.getMatcherCapabilityName);
-                
+                resolveLabels(om.getMatcherCapability(), labels,
+                        MatcherUtils.getMatcherCapabilityName);
+                resolveLabels(m.getMatcherCapability(), labels,
+                        MatcherUtils.getMatcherCapabilityName);
+
                 mb.setMatcherCapability(ImmutableList.copyOf(labels.values()));
                 matchers.put(m.getName(), mb.build());
             } else {
@@ -598,11 +614,12 @@ public class InheritanceUtils {
         }
     }
 
-    private static void 
-        resolveRequirementMatcher(Collection<RequirementMatcher> toResolve,
-                                  HashMap<RequirementMatcherName,
-                                          RequirementMatcher> matchers) {
-        if (toResolve == null) return;
+    private static void
+            resolveRequirementMatcher(Collection<RequirementMatcher> toResolve,
+                    HashMap<RequirementMatcherName,
+                    RequirementMatcher> matchers) {
+        if (toResolve == null)
+            return;
         for (RequirementMatcher m : toResolve) {
             if (matchers.containsKey(m.getName())) {
                 RequirementMatcher om = matchers.get(m.getName());
@@ -612,13 +629,13 @@ public class InheritanceUtils {
                 if (m.getMatchType() != null)
                     mb.setMatchType(m.getMatchType());
 
-                HashMap<RequirementName, MatcherRequirement> labels = 
+                HashMap<RequirementName, MatcherRequirement> labels =
                         new HashMap<>();
-                resolveLabels(om.getMatcherRequirement(), labels, 
-                              MatcherUtils.getMatcherRequirementName);
-                resolveLabels(m.getMatcherRequirement(), labels, 
-                              MatcherUtils.getMatcherRequirementName);
-                
+                resolveLabels(om.getMatcherRequirement(), labels,
+                        MatcherUtils.getMatcherRequirementName);
+                resolveLabels(m.getMatcherRequirement(), labels,
+                        MatcherUtils.getMatcherRequirementName);
+
                 mb.setMatcherRequirement(ImmutableList.copyOf(labels.values()));
                 matchers.put(m.getName(), mb.build());
             } else {
@@ -627,11 +644,12 @@ public class InheritanceUtils {
         }
     }
 
-    private static void 
-        resolveConditionMatcher(Collection<ConditionMatcher> toResolve,
-                                 HashMap<ConditionMatcherName,
-                                         ConditionMatcher> matchers) {
-        if (toResolve == null) return;
+    private static void
+            resolveConditionMatcher(Collection<ConditionMatcher> toResolve,
+                    HashMap<ConditionMatcherName,
+                    ConditionMatcher> matchers) {
+        if (toResolve == null)
+            return;
         for (ConditionMatcher m : toResolve) {
             if (matchers.containsKey(m.getName())) {
                 ConditionMatcher om = matchers.get(m.getName());
@@ -641,13 +659,13 @@ public class InheritanceUtils {
                 if (m.getMatchType() != null)
                     mb.setMatchType(m.getMatchType());
 
-                HashMap<ConditionName, Condition> labels = 
+                HashMap<ConditionName, Condition> labels =
                         new HashMap<>();
-                resolveLabels(om.getCondition(), labels, 
-                              MatcherUtils.getConditionName);
-                resolveLabels(m.getCondition(), labels, 
-                              MatcherUtils.getConditionName);
-                
+                resolveLabels(om.getCondition(), labels,
+                        MatcherUtils.getConditionName);
+                resolveLabels(m.getCondition(), labels,
+                        MatcherUtils.getConditionName);
+
                 mb.setCondition(ImmutableList.copyOf(labels.values()));
                 matchers.put(m.getName(), mb.build());
             } else {
@@ -657,9 +675,9 @@ public class InheritanceUtils {
     }
 
     private static void resolveClause(Tenant unresolvedTenant,
-                                      Contract unresolvedContract,
-                                      Clause unresolvedClause,
-                                      HashMap<ClauseName, Clause> resolvedClauses) {
+            Contract unresolvedContract,
+            Clause unresolvedClause,
+            HashMap<ClauseName, Clause> resolvedClauses) {
         HashMap<CapabilityMatcherName, CapabilityMatcher> capMatchers = new HashMap<>();
         HashMap<ConditionMatcherName, ConditionMatcher> provCondMatchers = new HashMap<>();
         HashMap<RequirementMatcherName, RequirementMatcher> reqMatchers = new HashMap<>();
@@ -667,78 +685,87 @@ public class InheritanceUtils {
         HashSet<SubjectName> subjectRefs = new HashSet<>();
         HashSet<ContractId> visited = new HashSet<>();
 
-        //TODO: Add GIC choices GroupNameConstraint and GroupAny
-       //TODO: Add EIC (ie L3Prefix) constraint.
+        // TODO: Add GIC choices GroupNameConstraint and GroupAny
+        // TODO: Add EIC (ie L3Prefix) constraint.
 
-        resolveClauseAttr(unresolvedTenant, unresolvedContract, 
-                          unresolvedClause.getName(), subjectRefs, 
-                          capMatchers, provCondMatchers,
-                          reqMatchers, consCondMatchers, visited);
-        
+        resolveClauseAttr(unresolvedTenant, unresolvedContract,
+                unresolvedClause.getName(), subjectRefs,
+                capMatchers, provCondMatchers,
+                reqMatchers, consCondMatchers, visited);
 
         Clause resolved = new ClauseBuilder()
-            .setName(unresolvedClause.getName())
-            .setSubjectRefs(ImmutableList.copyOf(subjectRefs))
-            .setProviderMatchers(new ProviderMatchersBuilder()
-                .setGroupIdentificationConstraints(new GroupCapabilityConstraintCaseBuilder()
-                .setCapabilityMatcher(ImmutableList.copyOf(capMatchers.values())).build())
-                .setConditionMatcher(ImmutableList.copyOf(provCondMatchers.values()))
-                .build())
-            .setConsumerMatchers(new ConsumerMatchersBuilder()
-                .setGroupIdentificationConstraints(new GroupRequirementConstraintCaseBuilder()
-                .setRequirementMatcher(ImmutableList.copyOf(reqMatchers.values())).build())               
-                .setConditionMatcher(ImmutableList.copyOf(consCondMatchers.values()))
-                .build())
-            .build();
+                .setName(unresolvedClause.getName())
+                .setSubjectRefs(ImmutableList.copyOf(subjectRefs))
+                .setProviderMatchers(new ProviderMatchersBuilder()
+                        .setGroupIdentificationConstraints(new GroupCapabilityConstraintCaseBuilder()
+                                .setCapabilityMatcher(ImmutableList.copyOf(capMatchers.values())).build())
+                        .setConditionMatcher(ImmutableList.copyOf(provCondMatchers.values()))
+                        .build())
+                .setConsumerMatchers(new ConsumerMatchersBuilder()
+                        .setGroupIdentificationConstraints(new GroupRequirementConstraintCaseBuilder()
+                                .setRequirementMatcher(ImmutableList.copyOf(reqMatchers.values())).build())
+                        .setConditionMatcher(ImmutableList.copyOf(consCondMatchers.values()))
+                        .build())
+                .build();
         resolvedClauses.put(resolved.getName(), resolved);
     }
-    
+
     private static void resolveClauseAttr(Tenant unresolvedTenant,
-                                          Contract unresolvedContract,
-                                          ClauseName clauseName,
-                                          HashSet<SubjectName> subjectRefs,
-                                          HashMap<CapabilityMatcherName, 
-                                                  CapabilityMatcher> capMatchers,
-                                          HashMap<ConditionMatcherName, 
-                                                  ConditionMatcher> provCondMatchers,
-                                          HashMap<RequirementMatcherName, 
-                                                  RequirementMatcher> reqMatchers,
-                                          HashMap<ConditionMatcherName, 
-                                                  ConditionMatcher> consCondMatchers,
-                                          HashSet<ContractId> visited) {
-        if (unresolvedContract == null) return;
-        if (visited.contains(unresolvedContract.getId())) return;
+            Contract unresolvedContract,
+            ClauseName clauseName,
+            HashSet<SubjectName> subjectRefs,
+            HashMap<CapabilityMatcherName,
+            CapabilityMatcher> capMatchers,
+            HashMap<ConditionMatcherName,
+            ConditionMatcher> provCondMatchers,
+            HashMap<RequirementMatcherName,
+            RequirementMatcher> reqMatchers,
+            HashMap<ConditionMatcherName,
+            ConditionMatcher> consCondMatchers,
+            HashSet<ContractId> visited) {
+        if (unresolvedContract == null)
+            return;
+        if (visited.contains(unresolvedContract.getId()))
+            return;
         visited.add(unresolvedContract.getId());
         if (unresolvedContract.getParent() != null) {
-            resolveClauseAttr(unresolvedTenant, 
-                              TenantUtils.findContract(unresolvedTenant, 
-                                                       unresolvedContract.getParent()), 
-                              clauseName, 
-                              subjectRefs, 
-                              capMatchers, 
-                              provCondMatchers,
-                              reqMatchers, 
-                              consCondMatchers, visited);
+            resolveClauseAttr(unresolvedTenant,
+                    TenantUtils.findContract(unresolvedTenant,
+                            unresolvedContract.getParent()),
+                    clauseName,
+                    subjectRefs,
+                    capMatchers,
+                    provCondMatchers,
+                    reqMatchers,
+                    consCondMatchers, visited);
         }
-        
+
         Clause unresolvedClause =
                 TenantUtils.findClause(unresolvedContract, clauseName);
-        if (unresolvedClause == null) return;
-        
+        if (unresolvedClause == null)
+            return;
+
         if (unresolvedClause.getProviderMatchers() != null) {
             ProviderMatchers pms = unresolvedClause.getProviderMatchers();
-            org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.contract.clause.provider.matchers.GroupIdentificationConstraints groupIdentificationConstraintsProvider = pms.getGroupIdentificationConstraints();
+            org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.contract.clause.provider.matchers.GroupIdentificationConstraints groupIdentificationConstraintsProvider = pms
+                    .getGroupIdentificationConstraints();
             if (groupIdentificationConstraintsProvider instanceof GroupCapabilityConstraintCase) {
-                resolveCapabilityMatcher(((GroupCapabilityConstraintCase)groupIdentificationConstraintsProvider).getCapabilityMatcher(), capMatchers);
+                resolveCapabilityMatcher(
+                        ((GroupCapabilityConstraintCase) groupIdentificationConstraintsProvider).getCapabilityMatcher(),
+                        capMatchers);
             }
             resolveConditionMatcher(pms.getConditionMatcher(), provCondMatchers);
         }
 
         if (unresolvedClause.getConsumerMatchers() != null) {
             ConsumerMatchers cms = unresolvedClause.getConsumerMatchers();
-            GroupIdentificationConstraints groupIdentificiationConstrainsConsumer = cms.getGroupIdentificationConstraints();
+            GroupIdentificationConstraints groupIdentificiationConstrainsConsumer = cms
+                    .getGroupIdentificationConstraints();
             if (groupIdentificiationConstrainsConsumer instanceof GroupRequirementConstraintCase) {
-                resolveRequirementMatcher(((GroupRequirementConstraintCase) groupIdentificiationConstrainsConsumer).getRequirementMatcher(), reqMatchers);
+                resolveRequirementMatcher(
+                        ((GroupRequirementConstraintCase) groupIdentificiationConstrainsConsumer)
+                                .getRequirementMatcher(),
+                        reqMatchers);
             }
             resolveConditionMatcher(cms.getConditionMatcher(), consCondMatchers);
 
@@ -750,63 +777,66 @@ public class InheritanceUtils {
     private static class Mutable<O> {
         O value;
     }
-    
+
     private static void resolveSubject(Tenant unresolvedTenant,
-                                       Contract unresolvedContract,
-                                       Subject unresolvedSubject,
-                                       HashMap<SubjectName, Subject> resolvedSubjects) {
+            Contract unresolvedContract,
+            Subject unresolvedSubject,
+            HashMap<SubjectName, Subject> resolvedSubjects) {
         Mutable<Integer> order = new Mutable<>();
         Mutable<List<Rule>> rules = new Mutable<>();
         rules.value = Collections.emptyList();
         HashSet<ContractId> visited = new HashSet<>();
-        
-        resolveSubjectAttr(unresolvedTenant, unresolvedContract, 
-                           unresolvedSubject.getName(), order, rules, visited);
-        
+
+        resolveSubjectAttr(unresolvedTenant, unresolvedContract,
+                unresolvedSubject.getName(), order, rules, visited);
+
         Subject resolved = new SubjectBuilder()
-            .setName(unresolvedSubject.getName())
-            .setOrder(order.value)
-            .setRule(rules.value)
-            .build();
+                .setName(unresolvedSubject.getName())
+                .setOrder(order.value)
+                .setRule(rules.value)
+                .build();
         resolvedSubjects.put(resolved.getName(), resolved);
     }
-    
+
     private static Rule makeRule(Rule r, int order) {
         return new RuleBuilder()
-            .setName(r.getName())
-            .setActionRef(r.getActionRef())
-            .setClassifierRef(r.getClassifierRef())
-            .setOrder(order)
-            .build();
+                .setName(r.getName())
+                .setActionRef(r.getActionRef())
+                .setClassifierRef(r.getClassifierRef())
+                .setOrder(order)
+                .build();
     }
-    
+
     private static void resolveSubjectAttr(Tenant unresolvedTenant,
-                                           Contract unresolvedContract,
-                                           SubjectName subjectName,
-                                           Mutable<Integer> order,
-                                           Mutable<List<Rule>> rules,
-                                           HashSet<ContractId> visited) {
-        if (unresolvedContract == null) return;
-        if (visited.contains(unresolvedContract.getId())) return;
+            Contract unresolvedContract,
+            SubjectName subjectName,
+            Mutable<Integer> order,
+            Mutable<List<Rule>> rules,
+            HashSet<ContractId> visited) {
+        if (unresolvedContract == null)
+            return;
+        if (visited.contains(unresolvedContract.getId()))
+            return;
         visited.add(unresolvedContract.getId());
         if (unresolvedContract.getParent() != null) {
-            resolveSubjectAttr(unresolvedTenant, 
-                              TenantUtils.findContract(unresolvedTenant, 
-                                                       unresolvedContract.getParent()), 
-                              subjectName,
-                              order,
-                              rules, visited);
+            resolveSubjectAttr(unresolvedTenant,
+                    TenantUtils.findContract(unresolvedTenant,
+                            unresolvedContract.getParent()),
+                    subjectName,
+                    order,
+                    rules, visited);
         }
-        
-        Subject unresolvedSubject = 
+
+        Subject unresolvedSubject =
                 TenantUtils.findSubject(unresolvedContract, subjectName);
-        if (unresolvedSubject == null) return;
+        if (unresolvedSubject == null)
+            return;
         if (unresolvedSubject.getOrder() != null)
             order.value = unresolvedSubject.getOrder();
         if (unresolvedSubject.getRule() != null) {
-            ImmutableList.Builder<Rule> rbuilder = 
+            ImmutableList.Builder<Rule> rbuilder =
                     new ImmutableList.Builder<Rule>();
-            ArrayList<Rule> nrules = 
+            ArrayList<Rule> nrules =
                     new ArrayList<>(unresolvedSubject.getRule());
             Collections.sort(nrules, TenantUtils.RULE_COMPARATOR);
             int index = 0;
@@ -819,18 +849,23 @@ public class InheritanceUtils {
             rules.value = rbuilder.build();
         }
     }
-    
+
     /**
      * Given a partially-resolved set of labels, add the next item in the
      * inheritance ordering to the set of resolved labels.
-     * @param toResolve the new set to add
-     * @param labels the partially-resolved set
-     * @param getName a function object to get the appropriate typed label name
+     *
+     * @param toResolve
+     *            the new set to add
+     * @param labels
+     *            the partially-resolved set
+     * @param getName
+     *            a function object to get the appropriate typed label name
      */
-    private static <L extends Label, LN extends LabelName> void 
-        resolveLabels(Collection<L> toResolve, HashMap<LN, L> labels, 
-                      GetLabelName<L, LN> getName) {
-        if (toResolve == null) return;
+    private static <L extends Label, LN extends LabelName> void
+            resolveLabels(Collection<L> toResolve, HashMap<LN, L> labels,
+                    GetLabelName<L, LN> getName) {
+        if (toResolve == null)
+            return;
         for (L l : toResolve) {
             if (l.getInclusionRule() != null) {
                 switch (l.getInclusionRule()) {
index 64c50f1372caee516d10072436c6487589d2f0c9..cf5cea330d01b96cd076007c755241cddd1b949d 100644 (file)
@@ -43,21 +43,23 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 
 /**
  * Utilities related to matchers and labels
- * @author readams
  */
 public class MatcherUtils {
     /**
      * Apply a quality matcher to a normalized target
-     * @param matcher the {@link QualityMatcher} to apply
-     * @param target the {@link Target} to match against
+     *
+     * @param matcher
+     *            the {@link QualityMatcher} to apply
+     * @param target
+     *            the {@link Target} to match against
      * @return <code>true</code> if the matcher matches the target
      */
     public static boolean applyQualityMatcher(QualityMatcher matcher,
-                                              Target target) {
-        List<MatcherLabel<QualityName,TargetName>> mls = new ArrayList<>();
+            Target target) {
+        List<MatcherLabel<QualityName, TargetName>> mls = new ArrayList<>();
         if (matcher.getMatcherQuality() != null) {
             for (MatcherQuality ml : matcher.getMatcherQuality()) {
-                mls.add(new MatcherLabel<>(ml.getName(), 
+                mls.add(new MatcherLabel<>(ml.getName(),
                         ml.getTargetNamespace()));
             }
         }
@@ -65,152 +67,162 @@ public class MatcherUtils {
         for (Quality q : target.getQuality()) {
             toMatch.add(q.getName());
         }
-        return applyLabelMatcher(mls, matcher.getMatchType(), 
-                                 toMatch, target.getName());
+        return applyLabelMatcher(mls, matcher.getMatchType(),
+                toMatch, target.getName());
     }
 
     /**
      * Apply a requirement matcher to a normalized consumer selection relator
-     * @param matcher the {@link RequirementMatcher} to apply
-     * @param target the {@link ConsumerSelectionRelator} to match against
+     *
+     * @param matcher
+     *            the {@link RequirementMatcher} to apply
+     * @param target
+     *            the {@link ConsumerSelectionRelator} to match against
      * @return <code>true</code> if the matcher matches the target
      */
     public static boolean applyReqMatcher(RequirementMatcher matcher,
-                                          ConsumerSelectionRelator relator) {
-        List<MatcherLabel<RequirementName,SelectorName>> mls = new ArrayList<>();
+            ConsumerSelectionRelator relator) {
+        List<MatcherLabel<RequirementName, SelectorName>> mls = new ArrayList<>();
         if (matcher.getMatcherRequirement() != null) {
             for (MatcherRequirement ml : matcher.getMatcherRequirement()) {
-                mls.add(new MatcherLabel<>(ml.getName(), 
-                                           ml.getSelectorNamespace()));
+                mls.add(new MatcherLabel<>(ml.getName(),
+                        ml.getSelectorNamespace()));
             }
         }
         Set<RequirementName> toMatch = new HashSet<>();
         for (Requirement q : relator.getRequirement()) {
             toMatch.add(q.getName());
         }
-        return applyLabelMatcher(mls, matcher.getMatchType(), 
-                                 toMatch, relator.getName());
+        return applyLabelMatcher(mls, matcher.getMatchType(),
+                toMatch, relator.getName());
     }
 
     /**
      * Apply a capability matcher to a normalized provider selection relator
-     * @param matcher the {@link RequirementMatcher} to apply
-     * @param target the {@link ProviderSelectionRelator} to match against
+     *
+     * @param matcher
+     *            the {@link RequirementMatcher} to apply
+     * @param target
+     *            the {@link ProviderSelectionRelator} to match against
      * @return <code>true</code> if the matcher matches the target
      */
     public static boolean applyCapMatcher(CapabilityMatcher matcher,
-                                          ProviderSelectionRelator relator) {
-        List<MatcherLabel<CapabilityName,SelectorName>> mls = new ArrayList<>();
-        if (matcher.getMatcherCapability() != null) { 
+            ProviderSelectionRelator relator) {
+        List<MatcherLabel<CapabilityName, SelectorName>> mls = new ArrayList<>();
+        if (matcher.getMatcherCapability() != null) {
             for (MatcherCapability ml : matcher.getMatcherCapability()) {
-                mls.add(new MatcherLabel<>(ml.getName(), 
-                                           ml.getSelectorNamespace()));
+                mls.add(new MatcherLabel<>(ml.getName(),
+                        ml.getSelectorNamespace()));
             }
         }
         Set<CapabilityName> toMatch = new HashSet<>();
         for (Capability q : relator.getCapability()) {
             toMatch.add(q.getName());
         }
-        return applyLabelMatcher(mls, matcher.getMatchType(), 
-                                 toMatch, relator.getName());
+        return applyLabelMatcher(mls, matcher.getMatchType(),
+                toMatch, relator.getName());
     }
-   
+
     /**
      * Functional interface used for generic label methods
+     *
      * @author readams
      *
-     * @param <L> The specific label type
-     * @param <LN> the related label name type
+     * @param <L>
+     *            The specific label type
+     * @param <LN>
+     *            the related label name type
      */
     public interface GetLabelName<L extends Label, LN extends LabelName> {
         /**
          * Get the appropriate typed name for the given label
-         * @param label the label
+         *
+         * @param label
+         *            the label
          * @return the name
          */
         public LN getName(L label);
     }
-    
+
     /**
      * A {@link GetLabelName} for qualities
      */
-    public static final GetLabelName<Quality, QualityName> getQualityName = 
-        new GetLabelName<Quality, QualityName>() {
-        @Override
-        public QualityName getName(Quality label) {
-            return label.getName();
-        }
-    };
-    
+    public static final GetLabelName<Quality, QualityName> getQualityName =
+            new GetLabelName<Quality, QualityName>() {
+                @Override
+                public QualityName getName(Quality label) {
+                    return label.getName();
+                }
+            };
+
     /**
      * A {@link GetLabelName} for matcher qualities
      */
-    public static final GetLabelName<MatcherQuality, QualityName> getMatcherQualityName = 
+    public static final GetLabelName<MatcherQuality, QualityName> getMatcherQualityName =
             new GetLabelName<MatcherQuality, QualityName>() {
-        @Override
-        public QualityName getName(MatcherQuality label) {
-            return label.getName();
-        }
-    };
-    
+                @Override
+                public QualityName getName(MatcherQuality label) {
+                    return label.getName();
+                }
+            };
+
     /**
      * A {@link GetLabelName} for requirements
      */
-    public static final GetLabelName<Requirement, RequirementName> getRequirementName = 
+    public static final GetLabelName<Requirement, RequirementName> getRequirementName =
             new GetLabelName<Requirement, RequirementName>() {
-        @Override
-        public RequirementName getName(Requirement label) {
-            return label.getName();
-        }
-    };
-    
+                @Override
+                public RequirementName getName(Requirement label) {
+                    return label.getName();
+                }
+            };
+
     /**
      * A {@link GetLabelName} for matcher requirements
      */
-    public static final GetLabelName<MatcherRequirement, RequirementName> getMatcherRequirementName = 
+    public static final GetLabelName<MatcherRequirement, RequirementName> getMatcherRequirementName =
             new GetLabelName<MatcherRequirement, RequirementName>() {
-        @Override
-        public RequirementName getName(MatcherRequirement label) {
-            return label.getName();
-        }
-    };
+                @Override
+                public RequirementName getName(MatcherRequirement label) {
+                    return label.getName();
+                }
+            };
 
     /**
      * A {@link GetLabelName} for capabilities
      */
-    public static final GetLabelName<Capability, CapabilityName> getCapabilityName = 
+    public static final GetLabelName<Capability, CapabilityName> getCapabilityName =
             new GetLabelName<Capability, CapabilityName>() {
-        @Override
-        public CapabilityName getName(Capability label) {
-            return label.getName();
-        }
-    };
+                @Override
+                public CapabilityName getName(Capability label) {
+                    return label.getName();
+                }
+            };
 
     /**
      * A {@link GetLabelName} for matcher capabilities
      */
-    public static final GetLabelName<MatcherCapability, CapabilityName> getMatcherCapabilityName = 
+    public static final GetLabelName<MatcherCapability, CapabilityName> getMatcherCapabilityName =
             new GetLabelName<MatcherCapability, CapabilityName>() {
-        @Override
-        public CapabilityName getName(MatcherCapability label) {
-            return label.getName();
-        }
-    };
+                @Override
+                public CapabilityName getName(MatcherCapability label) {
+                    return label.getName();
+                }
+            };
 
     /**
      * A {@link GetLabelName} for capabilities
      */
-    public static final GetLabelName<Condition, ConditionName> getConditionName = 
+    public static final GetLabelName<Condition, ConditionName> getConditionName =
             new GetLabelName<Condition, ConditionName>() {
-        @Override
-        public ConditionName getName(Condition label) {
-            return label.getName();
-        }
-    };
-    
+                @Override
+                public ConditionName getName(Condition label) {
+                    return label.getName();
+                }
+            };
+
     @Immutable
-    private static class MatcherLabel<LN extends LabelName, 
-                                      NS extends RelatorName> {
+    private static class MatcherLabel<LN extends LabelName, NS extends RelatorName> {
         final LN name;
         final NS namespace;
 
@@ -220,26 +232,28 @@ public class MatcherUtils {
             this.namespace = namespace;
         }
     }
-    private static <LN extends LabelName, L extends Label, 
-             NS extends RelatorName, R extends Relator>         
-        boolean applyLabelMatcher(Collection<MatcherLabel<LN, NS>> matcherLabels,
-                                  MatchType matchType,
-                                  Set<LN> toMatch,
-                                  NS matchNamespace) {
+
+    private static <LN extends LabelName, L extends Label,
+            NS extends RelatorName, R extends Relator>
+            boolean applyLabelMatcher(Collection<MatcherLabel<LN, NS>> matcherLabels,
+                    MatchType matchType,
+                    Set<LN> toMatch,
+                    NS matchNamespace) {
         int matches = 0;
         int matchersize = 0;
         if (matcherLabels != null) {
             matchersize = matcherLabels.size();
             for (MatcherLabel<LN, NS> matcherLabel : matcherLabels) {
-                if (matcherLabel.namespace != null && 
-                    !matcherLabel.namespace.equals(matchNamespace))
+                if (matcherLabel.namespace != null &&
+                        !matcherLabel.namespace.equals(matchNamespace))
                     continue;
                 if (!toMatch.contains(matcherLabel.name))
                     continue;
                 matches += 1;
             }
         }
-        if (matchType == null) matchType = MatchType.All;
+        if (matchType == null)
+            matchType = MatchType.All;
         switch (matchType) {
         case Any:
             return matches > 0;
index 4b2e0f7110143e2ead890c2e98cb56b2872c70ed..1c3aca97c920737d3477ad3079ad89e6b727b650 100644 (file)
@@ -83,22 +83,24 @@ import com.google.common.util.concurrent.ListenableFuture;
  * The policy resolver is a utility for renderers to help in resolving
  * group-based policy into a form that is easier to apply to the actual network.
  *
- * <p>For any pair of endpoint groups, there is a set of rules that could apply
- * to the endpoints on that group based on the policy configuration.  The exact
- * list of rules that apply to a given pair of endpoints depends on the
- * conditions that are active on the endpoints.
+ * <p>
+ * For any pair of endpoint groups, there is a set of rules that could apply to
+ * the endpoints on that group based on the policy configuration. The exact list
+ * of rules that apply to a given pair of endpoints depends on the conditions
+ * that are active on the endpoints.
  *
- * <p>We need to be able to query against this policy model, enumerate the
- * relevant classes of traffic and endpoints, and notify renderers when there
- * are changes to policy as it applies to active sets of endpoints and
- * endpoint groups.
+ * <p>
+ * We need to be able to query against this policy model, enumerate the relevant
+ * classes of traffic and endpoints, and notify renderers when there are changes
+ * to policy as it applies to active sets of endpoints and endpoint groups.
  *
- * <p>The policy resolver will maintain the necessary state for all tenants
- * in its control domain, which is the set of tenants for which
- * policy listeners have been registered.
+ * <p>
+ * The policy resolver will maintain the necessary state for all tenants in its
+ * control domain, which is the set of tenants for which policy listeners have
+ * been registered.
  *
- * @author readams
  */
+
 public class PolicyResolver implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(PolicyResolver.class);
 
@@ -106,22 +108,21 @@ public class PolicyResolver implements AutoCloseable {
     private final ScheduledExecutorService executor;
 
     /**
-     *  Keep track of the current relevant policy scopes.
+     * Keep track of the current relevant policy scopes.
      */
     protected CopyOnWriteArrayList<PolicyScope> policyListenerScopes;
 
     protected ConcurrentMap<TenantId, TenantContext> resolvedTenants;
 
     /**
-     * Store a policy object for each endpoint group pair.  The table
-     * is stored with the key as (consumer, provider).  Two endpoints could
-     * appear in both roles at the same time, in which case both policies would
-     * apply.
+     * Store a policy object for each endpoint group pair. The table is stored
+     * with the key as (consumer, provider). Two endpoints could appear in both
+     * roles at the same time, in which case both policies would apply.
      */
     AtomicReference<PolicyInfo> policy = new AtomicReference<>();
 
     public PolicyResolver(DataBroker dataProvider,
-                          ScheduledExecutorService executor) {
+            ScheduledExecutorService executor) {
         super();
         this.dataProvider = dataProvider;
         this.executor = executor;
@@ -148,8 +149,9 @@ public class PolicyResolver implements AutoCloseable {
 
     /**
      * Get a snapshot of the current policy
-     * @return the {@link PolicyInfo} object representing an immutable
-     * snapshot of the policy state
+     *
+     * @return the {@link PolicyInfo} object representing an immutable snapshot
+     *         of the policy state
      */
     public PolicyInfo getCurrentPolicy() {
         return policy.get();
@@ -157,19 +159,23 @@ public class PolicyResolver implements AutoCloseable {
 
     /**
      * Get the normalized tenant for the given ID
-     * @param tenant the tenant ID
+     *
+     * @param tenant
+     *            the tenant ID
      * @return the {@link Tenant}
      */
     public IndexedTenant getTenant(TenantId tenant) {
         TenantContext tc = resolvedTenants.get(tenant);
-        if (tc == null) return null;
+        if (tc == null)
+            return null;
         return tc.tenant.get();
     }
 
     /**
      * Register a listener to receive update events.
-     * @param listener the {@link PolicyListener} object to receive the update
-     * events
+     *
+     * @param listener
+     *            the {@link PolicyListener} object to receive the update events
      */
     public PolicyScope registerListener(PolicyListener listener) {
         PolicyScope ps = new PolicyScope(this, listener);
@@ -180,7 +186,9 @@ public class PolicyResolver implements AutoCloseable {
 
     /**
      * Remove the listener registered for the given {@link PolicyScope}.
-     * @param scope the scope to remove
+     *
+     * @param scope
+     *            the scope to remove
      * @see PolicyResolver#registerListener(PolicyListener)
      */
     public void removeListener(PolicyScope scope) {
@@ -192,26 +200,29 @@ public class PolicyResolver implements AutoCloseable {
     // **************
 
     /**
-     * Atomically update the active policy and notify policy listeners 
-     * of relevant changes
-     * @param policyMap the new policy to set
-     * @param egConditions the map of endpoint groups to relevant condition sets
+     * Atomically update the active policy and notify policy listeners of
+     * relevant changes
+     *
+     * @param policyMap
+     *            the new policy to set
+     * @param egConditions
+     *            the map of endpoint groups to relevant condition sets
      * @return the set of groups with updated policy
      */
     protected Set<EgKey> updatePolicy(Table<EgKey, EgKey, Policy> policyMap,
-                                      Map<EgKey, Set<ConditionSet>> egConditions,
-                                      List<PolicyScope> policyListenerScopes) {
+            Map<EgKey, Set<ConditionSet>> egConditions,
+            List<PolicyScope> policyListenerScopes) {
         PolicyInfo newPolicy = new PolicyInfo(policyMap, egConditions);
         PolicyInfo oldPolicy = policy.getAndSet(newPolicy);
-        
-        HashSet<EgKey> notifySet = new HashSet<>(); 
-        
+
+        HashSet<EgKey> notifySet = new HashSet<>();
+
         for (Cell<EgKey, EgKey, Policy> cell : newPolicy.getPolicyMap().cellSet()) {
             Policy newp = cell.getValue();
             Policy oldp = null;
             if (oldPolicy != null)
                 oldp = oldPolicy.getPolicyMap().get(cell.getRowKey(),
-                                                    cell.getColumnKey());
+                        cell.getColumnKey());
             if (oldp == null || !newp.equals(oldp)) {
                 notifySet.add(cell.getRowKey());
                 notifySet.add(cell.getColumnKey());
@@ -220,7 +231,7 @@ public class PolicyResolver implements AutoCloseable {
         if (oldPolicy != null) {
             for (Cell<EgKey, EgKey, Policy> cell : oldPolicy.getPolicyMap().cellSet()) {
                 if (!newPolicy.getPolicyMap().contains(cell.getRowKey(),
-                                                       cell.getColumnKey())) {
+                        cell.getColumnKey())) {
                     notifySet.add(cell.getRowKey());
                     notifySet.add(cell.getColumnKey());
                 }
@@ -228,7 +239,7 @@ public class PolicyResolver implements AutoCloseable {
         }
         return notifySet;
     }
-    
+
     /**
      * Notify the policy listeners about a set of updated groups
      */
@@ -239,7 +250,7 @@ public class PolicyResolver implements AutoCloseable {
                         @Override
                         public boolean apply(EgKey input) {
                             return scope.contains(input.getTenantId(),
-                                                  input.getEgId());
+                                    input.getEgId());
                         }
                     });
             if (!filtered.isEmpty()) {
@@ -249,9 +260,11 @@ public class PolicyResolver implements AutoCloseable {
     }
 
     /**
-     * Subscribe the resolver to updates related to a particular tenant
-     * Make sure that this can't be called concurrently with subscribe
-     * @param tenantId the tenant ID to subscribe to
+     * Subscribe the resolver to updates related to a particular tenant Make
+     * sure that this can't be called concurrently with subscribe
+     *
+     * @param tenantId
+     *            the tenant ID to subscribe to
      */
     protected void subscribeTenant(TenantId tenantId) {
         if (!resolvedTenants.containsKey(tenantId))
@@ -259,9 +272,11 @@ public class PolicyResolver implements AutoCloseable {
     }
 
     /**
-     * Unsubscribe the resolver from updates related to a particular tenant
-     * Make sure that this can't be called concurrently with subscribe
-     * @param tenantId the tenant ID to subscribe to
+     * Unsubscribe the resolver from updates related to a particular tenant Make
+     * sure that this can't be called concurrently with subscribe
+     *
+     * @param tenantId
+     *            the tenant ID to subscribe to
      */
     protected void unsubscribeTenant(TenantId tenantId) {
         TenantContext context = resolvedTenants.get(tenantId);
@@ -272,16 +287,17 @@ public class PolicyResolver implements AutoCloseable {
     }
 
     private void updateTenant(final TenantId tenantId) {
-        if (dataProvider == null) return;
+        if (dataProvider == null)
+            return;
 
         TenantContext context = resolvedTenants.get(tenantId);
         if (context == null) {
             ListenerRegistration<DataChangeListener> registration = null;
             registration = dataProvider
                     .registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
-                                                TenantUtils.tenantIid(tenantId),
-                                                new PolicyChangeListener(tenantId),
-                                                DataChangeScope.SUBTREE);
+                            TenantUtils.tenantIid(tenantId),
+                            new PolicyChangeListener(tenantId),
+                            DataChangeScope.SUBTREE);
 
             context = new TenantContext(registration);
             TenantContext oldContext =
@@ -313,10 +329,10 @@ public class PolicyResolver implements AutoCloseable {
                     LOG.warn("Tenant {} not found", tenantId);
                 }
 
-                Tenant t = InheritanceUtils.resolveTenant((Tenant)result.get());
+                Tenant t = InheritanceUtils.resolveTenant(result.get());
                 IndexedTenant it = new IndexedTenant(t);
                 if (!tenantRef.compareAndSet(ot, it)) {
-                    // concurrent update of tenant policy.  Retry
+                    // concurrent update of tenant policy. Retry
                     updateTenant(tenantId);
                 } else {
                     // Update the policy cache and notify listeners
@@ -337,82 +353,83 @@ public class PolicyResolver implements AutoCloseable {
     protected void updatePolicy() {
         try {
             Map<EgKey, Set<ConditionSet>> egConditions = new HashMap<>();
-            Table<EgKey, EgKey, Policy> policyMap = 
-                    resolvePolicy(resolvedTenants.values(), 
-                                  egConditions);
+            Table<EgKey, EgKey, Policy> policyMap =
+                    resolvePolicy(resolvedTenants.values(),
+                            egConditions);
             Set<EgKey> updatedGroups =
                     updatePolicy(policyMap,
-                                 egConditions, 
-                                 policyListenerScopes);
+                            egConditions,
+                            policyListenerScopes);
 
             notifyListeners(updatedGroups);
         } catch (Exception e) {
             LOG.error("Failed to update policy", e);
         }
     }
-    
+
     /**
-     * Resolve the policy in three phases:
-     * (1) select contracts that in scope based on contract selectors.
-     * (2) select subjects that are in scope for each contract based on
-     * matchers in clauses
-     * (3) resolve the set of in-scope contracts into a list of subjects that
-     * apply for each pair of endpoint groups and the conditions that can
-     * apply for for each endpoint in those groups.
+     * Resolve the policy in three phases: (1) select contracts that in scope
+     * based on contract selectors. (2) select subjects that are in scope for
+     * each contract based on matchers in clauses (3) resolve the set of
+     * in-scope contracts into a list of subjects that apply for each pair of
+     * endpoint groups and the conditions that can apply for for each endpoint
+     * in those groups.
      */
-    protected Table<EgKey, EgKey, Policy> 
+    protected Table<EgKey, EgKey, Policy>
             resolvePolicy(Collection<TenantContext> tenants,
-                          Map<EgKey, Set<ConditionSet>> egConditions) {
+                    Map<EgKey, Set<ConditionSet>> egConditions) {
         // select contracts that apply for the given tenant
         Table<EgKey, EgKey, List<ContractMatch>> contractMatches =
                 selectContracts(tenants);
 
         // select subjects for the matching contracts and resolve the policy
-        // for endpoint group pairs.  This does phase (2) and (3) as one step
+        // for endpoint group pairs. This does phase (2) and (3) as one step
         return selectSubjects(contractMatches, egConditions);
     }
 
     /**
-     * Choose the contracts that are in scope for each pair of endpoint
-     * groups, then perform subject selection for the pair
+     * Choose the contracts that are in scope for each pair of endpoint groups,
+     * then perform subject selection for the pair
      */
     protected Table<EgKey, EgKey, List<ContractMatch>>
-        selectContracts(Collection<TenantContext> tenants) {
-        Table<TenantId, ContractId, 
-              List<ConsumerContractMatch>> consumerMatches =
+            selectContracts(Collection<TenantContext> tenants) {
+        Table<TenantId, ContractId, List<ConsumerContractMatch>> consumerMatches =
                 HashBasedTable.create();
         Table<EgKey, EgKey, List<ContractMatch>> contractMatches =
                 HashBasedTable.create();
 
         for (TenantContext tenant : tenants) {
             IndexedTenant t = tenant.tenant.get();
-            if (t == null) continue;
-            selectContracts(consumerMatches, 
-                            contractMatches, 
-                            t.getTenant());
+            if (t == null)
+                continue;
+            selectContracts(consumerMatches,
+                    contractMatches,
+                    t.getTenant());
         }
         return contractMatches;
     }
-    protected void selectContracts(Table<TenantId, 
-                                         ContractId, 
-                                         List<ConsumerContractMatch>> consumerMatches,
-                                   Table<EgKey, EgKey, 
-                                         List<ContractMatch>> contractMatches,
-                                   Tenant tenant) {
+
+    protected void selectContracts(Table<TenantId,
+            ContractId,
+            List<ConsumerContractMatch>> consumerMatches,
+            Table<EgKey, EgKey,
+            List<ContractMatch>> contractMatches,
+            Tenant tenant) {
         // For each endpoint group, match consumer selectors
         // against contracts to get a set of matching consumer selectors
-        if (tenant.getEndpointGroup() == null) return;
+        if (tenant.getEndpointGroup() == null)
+            return;
         for (EndpointGroup group : tenant.getEndpointGroup()) {
             List<ConsumerContractMatch> r =
                     matchConsumerContracts(tenant, group);
             for (ConsumerContractMatch ccm : r) {
                 List<ConsumerContractMatch> cms =
                         consumerMatches.get(tenant.getId(),
-                                            ccm.contract.getId());
+                                ccm.contract.getId());
                 if (cms == null) {
                     cms = new ArrayList<>();
                     consumerMatches.put(tenant.getId(),
-                                        ccm.contract.getId(), cms);
+                            ccm.contract.getId(), cms);
                 }
                 cms.add(ccm);
             }
@@ -425,15 +442,15 @@ public class PolicyResolver implements AutoCloseable {
                     matchProviderContracts(tenant, group, consumerMatches);
             for (ContractMatch cm : matches) {
                 EgKey consumerKey = new EgKey(cm.consumerTenant.getId(),
-                                              cm.consumer.getId());
+                        cm.consumer.getId());
                 EgKey providerKey = new EgKey(cm.providerTenant.getId(),
-                                              cm.provider.getId());
+                        cm.provider.getId());
                 List<ContractMatch> egPairMatches =
                         contractMatches.get(consumerKey, providerKey);
                 if (egPairMatches == null) {
                     egPairMatches = new ArrayList<>();
                     contractMatches.put(consumerKey, providerKey,
-                                        egPairMatches);
+                            egPairMatches);
                 }
 
                 egPairMatches.add(cm);
@@ -479,7 +496,8 @@ public class PolicyResolver implements AutoCloseable {
     }
 
     private ConditionSet buildConditionSet(List<ConditionMatcher> condMatchers) {
-        if (condMatchers == null) return ConditionSet.EMPTY;
+        if (condMatchers == null)
+            return ConditionSet.EMPTY;
 
         ImmutableSet.Builder<ConditionName> allb = ImmutableSet.builder();
         ImmutableSet.Builder<ConditionName> noneb = ImmutableSet.builder();
@@ -489,7 +507,8 @@ public class PolicyResolver implements AutoCloseable {
             if (condMatcher.getCondition() == null)
                 continue;
             MatchType type = condMatcher.getMatchType();
-            if (type == null) type = MatchType.All;
+            if (type == null)
+                type = MatchType.All;
             if (type.equals(MatchType.Any)) {
                 ImmutableSet.Builder<ConditionName> a =
                         ImmutableSet.builder();
@@ -535,18 +554,17 @@ public class PolicyResolver implements AutoCloseable {
     }
 
     private Policy resolvePolicy(Tenant contractTenant,
-                                 Contract contract,
-                                 boolean reverse,
-                                 Policy merge,
-                                 Table<ConditionSet, ConditionSet,
-                                       List<Subject>> subjectMap) {
+            Contract contract,
+            boolean reverse,
+            Policy merge,
+            Table<ConditionSet, ConditionSet,
+            List<Subject>> subjectMap) {
         Table<ConditionSet, ConditionSet, List<RuleGroup>> ruleMap =
                 HashBasedTable.create();
         if (merge != null) {
             ruleMap.putAll(merge.ruleMap);
         }
-        for (Cell<ConditionSet, ConditionSet, List<Subject>> entry :
-                subjectMap.cellSet()) {
+        for (Cell<ConditionSet, ConditionSet, List<Subject>> entry : subjectMap.cellSet()) {
             List<RuleGroup> rules = new ArrayList<>();
             ConditionSet rowKey = entry.getRowKey();
             ConditionSet columnKey = entry.getColumnKey();
@@ -560,7 +578,8 @@ public class PolicyResolver implements AutoCloseable {
                 rules.addAll(oldrules);
             }
             for (Subject s : entry.getValue()) {
-                if (s.getRule() == null) continue;
+                if (s.getRule() == null)
+                    continue;
                 List<Rule> srules;
                 if (reverse)
                     srules = reverseRules(s.getRule());
@@ -570,22 +589,22 @@ public class PolicyResolver implements AutoCloseable {
                             .immutableSortedCopy(s.getRule());
 
                 RuleGroup rg = new RuleGroup(srules, s.getOrder(),
-                                             contractTenant, contract,
-                                             s.getName());
+                        contractTenant, contract,
+                        s.getName());
                 rules.add(rg);
             }
             Collections.sort(rules);
             ruleMap.put(rowKey, columnKey,
-                        Collections.unmodifiableList(rules));
+                    Collections.unmodifiableList(rules));
         }
         return new Policy(ruleMap);
     }
-    
+
     private List<Rule> reverseRules(List<Rule> rules) {
         ArrayList<Rule> nrules = new ArrayList<>();
         for (Rule input : rules) {
             if (input.getClassifierRef() == null ||
-                input.getClassifierRef().size() == 0) {
+                    input.getClassifierRef().size() == 0) {
                 nrules.add(input);
                 continue;
             }
@@ -607,21 +626,24 @@ public class PolicyResolver implements AutoCloseable {
                     }
                 }
                 classifiers.add(new ClassifierRefBuilder(clr)
-                    .setDirection(nd).build());
+                        .setDirection(nd).build());
             }
             nrules.add(new RuleBuilder(input)
-                .setClassifierRef(Collections.unmodifiableList(classifiers))
-                .build());
+                    .setClassifierRef(Collections.unmodifiableList(classifiers))
+                    .build());
         }
         Collections.sort(nrules, TenantUtils.RULE_COMPARATOR);
         return Collections.unmodifiableList(nrules);
     }
 
     /**
-     * Get the "natural" direction for the policy for the given pair of 
-     * endpoint groups.
-     * @param one The first endpoint group
-     * @param two The second endpoint group
+     * Get the "natural" direction for the policy for the given pair of endpoint
+     * groups.
+     *
+     * @param one
+     *            The first endpoint group
+     * @param two
+     *            The second endpoint group
      * @return true if the order should be reversed in the index
      */
     protected static boolean shouldReverse(EgKey one, EgKey two) {
@@ -630,43 +652,46 @@ public class PolicyResolver implements AutoCloseable {
         }
         return false;
     }
-    
-    private void addConditionSet(EgKey eg, ConditionSet cs, 
-                                 Map<EgKey, Set<ConditionSet>> egConditions) {
-        if (egConditions == null) return;
+
+    private void addConditionSet(EgKey eg, ConditionSet cs,
+            Map<EgKey, Set<ConditionSet>> egConditions) {
+        if (egConditions == null)
+            return;
         Set<ConditionSet> cset = egConditions.get(eg);
         if (cset == null) {
             egConditions.put(eg, cset = new HashSet<>());
         }
         cset.add(cs);
     }
-    
+
     /**
      * Choose the set of subjects that in scope for each possible set of
      * endpoint conditions
      */
     protected Table<EgKey, EgKey, Policy>
             selectSubjects(Table<EgKey, EgKey,
-                                 List<ContractMatch>> contractMatches,
-                           Map<EgKey, Set<ConditionSet>> egConditions) {
+                    List<ContractMatch>> contractMatches,
+                    Map<EgKey, Set<ConditionSet>> egConditions) {
         // Note that it's possible to further simplify the resulting policy
         // in the case of things like repeated rules, condition sets that
-        // cover other condition sets, etc.  This would be a good thing to do
+        // cover other condition sets, etc. This would be a good thing to do
         // at some point
         Table<EgKey, EgKey, Policy> policy = HashBasedTable.create();
 
         for (List<ContractMatch> matches : contractMatches.values()) {
             for (ContractMatch match : matches) {
                 List<Clause> clauses = match.contract.getClause();
-                if (clauses == null) continue;
+                if (clauses == null)
+                    continue;
 
                 List<Subject> subjectList = match.contract.getSubject();
-                if (subjectList == null) continue;
+                if (subjectList == null)
+                    continue;
 
                 EgKey ckey = new EgKey(match.consumerTenant.getId(),
-                                       match.consumer.getId());
+                        match.consumer.getId());
                 EgKey pkey = new EgKey(match.providerTenant.getId(),
-                                       match.provider.getId());
+                        match.provider.getId());
                 EgKey one = ckey;
                 EgKey two = pkey;
                 boolean reverse = shouldReverse(ckey, pkey);
@@ -686,7 +711,7 @@ public class PolicyResolver implements AutoCloseable {
 
                 for (Clause clause : clauses) {
                     if (clause.getSubjectRefs() != null &&
-                        clauseMatches(clause, match)) {
+                            clauseMatches(clause, match)) {
                         ConditionSet consCSet = buildConsConditionSet(clause);
                         addConditionSet(ckey, consCSet, egConditions);
                         ConditionSet provCSet = buildProvConditionSet(clause);
@@ -699,17 +724,18 @@ public class PolicyResolver implements AutoCloseable {
                         }
                         for (SubjectName sn : clause.getSubjectRefs()) {
                             Subject s = subjects.get(sn);
-                            if (s != null) clauseSubjects.add(s);
+                            if (s != null)
+                                clauseSubjects.add(s);
                         }
                     }
                 }
 
                 policy.put(one, two,
-                           resolvePolicy(match.contractTenant,
-                                         match.contract,
-                                         reverse,
-                                         existing,
-                                         subjectMap));
+                        resolvePolicy(match.contractTenant,
+                                match.contract,
+                                reverse,
+                                existing,
+                                subjectMap));
             }
         }
 
@@ -717,26 +743,30 @@ public class PolicyResolver implements AutoCloseable {
     }
 
     private List<ConsumerContractMatch> matchConsumerContracts(Tenant tenant,
-                                                               EndpointGroup consumer) {
+            EndpointGroup consumer) {
         List<ConsumerContractMatch> matches = new ArrayList<>();
         if (consumer.getConsumerNamedSelector() != null) {
             for (ConsumerNamedSelector cns : consumer.getConsumerNamedSelector()) {
-                if (cns.getContract() == null) continue;
+                if (cns.getContract() == null)
+                    continue;
                 for (ContractId contractId : cns.getContract()) {
                     Contract contract =
                             TenantUtils.findContract(tenant, contractId);
-                    if (contract == null) continue;
+                    if (contract == null)
+                        continue;
                     matches.add(new ConsumerContractMatch(tenant, contract,
-                                                          tenant, consumer,
-                                                          cns));
+                            tenant, consumer,
+                            cns));
                 }
             }
         }
         if (consumer.getConsumerTargetSelector() != null) {
             for (ConsumerTargetSelector cts : consumer.getConsumerTargetSelector()) {
-                if (tenant.getContract() == null) continue;
+                if (tenant.getContract() == null)
+                    continue;
                 for (Contract contract : tenant.getContract()) {
-                    if (contract.getTarget() == null) continue;
+                    if (contract.getTarget() == null)
+                        continue;
                     for (Target t : contract.getTarget()) {
                         boolean match = true;
                         if (cts.getQualityMatcher() != null) {
@@ -749,47 +779,51 @@ public class PolicyResolver implements AutoCloseable {
                         }
                         if (match) {
                             matches.add(new ConsumerContractMatch(tenant,
-                                                                  contract,
-                                                                  tenant,
-                                                                  consumer,
-                                                                  cts));
+                                    contract,
+                                    tenant,
+                                    consumer,
+                                    cts));
                         }
                     }
                 }
             }
         }
         // TODO match selectors also against contract references
-//        for (ConsumerTargetSelector cts : consumer.getConsumerTargetSelector()) {
-//            if (tenant.getContractRef() == null) continue;
-//            for (ContractRef c : tenant.getContractRef()) {
-//
-//            }
-//        }
+        // for (ConsumerTargetSelector cts :
+        // consumer.getConsumerTargetSelector()) {
+        // if (tenant.getContractRef() == null) continue;
+        // for (ContractRef c : tenant.getContractRef()) {
+        //
+        // }
+        // }
         return matches;
     }
 
     private void amendContractMatches(List<ContractMatch> matches,
-                                      List<ConsumerContractMatch> cMatches,
-                                      Tenant tenant, EndpointGroup provider,
-                                      ProviderSelectionRelator relator) {
-        if (cMatches == null) return;
+            List<ConsumerContractMatch> cMatches,
+            Tenant tenant, EndpointGroup provider,
+            ProviderSelectionRelator relator) {
+        if (cMatches == null)
+            return;
         for (ConsumerContractMatch cMatch : cMatches) {
             matches.add(new ContractMatch(cMatch, tenant, provider, relator));
         }
     }
 
     private List<ContractMatch>
-        matchProviderContracts(Tenant tenant, EndpointGroup provider,
-                               Table<TenantId,
-                                     ContractId,
-                                     List<ConsumerContractMatch>> consumerMatches) {
+            matchProviderContracts(Tenant tenant, EndpointGroup provider,
+                    Table<TenantId,
+                    ContractId,
+                    List<ConsumerContractMatch>> consumerMatches) {
         List<ContractMatch> matches = new ArrayList<>();
         if (provider.getProviderNamedSelector() != null) {
             for (ProviderNamedSelector pns : provider.getProviderNamedSelector()) {
-                if (pns.getContract() == null) continue;
+                if (pns.getContract() == null)
+                    continue;
                 for (ContractId contractId : pns.getContract()) {
                     Contract c = TenantUtils.findContract(tenant, contractId);
-                    if (c == null) continue;
+                    if (c == null)
+                        continue;
                     List<ConsumerContractMatch> cMatches =
                             consumerMatches.get(tenant.getId(), c.getId());
                     amendContractMatches(matches, cMatches, tenant, provider, pns);
@@ -798,9 +832,11 @@ public class PolicyResolver implements AutoCloseable {
         }
         if (provider.getProviderTargetSelector() != null) {
             for (ProviderTargetSelector pts : provider.getProviderTargetSelector()) {
-                if (tenant.getContract() == null) continue;
+                if (tenant.getContract() == null)
+                    continue;
                 for (Contract c : tenant.getContract()) {
-                    if (c.getTarget() == null) continue;
+                    if (c.getTarget() == null)
+                        continue;
                     for (Target t : c.getTarget()) {
                         boolean match = true;
                         if (pts.getQualityMatcher() != null) {
@@ -814,9 +850,9 @@ public class PolicyResolver implements AutoCloseable {
                         if (match) {
                             List<ConsumerContractMatch> cMatches =
                                     consumerMatches.get(tenant.getId(),
-                                                        c.getId());
+                                            c.getId());
                             amendContractMatches(matches, cMatches, tenant,
-                                                 provider, pts);
+                                    provider, pts);
 
                         }
                     }
@@ -838,9 +874,9 @@ public class PolicyResolver implements AutoCloseable {
     }
 
     /**
-     * Represents a selected contract made by endpoint groups matching it
-     * using selection relators.  This is the result of the contract selection
-     * phase.
+     * Represents a selected contract made by endpoint groups matching it using
+     * selection relators. This is the result of the contract selection phase.
+     *
      * @author readams
      *
      */
@@ -862,13 +898,13 @@ public class PolicyResolver implements AutoCloseable {
         final ProviderSelectionRelator providerRelator;
 
         public ContractMatch(ConsumerContractMatch consumerMatch,
-                             Tenant providerTenant, EndpointGroup provider,
-                             ProviderSelectionRelator providerRelator) {
+                Tenant providerTenant, EndpointGroup provider,
+                ProviderSelectionRelator providerRelator) {
             super(consumerMatch.contractTenant,
-                  consumerMatch.contract,
-                  consumerMatch.consumerTenant,
-                  consumerMatch.consumer,
-                  consumerMatch.consumerRelator);
+                    consumerMatch.contract,
+                    consumerMatch.consumerTenant,
+                    consumerMatch.consumer,
+                    consumerMatch.consumerRelator);
             this.providerTenant = providerTenant;
             this.provider = provider;
             this.providerRelator = providerRelator;
@@ -902,12 +938,11 @@ public class PolicyResolver implements AutoCloseable {
          */
         final ConsumerSelectionRelator consumerRelator;
 
-
         public ConsumerContractMatch(Tenant contractTenant,
-                                     Contract contract,
-                                     Tenant consumerTenant,
-                                     EndpointGroup consumer,
-                                     ConsumerSelectionRelator consumerRelator) {
+                Contract contract,
+                Tenant consumerTenant,
+                EndpointGroup consumer,
+                ConsumerSelectionRelator consumerRelator) {
             super();
             this.contractTenant = contractTenant;
             this.contract = contract;
index 474ee33013e615b904049a3e6f16d98749bbed5a..6149142e48aa1b10f613653434380ae9b0470c67 100644 (file)
@@ -12,7 +12,7 @@ module gbp-common {
     namespace "urn:opendaylight:groupbasedpolicy:common";
     prefix "gbp-common";
 
-    description 
+    description
         "Common types and definitions for group-based policy models";
 
     revision "2014-04-21" {
@@ -31,8 +31,8 @@ module gbp-common {
     }
 
     typedef name {
-        description 
-            "A generic string name type. 
+        description
+            "A generic string name type.
              Must start with a letter";
         type string {
             pattern '[a-zA-Z]([a-zA-Z0-9\-_.])*';
@@ -47,7 +47,7 @@ module gbp-common {
                 + '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
         }
         description
-            "A Universally Unique IDentifier in the string representation 
+            "A Universally Unique IDentifier in the string representation
              defined in RFC 4122.  The canonical representation uses
              lowercase characters.
 
@@ -90,7 +90,7 @@ module gbp-common {
         type unique-id;
         description "A unique ID for a network domain";
     }
-    
+
     typedef subnet-id {
         type network-domain-id;
         description "A unique ID for a subnet";
index 20c2172faad33d3e5e11e9ab2fac816c07dd25ae..42ff57d5c5079eb965d9d0883bff3b9f84db8308 100644 (file)
@@ -14,7 +14,7 @@ module endpoint-provider {
      import config { prefix config; revision-date 2013-04-05; }
 
      description
-         "This module contains the base YANG definitions for 
+         "This module contains the base YANG definitions for
           endpoint-provider services.";
 
      revision "2014-04-21" {
index e4bae7280864c3b6286f3361aa427882b2d07c1c..7e8372f1cc89ed703d1da122b15e6811188e2deb 100644 (file)
@@ -17,7 +17,7 @@ module endpoint {
     import ietf-yang-types {
         prefix yang;
         revision-date 2010-09-24;
-    } 
+    }
 
     revision "2014-04-21" {
         description
@@ -25,50 +25,50 @@ module endpoint {
     }
 
     grouping l2-key {
-        description 
+        description
             "The fields that identify an endpoint by a layer 2 address";
         leaf l2-context {
             type gbp-common:l2-bridge-domain-id;
-            description 
+            description
                 "The bridge domain for the layer 2 address for this endpoint";
         }
         leaf mac-address {
             type yang:mac-address;
-            description 
+            description
                 "The MAC address for the endpoint";
         }
     }
 
     grouping l3-key {
-        description 
+        description
             "The fields that identify an endpoint by a layer 3 address";
         leaf l3-context {
             type gbp-common:l3-context-id;
             mandatory true;
-            description 
+            description
                 "The context for this layer 3 address";
         }
         leaf ip-address {
             type inet:ip-address;
             mandatory true;
-            description 
+            description
                 "The actual IP address for the endpoint";
         }
     }
 
     grouping l3-prefix-key {
-        description 
+        description
             "The fields that identify an endpoint by a layer 3 prefix";
         leaf l3-context {
             type gbp-common:l3-context-id;
             mandatory true;
-            description 
+            description
                 "The context for this layer 3 prefix";
         }
         leaf ip-prefix {
             type inet:ip-prefix;
             mandatory true;
-            description 
+            description
                 "The IP prefix for the endpoint";
         }
     }
@@ -79,15 +79,15 @@ module endpoint {
         leaf tenant {
             type gbp-common:tenant-id;
             mandatory true;
-            description 
+            description
                 "The tenant with which this endpoint is associated";
         }
 
         uses l2-key;
-        
+
         leaf network-containment {
-            description 
-                "The network domain associated with this endpoint's fowarding 
+            description
+                "The network domain associated with this endpoint's fowarding
                 context.";
             type gbp-common:network-domain-id;
         }
@@ -99,34 +99,34 @@ module endpoint {
         }
         leaf endpoint-group {
             type gbp-common:endpoint-group-id;
-            description 
+            description
                 "The group associated with this endpoint";
         }
         leaf-list endpoint-groups {
             type gbp-common:endpoint-group-id;
-            description 
+            description
                 "The groups associated with this endpoint";
             ordered-by user;
         }
         leaf-list condition {
             type gbp-common:condition-name;
-            description 
+            description
                 "The conditions associated with this endpoint";
         }
         // This was a mistake and now it's an abomination.
         leaf port-name {
             type gbp-common:name;
-            description 
+            description
                 "Port name";
         } // end the abomination.
         leaf timestamp {
             type int64;
             description
-                "The last timestamp associated with this endpoint record.  
+                "The last timestamp associated with this endpoint record.
                  This will be used for aging data in the registry.";
         }
     }
-    
+
     //  L3 Prefix EndPointFields
     grouping endpoint-l3-prefix-fields {
         description "An l3 prefix endpoint and its associated metadata";
@@ -134,23 +134,23 @@ module endpoint {
         leaf tenant {
             type gbp-common:tenant-id;
             mandatory true;
-            description 
+            description
                 "The tenant with which this endpoint is associated";
         }
         leaf endpoint-group {
             type gbp-common:endpoint-group-id;
-            description 
+            description
                 "The group associated with this endpoint";
         }
         leaf-list endpoint-groups {
             type gbp-common:endpoint-group-id;
-            description 
+            description
                 "The groups associated with this endpoint";
             ordered-by user;
         }
         leaf-list condition {
             type gbp-common:condition-name;
-            description 
+            description
                 "The conditions associated with this endpoint";
         }
         list endpoint-l2-gateways {
@@ -164,14 +164,14 @@ module endpoint {
         leaf timestamp {
             type int64;
             description
-                "The last timestamp associated with this endpoint record.  
+                "The last timestamp associated with this endpoint record.
                  This will be used for aging data in the registry.";
         }
     }
 
     grouping has-endpoint-group-conditions {
-        description 
-            "Base type for object with endpoint group to condition 
+        description
+            "Base type for object with endpoint group to condition
              mappings.";
 
         leaf endpoint-group {
@@ -179,8 +179,8 @@ module endpoint {
             type gbp-common:endpoint-group-id;
         }
         list endpoint-group-condition {
-            description 
-                "The conditions associated with this endpoint 
+            description
+                "The conditions associated with this endpoint
                  group";
             key "condition";
             leaf condition {
@@ -191,13 +191,13 @@ module endpoint {
     }
 
     container endpoints {
-        description 
+        description
             "Repository for operational state data about endpoints needed for
              policy resolution.";
         config false;
 
         list endpoint {
-            description 
+            description
                 "Endpoints indexed by layer 2 addreses.  When modifying
                  data here, you must also modify data in the
                  endpoints-l3 list as well.";
@@ -206,8 +206,8 @@ module endpoint {
         }
 
         list endpoint-l3 {
-            description 
-                "Endpoints indexed by layer 3 addreses.  When modifying 
+            description
+                "Endpoints indexed by layer 3 addreses.  When modifying
                  data here, you must also modify data in the endpoints
                  list as well.";
             key "l3-context ip-address";
@@ -219,9 +219,9 @@ module endpoint {
             key "l3-context ip-prefix";
             uses endpoint-l3-prefix-fields;
         }
-        
+
         list condition-mapping {
-            description 
+            description
                 "A list mapping conditions to entire endpoint groups.
                  This offers a quickly way to set a condition on many
                  endpoints at once.";
@@ -234,7 +234,7 @@ module endpoint {
     rpc register-endpoint {
         description
             "Register a new endpoint into the registry.  If there
-             is already an existing endpoint with the same keys, they 
+             is already an existing endpoint with the same keys, they
              will be overwritten with the new information.";
 
         input {
@@ -274,9 +274,9 @@ module endpoint {
 
     rpc set-endpoint-group-conditions {
         description
-            "Set a list of conditions for a particular endpoint group.  
+            "Set a list of conditions for a particular endpoint group.
              These conditions will apply to all endpoints in the
-             endpoint group.  These conditions will be added to the 
+             endpoint group.  These conditions will be added to the
              existing list of conditions.";
 
         input {
index 21a72ae3b951c5c397969a0f27b7c4a8805a7f36..ea65b193419e9eb9c5367b5e5f136cfff056974e 100644 (file)
@@ -14,7 +14,7 @@ module policy-provider {
      import config { prefix config; revision-date 2013-04-05; }
 
      description
-         "This module contains the base YANG definitions for 
+         "This module contains the base YANG definitions for
           policy-provider services.";
 
      revision "2014-04-21" {
index db093b65327b1da7d21e7037704cb45abca13fe3..b0b044419b2a7b57f7880c88941d7e74a0ba59bd 100755 (executable)
@@ -15,8 +15,8 @@ module policy {
     import gbp-common {prefix gbp-common;}
     import ietf-inet-types {prefix inet;}
 
-    description 
-        "This module defines the group-based policy configuration 
+    description
+        "This module defines the group-based policy configuration
          model.";
 
     revision "2014-04-21" {
@@ -30,7 +30,7 @@ module policy {
 
     grouping label {
         description
-            "Labels are used for matching contracts to endpoint groups 
+            "Labels are used for matching contracts to endpoint groups
              through selectors and targets, as well as determining how
              those contracts will be applied.  See more detailed
              documentation for qualities, conditions, requirements,
@@ -46,13 +46,13 @@ module policy {
 
             type enumeration {
                 enum include {
-                    description 
-                        "This label will be included normally in the 
+                    description
+                        "This label will be included normally in the
                          matching.";
                 }
                 enum exclude {
-                    description 
-                        "This label will be excluded from the 
+                    description
+                        "This label will be excluded from the
                          matching.  This allows removing labels that
                          would have otherwise been included because of
                          inheritence rules.";
@@ -70,12 +70,12 @@ module policy {
         }
         uses label;
     }
-    
+
     grouping has-qualities {
         description "An object with a list of qualities";
         list quality {
-            description 
-                "A quality is a label which selects which selects the 
+            description
+                "A quality is a label which selects which selects the
                  contracts that are in scope.  Another name for
                  'quality' could be 'attribute' or 'characteristic.'
                  Qualities can be scoped to either a specific contract
@@ -110,8 +110,8 @@ module policy {
 
     grouping has-requirements {
         list requirement {
-            description 
-                "A requirement is a label that, along with capabilities, 
+            description
+                "A requirement is a label that, along with capabilities,
                  selects how contracts are applied by selecting the
                  applicable subjects within that contract.
                  Requirements represent the fact that an endpoint
@@ -127,7 +127,7 @@ module policy {
                  Note that requirements play no role in choosing which
                  contracts apply; they only affect how the contracts
                  that are chosen will be interpreted.";
-        
+
             key name;
             uses requirement-base;
         }
@@ -145,8 +145,8 @@ module policy {
 
     grouping has-capabilities {
         list capability {
-            description 
-                "A capability is a label that, along with requirements, 
+            description
+                "A capability is a label that, along with requirements,
                  selects how contracts are applied by selecting the
                  applicable subjects within that contract.
                  Capabilities are specific pieces of functionality
@@ -171,8 +171,8 @@ module policy {
 
     grouping has-conditions {
         list condition {
-            description 
-                "A condition is a state label for endpoints that can 
+            description
+                "A condition is a state label for endpoints that can
                  change over time.  As conditions change for certain
                  endpoints, this can affect which subjects are in
                  scope as determined by how the clauses in the
@@ -191,28 +191,28 @@ module policy {
     }
 
     grouping matcher {
-        description 
-            "A matcher allows matching against labels.  This is used 
+        description
+            "A matcher allows matching against labels.  This is used
              to both to match contracts to endpoint groups by matching
              on qualities, and then to match against subjects in the
              contract by matching on requirements, capabilities, and
              conditions.";
 
         leaf match-type {
-            description 
-                "Specify how many of the labels must match.  If not 
+            description
+                "Specify how many of the labels must match.  If not
                  specified, defaults to 'all'.";
             type enumeration {
                 enum all {
-                    description 
+                    description
                         "All specified labels must match.";
                 }
                 enum any {
-                    description 
+                    description
                         "At least one of the specified labels must match.";
                 }
                 enum none {
-                    description 
+                    description
                         "None of the specified labels can match.";
                 }
             }
@@ -223,15 +223,15 @@ module policy {
         description "Objects with condition matchers";
         list condition-matcher {
             description "Match against conditions on endpoints.";
-                
+
             key "name";
             leaf name {
-                description 
+                description
                     "A name for the condition matcher";
                 type gbp-common:condition-matcher-name;
                 mandatory true;
             }
-                
+
             uses matcher;
             uses has-conditions;
         }
@@ -243,16 +243,16 @@ module policy {
 
     grouping network-domain {
         description
-            "A base type for network domains.  Network domains 
+            "A base type for network domains.  Network domains
              represent some logical grouping or namespace of
              network addresses.";
         leaf name {
-            description 
+            description
                 "A human-readable name for the network domain.";
             type gbp-common:name;
         }
         leaf description {
-            description 
+            description
                 "A human-readable description for the context.";
             type gbp-common:description;
         }
@@ -264,7 +264,7 @@ module policy {
     }
 
     grouping l2-context {
-        description 
+        description
             "A base type for layer 2 contexts.  Layer 2 contexts
              represent a namespace or logical grouping of layer 2
              addresses.";
@@ -277,7 +277,7 @@ module policy {
     // ************************
 
     grouping relator {
-        description 
+        description
             "Relators allow contracts and endpoint groups to be related
              to each other through a matching process.  See target,
              selection-relator, target-selector, and named-selector
@@ -285,8 +285,8 @@ module policy {
     }
 
     grouping selection-relator {
-        description 
-            "Selection relators allow endpoint groups to select 
+        description
+            "Selection relators allow endpoint groups to select
              contracts based on their name or on their qualities.";
         uses relator;
 
@@ -339,7 +339,7 @@ module policy {
     }
 
     grouping target-selector {
-        description 
+        description
             "Target selectors select contracts for the endpoint group.
              First, the quality matchers are used to select the
              contracts.  Then, the requirements and capabilities are
@@ -355,7 +355,7 @@ module policy {
              groups.";
 
         list quality-matcher {
-            description 
+            description
                 "A quality matcher is used in a target selector to
                  match against the qualities in a contract target.
                  You can specify a list of qualities to match against.
@@ -408,15 +408,15 @@ module policy {
             default bidirectional;
             type enumeration {
                 enum in {
-                    description 
+                    description
                         "Applies to traffic into provider endpoint group";
                 }
                 enum out {
-                    description 
+                    description
                         "Applies to traffic out of provider endpoint group";
                 }
                 enum bidirectional {
-                    description 
+                    description
                         "Applies to traffic in both directions";
                 }
             }
@@ -425,7 +425,7 @@ module policy {
 
     grouping subject-feature-instance {
         description
-            "Specific instances of subject features with 
+            "Specific instances of subject features with
              parameters filled in.";
         list parameter-value {
             key "name";
@@ -455,8 +455,8 @@ module policy {
     grouping has-order {
         description "Objects containing an order parameter";
         leaf order {
-            description 
-                "Specify the ordering of an ordered list 
+            description
+                "Specify the ordering of an ordered list
                  of elements.";
             type int32 {
                 range "0..max";
@@ -469,8 +469,8 @@ module policy {
 
         list classifier-ref {
             key "name";
-            description 
-                "A reference to classifier instance that is used to match 
+            description
+                "A reference to classifier instance that is used to match
                  traffic traveling between the endpoint groups that
                  form the contract.";
 
@@ -489,24 +489,24 @@ module policy {
             }
 
             leaf connection-tracking {
-                description 
-                    "Set up connection tracking for this classifier, 
+                description
+                    "Set up connection tracking for this classifier,
                      which allows the traffic in the reverse direction
-                     as connections are established.  This enables 
-                     rules that allow connections to be initiated only 
-                     from one side, but once initiated the two sides 
+                     as connections are established.  This enables
+                     rules that allow connections to be initiated only
+                     from one side, but once initiated the two sides
                      can communicate for that connection.";
 
                 default normal;
                 type enumeration {
                     enum normal {
-                        description 
-                            "Match only traffic matching the classifier 
+                        description
+                            "Match only traffic matching the classifier
                              strictly";
                     }
                     enum reflexive {
-                        description 
-                            "Additionally match reverse traffic for 
+                        description
+                            "Additionally match reverse traffic for
                              connections";
                     }
                 }
@@ -520,8 +520,8 @@ module policy {
         description "Objects containing lists of action references";
 
         list action-ref {
-            description 
-                "A reference to an action defined in the subject 
+            description
+                "A reference to an action defined in the subject
                  feature instances for the tenant.";
 
             key name;
@@ -546,8 +546,8 @@ module policy {
         }
 
         list parameter {
-            description 
-                "A parameter for the feature that can be 
+            description
+                "A parameter for the feature that can be
                  passed in.";
             key "name";
             leaf name {
@@ -556,8 +556,8 @@ module policy {
                 mandatory true;
             }
             leaf description {
-                description 
-                    "A user-visible description of the meaning of 
+                description
+                    "A user-visible description of the meaning of
                      the parameter.";
                 type gbp-common:description;
             }
@@ -592,18 +592,18 @@ module policy {
         }
 
         leaf fallback-behavior {
-            description 
+            description
                 "Set the behavior when the underlying infrastructure
                  is unable to support a particular feature.";
             type enumeration {
                 enum strict {
-                    description 
+                    description
                         "A fatal exception MUST be raised which will
                          render the enclosing subject inactive.";
                 }
                 enum allow-fallback {
-                    description 
-                        "The infrastructure MAY fall back to using 
+                    description
+                        "The infrastructure MAY fall back to using
                          a parent definition of this feature, and
                          instread raise a nonfatal exception.";
                 }
@@ -639,7 +639,7 @@ module policy {
 
         list classifier-definition {
             description
-                "A classifier is used to match traffic traveling between 
+                "A classifier is used to match traffic traveling between
                  the endpoint groups that form the contract.
                  Classifier definitions can define parameters that
                  will need to be filled in when a particular rule
@@ -655,14 +655,14 @@ module policy {
             }
 
             leaf name {
-                description 
+                description
                     "A user-visible name for the classifier definition";
                 type gbp-common:classifier-name;
             }
 
             leaf parent {
-                description 
-                    "Parent classifier definition from which we inherit"; 
+                description
+                    "Parent classifier definition from which we inherit";
                 type leafref {
                     path "/subject-feature-definitions/classifier-definition/id";
                 }
@@ -671,7 +671,7 @@ module policy {
 
         list action-definition {
             description
-                "A action to be applied to traffic across endpoint 
+                "A action to be applied to traffic across endpoint
                  groups.  Action definitions can define parameters
                  that will need to be filled in when a particular rule
                  references it.";
@@ -691,8 +691,8 @@ module policy {
             }
 
             leaf parent {
-                description 
-                    "Parent action definition from which we inherit"; 
+                description
+                    "Parent action definition from which we inherit";
                 type leafref {
                     path "/subject-feature-definitions/action-definition/id";
                 }
@@ -710,8 +710,8 @@ module policy {
         config true;
 
         list tenant {
-            description 
-                "A tenant is a domain of administration which is 
+            description
+                "A tenant is a domain of administration which is
                  logically separate from other tenants.  Most policy
                  is defined in the context of a particular tenant";
 
@@ -744,15 +744,15 @@ module policy {
                 uses forwarding-context;
 
                 leaf id {
-                    description 
+                    description
                         "A unique ID for the layer 3 context";
                     type gbp-common:l3-context-id;
                 }
             }
-            
+
             list l2-bridge-domain {
-                description 
-                    "A layer 2 bridge domain represents a domain in which 
+                description
+                    "A layer 2 bridge domain represents a domain in which
                      layer 2 communication is possible when allowed by policy.";
                 key "id";
                 uses l2-context;
@@ -763,7 +763,7 @@ module policy {
                 }
 
                 leaf parent {
-                    description 
+                    description
                         "The layer 3 context that contains this bridge domain";
                     type leafref {
                         path "/tenants/tenant/l3-context/id";
@@ -772,8 +772,8 @@ module policy {
             }
 
             list l2-flood-domain {
-                description 
-                    "A layer 2 flood domain represents a domain in which 
+                description
+                    "A layer 2 flood domain represents a domain in which
                      layer 2 broadcast and multicast is allowed.";
                 key "id";
                 uses l2-context;
@@ -784,7 +784,7 @@ module policy {
                 }
 
                 leaf parent {
-                    description 
+                    description
                         "The bridge domain that contains this flood domain";
                     type leafref {
                         path "/tenants/tenant/l2-bridge-domain/id";
@@ -794,18 +794,18 @@ module policy {
 
             list subnet {
                 description
-                    "An IP subnet associated with a layer 2 or layer 3 
+                    "An IP subnet associated with a layer 2 or layer 3
                      context.";
                 key "id";
                 uses network-domain;
-                
+
                 leaf id {
                     description "A unique ID for the subnet";
                     type gbp-common:subnet-id;
                 }
 
                 leaf parent {
-                    description 
+                    description
                         "The forwarding context that contains this subnet";
                     type gbp-common:context-id;
                 }
@@ -828,12 +828,12 @@ module policy {
 
             list endpoint-group {
                 description
-                    "Endpoint groups are sets of endpoints that share a 
+                    "Endpoint groups are sets of endpoints that share a
                      common set of policies.  Endpoint groups are
                      matched to contracts using selectors, contracts
                      determine which endpoints can communicate and in
                      what way.
-                     
+
                      Endpoint groups have both requirements and
                      capabilities, which represent specific pieces of
                      functionality that are exposed at the boundary of
@@ -843,7 +843,7 @@ module policy {
                      Correspondingly, capabilities are pieces of
                      functionality that the endpoints in the endpoint
                      group can provide to other endpoints.
-                     
+
                      Contracts can be selected through either a named
                      selector, which matches specific contracts by
                      name, or by a target selector which will match
@@ -854,7 +854,7 @@ module policy {
                      and capabilities are not used when choosing which
                      contracts are in scope; these are used to
                      determine how a contract will be interpreted.
-                     
+
                      There are two broad category of selectors:
                      provider selectors and consumer selectors.  The
                      provider selectors allow selecting contracts that
@@ -864,19 +864,19 @@ module policy {
                      group to meet its requirements.";
 
                 key "id";
-            
+
                 leaf id {
                     mandatory true;
                     type gbp-common:endpoint-group-id;
                 }
-                
+
                 leaf name {
-                    description 
+                    description
                         "A user-visible name for the endpoint group";
                     type gbp-common:name;
                 }
                 leaf description {
-                    description 
+                    description
                         "A human-readable description for the endpoint
                          group.";
                     type gbp-common:description;
@@ -885,20 +885,20 @@ module policy {
                 uses has-capabilities;
 
                 leaf intra-group-policy {
-                    description 
-                        "Governs how traffic within the endpoint group 
+                    description
+                        "Governs how traffic within the endpoint group
                          should be handled.";
                     default allow;
                     type enumeration {
                         enum allow {
-                            description 
+                            description
                                 "Traffic between two endpoints in the group
                                  is always allowed";
                         }
                         enum require-contract {
                             description
                                 "Traffic between two endpoints in the group
-                                 is allowed only when a contract exists to 
+                                 is allowed only when a contract exists to
                                  allow it explicitly";
                         }
                     }
@@ -906,10 +906,10 @@ module policy {
 
                 list consumer-named-selector {
                     description
-                        "Consumer named selectors are named selectors 
+                        "Consumer named selectors are named selectors
                          that select contracts to meet the
                          requirements of the endpoint group.
-                         
+
                          The consumer named selector selects a
                          contract based on the name of the contract.
                          Once the contract is selected, the
@@ -922,11 +922,11 @@ module policy {
                 }
 
                 list provider-named-selector {
-                    description 
-                        "Provider named selectors are named selectors 
+                    description
+                        "Provider named selectors are named selectors
                          that select contracts to provide capabilties
                          to other endpoint group.
-                         
+
                          The provider named selector selects a
                          contract based on the name of the contract.
                          Once the contract is selected, the capabilies
@@ -939,11 +939,11 @@ module policy {
                 }
 
                 list consumer-target-selector {
-                    description 
-                        "Consumer target selectors are target selectors 
-                         that select contracts to meet the requirements 
+                    description
+                        "Consumer target selectors are target selectors
+                         that select contracts to meet the requirements
                          of the endpoint group.
-                         
+
                          The consumer target selector selects a
                          contract using the quality matchers to match
                          against the qualities specified on the
@@ -958,10 +958,10 @@ module policy {
 
                 list provider-target-selector {
                     description
-                        "Provider target selectors are target selectors 
+                        "Provider target selectors are target selectors
                          that select contracts to provide capabilties
                          to other endpoint group.
-                         
+
                          The provider target selector selects a
                          contract using the quality matchers to match
                          against the qualities specified on the
@@ -975,16 +975,16 @@ module policy {
                 }
 
                 leaf network-domain {
-                    description 
+                    description
                         "The network domain associated with this endpoint
-                         group.  The network domain controls which endpoints 
+                         group.  The network domain controls which endpoints
                          are addressible by the endpoints in the group.";
                     type gbp-common:network-domain-id;
                 }
 
                 leaf parent {
-                    description 
-                        "Parent endpoint group from which we inherit"; 
+                    description
+                        "Parent endpoint group from which we inherit";
 
                     type leafref {
                         path "/tenants/tenant/endpoint-group/id";
@@ -997,12 +997,12 @@ module policy {
                     ".";
 
                 key "id";
-            
+
                 leaf id {
                     mandatory true;
                     type gbp-common:endpoint-group-id;
                 }
-                // Fields to be determined and completed before Code Freeze                
+                // Fields to be determined and completed before Code Freeze
 
             }
             // *************************
@@ -1010,8 +1010,8 @@ module policy {
             // *************************
 
             container subject-feature-instances {
-                description 
-                    "Contains instances of subject features.  Subject 
+                description
+                    "Contains instances of subject features.  Subject
                      feature instances reference a subject feature
                      definition but fill in the required parameters so
                      that they can be easily references elsewhere.";
@@ -1061,52 +1061,52 @@ module policy {
                      the communication allowed between endpoints in
                      endpoint groups.  Contracts are matched to endpoint
                      groups by selectors.";
-                
+
                 key "id";
                 leaf id {
                     description "A unique ID for the contract";
                     type gbp-common:contract-id;
                     mandatory true;
                 }
-                
+
                 leaf description {
-                    description 
+                    description
                         "A human-readable description for the contract.";
                     type gbp-common:description;
                 }
-                                
+
                 // *******
                 // Relator
                 // *******
-                
+
                 uses has-qualities;
-                
+
                 list target {
-                    description 
+                    description
                         "Targets on a contract allow grouping sets of qualities
                          together, as well as providing a namespace for
                          the qualities that are matched.";
-                
+
                     key "name";
                     leaf name {
-                        description 
-                            "The name for this target.  This can also be used 
+                        description
+                            "The name for this target.  This can also be used
                              by quality matchers as a namespace for qualities.";
                         type gbp-common:target-name;
                         mandatory true;
                     }
-                
+
                     uses relator;
                     uses has-qualities;
                 }
-                
+
                 // ********************
                 // Clauses and subjects
                 // ********************
-                
+
                 list subject {
                     description
-                        "Subjects define rules to allow traffic to flow 
+                        "Subjects define rules to allow traffic to flow
                          between endpoints in different endpoint
                          groups.  No communication is allowed unless a
                          subject allows that communication.
@@ -1118,7 +1118,7 @@ module policy {
                          groups that are participating in the
                          contract.  Clauses that match each point to a
                          subject which then becomes active.
-                         
+
                          An active subject can then apply its rules to
                          the traffic between the endpoints.";
 
@@ -1130,8 +1130,8 @@ module policy {
                     }
 
                     list rule {
-                        description 
-                            "A rule is applied to traffic between 
+                        description
+                            "A rule is applied to traffic between
                              endpoints in different endpoint groups.
                              Rules match against the traffic using
                              classifiers, and then apply actions to
@@ -1165,60 +1165,60 @@ module policy {
                 }
 
                 list clause {
-                    description 
-                        "Clauses are used to determine which subjects are 
+                    description
+                        "Clauses are used to determine which subjects are
                          active once a contract is selected using the
                          contract selectors.
-                
+
                          Clauses are activated by matching against
                          requirements on the consumer endpoint group,
                          capabilities on the provider endpoint group, and
                          conditions on the individual endpoints in the
-                         endpoint group.";             
+                         endpoint group.";
                     key "name";
                     leaf name {
                         type gbp-common:clause-name;
                         mandatory true;
-                    }               
+                    }
                     // ********
                     // Matchers
                     // ********
-                
+
                     container consumer-matchers {
-                        description 
-                            "Matchers that apply to the consumer endpoint 
+                        description
+                            "Matchers that apply to the consumer endpoint
                              group.";
-                        
+
                         // GIC mutually OR'd within role
                         choice group-identification-constraints {
                             description "Returns Groups which match, MUTALLY OR within role. Must be Either/Or";
 
-                            case group-name-constraint-case {                                
+                            case group-name-constraint-case {
                                 list group-name-constraint {
                                     key endpoint-group-name;
                                     leaf endpoint-group-name {
                                         type gbp-common:name;
                                     }
-                                } 
+                                }
                             }
                             case group-requirement-constraint-case {
                                 list requirement-matcher {
-                                    description 
-                                        "Match against requirements in the consumer 
+                                    description
+                                        "Match against requirements in the consumer
                                          endpoint group.";
-                        
+
                                     key "name";
                                     leaf name {
-                                        description 
+                                        description
                                             "A name for the requirement matcher";
                                         type gbp-common:requirement-matcher-name;
                                         mandatory true;
                                     }
-                        
+
                                     uses matcher;
                                     list matcher-requirement {
-                                        description 
-                                            "A matcher requirement is a 
+                                        description
+                                            "A matcher requirement is a
                                              requirement with a selector name
                                              field used in requirement
                                              matchers.  The name of the
@@ -1230,8 +1230,8 @@ module policy {
                                         uses requirement-base;
 
                                         leaf selector-namespace {
-                                            description 
-                                                "The name of the selector to  
+                                            description
+                                                "The name of the selector to
                                                  match.  This allows us to
                                                  specify that we want to match
                                                  only requirements scoped to a
@@ -1242,33 +1242,33 @@ module policy {
                                                  inherited selector namespace
                                                  if it exists, or match
                                                  against any selector name.";
-                        
+
                                             type gbp-common:selector-name;
                                         }
                                     }
                                 }
                             }
-                            
+
                             case group-any-case {
                                 container group-any {
 
-                                    description 
+                                    description
                                         "A presence container stating that, if this exists,
                                         the role matcher will match on any group.";
                                     presence "This matches any group";
                                 }
                             }
                         }
-                        
 
-                        
+
+
                         uses has-condition-matchers;
 
                         container endpoint-identification-constraints {
                             description
                                 "Identify endpoints via other attributes other than conditions.
                                 These can be things such as ip-prefix, vlan, mpls label etc. These
-                                things are intended to be explicity stated, and should not contain 
+                                things are intended to be explicity stated, and should not contain
                                 references to other objects like endpointsIDs.";
                             container l3-endpoint-identification-constraints {
                                 list prefix-constraint {
@@ -1285,7 +1285,7 @@ module policy {
                         description
                             "Matchers that apply to the provider endpoint
                              group";
-                                      
+
                         // GIC mutually OR'd within role
                         choice group-identification-constraints {
                             description "Returns Groups which match, MUTALLY OR within role. Must be Either/Or";
@@ -1300,13 +1300,13 @@ module policy {
                             }
                             case group-capability-constraint-case {
                                 list capability-matcher {
-                                    description 
+                                    description
                                         "Match against capabilities in the provider
                                          endpoint group.";
 
                                     key "name";
                                     leaf name {
-                                        description 
+                                        description
                                             "A name for the capability matcher";
                                         type gbp-common:capability-matcher-name;
                                         mandatory true;
@@ -1352,14 +1352,14 @@ module policy {
                                 }
                             }
                         }
-         
+
                         uses has-condition-matchers;
-                        
+
                         container endpoint-identification-constraints {
                             description
                                 "Identify endpoints via other attributes other than conditions.
                                 These can be things such as ip-prefix, vlan, mpls label etc. These
-                                things are intended to be explicity stated, and should not contain 
+                                things are intended to be explicity stated, and should not contain
                                 references to other objects like endpointsIDs.";
                             container l3-endpoint-identification-constraints {
                                 list prefix-constraint {
@@ -1371,7 +1371,7 @@ module policy {
                             }
                         }
                     }
-                
+
                     container any-matchers {
                         description
                             "Matchers that apply to either provider endpoint group or consumer endpoint group.";
@@ -1384,7 +1384,7 @@ module policy {
 
                     leaf-list subject-refs {
                         description
-                            "The subjects that will be activated if this 
+                            "The subjects that will be activated if this
                              clause matches.";
 
                         type leafref {
@@ -1396,18 +1396,18 @@ module policy {
                 // ***********
                 // Inheritance
                 // ***********
-                
+
                 leaf parent {
-                    description "Parent contract from which we inherit"; 
-                
+                    description "Parent contract from which we inherit";
+
                     type leafref {
                         path "/tenants/tenant/contract/id";
                     }
-                } 
+                }
             }
-                
+
             list contract-ref {
-                description 
+                description
                     "Contract references allow forming contracts
                      between endpoint groups in different tenants.
                      Once the contract reference is created, it is
@@ -1426,7 +1426,7 @@ module policy {
 
                 leaf tenant-id {
                     description
-                        "The tenant ID of the tenant containing the 
+                        "The tenant ID of the tenant containing the
                          contract.";
                     type leafref {
                         path "/tenants/tenant/id";
index 11dc43b152d65ea2e4166f26321284b33971f70b..0fb4e1269c77103c3616d58dcc06314f8eb13e46 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011, Big Switch Networks, Inc. 
+ * Copyright 2011, Big Switch Networks, Inc.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -8,7 +8,9 @@
 
 package org.opendaylight.groupbasedpolicy.util;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -16,7 +18,6 @@ import java.util.concurrent.TimeUnit;
 
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.groupbasedpolicy.util.SingletonTask;
 
 public class SingletonTaskTest {
 
index daca8ba16dbe049beba653e03d9203759de8a2d0..735076320e17b90e07153b91af21179456b60150 100644 (file)
@@ -70,19 +70,18 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 
 /**
- * Keep track of endpoints on the system.  Maintain an index of endpoints
- * and their locations for renderering.  The endpoint manager will maintain
+ * Keep track of endpoints on the system. Maintain an index of endpoints and
+ * their locations for renderering. The endpoint manager will maintain
  * appropriate indexes only for switches that are attached to the current
  * controller node.
- * 
+ *
  * In order to render the policy, we need to be able to efficiently enumerate
- * all endpoints on a particular switch and also all the switches containing 
+ * all endpoints on a particular switch and also all the switches containing
  * each particular endpoint group
- * @author readams
  */
 public class EndpointManager implements AutoCloseable, DataChangeListener
-    {
-    private static final Logger LOG = 
+{
+    private static final Logger LOG =
             LoggerFactory.getLogger(EndpointManager.class);
     private final static InstanceIdentifier<Nodes> nodesIid = InstanceIdentifier
             .builder(Nodes.class).build();
@@ -90,19 +89,18 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
             .builder(Nodes.class).child(Node.class).build();
     private ListenerRegistration<DataChangeListener> nodesReg;
 
-    private static final InstanceIdentifier<Endpoint> endpointsIid = 
+    private static final InstanceIdentifier<Endpoint> endpointsIid =
             InstanceIdentifier.builder(Endpoints.class)
-                .child(Endpoint.class).build();
+                    .child(Endpoint.class).build();
     final ListenerRegistration<DataChangeListener> listenerReg;
 
     private final ConcurrentHashMap<EpKey, Endpoint> endpoints =
             new ConcurrentHashMap<>();
-    private final ConcurrentHashMap<NodeId, 
-                                    ConcurrentMap<EgKey, Set<EpKey>>> endpointsByNode =
+    private final ConcurrentHashMap<NodeId, ConcurrentMap<EgKey, Set<EpKey>>> endpointsByNode =
             new ConcurrentHashMap<>();
-    private final ConcurrentHashMap<EgKey, Set<EpKey>> endpointsByGroup = 
+    private final ConcurrentHashMap<EgKey, Set<EpKey>> endpointsByGroup =
             new ConcurrentHashMap<>();
-            
+
     private List<EndpointListener> listeners = new CopyOnWriteArrayList<>();
 
     final private OfEndpointAug endpointRpcAug = new OfEndpointAug();
@@ -112,23 +110,23 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
     final private DataBroker dataProvider;
 
     public EndpointManager(DataBroker dataProvider,
-                           RpcProviderRegistry rpcRegistry,
-                           ScheduledExecutorService executor,
-                           SwitchManager switchManager) {
+            RpcProviderRegistry rpcRegistry,
+            ScheduledExecutorService executor,
+            SwitchManager switchManager) {
         this.executor = executor;
         this.dataProvider = dataProvider;
         EndpointRpcRegistry.register(dataProvider, rpcRegistry, executor, endpointRpcAug);
         if (dataProvider != null) {
             listenerReg = dataProvider
-                    .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, 
-                                                endpointsIid, 
-                                                this, 
-                                                DataChangeScope.ONE);
+                    .registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+                            endpointsIid,
+                            this,
+                            DataChangeScope.ONE);
             nodesReg = dataProvider.registerDataChangeListener(
                     LogicalDatastoreType.OPERATIONAL, nodeIid,
                     new NodesListener(), DataChangeScope.SUBTREE);
 
-        } else 
+        } else
             listenerReg = null;
 
         LOG.debug("Initialized OFOverlay endpoint manager");
@@ -140,101 +138,123 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
 
     /**
      * Add a {@link EndpointListener} to get notifications of switch events
-     * @param listener the {@link EndpointListener} to add
+     *
+     * @param listener
+     *            the {@link EndpointListener} to add
      */
     public void registerListener(EndpointListener listener) {
         listeners.add(listener);
     }
-    
+
     /**
      * Get a collection of endpoints attached to a particular switch
-     * @param nodeId the nodeId of the switch to get endpoints for
+     *
+     * @param nodeId
+     *            the nodeId of the switch to get endpoints for
      * @return a collection of {@link Endpoint} objects.
      */
     public Set<EgKey> getGroupsForNode(NodeId nodeId) {
         Map<EgKey, Set<EpKey>> nodeEps = endpointsByNode.get(nodeId);
-        if (nodeEps == null) return Collections.emptySet();
+        if (nodeEps == null)
+            return Collections.emptySet();
         return Collections.unmodifiableSet(nodeEps.keySet());
     }
-    
+
     /**
      * Get the set of nodes
-     * @param nodeId the nodeId of the switch to get endpoints for
+     *
+     * @param nodeId
+     *            the nodeId of the switch to get endpoints for
      * @return a collection of {@link Endpoint} objects.
      */
     public Set<NodeId> getNodesForGroup(final EgKey egKey) {
         return Collections.unmodifiableSet(Sets.filter(endpointsByNode.keySet(),
-                                                       new Predicate<NodeId>() {
-            @Override
-            public boolean apply(NodeId input) {
-                Map<EgKey, Set<EpKey>> nodeEps = 
-                        endpointsByNode.get(input);
-                return (nodeEps != null && 
+                new Predicate<NodeId>() {
+                    @Override
+                    public boolean apply(NodeId input) {
+                        Map<EgKey, Set<EpKey>> nodeEps =
+                                endpointsByNode.get(input);
+                        return (nodeEps != null &&
                         nodeEps.containsKey(egKey));
-            }
+                    }
 
-        }));
+                }));
     }
-    
+
     /**
      * Get the endpoints in a particular group on a particular node
-     * @param nodeId the node ID to look up
-     * @param eg the group to look up
+     *
+     * @param nodeId
+     *            the node ID to look up
+     * @param eg
+     *            the group to look up
      * @return the endpoints
      */
     public Collection<Endpoint> getEPsForNode(NodeId nodeId, EgKey eg) {
         Map<EgKey, Set<EpKey>> nodeEps = endpointsByNode.get(nodeId);
-        if (nodeEps == null) return Collections.emptyList();
-        Collection<EpKey> ebn = nodeEps.get(eg); 
-        if (ebn == null) return Collections.emptyList();
+        if (nodeEps == null)
+            return Collections.emptyList();
+        Collection<EpKey> ebn = nodeEps.get(eg);
+        if (ebn == null)
+            return Collections.emptyList();
         return Collections.unmodifiableCollection(Collections2
-                                                  .transform(ebn, 
-                                                             indexTransform));
+                .transform(ebn,
+                        indexTransform));
     }
 
     /**
      * Get the endpoint object for the given key
-     * @param epKey the key
+     *
+     * @param epKey
+     *            the key
      * @return the {@link Endpoint} corresponding to the key
      */
     public Endpoint getEndpoint(EpKey epKey) {
         return endpoints.get(epKey);
     }
-    
+
     /**
      * Set the learning mode to the specified value
-     * @param learningMode the learning mode to set
+     *
+     * @param learningMode
+     *            the learning mode to set
      */
     public void setLearningMode(LearningMode learningMode) {
         // No-op for now
     }
-    
+
     /**
      * Get a collection of endpoints in a particular endpoint group
-     * @param nodeId the nodeId of the switch to get endpoints for
+     *
+     * @param nodeId
+     *            the nodeId of the switch to get endpoints for
      * @return a collection of {@link Endpoint} objects.
      */
     public Collection<Endpoint> getEndpointsForGroup(EgKey eg) {
         Collection<EpKey> ebg = endpointsByGroup.get(eg);
-        if (ebg == null) return Collections.emptyList();
+        if (ebg == null)
+            return Collections.emptyList();
         return Collections2.transform(ebg, indexTransform);
     }
 
     /**
-     * Get the effective list of conditions that apply to a particular 
-     * endpoint.  This could include additional conditions over the condition
-     * labels directly represented in the endpoint object
-     * @param endpoint the {@link Endpoint} to resolve
+     * Get the effective list of conditions that apply to a particular endpoint.
+     * This could include additional conditions over the condition labels
+     * directly represented in the endpoint object
+     *
+     * @param endpoint
+     *            the {@link Endpoint} to resolve
      * @return the list of {@link ConditionName}
      */
     public List<ConditionName> getCondsForEndpoint(Endpoint endpoint) {
-        // XXX TODO consider group conditions as well.  Also need to notify
+        // XXX TODO consider group conditions as well. Also need to notify
         // endpoint updated if the endpoint group conditions change
         if (endpoint.getCondition() != null)
             return endpoint.getCondition();
-        else return Collections.emptyList();
+        else
+            return Collections.emptyList();
     }
-    
+
     // ************************
     // Endpoint Augmentation
     // ************************
@@ -243,7 +263,8 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
         @Override
         public void buildEndpointAugmentation(EndpointBuilder eb,
                 RegisterEndpointInput input) {
-            // In order to support both the port-name and the data-path information, allow
+            // In order to support both the port-name and the data-path
+            // information, allow
             // an EP to register without the augmentations, and resolve later.
             OfOverlayContextBuilder ictx = checkAugmentation(input);
             if (ictx != null) {
@@ -259,7 +280,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
         @Override
         public void buildL3PrefixEndpointAugmentation(EndpointL3PrefixBuilder eb, RegisterL3PrefixEndpointInput input) {
             // TODO Auto-generated method stub
-            
+
         }
     }
 
@@ -269,7 +290,8 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
 
     @Override
     public void close() throws Exception {
-        if (listenerReg != null) listenerReg.close();
+        if (listenerReg != null)
+            listenerReg.close();
         EndpointRpcRegistry.unregister(endpointRpcAug);
     }
 
@@ -281,21 +303,22 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
     public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
         for (DataObject dao : change.getCreatedData().values()) {
             if (dao instanceof Endpoint)
-                updateEndpoint(null, (Endpoint)dao);
+                updateEndpoint(null, (Endpoint) dao);
         }
         for (InstanceIdentifier<?> iid : change.getRemovedPaths()) {
             DataObject old = change.getOriginalData().get(iid);
             if (old != null && old instanceof Endpoint)
-                updateEndpoint((Endpoint)old, null);
+                updateEndpoint((Endpoint) old, null);
         }
-        Map<InstanceIdentifier<?>,DataObject> d = change.getUpdatedData();
+        Map<InstanceIdentifier<?>, DataObject> d = change.getUpdatedData();
         for (Entry<InstanceIdentifier<?>, DataObject> entry : d.entrySet()) {
-            if (!(entry.getValue() instanceof Endpoint)) continue;
+            if (!(entry.getValue() instanceof Endpoint))
+                continue;
             DataObject old = change.getOriginalData().get(entry.getKey());
             Endpoint oldEp = null;
             if (old != null && old instanceof Endpoint)
-                oldEp = (Endpoint)old;
-            updateEndpoint(oldEp, (Endpoint)entry.getValue());
+                oldEp = (Endpoint) old;
+            updateEndpoint(oldEp, (Endpoint) entry.getValue());
         }
     }
 
@@ -330,76 +353,81 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
 
         public UpdateEndpoint(Node node) {
             this.node = node;
-            this.endpointsIid=InstanceIdentifier.builder(Endpoints.class).build();
+            this.endpointsIid = InstanceIdentifier.builder(Endpoints.class).build();
         }
+
         @Override
         public void run() {
             Optional<Endpoints> epResult;
-            EpKey epKey=null;
+            EpKey epKey = null;
             for (NodeConnector nc : node.getNodeConnector()) {
                 FlowCapableNodeConnector fcnc = nc
                         .getAugmentation(FlowCapableNodeConnector.class);
                 try {
-                    epResult = dataProvider.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, endpointsIid).get();
-                    if(epResult.isPresent()) {
+                    epResult = dataProvider.newReadOnlyTransaction()
+                            .read(LogicalDatastoreType.OPERATIONAL, endpointsIid).get();
+                    if (epResult.isPresent()) {
                         Endpoints endpoints = epResult.get();
-                        if(endpoints.getEndpoint() != null) {
+                        if (endpoints.getEndpoint() != null) {
                             WriteTransaction tx = dataProvider.newWriteOnlyTransaction();
                             Boolean isEmpty = true;
-                            for (Endpoint ep : endpoints.getEndpoint()){
+                            for (Endpoint ep : endpoints.getEndpoint()) {
                                 // 2. Search for portname
                                 OfOverlayContext currentAugmentation = ep.getAugmentation(OfOverlayContext.class);
-                                if(ep.getPortName().getValue().equals(fcnc.getName())) {
+                                if (ep.getPortName().getValue().equals(fcnc.getName())) {
                                     NodeId nodeId;
                                     NodeConnectorId nodeConnectorId;
                                     try {
-                                        nodeId=currentAugmentation.getNodeId();
-                                        nodeConnectorId=currentAugmentation.getNodeConnectorId();
+                                        nodeId = currentAugmentation.getNodeId();
+                                        nodeConnectorId = currentAugmentation.getNodeConnectorId();
                                     } catch (Exception e) {
                                         nodeId = null;
                                         nodeConnectorId = null;
                                     }
-                                    Boolean process=false;
-                                    if(nodeId==null && nodeConnectorId ==null) {
+                                    Boolean process = false;
+                                    if (nodeId == null && nodeConnectorId == null) {
                                         LOG.debug("ep NodeID and NC ID Both null");
-                                        process=true;
+                                        process = true;
                                     }
-                                    if(nodeId!=null && nodeConnectorId !=null) {
+                                    if (nodeId != null && nodeConnectorId != null) {
                                         if (!(nodeConnectorId.getValue().equals(nc.getId().getValue()))) {
                                             LOG.debug("ep NodeID and NC ID Both NOT null but epNCID !=nodeNCID");
-                                            process=true;
+                                            process = true;
                                         }
                                     }
-                                    if(process) {
+                                    if (process) {
                                         // 3. Update endpoint
                                         EndpointBuilder epBuilder = new EndpointBuilder(ep);
                                         OfOverlayContextBuilder ofOverlayAugmentation = new OfOverlayContextBuilder();
                                         ofOverlayAugmentation.setNodeId(node.getId());
                                         ofOverlayAugmentation.setNodeConnectorId(nc.getId());
-                                        epBuilder.addAugmentation(OfOverlayContext.class,ofOverlayAugmentation.build());
-                                        //TODO Hack to remove:
-                                        List<L3Address> l3Addresses= new ArrayList<>();
-                                        for(L3Address l3Address: ep.getL3Address()) {
+                                        epBuilder
+                                                .addAugmentation(OfOverlayContext.class, ofOverlayAugmentation.build());
+                                        // TODO Hack to remove:
+                                        List<L3Address> l3Addresses = new ArrayList<>();
+                                        for (L3Address l3Address : ep.getL3Address()) {
                                             L3AddressBuilder l3AB = new L3AddressBuilder();
-                                            l3AB.setIpAddress(l3Address.getIpAddress()).setL3Context(l3Address.getL3Context());
+                                            l3AB.setIpAddress(l3Address.getIpAddress()).setL3Context(
+                                                    l3Address.getL3Context());
                                             l3Addresses.add(l3AB.build());
                                         }
                                         epBuilder.setL3Address(l3Addresses);
-                                        InstanceIdentifier<Endpoint> iidEp = InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class,ep.getKey()).build();
+                                        InstanceIdentifier<Endpoint> iidEp = InstanceIdentifier
+                                                .builder(Endpoints.class).child(Endpoint.class, ep.getKey()).build();
                                         tx.put(LogicalDatastoreType.OPERATIONAL, iidEp, epBuilder.build());
-                                        epKey=new EpKey(ep.getKey().getL2Context(),ep.getKey().getMacAddress());
+                                        epKey = new EpKey(ep.getKey().getL2Context(), ep.getKey().getMacAddress());
                                         LOG.debug("Values:");
-                                        LOG.debug("node: Node ID:"+node.getId().getValue());
-                                        LOG.debug("node: NodeConnectorID: "+nc.getId().getValue());
-                                        if(nodeId!=null && nodeConnectorId != null) {
-                                            LOG.debug("ep: nodeID:"+nodeId.getValue());
-                                            LOG.debug("ep: nodeConnectorID:"+nodeConnectorId.getValue());
+                                        LOG.debug("node: Node ID:" + node.getId().getValue());
+                                        LOG.debug("node: NodeConnectorID: " + nc.getId().getValue());
+                                        if (nodeId != null && nodeConnectorId != null) {
+                                            LOG.debug("ep: nodeID:" + nodeId.getValue());
+                                            LOG.debug("ep: nodeConnectorID:" + nodeConnectorId.getValue());
                                         }
-                                        isEmpty=false;
+                                        isEmpty = false;
                                     }
                                 }
                             }
-                            if(!isEmpty) {
+                            if (!isEmpty) {
                                 CheckedFuture<Void, TransactionCommitFailedException> f = tx.submit();
                                 notifyEndpointUpdated(epKey);
                                 Futures.addCallback(f, new FutureCallback<Void>() {
@@ -419,11 +447,12 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
                         }
                     }
                 } catch (InterruptedException | ExecutionException e) {
-                    LOG.error("Caught exception in UpdateEndpoint",e);
+                    LOG.error("Caught exception in UpdateEndpoint", e);
                 }
             }
         }
     }
+
     // **************
     // Implementation
     // **************
@@ -446,68 +475,67 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
         }
     }
 
-    private Function<EpKey, Endpoint> indexTransform = 
+    private Function<EpKey, Endpoint> indexTransform =
             new Function<EpKey, Endpoint>() {
-        @Override
-        public Endpoint apply(EpKey input) {
-            return endpoints.get(input);
-        }
-    };
-    
+                @Override
+                public Endpoint apply(EpKey input) {
+                    return endpoints.get(input);
+                }
+            };
+
     private boolean validEp(Endpoint endpoint) {
-        return (endpoint != null && endpoint.getTenant() != null && 
+        return (endpoint != null && endpoint.getTenant() != null &&
                 endpoint.getEndpointGroup() != null &&
-                endpoint.getL2Context() != null &&
-                endpoint.getMacAddress() != null);
+                endpoint.getL2Context() != null && endpoint.getMacAddress() != null);
     }
-    
+
     private NodeId getLocation(Endpoint endpoint) {
-        if (!validEp(endpoint)) 
+        if (!validEp(endpoint))
             return null;
-        OfOverlayContext context = 
+        OfOverlayContext context =
                 endpoint.getAugmentation(OfOverlayContext.class);
         if (context != null)
             return context.getNodeId();
 
         return null;
     }
-    
+
     private EpKey getEpKey(Endpoint endpoint) {
-        if (!validEp(endpoint)) 
+        if (!validEp(endpoint))
             return null;
         return new EpKey(endpoint.getL2Context(), endpoint.getMacAddress());
     }
-    
+
     private EgKey getEgKey(Endpoint endpoint) {
-        if (!validEp(endpoint)) 
+        if (!validEp(endpoint))
             return null;
         return new EgKey(endpoint.getTenant(), endpoint.getEndpointGroup());
     }
-    
+
     private Set<EpKey> getEpNGSet(NodeId location, EgKey eg) {
         ConcurrentMap<EgKey, Set<EpKey>> map = endpointsByNode.get(location);
         if (map == null) {
             map = new ConcurrentHashMap<>();
-            ConcurrentMap<EgKey, Set<EpKey>> old = 
+            ConcurrentMap<EgKey, Set<EpKey>> old =
                     endpointsByNode.putIfAbsent(location, map);
             if (old != null)
                 map = old;
         }
         return SetUtils.getNestedSet(eg, map);
     }
-    
+
     private static final ConcurrentMap<EgKey, Set<EpKey>> EMPTY_MAP =
             new ConcurrentHashMap<>();
 
     private Set<EpKey> getEpGSet(EgKey eg) {
         return SetUtils.getNestedSet(eg, endpointsByGroup);
     }
-    
+
     /**
-     * Update the endpoint indexes.  Set newEp to null to remove.
+     * Update the endpoint indexes. Set newEp to null to remove.
      */
     protected void updateEndpoint(Endpoint oldEp, Endpoint newEp) {
-        // XXX TODO only keep track of endpoints that are attached 
+        // XXX TODO only keep track of endpoints that are attached
         // to switches that are actually connected to us
         NodeId oldLoc = getLocation(oldEp);
         NodeId newLoc = getLocation(newEp);
@@ -516,21 +544,23 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
         EgKey newKey = getEgKey(newEp);
 
         EpKey epKey = getEpKey(oldEp);
-        if (epKey == null) epKey = getEpKey(newEp);
-        if (epKey == null) return;
+        if (epKey == null)
+            epKey = getEpKey(newEp);
+        if (epKey == null)
+            return;
 
         boolean notifyOldLoc = false;
         boolean notifyNewLoc = false;
         boolean notifyOldEg = false;
         boolean notifyNewEg = false;
-        
+
         if (newEp != null)
             endpoints.put(epKey, newEp);
 
         if (oldLoc != null && oldKey != null &&
-            (newLoc == null || !oldLoc.equals(newLoc) ||
-            newKey == null || !oldKey.equals(newKey))) {
-            ConcurrentMap<EgKey, Set<EpKey>> map = 
+                (newLoc == null || !oldLoc.equals(newLoc) ||
+                        newKey == null || !oldKey.equals(newKey))) {
+            ConcurrentMap<EgKey, Set<EpKey>> map =
                     endpointsByNode.get(oldLoc);
             Set<EpKey> eps = map.get(oldKey);
             eps.remove(epKey);
@@ -539,7 +569,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
             notifyOldLoc = true;
         }
         if (oldKey != null &&
-            (newKey == null || !oldKey.equals(newKey))) {
+                (newKey == null || !oldKey.equals(newKey))) {
             Set<EpKey> gns = getEpGSet(oldKey);
             gns.remove(epKey);
             notifyOldEg = true;
@@ -560,13 +590,13 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
 
         if (newEp == null)
             endpoints.remove(epKey);
-        
+
         notifyEndpointUpdated(epKey);
 
         if (notifyOldLoc)
-            notifyNodeEndpointUpdated(oldLoc,epKey);
+            notifyNodeEndpointUpdated(oldLoc, epKey);
         if (notifyNewLoc)
-            notifyNodeEndpointUpdated(newLoc,epKey);
+            notifyNodeEndpointUpdated(newLoc, epKey);
         if (notifyOldEg)
             notifyGroupEndpointUpdated(oldKey, epKey);
         if (notifyNewEg)
@@ -574,21 +604,21 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
     }
 
     private OfOverlayContextBuilder checkAugmentation(RegisterEndpointInput input) {
-        OfOverlayContextBuilder ictxBuilder=new OfOverlayContextBuilder();
-        OfOverlayContextInput ictx =null;
+        OfOverlayContextBuilder ictxBuilder = new OfOverlayContextBuilder();
+        OfOverlayContextInput ictx = null;
 
         ictx = input.getAugmentation(OfOverlayContextInput.class);
-        if(ictx!=null) {
+        if (ictx != null) {
             ictxBuilder.setNodeConnectorId(ictx.getNodeConnectorId());
             ictxBuilder.setNodeId(ictx.getNodeId());
-        } else if(input.getPortName()!=null) {
+        } else if (input.getPortName() != null) {
             NodeInfo augmentation = fetchAugmentation(input.getPortName().getValue());
-            if(augmentation != null) {
+            if (augmentation != null) {
                 ictxBuilder.setNodeId(augmentation.getNode().getId());
                 ictxBuilder.setNodeConnectorId(augmentation.getNodeConnector().getId());
             }
         } else {
-            ictxBuilder=null;
+            ictxBuilder = null;
         }
         return ictxBuilder;
     }
@@ -626,7 +656,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
     }
 
     private NodeInfo fetchAugmentation(String portName) {
-        NodeInfo nodeInfo=null;
+        NodeInfo nodeInfo = null;
 
         if (dataProvider != null) {
 
@@ -644,21 +674,22 @@ public class EndpointManager implements AutoCloseable, DataChangeListener
                                 FlowCapableNodeConnector fcnc = nc
                                         .getAugmentation(FlowCapableNodeConnector.class);
                                 if (fcnc.getName().equals(portName)) {
-                                    nodeInfo=new NodeInfo();
+                                    nodeInfo = new NodeInfo();
                                     nodeInfo.setNode(node);
                                     nodeInfo.setNodeConnector(nc);
-                                    found=true;
+                                    found = true;
                                     break;
                                 }
                             }
-                            if(found) break;
+                            if (found)
+                                break;
                         }
                     }
                 }
             } catch (InterruptedException | ExecutionException e) {
-                LOG.error("Could not fetch Node Augmentation",e);
+                LOG.error("Could not fetch Node Augmentation", e);
             }
-         
+
         }
         return nodeInfo;
     }
index 19e65df353933ea11cc37eff3fb31a71622d8f06..0f014b6a745e3145478edc54e2a3c0cfcd1a85c5 100644 (file)
@@ -47,12 +47,12 @@ module ofoverlay {
         }
 
         leaf learning-mode {
-            description 
+            description
                 "Selects how and whether we learn endpoints";
             type enumeration {
                 enum orchestrated {
-                    description 
-                        "An external orchestration system will provide 
+                    description
+                        "An external orchestration system will provide
                          information about all endpoints, and no
                          direct learning will occur.";
                 }
@@ -61,13 +61,13 @@ module ofoverlay {
     }
     /*
     container of-overlay-operational {
-        description 
+        description
             "Operational parameters for the OpenFlow overlay renderer";
 
         config false;
 
         list data-plane-ordinal {
-            description 
+            description
                 "Map elements of the policy to the id used on the network";
             key "tenant id";
             leaf tenant {
@@ -86,7 +86,7 @@ module ofoverlay {
     }
     */
     grouping endpoint-location {
-        description 
+        description
             "The location for this endpoint in the overlay network";
 
         leaf location-type {
@@ -94,8 +94,8 @@ module ofoverlay {
 
             type enumeration {
                 enum internal {
-                    description 
-                    "The endpoint is located on a port that is part of 
+                    description
+                    "The endpoint is located on a port that is part of
                      the overlay network.  You must include the node
                      ID and port number for this endpoint.";
                 }
@@ -106,8 +106,8 @@ module ofoverlay {
         }
 
         leaf node-id {
-            description 
-                "The OpenFlow switch for the endpoint. Must be included 
+            description
+                "The OpenFlow switch for the endpoint. Must be included
                  for all internal endpoints.  The format is
                  openflow:[dpid] where the dpid is the value of the
                  switch DPID cast to a long.";
@@ -115,8 +115,8 @@ module ofoverlay {
         }
 
         leaf node-connector-id {
-            description 
-                "The node connector for the endpoint's OpenFlow port. The 
+            description
+                "The node connector for the endpoint's OpenFlow port. The
                  format is openflow:[dpid]:[port] where the dpid is
                  the value of the switch DPID cast to a long, and port
                  is the openflow port number of the interface where
@@ -139,27 +139,27 @@ module ofoverlay {
         ext:augment-identifier "of-overlay-node-config";
 
         leaf tunnel-ip {
-            description 
+            description
                 "The IP address used for tunnel termination on this switch";
             type inet:ip-address;
         }
         container ovsdb-config {
             leaf ip {
-                description 
+                description
                     "The IP address used to connect to OVSDB on this switch";
                 type inet:ip-address;
             }
             leaf port {
-                description 
+                description
                     "The port number used to connect to OVSDB on this switch";
                 type inet:port-number;
                 default 6640;
             }
         }
         leaf-list external-interfaces {
-            description 
-                "The names of the OpenFlow interfaces that are external and 
-                 lead to the underlay network.  Can be specified as a 
+            description
+                "The names of the OpenFlow interfaces that are external and
+                 lead to the underlay network.  Can be specified as a
                  regular expression.";
             type string;
         }
index 7e55de8772d9f0a1309481c5c9fc31bf5e6fff19..b4372da9aa7faa2c892d890e7f211caa94c85ae2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -69,15 +69,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Keep track of endpoints on the system. Maintain an index of endpoints
- * and their locations for queries from agents. The endpoint manager will maintain
+ * Keep track of endpoints on the system. Maintain an index of endpoints and
+ * their locations for queries from agents. The endpoint manager will maintain
  * appropriate indexes only for agents that are attached to the current
- * controller node.
- * In order to render the policy, we need to be able to efficiently enumerate
- * all endpoints on a particular agent and also all the agents containing
- * each particular endpoint group
- * 
- * @author tbachman
+ * controller node. In order to render the policy, we need to be able to
+ * efficiently enumerate all endpoints on a particular agent and also all the
+ * agents containing each particular endpoint group
+ *
  */
 public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBroker.RpcCallback,
         EprContext.EprCtxCallback {
@@ -85,11 +83,11 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
     protected static final Logger LOG = LoggerFactory.getLogger(EndpointManager.class);
 
     private static final InstanceIdentifier<Endpoint> endpointsIid = InstanceIdentifier.builder(Endpoints.class)
-        .child(Endpoint.class)
-        .build();
+            .child(Endpoint.class)
+            .build();
     private static final InstanceIdentifier<EndpointL3> endpointsL3Iid = InstanceIdentifier.builder(Endpoints.class)
-        .child(EndpointL3.class)
-        .build();
+            .child(EndpointL3.class)
+            .build();
 
     final ListenerRegistration<DataChangeListener> listenerReg;
     final ListenerRegistration<DataChangeListener> listenerL3Reg;
@@ -153,8 +151,9 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
 
     /**
      * Get the endpoint object for the given key
-     * 
-     * @param epKey the key
+     *
+     * @param epKey
+     *            the key
      * @return the {@link Endpoint} corresponding to the key
      */
     public Endpoint getEndpoint(EpKey epKey) {
@@ -180,8 +179,9 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
 
         @Override
         public void buildL3PrefixEndpointAugmentation(EndpointL3PrefixBuilder eb, RegisterL3PrefixEndpointInput input) {
-            // TODO These methods will be replaced by getAugmentation and augmentation applied at caller.
-            
+            // TODO These methods will be replaced by getAugmentation and
+            // augmentation applied at caller.
+
         }
     }
 
@@ -259,9 +259,9 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
         Identity oldId = getIdentity(oldEp);
         Identity newId = getIdentity(newEp);
         /*
-         * If an endpoint has changed, we need to provide notifications
-         * to agents that have subscribed to that endpoint. Batch up
-         * the notifications to be sent to the agents.
+         * If an endpoint has changed, we need to provide notifications to
+         * agents that have subscribed to that endpoint. Batch up the
+         * notifications to be sent to the agents.
          */
         Queue<EndpointUpdate> updateQ = new ConcurrentLinkedQueue<EndpointUpdate>();
 
@@ -359,8 +359,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
     }
 
     /**
-     * Create an Endpoint Registry Context for an OpFlex
-     * Request message.
+     * Create an Endpoint Registry Context for an OpFlex Request message.
      *
      * @param agent
      * @param request
@@ -376,8 +375,8 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
         if (message instanceof EndpointDeclareRequest) {
             EndpointDeclareRequest request = (EndpointDeclareRequest) message;
             /*
-             * There theoretically could be a list of parameters,
-             * but we'll likely only ever see one element.
+             * There theoretically could be a list of parameters, but we'll
+             * likely only ever see one element.
              */
             ec = new EprContext(agent, request, dataProvider, executor);
             for (EndpointDeclareRequest.Params params : request.getParams()) {
@@ -385,9 +384,9 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
                 int prr = params.getPrr();
 
                 /*
-                 * We have a list of endpoints, so iterate through the
-                 * list and register each one, extracting the identities
-                 * for registration.
+                 * We have a list of endpoints, so iterate through the list and
+                 * register each one, extracting the identities for
+                 * registration.
                  */
                 List<ManagedObject> endpoints = params.getEndpoint();
                 if (endpoints != null) {
@@ -417,9 +416,9 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
             ec = new EprContext(agent, request, dataProvider, executor);
             for (EndpointResolveRequest.Params params : request.getParams()) {
                 /*
-                 * The resolve message contains either the URI
-                 * or a context/URI and an identifier. There is only
-                 * one of these per param array entry.
+                 * The resolve message contains either the URI or a context/URI
+                 * and an identifier. There is only one of these per param array
+                 * entry.
                  */
                 EndpointIdentity eid = params.getEndpoint_ident();
 
@@ -432,8 +431,7 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
 
                 } else {
                     /*
-                     * Extract the list to add the EP to from
-                     * the URI
+                     * Extract the list to add the EP to from the URI
                      */
                     Uri uri = params.getEndpoint_uri();
                     if (uri != null) {
@@ -466,13 +464,14 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
     }
 
     /**
-     * This notification handles the OpFlex Endpoint messages.
-     * We should only receive request messages. Responses are
-     * sent in a different context, as all requests result
-     * in a Future to access the data store.
+     * This notification handles the OpFlex Endpoint messages. We should only
+     * receive request messages. Responses are sent in a different context, as
+     * all requests result in a Future to access the data store.
      *
-     * @param agent The JsonRpcEndpoint that received the request
-     * @param request The request message from the endpoint
+     * @param agent
+     *            The JsonRpcEndpoint that received the request
+     * @param request
+     *            The request message from the endpoint
      */
     @Override
     public void callback(JsonRpcEndpoint agent, RpcMessage request) {
@@ -483,9 +482,9 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
         }
 
         /*
-         * For declaration requests, we need to make sure that this
-         * EP is in our registry. Since we can have multiple identifiers,
-         * we create a Set of endpoints.
+         * For declaration requests, we need to make sure that this EP is in our
+         * registry. Since we can have multiple identifiers, we create a Set of
+         * endpoints.
          */
 
         if (request instanceof EndpointDeclareRequest) {
@@ -502,16 +501,15 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
             }
 
             /*
-             * OpFlex EP declaration/registration is different from
-             * REST EP declaration/registration -- REST only allows
-             * a single EP to be registered at a time. Since each MO
-             * represents an Endpoint that's being declared, we need
-             * add each one up separately,yet provide a single response.
-             * We also want to know the result of the registration so
-             * we can provide the appropriate response. We create a
-             * context for the Endpoint Registry interaction, where
-             * we can track the status of all the EP registrations,
-             * and provide a response when all have completed.
+             * OpFlex EP declaration/registration is different from REST EP
+             * declaration/registration -- REST only allows a single EP to be
+             * registered at a time. Since each MO represents an Endpoint that's
+             * being declared, we need add each one up separately,yet provide a
+             * single response. We also want to know the result of the
+             * registration so we can provide the appropriate response. We
+             * create a context for the Endpoint Registry interaction, where we
+             * can track the status of all the EP registrations, and provide a
+             * response when all have completed.
              */
             EprContext ctx = create(agent, req, dataProvider, executor);
             ctx.setCallback(this);
@@ -530,16 +528,15 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
             }
 
             /*
-             * OpFlex EP undeclaration/unregistration is different from
-             * REST EP declaration/registration -- REST only allows
-             * a single EP to be unregistered at a time. Since each MO
-             * represents an Endpoint that's being undeclared, we need
-             * add each one up separately,yet provide a single response.
-             * We also want to know the result of the unregistration so
-             * we can provide the appropriate response. We create a
-             * context for the Endpoint Registry interaction, where
-             * we can track the status of all the EP unregistrations,
-             * and provide a response when all have completed.
+             * OpFlex EP undeclaration/unregistration is different from REST EP
+             * declaration/registration -- REST only allows a single EP to be
+             * unregistered at a time. Since each MO represents an Endpoint
+             * that's being undeclared, we need add each one up separately,yet
+             * provide a single response. We also want to know the result of the
+             * unregistration so we can provide the appropriate response. We
+             * create a context for the Endpoint Registry interaction, where we
+             * can track the status of all the EP unregistrations, and provide a
+             * response when all have completed.
              */
             EprContext ctx = create(agent, req, dataProvider, executor);
             ctx.setCallback(this);
@@ -565,8 +562,8 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
                 ctx.lookupEndpoint();
 
                 /*
-                 * A request is effectively a subscription. Add this agent
-                 * to the set of listeners.
+                 * A request is effectively a subscription. Add this agent to
+                 * the set of listeners.
                  */
                 Identity id = null;
                 if (param.getEndpoint_ident() != null) {
@@ -593,8 +590,8 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
 
             for (EndpointUnresolveRequest.Params param : params) {
                 /*
-                 * No interaction with the Data Store is required -- just
-                 * cancel the notification subscription for this EP..
+                 * No interaction with the Data Store is required -- just cancel
+                 * the notification subscription for this EP..
                  */
                 Identity id = null;
                 if (param.getEndpoint_ident() != null) {
@@ -610,8 +607,8 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
             }
 
             /*
-             * No EprContext is used in unresolve -- so
-             * just send the response directly
+             * No EprContext is used in unresolve -- so just send the response
+             * directly
              */
             EndpointUnresolveResponse resp = new EndpointUnresolveResponse();
             EndpointUnresolveResponse.Result result = new EndpointUnresolveResponse.Result();
@@ -652,11 +649,10 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
     }
 
     /**
-     * This notification handles the callback from an interaction
-     * with the Endpoint Registry. The context for the callback
-     * is a notification from the data store, so so the code
-     * has to ensure that it won't block. Responses are sent
-     * using an executor
+     * This notification handles the callback from an interaction with the
+     * Endpoint Registry. The context for the callback is a notification from
+     * the data store, so so the code has to ensure that it won't block.
+     * Responses are sent using an executor
      */
     @Override
     public void callback(EprContext ctx) {
@@ -696,11 +692,10 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
             if (ctx.getOperations().size() > 0) {
 
                 /*
-                 * If we get any EP, then we can
-                 * provide a response to the original request
-                 * Note that we could potentially have multiple
-                 * requests outstanding for the same EP, and
-                 * even using different context types (L2 or L3).
+                 * If we get any EP, then we can provide a response to the
+                 * original request Note that we could potentially have multiple
+                 * requests outstanding for the same EP, and even using
+                 * different context types (L2 or L3).
                  */
                 for (EprOperation op : ctx.getOperations()) {
 
@@ -709,10 +704,10 @@ public class EndpointManager implements AutoCloseable, DataChangeListener, RpcBr
                         epList.add(mo);
                     }
                     /*
-                     * For EPs on a different agent, we need to look up the
-                     * VTEP information. For now, we're only supporting
-                     * VXLAN VTEPs, so we look up the destination tunnel IP,
-                     * and provide that in the data field of the response
+                     * For EPs on a different agent, we need to look up the VTEP
+                     * information. For now, we're only supporting VXLAN VTEPs,
+                     * so we look up the destination tunnel IP, and provide that
+                     * in the data field of the response
                      */
                     // TODO: Need to look this up in op store
                     // endpoint.setData();
index 0611a8e30933cef55d6b5b0ffba4101b8c487d44..9ab38a384a939d7d99f451d12f8294a12c930405 100644 (file)
@@ -25,7 +25,7 @@ module opflex {
         description
             "Initial revision.";
     }
-    
+
     typedef serialization {
         description
             "The serialization to use for OpFlex messages.";
@@ -56,9 +56,9 @@ module opflex {
         leaf domain {
             description
                 "The OpFlex administrative domain.";
-    
+
             config true;
-    
+
             type string;
         }
 
@@ -70,17 +70,17 @@ module opflex {
             key "id";
 
             leaf id {
-                description 
+                description
                    "The id for the policy repository.";
                 type string;
             }
             leaf port {
-                description 
+                description
                    "The port number to use for the connection";
                 type int32;
             }
             leaf serialization-type {
-                description 
+                description
                     "The serialization to use for this connection.";
                 type serialization;
             }
@@ -94,17 +94,17 @@ module opflex {
             key "id";
 
             leaf id {
-                description 
+                description
                    "The id for the endpoint registry.";
                 type string;
             }
             leaf port {
-                description 
+                description
                    "The port number to use for the connection";
                 type int32;
             }
             leaf serialization-type {
-                description 
+                description
                     "The serialization to use for this connection.";
                 type serialization;
             }
@@ -118,17 +118,17 @@ module opflex {
             key "id";
 
             leaf id {
-                description 
+                description
                    "The id for the Observer.";
                 type string;
             }
             leaf port {
-                description 
+                description
                    "The port number to use for the connection";
                 type int32;
             }
             leaf serialization-type {
-                description 
+                description
                     "The serialization to use for this connection.";
                 type serialization;
             }
@@ -136,7 +136,7 @@ module opflex {
     }
 
     grouping endpoint-location {
-        description 
+        description
             "The location for this endpoint in the overlay network";
 
         leaf location-type {
@@ -144,8 +144,8 @@ module opflex {
 
             type enumeration {
                 enum internal {
-                    description 
-                    "The endpoint is located on a port that is part of 
+                    description
+                    "The endpoint is located on a port that is part of
                      the overlay network.  You must include the node
                      ID and port number for this endpoint.";
                 }
@@ -155,14 +155,14 @@ module opflex {
             }
         }
         leaf agent-id {
-            description 
-                "The OpFlex agent where the endpoing is located. Must be included 
+            description
+                "The OpFlex agent where the endpoing is located. Must be included
                  for all internal endpoints.  The format is the agent identifier,
                  which is an IP address or DNS name ':' port number.";
             type string;
         }
         leaf agent-ep-location {
-            description 
+            description
                 "The location of the endpoint on the OpFlex agent. The format of
                  this is dependent on the renderer used by the agent.";
             type string;