Merge "Change target to ${project.build.target} in a bunch of pom file. Add some...
authorGiovanni Meo <gmeo@cisco.com>
Thu, 23 Jan 2014 09:05:39 +0000 (09:05 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 23 Jan 2014 09:05:39 +0000 (09:05 +0000)
86 files changed:
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java
opendaylight/commons/opendaylight/pom.xml
opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/AbstractSessionNegotiator.java
opendaylight/commons/protocol-framework/src/main/java/org/opendaylight/protocol/framework/ProtocolSessionPromise.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DestroyedModule.java
opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownServiceImpl.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlFilePersister.java
opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java
opendaylight/configuration/implementation/src/main/java/org/opendaylight/controller/configuration/internal/ConfigurationService.java
opendaylight/configuration/implementation/src/main/java/org/opendaylight/controller/configuration/internal/ContainerConfigurationService.java
opendaylight/containermanager/implementation/src/main/java/org/opendaylight/controller/containermanager/internal/ContainerManager.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/internal/StaticRoutingImplementation.java
opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java
opendaylight/logging/bridge/src/main/java/org/opendaylight/controller/logging/bridge/internal/Activator.java
opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreImpl.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.xtend
opendaylight/md-sal/model/model-flow-base/pom.xml
opendaylight/md-sal/model/model-flow-management/pom.xml
opendaylight/md-sal/model/model-flow-service/pom.xml
opendaylight/md-sal/model/model-flow-statistics/pom.xml
opendaylight/md-sal/model/pom.xml
opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/RpcProviderRegistry.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/RuntimeGeneratedMappingServiceImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/TransformerGenerator.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/service/AbstractDataBroker.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/SchemaServiceImplSingletonModule.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/SchemaServiceImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/NotificationRouterImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProviders.java [new file with mode: 0644]
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfRemoteSchemaSourceProvider.java
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend
opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/toaster/provider/impl/ToastConsumerImpl.java
opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatistics.java [deleted file]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsAger.java [new file with mode: 0644]
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsManagerActivator.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsProvider.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateCommiter.java
opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateHandler.java [new file with mode: 0644]
opendaylight/md-sal/test/sal-rest-connector-it/pom.xml
opendaylight/md-sal/topology-lldp-discovery/pom.xml
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Commit.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/DiscardChanges.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/Validate.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/MissingInstanceHandlingStrategy.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPersisterNotificationHandler.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchema.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStartExi.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultStopExi.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/osgi/NetconfSSHActivator.java
opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/SocketThread.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/SendErrorExceptionUtil.java
opendaylight/northbound/bundlescanner/implementation/src/main/java/org/opendaylight/controller/northbound/bundlescanner/internal/BundleScanner.java
opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/utils/NorthboundUtils.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java
opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/ConfigManager.java
opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/LBUtil.java
opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/internal/LoadBalancerService.java
opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/policies/RandomLBPolicy.java
opendaylight/samples/loadbalancer/src/main/java/org/opendaylight/controller/samples/loadbalancer/policies/RoundRobinLBPolicy.java
opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/SimpleForwardingImpl.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java
opendaylight/usermanager/implementation/src/main/java/org/opendaylight/controller/usermanager/internal/UserManager.java
opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebUtil.java

index 65e7720..83db414 100644 (file)
@@ -69,7 +69,7 @@ public class ClusterManager implements IClusterServices {
     private ViewChangedListener cacheManagerListener;
 
     private static String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress();
-
+    private static final int gossipRouterPortDefault = 12001;
     // defaultTransactionTimeout is 60 seconds
     private static int DEFAULT_TRANSACTION_TIMEOUT = 60;
 
@@ -91,12 +91,11 @@ public class ClusterManager implements IClusterServices {
      */
     private GossipRouter startGossiper() {
         boolean amIGossipRouter = false;
-        Integer gossipRouterPortDefault = 12001;
         Integer gossipRouterPort = gossipRouterPortDefault;
         InetAddress gossipRouterAddress = null;
         String supernodes_list = System.getProperty("supernodes",
                 loopbackAddress);
-        StringBuffer sanitized_supernodes_list = new StringBuffer();
+        StringBuilder sanitized_supernodes_list = new StringBuilder();
         List<InetAddress> myAddresses = new ArrayList<InetAddress>();
 
         StringTokenizer supernodes = new StringTokenizer(supernodes_list, ":");
@@ -135,7 +134,7 @@ public class ClusterManager implements IClusterServices {
             try {
                 hostAddr = InetAddress.getByName(host);
             } catch (UnknownHostException ue) {
-                logger.error("Host not known");
+                logger.error("Host {} is not known", host);
                 continue;
             }
             if (host_port.hasMoreTokens()) {
@@ -143,13 +142,12 @@ public class ClusterManager implements IClusterServices {
                 try {
                     port_num = Integer.valueOf(port);
                 } catch (NumberFormatException ne) {
-                    logger
-                            .error("Supplied supernode gossiepr port is not recognized, using standard gossipport");
+                    logger.error("Supplied supernode gossip port is not recognized, using default gossip port {}",
+                                 gossipRouterPortDefault);
                     port_num = gossipRouterPortDefault;
                 }
                 if ((port_num > 65535) || (port_num < 0)) {
-                    logger
-                            .error("Supplied supernode gossip port is outside a valid TCP port range");
+                    logger.error("Supplied supernode gossip port is outside a valid TCP port range");
                     port_num = gossipRouterPortDefault;
                 }
             }
@@ -168,8 +166,7 @@ public class ClusterManager implements IClusterServices {
             if (!sanitized_supernodes_list.toString().equals("")) {
                 sanitized_supernodes_list.append(",");
             }
-            sanitized_supernodes_list.append(hostAddr.getHostAddress() + "["
-                    + port_num + "]");
+            sanitized_supernodes_list.append(hostAddr.getHostAddress()).append("[").append(port_num).append("]");
         }
 
         if (amIGossipRouter) {
index 3eba5f0..64c873b 100644 (file)
@@ -62,8 +62,8 @@
     <ietf-inet-types.version>2010.09.24.2-SNAPSHOT</ietf-inet-types.version>
     <ietf-yang-types.version>2010.09.24.2-SNAPSHOT</ietf-yang-types.version>
     <ietf-topology.version>2013.10.21.0-SNAPSHOT</ietf-topology.version>
-    <opendaylight-l2-types.version>2013.08.27.1</opendaylight-l2-types.version>
-    <yang-ext.version>2013.09.07.1</yang-ext.version>
+    <opendaylight-l2-types.version>2013.08.27.2-SNAPSHOT</opendaylight-l2-types.version>
+    <yang-ext.version>2013.09.07.2-SNAPSHOT</yang-ext.version>
     <javassist.version>3.17.1-GA</javassist.version>
     <sample-toaster.version>1.0-SNAPSHOT</sample-toaster.version>
     <releaseplugin.version>2.3.2</releaseplugin.version>
index 9ecfb1b..9f9f811 100644 (file)
@@ -56,7 +56,7 @@ public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSes
         try {
             startNegotiation();
         } catch (Exception e) {
-            logger.info("Unexpected negotiation failure", e);
+            logger.warn("Unexpected negotiation failure", e);
             negotiationFailed(e);
         }
     }
@@ -67,8 +67,14 @@ public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSes
         try {
             handleMessage((M)msg);
         } catch (Exception e) {
-            logger.debug("Unexpected exception during negotiation", e);
+            logger.debug("Unexpected error while handling negotiation message {}", msg, e);
             negotiationFailed(e);
         }
     }
+
+    @Override
+    public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
+        logger.info("Unexpected error during negotiation", cause);
+        negotiationFailed(cause);
+    }
 }
index c54bf84..67cf07c 100644 (file)
@@ -82,7 +82,7 @@ final class ProtocolSessionPromise<S extends ProtocolSession<?>> extends Default
                         }
 
                         if (!cf.isSuccess()) {
-                            LOG.info("Attempt to connect to connect to {} failed", ProtocolSessionPromise.this.address, cf.cause());
+                            LOG.warn("Attempt to connect to connect to {} failed", ProtocolSessionPromise.this.address, cf.cause());
                             final Future<Void> rf = ProtocolSessionPromise.this.strategy.scheduleReconnect(cf.cause());
                             rf.addListener(new FutureListener<Void>() {
                                 @Override
index 1923170..a8406b0 100644 (file)
@@ -182,7 +182,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             throws ConflictingVersionException, ValidationException {
         final String transactionName = ObjectNameUtil
                 .getTransactionName(transactionControllerON);
-        logger.info("About to commit {}. Current parentVersion: {}, versionCounter {}", transactionName, version, versionCounter);
+        logger.trace("About to commit {}. Current parentVersion: {}, versionCounter {}", transactionName, version, versionCounter);
 
         // find ConfigTransactionController
         Map<String, ConfigTransactionControllerInternal> transactions = transactionsHolder.getCurrentTransactions();
index e0d1a42..90d2cb4 100644 (file)
@@ -306,7 +306,7 @@ class ConfigTransactionControllerImpl implements
 
     private void validate_noLocks() throws ValidationException {
         transactionStatus.checkNotAborted();
-        logger.info("Validating transaction {}", getTransactionIdentifier());
+        logger.trace("Validating transaction {}", getTransactionIdentifier());
         // call validate()
         List<ValidationException> collectedExceptions = new ArrayList<>();
         for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager
@@ -326,7 +326,7 @@ class ConfigTransactionControllerImpl implements
             throw ValidationException
                     .createFromCollectedValidationExceptions(collectedExceptions);
         }
-        logger.info("Validated transaction {}", getTransactionIdentifier());
+        logger.trace("Validated transaction {}", getTransactionIdentifier());
     }
 
     /**
@@ -345,7 +345,7 @@ class ConfigTransactionControllerImpl implements
         try {
             validate_noLocks();
         } catch (ValidationException e) {
-            logger.info("Commit failed on validation");
+            logger.trace("Commit failed on validation");
             configBeanModificationDisabled.set(false); // recoverable error
             throw e;
         }
@@ -368,7 +368,7 @@ class ConfigTransactionControllerImpl implements
                             + "to obtain a lock");
         }
 
-        logger.info("Committing transaction {}", getTransactionIdentifier());
+        logger.trace("Committing transaction {}", getTransactionIdentifier());
 
         // call getInstance()
         for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager
@@ -391,7 +391,7 @@ class ConfigTransactionControllerImpl implements
 
         // count dependency order
 
-        logger.info("Committed configuration {}", getTransactionIdentifier());
+        logger.trace("Committed configuration {}", getTransactionIdentifier());
         transactionStatus.setCommitted();
         // unregister this and all modules from jmx
         close();
index 682d4a1..e4652c9 100644 (file)
@@ -43,7 +43,7 @@ public class DestroyedModule implements AutoCloseable,
 
     @Override
     public void close() {
-        logger.info("Destroying {}", identifier);
+        logger.trace("Destroying {}", identifier);
         try {
             instance.close();
         } catch (Exception e) {
index 6cdcf60..584ea17 100644 (file)
@@ -138,7 +138,7 @@ class CallSystemExitThread extends Thread {
             logger.warn("Thread dump:{}", sb);
             System.exit(1);
         } catch (InterruptedException e) {
-            logger.info("Interrupted, not going to call System.exit(1)");
+            logger.warn("Interrupted, not going to call System.exit(1)");
         }
     }
 }
index f721895..d6d3893 100644 (file)
@@ -83,12 +83,12 @@ public class FtlFilePersister {
                 pathToFile.mkdirs();
             }
             if (targetFile.exists() && overwrite == false) {
-                logger.info("Skipping {} since it already exists", targetFile);
+                logger.trace("Skipping {} since it already exists", targetFile);
             } else {
                 try (Writer fileWriter = new FileWriter(targetFile)) {
                     fileWriter.write(entry.getValue());
                 }
-                logger.info("{}: File {} generated successfully",
+                logger.trace("{}: File {} generated successfully",
                         JMXGenerator.class.getCanonicalName(), targetFile);
                 result.add(targetFile);
             }
index b5efc51..74a36c5 100644 (file)
@@ -136,7 +136,7 @@ public class ExtenderYangTracker extends BundleTracker<Object> implements YangSt
 
         updateCache(snapshot);
         cache.setInconsistentURLsForReporting(Collections.<URL> emptySet());
-        logger.info("Yang store updated to new consistent state containing {} yang files", consistentBundlesToYangURLs.size());
+        logger.trace("Yang store updated to new consistent state containing {} yang files", consistentBundlesToYangURLs.size());
         logger.debug("Yang store updated to new consistent state containing {}", consistentBundlesToYangURLs);
     }
 
index ce2aaea..e6bbcf8 100644 (file)
@@ -99,7 +99,7 @@ public class ConfigurationService implements IConfigurationService, ICacheUpdate
             Status status = configurationAware.saveConfiguration();
             if (!status.isSuccess()) {
                 success = false;
-                logger.info("Failed to save config for {}",
+                logger.warn("Failed to save config for {}",
                         configurationAware.getClass().getName());
             }
         }
index d476901..5f1db6b 100644 (file)
@@ -96,12 +96,12 @@ public class ContainerConfigurationService implements IConfigurationContainerSer
     public Status saveConfiguration() {
         boolean success = true;
         for (IConfigurationContainerAware configurationAware : configurationAwareList) {
-            logger.info("Save Config triggered for {}", configurationAware.getClass().getSimpleName());
+            logger.trace("Save Config triggered for {}", configurationAware.getClass().getSimpleName());
 
             Status status = configurationAware.saveConfiguration();
             if (!status.isSuccess()) {
                 success = false;
-                logger.info("Failed to save config for {}", configurationAware.getClass().getSimpleName());
+                logger.warn("Failed to save config for {}", configurationAware.getClass().getSimpleName());
             }
         }
         if (success) {
index d9e941e..e096c73 100644 (file)
@@ -896,7 +896,7 @@ public class ContainerManager extends Authorization<String> implements IContaine
      */
     private void notifyContainerModeChange(boolean lastActionDelete, boolean notifyLocal) {
         if (lastActionDelete == false && containerConfigs.size() == 1) {
-            logger.info("First container Creation. Inform listeners");
+            logger.trace("First container Creation. Inform listeners");
             synchronized (this.iContainerListener) {
                 for (IContainerListener i : this.iContainerListener) {
                     i.containerModeUpdated(UpdateType.ADDED);
@@ -910,7 +910,7 @@ public class ContainerManager extends Authorization<String> implements IContaine
                 }
             }
         } else if (lastActionDelete == true && containerConfigs.isEmpty()) {
-            logger.info("Last container Deletion. Inform listeners");
+            logger.trace("Last container Deletion. Inform listeners");
             synchronized (this.iContainerListener) {
                 for (IContainerListener i : this.iContainerListener) {
                     i.containerModeUpdated(UpdateType.REMOVED);
index e6651b8..fe00b77 100644 (file)
@@ -143,7 +143,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify, IForwarding
     @SuppressWarnings("deprecation")
     private void allocateCaches() {
         if (this.clusterContainerService == null) {
-            log.info("un-initialized clusterContainerService, can't create cache");
+            log.trace("un-initialized clusterContainerService, can't create cache");
             return;
         }
 
@@ -162,7 +162,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify, IForwarding
     @SuppressWarnings({ "unchecked", "deprecation" })
     private void retrieveCaches() {
         if (this.clusterContainerService == null) {
-            log.info("un-initialized clusterContainerService, can't retrieve cache");
+            log.warn("un-initialized clusterContainerService, can't retrieve cache");
             return;
         }
 
@@ -181,7 +181,7 @@ public class StaticRoutingImplementation implements IfNewHostNotify, IForwarding
 
     private void notifyStaticRouteUpdate(StaticRoute s, boolean update) {
         if (this.staticRoutingAware != null) {
-            log.info("Invoking StaticRoutingAware listeners");
+            log.trace("Invoking StaticRoutingAware listeners");
             synchronized (this.staticRoutingAware) {
                 for (IStaticRoutingAware ra : this.staticRoutingAware) {
                     try {
index 21b747b..fc5aac0 100644 (file)
@@ -467,7 +467,7 @@ public class ForwardingRulesManager implements
         Status succeeded = null;
         boolean decouple = false;
         if (installedList.size() != toInstallList.size()) {
-            log.info("Modify: New flow entry does not satisfy the same "
+            log.trace("Modify: New flow entry does not satisfy the same "
                     + "number of container flows as the original entry does");
             decouple = true;
         }
@@ -479,7 +479,7 @@ public class ForwardingRulesManager implements
              */
             FlowEntryInstall sameMatchEntry = installedSwView.get(installEntry);
             if (sameMatchEntry != null && !sameMatchEntry.getOriginal().equals(currentFlowEntry)) {
-                log.info("Modify: new container flow merged flow entry clashes with existing flow");
+                log.trace("Modify: new container flow merged flow entry clashes with existing flow");
                 decouple = true;
             } else {
                 toInstallSafe.add(installEntry);
@@ -1263,7 +1263,7 @@ public class ForwardingRulesManager implements
                 }
                 Status error = modifyEntry(currentFlowEntry, newFlowEntry, false);
                 if (error.isSuccess()) {
-                    log.info("Ports {} added to FlowEntry {}", portList, flowName);
+                    log.trace("Ports {} added to FlowEntry {}", portList, flowName);
                 } else {
                     log.warn("Failed to add ports {} to Flow entry {}. The failure is: {}", portList,
                             currentFlowEntry.toString(), error.getDescription());
@@ -1287,7 +1287,7 @@ public class ForwardingRulesManager implements
                 }
                 Status status = modifyEntry(currentFlowEntry, newFlowEntry, false);
                 if (status.isSuccess()) {
-                    log.info("Ports {} removed from FlowEntry {}", portList, flowName);
+                    log.trace("Ports {} removed from FlowEntry {}", portList, flowName);
                 } else {
                     log.warn("Failed to remove ports {} from Flow entry {}. The failure is: {}", portList,
                             currentFlowEntry.toString(), status.getDescription());
@@ -1335,7 +1335,7 @@ public class ForwardingRulesManager implements
         Status status = modifyEntry(currentFlowEntry, newFlowEntry, false);
 
         if (status.isSuccess()) {
-            log.info("Output port replaced with {} for flow {} on node {}", outPort, flowName, node);
+            log.trace("Output port replaced with {} for flow {} on node {}", outPort, flowName, node);
         } else {
             log.warn("Failed to replace output port for flow {} on node {}. The failure is: {}", flowName, node,
                     status.getDescription());
@@ -1793,7 +1793,7 @@ public class ForwardingRulesManager implements
         // Do not attempt to reinstall the flow, warn user
         if (newFlowConfig.equals(oldFlowConfig)) {
             String msg = "No modification detected";
-            log.info("Static flow modification skipped. New flow and old flow are the same: {}", newFlowConfig);
+            log.trace("Static flow modification skipped. New flow and old flow are the same: {}", newFlowConfig);
             return new Status(StatusCode.SUCCESS, msg);
         }
 
@@ -1895,7 +1895,7 @@ public class ForwardingRulesManager implements
      *            inactive list
      */
     private void uninstallAllFlowEntries(boolean preserveFlowEntries) {
-        log.info("Uninstalling all non-internal flows");
+        log.trace("Uninstalling all non-internal flows");
 
         List<FlowEntryInstall> toRemove = new ArrayList<FlowEntryInstall>();
 
@@ -1933,7 +1933,7 @@ public class ForwardingRulesManager implements
      * default container instance of FRM only when the last container is deleted
      */
     private void reinstallAllFlowEntries() {
-        log.info("Reinstalling all inactive flows");
+        log.trace("Reinstalling all inactive flows");
 
         for (FlowEntry flowEntry : this.inactiveFlows.keySet()) {
             this.addEntry(flowEntry, false);
@@ -2118,11 +2118,11 @@ public class ForwardingRulesManager implements
                 dropAllConfig.setActions(dropAction);
                 defaultConfigs.add(dropAllConfig);
 
-                log.info("Forwarding mode for node {} set to {}", node, (proactive ? "proactive" : "reactive"));
+                log.trace("Forwarding mode for node {} set to {}", node, (proactive ? "proactive" : "reactive"));
                 for (FlowConfig fc : defaultConfigs) {
                     Status status = (proactive) ? addStaticFlowInternal(fc, false) : removeStaticFlow(fc);
                     if (status.isSuccess()) {
-                        log.info("{} Proactive Static flow: {}", (proactive ? "Installed" : "Removed"), fc.getName());
+                        log.trace("{} Proactive Static flow: {}", (proactive ? "Installed" : "Removed"), fc.getName());
                     } else {
                         log.warn("Failed to {} Proactive Static flow: {}", (proactive ? "install" : "remove"),
                                 fc.getName());
@@ -2145,7 +2145,7 @@ public class ForwardingRulesManager implements
      * @param node
      */
     private void cleanDatabaseForNode(Node node) {
-        log.info("Cleaning Flow database for Node {}", node);
+        log.trace("Cleaning Flow database for Node {}", node);
         if (nodeFlows.containsKey(node)) {
             List<FlowEntryInstall> toRemove = new ArrayList<FlowEntryInstall>(nodeFlows.get(node));
 
@@ -2322,7 +2322,7 @@ public class ForwardingRulesManager implements
 
     @Override
     public void portGroupChanged(PortGroupConfig config, Map<Node, PortGroup> data, boolean add) {
-        log.info("PortGroup Changed for: {} Data: {}", config, portGroupData);
+        log.trace("PortGroup Changed for: {} Data: {}", config, portGroupData);
         Map<Node, PortGroup> existingData = portGroupData.get(config);
         if (existingData != null) {
             for (Map.Entry<Node, PortGroup> entry : data.entrySet()) {
index b231faf..fcd27d9 100644 (file)
@@ -50,14 +50,15 @@ public class Activator implements BundleActivator {
                 if (reader == null) {
                     this.log.error("Cannot register the LogListener because "
                             + "cannot retrieve LogReaderService");
-                }
-                reader.addLogListener(this.listener);
-                // Now lets walk all the exiting messages
-                Enumeration<LogEntry> entries = reader.getLog();
-                if (entries != null) {
-                    while (entries.hasMoreElements()) {
-                        LogEntry entry = (LogEntry) entries.nextElement();
-                        this.listener.logged(entry);
+                } else {
+                    reader.addLogListener(this.listener);
+                    // Now lets walk all the exiting messages
+                    Enumeration<LogEntry> entries = reader.getLog();
+                    if (entries != null) {
+                        while (entries.hasMoreElements()) {
+                            LogEntry entry = entries.nextElement();
+                            this.listener.logged(entry);
+                        }
                     }
                 }
 
@@ -76,7 +77,7 @@ public class Activator implements BundleActivator {
                         log.warn("Invalid policy name \"{}\", defaulting to {}", policy, handler);
                     }
                 }
-                log.info("Setting uncaught exception policy to {}", handler);
+                log.trace("Setting uncaught exception policy to {}", handler);
                 Thread.setDefaultUncaughtExceptionHandler(handler);
 
                 /*
@@ -98,10 +99,10 @@ public class Activator implements BundleActivator {
 
     @Override
     public void stop(BundleContext context) {
-        ServiceReference service = null;
-        service = context.getServiceReference(LogReaderService.class.getName());
-        if (service != null) {
-            LogReaderService reader = (LogReaderService) service;
+        ServiceReference serviceRef = context.getServiceReference(
+                LogReaderService.class.getName());
+        if (serviceRef != null) {
+            LogReaderService reader = (LogReaderService) context.getService(serviceRef);
             reader.removeLogListener(this.listener);
         }
         if (this.shutdownHandler != null) {
index 5449c83..0809ba3 100644 (file)
@@ -45,7 +45,7 @@ public class ClusteredDataStoreImpl implements ClusteredDataStore {
     private Logger logger = LoggerFactory.getLogger(ClusteredDataStoreImpl.class);
 
     public ClusteredDataStoreImpl(IClusterGlobalServices clusterGlobalServices) throws CacheConfigException {
-        logger.info("Constructing clustered data store");
+        logger.trace("Constructing clustered data store");
         Preconditions.checkNotNull(clusterGlobalServices, "clusterGlobalServices cannot be null");
 
         operationalDataCache = getOrCreateCache(clusterGlobalServices, OPERATIONAL_DATA_CACHE);
@@ -72,24 +72,24 @@ public class ClusteredDataStoreImpl implements ClusteredDataStore {
     public boolean containsConfigurationPath(InstanceIdentifier path) {
         return configurationDataCache.containsKey(path);
     }
-    
+
     @Override
     public boolean containsOperationalPath(InstanceIdentifier path) {
         return operationalDataCache.containsKey(path);
     }
-    
+
     @Override
     public Iterable<InstanceIdentifier> getStoredConfigurationPaths() {
         return configurationDataCache.keySet();
     }
-    
+
     @Override
     public Iterable<InstanceIdentifier> getStoredOperationalPaths() {
         return operationalDataCache.keySet();
     }
-    
-    
-    
+
+
+
     @Override
     public CompositeNode readConfigurationData(InstanceIdentifier path) {
         Preconditions.checkNotNull(path, "path cannot be null");
index 21af047..39d224b 100644 (file)
@@ -142,7 +142,7 @@ class InventoryAndReadAdapter implements IPluginInReadService,
                val table= it.readConfigurationData(tableRef) as Table;
                
                if(table != null){
-                       LOG.info("Number of flows installed in table 0 of node {} : {}",node,table.flow.size);
+                       LOG.trace("Number of flows installed in table 0 of node {} : {}",node,table.flow.size);
                        
                        for(flow : table.flow){
                                
@@ -248,7 +248,7 @@ class InventoryAndReadAdapter implements IPluginInReadService,
                val table= it.readConfigurationData(tableRef) as Table;
                
                if(table != null){
-                       LOG.info("Number of flows installed in table 0 of node {} : {}",node,table.flow.size);
+                       LOG.trace("Number of flows installed in table 0 of node {} : {}",node,table.flow.size);
                        
                        for(mdsalFlow : table.flow){
                                if(FromSalConversionsUtils.flowEquals(mdsalFlow, MDFlowMapping.toMDSalflow(targetFlow))){
index 5e69548..ffa3194 100644 (file)
@@ -19,7 +19,7 @@
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>opendaylight-l2-types</artifactId>
-            <version>2013.08.27.1</version>
+            <version>2013.08.27.2-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
index db2c62d..fe7b9f2 100644 (file)
@@ -29,7 +29,7 @@
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>opendaylight-l2-types</artifactId>
-            <version>2013.08.27.1</version>
+            <version>2013.08.27.2-SNAPSHOT</version>
         </dependency>
     </dependencies>
     <packaging>bundle</packaging>
index c2e48b3..fac7cfa 100644 (file)
@@ -29,7 +29,7 @@
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>opendaylight-l2-types</artifactId>
-            <version>2013.08.27.1</version>
+            <version>2013.08.27.2-SNAPSHOT</version>
         </dependency>
     </dependencies>
     <packaging>bundle</packaging>
index e95fe24..e357f7d 100644 (file)
@@ -29,7 +29,7 @@
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>opendaylight-l2-types</artifactId>
-            <version>2013.08.27.1-SNAPSHOT</version>
+            <version>2013.08.27.2-SNAPSHOT</version>
         </dependency>
     </dependencies>
     <packaging>bundle</packaging>
index f7c137f..f803180 100644 (file)
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>yang-ext</artifactId>
-            <version>2013.09.07.1-SNAPSHOT</version>
+            <version>2013.09.07.2-SNAPSHOT</version>
         </dependency>
     </dependencies>
 
index cc76488..0fa85d5 100644 (file)
@@ -4,6 +4,7 @@ import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublishe
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
index f84503b..d910372 100644 (file)
@@ -59,6 +59,7 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
             baArgs.add(baArg)
         }
         val ret = new InstanceIdentifier(baArgs,baType as Class<? extends DataObject>);
+        LOG.debug("DOM Instance Identifier {} deserialized to {}",input,ret);
         return ret;
     }
     
@@ -110,7 +111,9 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec {
                 previousAugmentation = baArg.type;
             }
         }
-        return new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(components);
+        val ret = new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(components);
+        LOG.debug("Binding Instance Identifier {} serialized to DOM InstanceIdentifier {}",input,ret);
+        return ret;
     }
     
     def updateAugmentationInjection(Class<? extends DataObject> class1, ImmutableList<QName> list, Class<?> augmentation) {
index 1b3acf7..7461ba8 100644 (file)
@@ -260,7 +260,7 @@ class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingSer
         if (typeDef !== null) {
             return typeDef;
         }
-        LOG.info("Thread blocked waiting for schema for: {}",type.fullyQualifiedName)
+        LOG.trace("Thread blocked waiting for schema for: {}",type.fullyQualifiedName)
         return type.getSchemaInFuture.get();
     }
 
index b22f328..f68f94e 100644 (file)
@@ -1102,7 +1102,7 @@ class TransformerGenerator {
     }
 
     private def createDummyImplementation(Class<?> object, GeneratedTransferObject typeSpec) {
-        log.info("Generating Dummy DOM Codec for {} with {}", object, object.classLoader)
+        log.trace("Generating Dummy DOM Codec for {} with {}", object, object.classLoader)
         return createClass(typeSpec.codecClassName) [
             if (object.isYangBindingAvailable) {
                 implementsType(BINDING_CODEC)
index b4fd6b6..a3c8c5f 100644 (file)
@@ -185,13 +185,13 @@ class NotifyTask implements Callable<Object> {
             if(log.isDebugEnabled){\r
                 log.debug("Delivering notification {} to {}",notification,listener);\r
             } else {\r
-                log.info("Delivering notification {} to {}",notification.class.name,listener);\r
+                log.trace("Delivering notification {} to {}",notification.class.name,listener);\r
             }\r
             listener.onNotification(notification);\r
             if(log.isDebugEnabled){\r
                 log.debug("Notification delivered {} to {}",notification,listener);\r
             } else {\r
-                log.info("Notification delivered {} to {}",notification.class.name,listener);\r
+                log.trace("Notification delivered {} to {}",notification.class.name,listener);\r
             }\r
         } catch (Exception e) {\r
             log.error("Unhandled exception thrown by listener: {}", listener, e);\r
index ffc7265..f934571 100644 (file)
@@ -56,6 +56,8 @@ public class RpcProviderRegistryImpl implements //
 
     private final String name;
 
+    private ListenerRegistry<GlobalRpcRegistrationListener> globalRpcListeners = ListenerRegistry.create();
+
     public String getName() {
         return name;
     }
@@ -86,6 +88,7 @@ public class RpcProviderRegistryImpl implements //
         checkState(currentDelegate == null, "Rpc service is already registered");
         LOG.debug("Registering {} as global implementation of {} in {}", implementation, type.getSimpleName(), this);
         RuntimeCodeHelper.setDelegate(publicProxy, implementation);
+        notifyGlobalRpcAdded(type);
         return new RpcProxyRegistration<T>(type, implementation, this);
     }
 
@@ -140,6 +143,17 @@ public class RpcProviderRegistryImpl implements //
         }
     }
 
+    private void notifyGlobalRpcAdded(Class<? extends RpcService> type) {
+        for(ListenerRegistration<GlobalRpcRegistrationListener> listener : globalRpcListeners) {
+            try {
+                listener.getInstance().onGlobalRpcRegistered(type);
+            } catch (Exception e) {
+                LOG.error("Unhandled exception during invoking listener {}", e);
+            }
+        }
+        
+    }
+
     private void notifyListenersRoutedCreated(RpcRouter router) {
 
         for (ListenerRegistration<RouterInstantiationListener> listener : routerInstantiationListener) {
@@ -182,6 +196,16 @@ public class RpcProviderRegistryImpl implements //
     public interface RouterInstantiationListener extends EventListener {
         void onRpcRouterCreated(RpcRouter<?> router);
     }
+    
+    public ListenerRegistration<GlobalRpcRegistrationListener> registerGlobalRpcRegistrationListener(GlobalRpcRegistrationListener listener) {
+        return globalRpcListeners.register(listener);
+    }
+
+    public interface GlobalRpcRegistrationListener extends EventListener {
+        void onGlobalRpcRegistered(Class<? extends RpcService> cls);
+        void onGlobalRpcUnregistered(Class<? extends RpcService> cls);
+        
+    }
 
     private class RouteChangeForwarder<T extends RpcService> implements
             RouteChangeListener<Class<? extends BaseIdentity>, InstanceIdentifier<?>> {
index 7a7e086..5d48548 100644 (file)
@@ -43,6 +43,7 @@ import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
+import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl.GlobalRpcRegistrationListener;
 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl.RouterInstantiationListener;
 import org.opendaylight.controller.sal.common.util.CommitHandlerTransactions;
 import org.opendaylight.controller.sal.common.util.Rpcs;
@@ -190,25 +191,30 @@ public class BindingIndependentConnector implements //
     private DataModificationTransaction createBindingToDomTransaction(
             DataModification<InstanceIdentifier<? extends DataObject>, DataObject> source) {
         DataModificationTransaction target = biDataService.beginTransaction();
+        LOG.debug("Created DOM Transaction {} for {},", target.getIdentifier(),source.getIdentifier());
         for (Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : source.getUpdatedConfigurationData()
                 .entrySet()) {
             Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> biEntry = mappingService
                     .toDataDom(entry);
             target.putConfigurationData(biEntry.getKey(), biEntry.getValue());
+            LOG.debug("Update of Binding Configuration Data {} is translated to {}",entry,biEntry);
         }
         for (Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : source.getUpdatedOperationalData()
                 .entrySet()) {
             Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> biEntry = mappingService
                     .toDataDom(entry);
             target.putOperationalData(biEntry.getKey(), biEntry.getValue());
+            LOG.debug("Update of Binding Operational Data {} is translated to {}",entry,biEntry);
         }
         for (InstanceIdentifier<? extends DataObject> entry : source.getRemovedConfigurationData()) {
             org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry);
             target.removeConfigurationData(biEntry);
+            LOG.debug("Delete of Binding Configuration Data {} is translated to {}",entry,biEntry);
         }
         for (InstanceIdentifier<? extends DataObject> entry : source.getRemovedOperationalData()) {
             org.opendaylight.yangtools.yang.data.api.InstanceIdentifier biEntry = mappingService.toDataDom(entry);
             target.removeOperationalData(biEntry);
+            LOG.debug("Delete of Binding Operational Data {} is translated to {}",entry,biEntry);
         }
         return target;
     }
@@ -299,6 +305,7 @@ public class BindingIndependentConnector implements //
             if (baRpcRegistry instanceof RpcProviderRegistryImpl) {
                 baRpcRegistryImpl = (RpcProviderRegistryImpl) baRpcRegistry;
                 baRpcRegistryImpl.registerRouterInstantiationListener(domToBindingRpcManager.getInstance());
+                baRpcRegistryImpl.registerGlobalRpcRegistrationListener(domToBindingRpcManager.getInstance());
             }
             if(biRpcRegistry instanceof org.opendaylight.controller.sal.dom.broker.spi.RpcRouter) {
                 biRouter = (org.opendaylight.controller.sal.dom.broker.spi.RpcRouter) biRpcRegistry;
@@ -444,7 +451,7 @@ public class BindingIndependentConnector implements //
             }
             DataModificationTransaction domTransaction = createBindingToDomTransaction(bindingTransaction);
             BindingToDomTransaction wrapped = new BindingToDomTransaction(domTransaction, bindingTransaction);
-            LOG.info("Forwarding Binding Transaction: {} as DOM Transaction: {} .", bindingTransaction.getIdentifier(),
+            LOG.trace("Forwarding Binding Transaction: {} as DOM Transaction: {} .", bindingTransaction.getIdentifier(),
                     domTransaction.getIdentifier());
             return wrapped;
         }
@@ -484,7 +491,7 @@ public class BindingIndependentConnector implements //
 
             org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction baTransaction = createDomToBindingTransaction(domTransaction);
             DomToBindingTransaction forwardedTransaction = new DomToBindingTransaction(baTransaction, domTransaction);
-            LOG.info("Forwarding DOM Transaction: {} as Binding Transaction: {}.", domTransaction.getIdentifier(),
+            LOG.trace("Forwarding DOM Transaction: {} as Binding Transaction: {}.", domTransaction.getIdentifier(),
                     baTransaction.getIdentifier());
             return forwardedTransaction;
         }
@@ -497,7 +504,8 @@ public class BindingIndependentConnector implements //
      */
     private class DomToBindingRpcForwardingManager implements
             RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>,
-            RouterInstantiationListener {
+            RouterInstantiationListener,
+            GlobalRpcRegistrationListener {
 
         private final Map<Class<? extends RpcService>, DomToBindingRpcForwarder> forwarders = new WeakHashMap<>();
         private RpcProviderRegistryImpl registryImpl;
@@ -510,6 +518,15 @@ public class BindingIndependentConnector implements //
             this.registryImpl = registryImpl;
         }
         
+        @Override
+        public void onGlobalRpcRegistered(Class<? extends RpcService> cls) {
+            getRpcForwarder(cls, null);
+        }
+        
+        @Override
+        public void onGlobalRpcUnregistered(Class<? extends RpcService> cls) {
+            // NOOP
+        }
         
         @Override
         public void onRpcRouterCreated(RpcRouter<?> router) {
index f90465f..d86547a 100644 (file)
@@ -85,7 +85,7 @@ DataProvisionService<P, D> {
     override final registerCommitHandler(P path, DataCommitHandler<P, D> commitHandler) {\r
         val registration = new DataCommitHandlerRegistrationImpl(path, commitHandler, this);\r
         commitHandlers.put(path, registration)\r
-        LOG.info("Registering Commit Handler {} for path: {}",commitHandler,path);\r
+        LOG.trace("Registering Commit Handler {} for path: {}",commitHandler,path);\r
         for(listener : commitHandlerRegistrationListeners) {\r
             try {\r
                 listener.instance.onRegister(registration);\r
@@ -132,7 +132,7 @@ DataProvisionService<P, D> {
     protected final def removeCommitHandler(DataCommitHandlerRegistrationImpl<P, D> registration) {\r
         commitHandlers.remove(registration.path, registration);\r
         \r
-         LOG.info("Removing Commit Handler {} for path: {}",registration.instance,registration.path);\r
+         LOG.trace("Removing Commit Handler {} for path: {}",registration.instance,registration.path);\r
         for(listener : commitHandlerRegistrationListeners) {\r
             try {\r
                 listener.instance.onUnregister(registration);\r
@@ -264,7 +264,7 @@ package class TwoPhaseCommit<P extends Path<P>, D, DCL extends DataChangeListene
 \r
         val transactionId = transaction.identifier;\r
 \r
-        log.info("Transaction: {} Started.",transactionId);\r
+        log.trace("Transaction: {} Started.",transactionId);\r
         // requesting commits\r
         val Iterable<DataCommitHandler<P, D>> commitHandlers = dataBroker.affectedCommitHandlers(affectedPaths);\r
         val List<DataCommitTransaction<P, D>> handlerTransactions = new ArrayList();\r
@@ -288,7 +288,7 @@ package class TwoPhaseCommit<P extends Path<P>, D, DCL extends DataChangeListene
             dataBroker.failedTransactionsCount.andIncrement\r
             return rollback(handlerTransactions, e);\r
         }\r
-        log.info("Transaction: {} Finished successfully.",transactionId);\r
+        log.trace("Transaction: {} Finished successfully.",transactionId);\r
         dataBroker.finishedTransactionsCount.andIncrement;\r
         return Rpcs.getRpcResult(true, TransactionStatus.COMMITED, Collections.emptySet());\r
 \r
index 6b597de..d61d709 100644 (file)
@@ -51,7 +51,6 @@ public final class SchemaServiceImplSingletonModule extends org.opendaylight.con
     public java.lang.AutoCloseable createInstance() {
         SchemaServiceImpl newInstance = new SchemaServiceImpl();
         newInstance.setContext(getBundleContext());
-        newInstance.setParser(new YangParserImpl());
         newInstance.start();
         return newInstance;
     }
index 3baae04..b5737a5 100644 (file)
@@ -1,73 +1,75 @@
+/*
+ * Copyright (c) 2013 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
+ */
 package org.opendaylight.controller.sal.dom.broker
 
-import org.osgi.framework.ServiceRegistration
-import org.opendaylight.controller.sal.core.api.model.SchemaService
+import java.util.Hashtable
 import org.opendaylight.controller.sal.core.api.data.DataBrokerService
 import org.opendaylight.controller.sal.core.api.data.DataProviderService
-import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore
+import org.opendaylight.controller.sal.core.api.data.DataStore
+import org.opendaylight.controller.sal.core.api.model.SchemaService
+import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener
 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
 import org.opendaylight.controller.sal.core.api.mount.MountService
-import org.osgi.framework.BundleContext
-import java.util.Hashtable
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
-import org.opendaylight.controller.sal.core.api.data.DataStore
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener
 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
+import org.osgi.framework.BundleContext
+import org.osgi.framework.ServiceRegistration
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders
 
 class BrokerConfigActivator implements AutoCloseable {
-    
-    
+
     private static val ROOT = InstanceIdentifier.builder().toInstance();
 
     @Property
     private var DataBrokerImpl dataService;
-    
+
     private var ServiceRegistration<SchemaService> schemaReg;
     private var ServiceRegistration<DataBrokerService> dataReg;
     private var ServiceRegistration<DataProviderService> dataProviderReg;
     private var ServiceRegistration<MountService> mountReg;
     private var ServiceRegistration<MountProvisionService> mountProviderReg;
-    private var SchemaServiceImpl schemaService;
+    private var SchemaService schemaService;
     private var MountPointManagerImpl mountService;
-    
+
     SchemaAwareDataStoreAdapter wrappedStore
 
-    public def void start(BrokerImpl broker,DataStore store,BundleContext context) {
+    public def void start(BrokerImpl broker, DataStore store, BundleContext context) {
         val emptyProperties = new Hashtable<String, String>();
         broker.setBundleContext(context);
-        
-        
-        schemaService = new SchemaServiceImpl();
-        schemaService.setContext(context);
-        schemaService.setParser(new YangParserImpl());
-        schemaService.start();
+
+        val serviceRef = context.getServiceReference(SchemaService);
+        schemaService = context.getService(serviceRef);
         schemaReg = context.registerService(SchemaService, schemaService, emptyProperties);
-        
-        broker.setRouter(new SchemaAwareRpcBroker("/",schemaService));
-        
+
+        broker.setRouter(new SchemaAwareRpcBroker("/", SchemaContextProviders.fromSchemaService(schemaService)));
+
         dataService = new DataBrokerImpl();
         dataService.setExecutor(broker.getExecutor());
-        
+
         dataReg = context.registerService(DataBrokerService, dataService, emptyProperties);
         dataProviderReg = context.registerService(DataProviderService, dataService, emptyProperties);
 
         wrappedStore = new SchemaAwareDataStoreAdapter();
         wrappedStore.changeDelegate(store);
         wrappedStore.setValidationEnabled(false);
-       
-        context.registerService(SchemaServiceListener,wrappedStore,emptyProperties)  
-        
+
+        context.registerService(SchemaServiceListener, wrappedStore, emptyProperties)
+
         dataService.registerConfigurationReader(ROOT, wrappedStore);
         dataService.registerCommitHandler(ROOT, wrappedStore);
         dataService.registerOperationalReader(ROOT, wrappedStore);
-        
+
         mountService = new MountPointManagerImpl();
         mountService.setDataBroker(dataService);
-        
+
         mountReg = context.registerService(MountService, mountService, emptyProperties);
-        mountProviderReg =  context.registerService(MountProvisionService, mountService, emptyProperties);
+        mountProviderReg = context.registerService(MountProvisionService, mountService, emptyProperties);
     }
 
     override def close() {
@@ -77,5 +79,5 @@ class BrokerConfigActivator implements AutoCloseable {
         mountReg?.unregister();
         mountProviderReg?.unregister();
     }
-    
-}
\ No newline at end of file
+
+}
index 4c84440..aa5138a 100644 (file)
@@ -57,7 +57,7 @@ public class BrokerImpl implements Broker, RpcProvisionRegistry, AutoCloseable {
 
     override registerConsumer(Consumer consumer, BundleContext ctx) {
         checkPredicates(consumer);
-        log.info("Registering consumer " + consumer);
+        log.trace("Registering consumer " + consumer);
         val session = newSessionFor(consumer, ctx);
         consumer.onSessionInitiated(session);
         sessions.add(session);
index 8c272e5..403f7c8 100644 (file)
@@ -83,7 +83,7 @@ public class NotificationModule implements BrokerModule {
     private void sendNotification(CompositeNode notification) {
         QName type = notification.getNodeType();
         Collection<NotificationListener> toNotify = listeners.get(type);
-        log.info("Publishing notification " + type);
+        log.trace("Publishing notification " + type);
 
         if (toNotify == null) {
             // No listeners were registered - returns.
@@ -118,7 +118,7 @@ public class NotificationModule implements BrokerModule {
                 .create();
         private boolean closed = false;
 
-    
+
         public Registration<NotificationListener> addNotificationListener(QName notification,
                 NotificationListener listener) {
             checkSessionState();
@@ -132,7 +132,7 @@ public class NotificationModule implements BrokerModule {
 
             consumerListeners.put(notification, listener);
             listeners.put(notification, listener);
-            log.info("Registered listener for notification: " + notification);
+            log.trace("Registered listener for notification: " + notification);
             return null; // Return registration Object.
         }
 
index 8afa1ee..428521b 100644 (file)
@@ -1,45 +1,40 @@
+/*
+ * Copyright (c) 2013 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
+ */
 package org.opendaylight.controller.sal.dom.broker;
 
-import java.io.IOException;
-import java.io.InputStream;
+import static com.google.common.base.Preconditions.checkState;
+
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Enumeration;
-import java.util.List;
-import java.util.Set;
-import java.util.zip.Checksum;
 
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.osgi.util.tracker.BundleTracker;
-import org.osgi.util.tracker.BundleTrackerCustomizer;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.impl.util.URLSchemaContextResolver;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.ServiceReference;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Function;
 import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
-
-import static com.google.common.base.Preconditions.*;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
 
 public class SchemaServiceImpl implements //
         SchemaContextProvider, //
@@ -49,22 +44,18 @@ public class SchemaServiceImpl implements //
     private static final Logger logger = LoggerFactory.getLogger(SchemaServiceImpl.class);
 
     private ListenerRegistry<SchemaServiceListener> listeners;
-    private YangModelParser parser;
-
+    
     private BundleContext context;
     private BundleScanner scanner = new BundleScanner();
 
-    /**
-     * Map of currently problematic yang files that should get fixed eventually
-     * after all events are received.
-     */
-    private final Multimap<Bundle, URL> inconsistentBundlesToYangURLs = HashMultimap.create();
-    private final Multimap<Bundle, URL> consistentBundlesToYangURLs = HashMultimap.create();
-    private BundleTracker<Object> bundleTracker;
-    private final YangStoreCache cache = new YangStoreCache();
+    private BundleTracker<ImmutableSet<Registration<URL>>> bundleTracker;
+
+    private final URLSchemaContextResolver contextResolver = new URLSchemaContextResolver();
 
     private ServiceTracker<SchemaServiceListener, SchemaServiceListener> listenerTracker;
 
+    private boolean starting = true;
+
     public ListenerRegistry<SchemaServiceListener> getListeners() {
         return listeners;
     }
@@ -73,14 +64,6 @@ public class SchemaServiceImpl implements //
         this.listeners = listeners;
     }
 
-    public YangModelParser getParser() {
-        return parser;
-    }
-
-    public void setParser(YangModelParser parser) {
-        this.parser = parser;
-    }
-
     public BundleContext getContext() {
         return context;
     }
@@ -90,53 +73,41 @@ public class SchemaServiceImpl implements //
     }
 
     public void start() {
-        checkState(parser != null);
         checkState(context != null);
         if (listeners == null) {
             listeners = new ListenerRegistry<>();
         }
 
-        listenerTracker = new ServiceTracker<>(context, SchemaServiceListener.class, this);
-        bundleTracker = new BundleTracker<Object>(context, BundleEvent.RESOLVED | BundleEvent.UNRESOLVED, scanner);
+        listenerTracker = new ServiceTracker<>(context, SchemaServiceListener.class, SchemaServiceImpl.this);
+        bundleTracker = new BundleTracker<ImmutableSet<Registration<URL>>>(context, BundleEvent.RESOLVED
+                        | BundleEvent.UNRESOLVED, scanner);
         bundleTracker.open();
         listenerTracker.open();
+        starting = false;
+        tryToUpdateSchemaContext();
     }
 
-    
     @Override
     public SchemaContext getSchemaContext() {
         return getGlobalContext();
     }
-    
-    public SchemaContext getGlobalContext() {
-        return getSchemaContextSnapshot();
-    }
 
-    public synchronized SchemaContext getSchemaContextSnapshot() {
-        Optional<SchemaContext> yangStoreOpt = cache.getCachedSchemaContext(consistentBundlesToYangURLs);
-        if (yangStoreOpt.isPresent()) {
-            return yangStoreOpt.get();
-        }
-        SchemaContext snapshot = createSnapshot(parser, consistentBundlesToYangURLs);
-        updateCache(snapshot);
-        return snapshot;
+    public SchemaContext getGlobalContext() {
+        return contextResolver.getSchemaContext().orNull();
     }
 
     @Override
     public void addModule(Module module) {
-        // TODO Auto-generated method stub
         throw new UnsupportedOperationException();
     }
 
     @Override
     public SchemaContext getSessionContext() {
-        // TODO Auto-generated method stub
         throw new UnsupportedOperationException();
     }
 
     @Override
     public void removeModule(Module module) {
-        // TODO Auto-generated method stub
         throw new UnsupportedOperationException();
     }
 
@@ -147,63 +118,17 @@ public class SchemaServiceImpl implements //
 
     @Override
     public void close() throws Exception {
-        bundleTracker.close();
-        // FIXME: Add listeners.close();
-
-    }
-
-    private synchronized boolean tryToUpdateState(Collection<URL> changedURLs, Multimap<Bundle, URL> proposedNewState,
-            boolean adding) {
-        Preconditions.checkArgument(!changedURLs.isEmpty(), "No change can occur when no URLs are changed");
-
-        try {
-            // consistent state
-            // merge into
-            SchemaContext snapshot = createSnapshot(parser, proposedNewState);
-            consistentBundlesToYangURLs.clear();
-            consistentBundlesToYangURLs.putAll(proposedNewState);
-            inconsistentBundlesToYangURLs.clear();
-            // update cache
-            updateCache(snapshot);
-            logger.info("SchemaService updated to new consistent state");
-            logger.trace("SchemaService  updated to new consistent state containing {}", consistentBundlesToYangURLs);
-
-            // notifyListeners(changedURLs, adding);
-            return true;
-        } catch (Exception e) {
-            // inconsistent state
-            logger.debug(
-                    "SchemaService is falling back on last consistent state containing {}, inconsistent yang files {}",
-                    consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, e);
-            return false;
+        if (bundleTracker != null) {
+            bundleTracker.close();
         }
+        if (listenerTracker != null) {
+            listenerTracker.close();
+        }
+        // FIXME: Add listeners.close();
     }
 
-    private static Collection<InputStream> fromUrlsToInputStreams(Multimap<Bundle, URL> multimap) {
-        return Collections2.transform(multimap.values(), new Function<URL, InputStream>() {
-
-            @Override
-            public InputStream apply(URL url) {
-                try {
-                    return url.openStream();
-                } catch (IOException e) {
-                    logger.warn("Unable to open stream from {}", url);
-                    throw new IllegalStateException("Unable to open stream from " + url, e);
-                }
-            }
-        });
-    }
-
-    private static SchemaContext createSnapshot(YangModelParser parser, Multimap<Bundle, URL> multimap) {
-        List<InputStream> models = new ArrayList<>(fromUrlsToInputStreams(multimap));
-        Set<Module> modules = parser.parseYangModelsFromStreams(models);
-        SchemaContext yangStoreSnapshot = parser.resolveSchemaContext(modules);
-        return yangStoreSnapshot;
-    }
-
-    private void updateCache(SchemaContext snapshot) {
-        cache.cacheYangStore(consistentBundlesToYangURLs, snapshot);
 
+    private void updateContext(SchemaContext snapshot) {
         Object[] services = listenerTracker.getServices();
         if (services != null) {
             for (Object rawListener : services) {
@@ -224,44 +149,30 @@ public class SchemaServiceImpl implements //
         }
     }
 
-    private class BundleScanner implements BundleTrackerCustomizer<Object> {
+    private class BundleScanner implements BundleTrackerCustomizer<ImmutableSet<Registration<URL>>> {
         @Override
-        public Object addingBundle(Bundle bundle, BundleEvent event) {
+        public ImmutableSet<Registration<URL>> addingBundle(Bundle bundle, BundleEvent event) {
 
-            // Ignore system bundle:
-            // system bundle might have config-api on classpath &&
-            // config-api contains yang files =>
-            // system bundle might contain yang files from that bundle
             if (bundle.getBundleId() == 0) {
-                return bundle;
+                return ImmutableSet.of();
             }
 
             Enumeration<URL> enumeration = bundle.findEntries("META-INF/yang", "*.yang", false);
-            if (enumeration != null && enumeration.hasMoreElements()) {
-                synchronized (this) {
-                    List<URL> addedURLs = new ArrayList<>();
-                    while (enumeration.hasMoreElements()) {
-                        URL url = enumeration.nextElement();
-                        addedURLs.add(url);
-                    }
-                    logger.trace("Bundle {} has event {}, bundle state {}, URLs {}", bundle, event, bundle.getState(),
-                            addedURLs);
-                    // test that yang store is consistent
-                    Multimap<Bundle, URL> proposedNewState = HashMultimap.create(consistentBundlesToYangURLs);
-                    proposedNewState.putAll(inconsistentBundlesToYangURLs);
-                    proposedNewState.putAll(bundle, addedURLs);
-                    boolean adding = true;
-
-                    if (tryToUpdateState(addedURLs, proposedNewState, adding) == false) {
-                        inconsistentBundlesToYangURLs.putAll(bundle, addedURLs);
-                    }
-                }
+            Builder<Registration<URL>> builder = ImmutableSet.<Registration<URL>> builder();
+            while (enumeration != null && enumeration.hasMoreElements()) {
+                Registration<URL> reg = contextResolver.registerSource(enumeration.nextElement());
+                builder.add(reg);
+            }
+            ImmutableSet<Registration<URL>> urls = builder.build();
+            if(urls.isEmpty()) {
+                return urls;
             }
-            return bundle;
+            tryToUpdateSchemaContext();
+            return urls;
         }
 
         @Override
-        public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
+        public void modifiedBundle(Bundle bundle, BundleEvent event, ImmutableSet<Registration<URL>> object) {
             logger.debug("Modified bundle {} {} {}", bundle, event, object);
         }
 
@@ -272,41 +183,15 @@ public class SchemaServiceImpl implements //
          */
 
         @Override
-        public synchronized void removedBundle(Bundle bundle, BundleEvent event, Object object) {
-            inconsistentBundlesToYangURLs.removeAll(bundle);
-            Collection<URL> consistentURLsToBeRemoved = consistentBundlesToYangURLs.removeAll(bundle);
-
-            if (consistentURLsToBeRemoved.isEmpty()) {
-                return; // no change
-            }
-            boolean adding = false;
-            // notifyListeners(consistentURLsToBeRemoved, adding);
-        }
-    }
-
-    private static final class YangStoreCache {
-
-        Set<URL> cachedUrls;
-        SchemaContext cachedContextSnapshot;
-
-        Optional<SchemaContext> getCachedSchemaContext(Multimap<Bundle, URL> bundlesToYangURLs) {
-            Set<URL> urls = setFromMultimapValues(bundlesToYangURLs);
-            if (cachedUrls != null && cachedUrls.equals(urls)) {
-                Preconditions.checkState(cachedContextSnapshot != null);
-                return Optional.of(cachedContextSnapshot);
+        public synchronized void removedBundle(Bundle bundle, BundleEvent event, ImmutableSet<Registration<URL>> urls) {
+            for (Registration<URL> url : urls) {
+                try {
+                    url.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
-            return Optional.absent();
-        }
-
-        private static Set<URL> setFromMultimapValues(Multimap<Bundle, URL> bundlesToYangURLs) {
-            Set<URL> urls = Sets.newHashSet(bundlesToYangURLs.values());
-            Preconditions.checkState(bundlesToYangURLs.size() == urls.size());
-            return urls;
-        }
-
-        void cacheYangStore(Multimap<Bundle, URL> urls, SchemaContext ctx) {
-            this.cachedUrls = setFromMultimapValues(urls);
-            this.cachedContextSnapshot = ctx;
+            tryToUpdateSchemaContext();
         }
     }
 
@@ -321,6 +206,16 @@ public class SchemaServiceImpl implements //
         return listener;
     }
 
+    public synchronized void tryToUpdateSchemaContext() {
+        if(starting ) {
+            return;
+        }
+        Optional<SchemaContext> schema = contextResolver.tryToUpdateSchemaContext();
+        if(schema.isPresent()) {
+            updateContext(schema.get());
+        }
+    }
+
     @Override
     public void modifiedService(ServiceReference<SchemaServiceListener> reference, SchemaServiceListener service) {
         // NOOP
index 6d7b600..6242dee 100644 (file)
@@ -43,7 +43,7 @@ public class NotificationRouterImpl implements NotificationRouter {
     private void sendNotification(CompositeNode notification) {
         QName type = notification.getNodeType();
         Collection<Registration<NotificationListener>> toNotify = listeners.get(type);
-        log.info("Publishing notification " + type);
+        log.trace("Publishing notification " + type);
 
         if (toNotify == null) {
             // No listeners were registered - returns.
index 75e9649..8dc65e2 100644 (file)
@@ -131,7 +131,7 @@ public class SchemaAwareDataStoreAdapter extends AbstractLockableDelegator<DataS
         }
 
         if (schema == null) {
-            LOG.info("Validation not performed for {}. Reason: YANG Schema not present.", modification.getIdentifier());
+            LOG.warn("Validation not performed for {}. Reason: YANG Schema not present.", modification.getIdentifier());
             return;
         }
     }
index 3cf9a5d..fc8ccd6 100644 (file)
@@ -1,11 +1,16 @@
+/*
+ * Copyright (c) 2013 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
+ */
 package org.opendaylight.controller.sal.dom.broker.impl;
 
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-import com.google.common.base.Optional;
-
 public interface SchemaContextProvider {
 
     SchemaContext getSchemaContext();
-    
+
 }
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProviders.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProviders.java
new file mode 100644 (file)
index 0000000..df985cb
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 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
+ */
+package org.opendaylight.controller.sal.dom.broker.impl;
+
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.yangtools.concepts.Delegator;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class SchemaContextProviders {
+
+    public static final SchemaContextProvider fromSchemaService(SchemaService schemaService) {
+        if (schemaService instanceof SchemaContextProvider) {
+            return (SchemaContextProvider) schemaService;
+        }
+        return new SchemaServiceAdapter(schemaService);
+    }
+
+    private final static class SchemaServiceAdapter implements SchemaContextProvider, Delegator<SchemaService> {
+
+        private final SchemaService service;
+
+        public SchemaServiceAdapter(SchemaService service) {
+            super();
+            this.service = service;
+        }
+
+        @Override
+        public SchemaContext getSchemaContext() {
+            return service.getGlobalContext();
+        }
+
+        @Override
+        public SchemaService getDelegate() {
+            return service;
+        }
+
+        @Override
+        public String toString() {
+            return "SchemaServiceAdapter [service=" + service + "]";
+        }
+    }
+}
index 12be689..79264ab 100644 (file)
@@ -38,16 +38,16 @@ class NetconfRemoteSchemaSourceProvider implements SchemaSourceProvider<String>
             request.addLeaf("version", revision.get());
         }
 
-        device.logger.info("Loading YANG schema source for {}:{}", moduleName, revision);
+        device.logger.trace("Loading YANG schema source for {}:{}", moduleName, revision);
         RpcResult<CompositeNode> schemaReply = device.invokeRpc(GET_SCHEMA_QNAME, request.toInstance());
         if (schemaReply.isSuccessful()) {
             String schemaBody = getSchemaFromRpc(schemaReply.getResult());
             if (schemaBody != null) {
-                device.logger.info("YANG Schema successfully retrieved from remote for {}:{}", moduleName, revision);
+                device.logger.trace("YANG Schema successfully retrieved from remote for {}:{}", moduleName, revision);
                 return Optional.of(schemaBody);
             }
         }
-        device.logger.info("YANG shcema was not successfully retrieved.");
+        device.logger.warn("YANG shcema was not successfully retrieved.");
         return Optional.absent();
     }
 
@@ -62,7 +62,7 @@ class NetconfRemoteSchemaSourceProvider implements SchemaSourceProvider<String>
         }
         return null;
     }
-    
+
     public static final boolean isSupportedFor(Set<QName> capabilities) {
         return capabilities.contains(IETF_NETCONF_MONITORING);
     }
index d748d69..96eda6e 100644 (file)
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>yang-ext</artifactId>
-            <version>2013.09.07.1</version>
+            <version>2013.09.07.2-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>opendaylight-l2-types</artifactId>
-            <version>2013.08.27.1</version>
+            <version>2013.08.27.2-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
index 9c0c3ac..6e05d3f 100644 (file)
@@ -42,25 +42,25 @@ class BrokerFacade implements DataReader<InstanceIdentifier, CompositeNode> {
 
     override readConfigurationData(InstanceIdentifier path) {
         checkPreconditions
-        LOG.info("Read Configuration via Restconf: {}", path)
+        LOG.trace("Read Configuration via Restconf: {}", path)
         return dataService.readConfigurationData(path);
     }
     
     def readConfigurationDataBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) {
         checkPreconditions
-        LOG.info("Read Configuration via Restconf: {}", path)
+        LOG.trace("Read Configuration via Restconf: {}", path)
         return mountPoint.readConfigurationData(path);
     }
 
     override readOperationalData(InstanceIdentifier path) {
         checkPreconditions
-        LOG.info("Read Operational via Restconf: {}", path)
+        LOG.trace("Read Operational via Restconf: {}", path)
         return dataService.readOperationalData(path);
     }
     
     def readOperationalDataBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) {
         checkPreconditions
-        LOG.info("Read Operational via Restconf: {}", path)
+        LOG.trace("Read Operational via Restconf: {}", path)
         return mountPoint.readOperationalData(path);
     }
 
@@ -73,7 +73,7 @@ class BrokerFacade implements DataReader<InstanceIdentifier, CompositeNode> {
     def commitConfigurationDataPut(InstanceIdentifier path, CompositeNode payload) {
         checkPreconditions
         val transaction = dataService.beginTransaction;
-        LOG.info("Put Configuration via Restconf: {}", path)
+        LOG.trace("Put Configuration via Restconf: {}", path)
         transaction.putConfigurationData(path, payload);
         return transaction.commit
     }
@@ -81,7 +81,7 @@ class BrokerFacade implements DataReader<InstanceIdentifier, CompositeNode> {
     def commitConfigurationDataPutBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path, CompositeNode payload) {
         checkPreconditions
         val transaction = mountPoint.beginTransaction;
-        LOG.info("Put Configuration via Restconf: {}", path)
+        LOG.trace("Put Configuration via Restconf: {}", path)
         transaction.putConfigurationData(path, payload);
         return transaction.commit
     }
@@ -91,10 +91,10 @@ class BrokerFacade implements DataReader<InstanceIdentifier, CompositeNode> {
         val transaction = dataService.beginTransaction;
         transaction.putConfigurationData(path, payload);
         if (payload == transaction.createdConfigurationData.get(path)) {
-            LOG.info("Post Configuration via Restconf: {}", path)
+            LOG.trace("Post Configuration via Restconf: {}", path)
             return transaction.commit
         }
-        LOG.info("Post Configuration via Restconf was not executed because data already exists: {}", path)
+        LOG.trace("Post Configuration via Restconf was not executed because data already exists: {}", path)
         return null;
     }
     
@@ -103,10 +103,10 @@ class BrokerFacade implements DataReader<InstanceIdentifier, CompositeNode> {
         val transaction = mountPoint.beginTransaction;
         transaction.putConfigurationData(path, payload);
         if (payload == transaction.createdConfigurationData.get(path)) {
-            LOG.info("Post Configuration via Restconf: {}", path)
+            LOG.trace("Post Configuration via Restconf: {}", path)
             return transaction.commit
         }
-        LOG.info("Post Configuration via Restconf was not executed because data already exists: {}", path)
+        LOG.trace("Post Configuration via Restconf was not executed because data already exists: {}", path)
         return null;
     }
 
index 91146f3..fde60d6 100644 (file)
@@ -49,18 +49,18 @@ public class ToastConsumerImpl extends AbstractBindingAwareConsumer implements B
             RpcResult<Void> result = getToastService().makeToast(toastInput.build()).get();
 
             if (result.isSuccessful()) {
-                log.info("Toast was successfuly finished");
+                log.trace("Toast was successfuly finished");
             } else {
-                log.info("Toast was not successfuly finished");
+                log.warn("Toast was not successfuly finished");
             }
             return result.isSuccessful();
         } catch (InterruptedException | ExecutionException e) {
-            log.info("Error occured during toast creation");
+            log.warn("Error occured during toast creation");
         }
         return false;
 
     }
-    
+
     @Override
     @Deprecated
     protected void startImpl(BundleContext context) {
@@ -76,7 +76,7 @@ public class ToastConsumerImpl extends AbstractBindingAwareConsumer implements B
 
     @Override
     public void onNotification(ToastDone notification) {
-        log.info("ToastDone Notification Received: {} ",notification.getToastStatus());
+        log.trace("ToastDone Notification Received: {} ",notification.getToastStatus());
 
     }
 
index f54213e..ce541ba 100644 (file)
@@ -64,7 +64,7 @@ public class OpendaylightToaster implements ToasterData, ToasterService {
     @Override
     public Future<RpcResult<Void>> makeToast(MakeToastInput input) {
         // TODO Auto-generated method stub
-        log.info("makeToast - Received input for toast");
+        log.trace("makeToast - Received input for toast");
         logToastInput(input);
         if (currentTask != null) {
             return inProgressError();
@@ -92,7 +92,7 @@ public class OpendaylightToaster implements ToasterData, ToasterService {
     private void logToastInput(MakeToastInput input) {
         String toastType = input.getToasterToastType().getName();
         String toastDoneness = input.getToasterDoneness().toString();
-        log.info("Toast: {} doneness: {}", toastType, toastDoneness);
+        log.trace("Toast: {} doneness: {}", toastType, toastDoneness);
     }
 
     private class MakeToastTask implements Callable<RpcResult<Void>> {
@@ -110,7 +110,7 @@ public class OpendaylightToaster implements ToasterData, ToasterService {
             ToastDoneBuilder notifyBuilder = new ToastDoneBuilder();
             notifyBuilder.setToastStatus(ToastStatus.Done);
             notificationProvider.notify(notifyBuilder.build());
-            log.info("Toast Done");
+            log.trace("Toast Done");
             logToastInput(toastRequest);
             currentTask = null;
             return Rpcs.<Void> getRpcResult(true, null, Collections.<RpcError> emptySet());
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatistics.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatistics.java
deleted file mode 100644 (file)
index e84b437..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright IBM Corporation, 2013.  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
- */
-package org.opendaylight.controller.md.statistics.manager;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.aggregate.flow.statistics.AggregateFlowStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.features.GroupFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.MeterFeatures;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericQueueStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericTableStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.NodeConnectorStatistics;
-
-public class NodeStatistics {
-
-    private NodeRef targetNode;
-    
-    private List<GroupStats> groupStatistics;
-    
-    private List<MeterStats> meterStatistics;
-    
-    private List<GroupDescStats> groupDescStats;
-    
-    private List<MeterConfigStats> meterConfigStats;
-    
-    private GroupFeatures groupFeatures;
-    
-    private MeterFeatures meterFeatures;
-    
-    private final Map<Short,Map<Flow,GenericStatistics>> flowAndStatsMap= 
-            new HashMap<Short,Map<Flow,GenericStatistics>>();
-    
-    private final Map<Short,AggregateFlowStatistics> tableAndAggregateFlowStatsMap = 
-            new HashMap<Short,AggregateFlowStatistics>();
-    
-    private final Map<NodeConnectorId,NodeConnectorStatistics> nodeConnectorStats = 
-            new ConcurrentHashMap<NodeConnectorId,NodeConnectorStatistics>();
-    
-    private final Map<Short,GenericTableStatistics> flowTableAndStatisticsMap = 
-            new HashMap<Short,GenericTableStatistics>();
-    
-    private final Map<NodeConnectorId,Map<QueueId,GenericQueueStatistics>> NodeConnectorAndQueuesStatsMap = 
-            new HashMap<NodeConnectorId,Map<QueueId,GenericQueueStatistics>>();
-    
-    public NodeStatistics(){
-        
-    }
-
-    public NodeRef getTargetNode() {
-        return targetNode;
-    }
-
-    public void setTargetNode(NodeRef targetNode) {
-        this.targetNode = targetNode;
-    }
-
-    public List<GroupStats> getGroupStatistics() {
-        return groupStatistics;
-    }
-
-    public void setGroupStatistics(List<GroupStats> groupStatistics) {
-        this.groupStatistics = groupStatistics;
-    }
-
-    public List<MeterStats> getMeterStatistics() {
-        return meterStatistics;
-    }
-
-    public void setMeterStatistics(List<MeterStats> meterStatistics) {
-        this.meterStatistics = meterStatistics;
-    }
-
-    public List<GroupDescStats> getGroupDescStats() {
-        return groupDescStats;
-    }
-
-    public void setGroupDescStats(List<GroupDescStats> groupDescStats) {
-        this.groupDescStats = groupDescStats;
-    }
-
-    public List<MeterConfigStats> getMeterConfigStats() {
-        return meterConfigStats;
-    }
-
-    public void setMeterConfigStats(List<MeterConfigStats> meterConfigStats) {
-        this.meterConfigStats = meterConfigStats;
-    }
-
-    public GroupFeatures getGroupFeatures() {
-        return groupFeatures;
-    }
-
-    public void setGroupFeatures(GroupFeatures groupFeatures) {
-        this.groupFeatures = groupFeatures;
-    }
-
-    public MeterFeatures getMeterFeatures() {
-        return meterFeatures;
-    }
-
-    public void setMeterFeatures(MeterFeatures meterFeatures) {
-        this.meterFeatures = meterFeatures;
-    }
-
-    public Map<Short,Map<Flow,GenericStatistics>> getFlowAndStatsMap() {
-        return flowAndStatsMap;
-    }
-
-    public Map<Short, GenericTableStatistics> getFlowTableAndStatisticsMap() {
-        return flowTableAndStatisticsMap;
-    }
-
-    public Map<Short, AggregateFlowStatistics> getTableAndAggregateFlowStatsMap() {
-        return tableAndAggregateFlowStatsMap;
-    }
-    public Map<NodeConnectorId, NodeConnectorStatistics> getNodeConnectorStats() {
-        return nodeConnectorStats;
-    }
-
-    public Map<NodeConnectorId, Map<QueueId, GenericQueueStatistics>> getNodeConnectorAndQueuesStatsMap() {
-        return NodeConnectorAndQueuesStatsMap;
-    }
-}
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsAger.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/NodeStatisticsAger.java
new file mode 100644 (file)
index 0000000..4ecd620
--- /dev/null
@@ -0,0 +1,346 @@
+/*
+ * Copyright IBM Corporation, 2013.  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
+ */
+package org.opendaylight.controller.md.statistics.manager;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+
+/**
+ * Main responsibility of this class to clean up all the stale statistics data
+ * associated to Flow,Meter,Group,Queue.
+ * @author avishnoi@in.ibm.com
+ *
+ */
+public class NodeStatisticsAger {
+    
+    private final int NUMBER_OF_WAIT_CYCLES =2;
+
+    private final StatisticsProvider statisticsProvider;
+
+    private final NodeKey targetNodeKey;
+    
+    private final Map<GroupDescStats,Date> groupDescStatsUpdate
+                = new ConcurrentHashMap<GroupDescStats,Date>();
+    
+    private final Map<MeterConfigStats,Date> meterConfigStatsUpdate
+                = new ConcurrentHashMap<MeterConfigStats,Date>();
+    
+    private final Map<FlowEntry,Date> flowStatsUpdate
+                = new ConcurrentHashMap<FlowEntry,Date>();
+    
+    private final Map<QueueEntry,Date> queuesStatsUpdate 
+                = new ConcurrentHashMap<QueueEntry,Date>();
+    
+    public NodeStatisticsAger(StatisticsProvider statisticsProvider, NodeKey nodeKey){
+        this.targetNodeKey = nodeKey;
+        this.statisticsProvider = statisticsProvider;
+    }
+
+    public class FlowEntry{
+        private final Short tableId;
+        private final Flow flow;
+        
+        public FlowEntry(Short tableId, Flow flow){
+            this.tableId = tableId;
+            this.flow = flow;
+        }
+
+        public Short getTableId() {
+            return tableId;
+        }
+
+        public Flow getFlow() {
+            return flow;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + getOuterType().hashCode();
+            result = prime * result + ((flow == null) ? 0 : flow.hashCode());
+            result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+            if (getClass() != obj.getClass())
+                return false;
+            FlowEntry other = (FlowEntry) obj;
+            if (!getOuterType().equals(other.getOuterType()))
+                return false;
+            if (flow == null) {
+                if (other.flow != null)
+                    return false;
+            } else if (!flow.equals(other.flow))
+                return false;
+            if (tableId == null) {
+                if (other.tableId != null)
+                    return false;
+            } else if (!tableId.equals(other.tableId))
+                return false;
+            return true;
+        }
+
+        private NodeStatisticsAger getOuterType() {
+            return NodeStatisticsAger.this;
+        }
+        
+    }
+    
+    public class QueueEntry{
+        private final NodeConnectorId nodeConnectorId;
+        private final QueueId queueId;
+        public QueueEntry(NodeConnectorId ncId, QueueId queueId){
+            this.nodeConnectorId = ncId;
+            this.queueId = queueId;
+        }
+        public NodeConnectorId getNodeConnectorId() {
+            return nodeConnectorId;
+        }
+        public QueueId getQueueId() {
+            return queueId;
+        }
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + getOuterType().hashCode();
+            result = prime * result + ((nodeConnectorId == null) ? 0 : nodeConnectorId.hashCode());
+            result = prime * result + ((queueId == null) ? 0 : queueId.hashCode());
+            return result;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (!(obj instanceof QueueEntry)) {
+                return false;
+            }
+            QueueEntry other = (QueueEntry) obj;
+            if (!getOuterType().equals(other.getOuterType())) {
+                return false;
+            }
+            if (nodeConnectorId == null) {
+                if (other.nodeConnectorId != null) {
+                    return false;
+                }
+            } else if (!nodeConnectorId.equals(other.nodeConnectorId)) {
+                return false;
+            }
+            if (queueId == null) {
+                if (other.queueId != null) {
+                    return false;
+                }
+            } else if (!queueId.equals(other.queueId)) {
+                return false;
+            }
+            return true;
+        }
+        private NodeStatisticsAger getOuterType() {
+            return NodeStatisticsAger.this;
+        }
+    }
+    
+    public NodeKey getTargetNodeKey() {
+        return targetNodeKey;
+    }
+
+    public Map<GroupDescStats, Date> getGroupDescStatsUpdate() {
+        return groupDescStatsUpdate;
+    }
+
+    public Map<MeterConfigStats, Date> getMeterConfigStatsUpdate() {
+        return meterConfigStatsUpdate;
+    }
+
+    public Map<FlowEntry, Date> getFlowStatsUpdate() {
+        return flowStatsUpdate;
+    }
+
+    public Map<QueueEntry, Date> getQueuesStatsUpdate() {
+        return queuesStatsUpdate;
+    }
+
+    public void updateGroupDescStats(List<GroupDescStats> list){
+        Date expiryTime = getExpiryTime();
+        for(GroupDescStats groupDescStats : list)
+            this.groupDescStatsUpdate.put(groupDescStats, expiryTime);
+    }
+    
+    public void updateMeterConfigStats(List<MeterConfigStats> list){
+        Date expiryTime = getExpiryTime();
+        for(MeterConfigStats meterConfigStats: list)
+            this.meterConfigStatsUpdate.put(meterConfigStats, expiryTime);
+    }
+    
+    public void  updateFlowStats(FlowEntry flowEntry){
+        this.flowStatsUpdate.put(flowEntry, getExpiryTime());
+    }
+    public void updateQueueStats(QueueEntry queueEntry){
+        this.queuesStatsUpdate.put(queueEntry, getExpiryTime());
+    }
+    
+    private Date getExpiryTime(){
+        Date expires = new Date();
+        expires.setTime(expires.getTime()+StatisticsProvider.STATS_THREAD_EXECUTION_TIME*NUMBER_OF_WAIT_CYCLES);
+        return expires;
+    }
+    
+    public void cleanStaleStatistics(){
+        //Clean stale statistics related to group 
+        for (Iterator<GroupDescStats> it = this.groupDescStatsUpdate.keySet().iterator();it.hasNext();){
+            GroupDescStats groupDescStats = it.next();
+            Date now = new Date();
+            Date expiryTime = this.groupDescStatsUpdate.get(groupDescStats);
+            if(now.after(expiryTime)){
+                cleanGroupStatsFromDataStore(groupDescStats );
+                it.remove();
+            }
+        }
+        
+        //Clean stale statistics related to meter 
+        for (Iterator<MeterConfigStats> it = this.meterConfigStatsUpdate.keySet().iterator();it.hasNext();){
+            MeterConfigStats meterConfigStats = it.next();
+            Date now = new Date();
+            Date expiryTime = this.meterConfigStatsUpdate.get(meterConfigStats);
+            if(now.after(expiryTime)){
+                cleanMeterStatsFromDataStore(meterConfigStats);
+                it.remove();
+            }            
+        }
+        
+        //Clean stale statistics related to flow 
+        for (Iterator<FlowEntry> it = this.flowStatsUpdate.keySet().iterator();it.hasNext();){
+            FlowEntry flowEntry = it.next();
+            Date now = new Date();
+            Date expiryTime = this.flowStatsUpdate.get(flowEntry);
+            if(now.after(expiryTime)){
+                cleanFlowStatsFromDataStore(flowEntry);
+                it.remove();
+            }            
+        }
+
+        //Clean stale statistics related to queue
+        for (Iterator<QueueEntry> it = this.queuesStatsUpdate.keySet().iterator();it.hasNext();){
+            QueueEntry queueEntry = it.next();
+            Date now = new Date();
+            Date expiryTime = this.queuesStatsUpdate.get(queueEntry);
+            if(now.after(expiryTime)){
+                cleanQueueStatsFromDataStore(queueEntry);
+                it.remove();
+            }            
+        }
+        
+    }
+
+    private void cleanQueueStatsFromDataStore(QueueEntry queueEntry) {
+        InstanceIdentifier<?> queueRef 
+                        = InstanceIdentifier.builder(Nodes.class)
+                                            .child(Node.class, this.targetNodeKey)
+                                            .child(NodeConnector.class, new NodeConnectorKey(queueEntry.getNodeConnectorId()))
+                                            .augmentation(FlowCapableNodeConnector.class)
+                                            .child(Queue.class, new QueueKey(queueEntry.getQueueId()))
+                                            .augmentation(FlowCapableNodeConnectorQueueStatisticsData.class).toInstance();
+        cleanStaleStatisticsFromDataStore(queueRef);
+    }
+
+    private void cleanFlowStatsFromDataStore(FlowEntry flowEntry) {
+        InstanceIdentifier<?> flowRef 
+                        = InstanceIdentifier.builder(Nodes.class).child(Node.class, this.targetNodeKey)
+                                            .augmentation(FlowCapableNode.class)
+                                            .child(Table.class, new TableKey(flowEntry.getTableId()))
+                                            .child(Flow.class,flowEntry.getFlow().getKey())
+                                            .augmentation(FlowStatisticsData.class).toInstance();
+        
+        cleanStaleStatisticsFromDataStore(flowRef);
+        
+    }
+
+    private void cleanMeterStatsFromDataStore(MeterConfigStats meterConfigStats) {
+        InstanceIdentifierBuilder<Meter> meterRef 
+                        = InstanceIdentifier.builder(Nodes.class).child(Node.class,this.targetNodeKey)
+                                            .augmentation(FlowCapableNode.class)
+                                            .child(Meter.class,new MeterKey(meterConfigStats.getMeterId()));
+        
+        InstanceIdentifier<?> nodeMeterConfigStatsAugmentation = meterRef.augmentation(NodeMeterConfigStats.class).toInstance();
+                                            
+        cleanStaleStatisticsFromDataStore(nodeMeterConfigStatsAugmentation);
+        
+        InstanceIdentifier<?> nodeMeterStatisticsAugmentation = meterRef.augmentation(NodeMeterStatistics.class).toInstance();
+        
+        cleanStaleStatisticsFromDataStore(nodeMeterStatisticsAugmentation);
+        
+    }
+
+    private void cleanGroupStatsFromDataStore(GroupDescStats groupDescStats) {
+        InstanceIdentifierBuilder<Group> groupRef 
+                        = InstanceIdentifier.builder(Nodes.class).child(Node.class,this.targetNodeKey)
+                                            .augmentation(FlowCapableNode.class)
+                                            .child(Group.class,new GroupKey(groupDescStats.getGroupId()));
+        
+        InstanceIdentifier<?> nodeGroupDescStatsAugmentation = groupRef.augmentation(NodeGroupDescStats.class).toInstance();
+        
+        cleanStaleStatisticsFromDataStore(nodeGroupDescStatsAugmentation);
+
+        InstanceIdentifier<?> nodeGroupStatisticsAugmentation = groupRef.augmentation(NodeGroupStatistics.class).toInstance();
+        
+        cleanStaleStatisticsFromDataStore(nodeGroupStatisticsAugmentation);
+    }
+    
+    private void cleanStaleStatisticsFromDataStore(InstanceIdentifier<? extends DataObject> ii){
+        if(ii != null){
+            DataModificationTransaction it = this.statisticsProvider.startChange();
+            it.removeOperationalData(ii);
+            it.commit();
+        }
+    }
+}
index 738c2cb..653cc80 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.md.statistics.manager;
 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.osgi.framework.BundleContext;
 
@@ -26,6 +27,8 @@ public class StatisticsManagerActivator extends AbstractBindingAwareProvider {
         pSession = session;
         DataProviderService dps = session.<DataProviderService>getSALService(DataProviderService.class);
         StatisticsManagerActivator.statsProvider.setDataService(dps);
+        DataBrokerService dbs = session.<DataBrokerService>getSALService(DataBrokerService.class);
+        StatisticsManagerActivator.statsProvider.setDataBrokerService(dbs);
         NotificationProviderService nps = session.<NotificationProviderService>getSALService(NotificationProviderService.class);
         StatisticsManagerActivator.statsProvider.setNotificationService(nps);
         StatisticsManagerActivator.statsProvider.start();
index bb5dea3..7b7403f 100644 (file)
@@ -17,26 +17,37 @@ import java.util.concurrent.Future;
 import org.eclipse.xtext.xbase.lib.Exceptions;
 import org.opendaylight.controller.md.statistics.manager.MultipartMessageManager.StatsRequestType;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
@@ -49,19 +60,36 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.G
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/** 
+ * Following are main responsibilities of the class:
+ * 1) Invoke statistics request thread to send periodic statistics request to all the 
+ * flow capable switch connected to the controller. It sends statistics request for 
+ * Group,Meter,Table,Flow,Queue,Aggregate stats.   
+ * 
+ * 2) Invoke statistics ager thread, to clean up all the stale statistics data from 
+ * operational data store.
+ * 
+ * @author avishnoi@in.ibm.com
+ *
+ */
 public class StatisticsProvider implements AutoCloseable {
 
     public final static Logger spLogger = LoggerFactory.getLogger(StatisticsProvider.class);
     
     private DataProviderService dps;
+    
+    private DataBrokerService dbs;
 
     private NotificationProviderService nps;
     
@@ -79,15 +107,19 @@ public class StatisticsProvider implements AutoCloseable {
 
     private final MultipartMessageManager multipartMessageManager = new MultipartMessageManager();
     
+    private StatisticsUpdateHandler statsUpdateHandler;
+    
     private Thread statisticsRequesterThread;
     
+    private Thread statisticsAgerThread;
+
     private final  InstanceIdentifier<Nodes> nodesIdentifier = InstanceIdentifier.builder(Nodes.class).toInstance();
     
-    private final int STATS_THREAD_EXECUTION_TIME= 50000;
+    public static final int STATS_THREAD_EXECUTION_TIME= 30000;
     //Local caching of stats
     
-    private final ConcurrentMap<NodeId,NodeStatistics> statisticsCache = 
-            new ConcurrentHashMap<NodeId,NodeStatistics>();
+    private final ConcurrentMap<NodeId,NodeStatisticsAger> statisticsCache = 
+            new ConcurrentHashMap<NodeId,NodeStatisticsAger>();
     
     public DataProviderService getDataService() {
       return this.dps;
@@ -97,6 +129,14 @@ public class StatisticsProvider implements AutoCloseable {
       this.dps = dataService;
     }
     
+    public DataBrokerService getDataBrokerService() {
+        return this.dbs;
+    }
+      
+    public void setDataBrokerService(final DataBrokerService dataBrokerService) {
+        this.dbs = dataBrokerService;
+    }
+
     public NotificationProviderService getNotificationService() {
       return this.nps;
     }
@@ -119,6 +159,10 @@ public class StatisticsProvider implements AutoCloseable {
         Registration<NotificationListener> registerNotificationListener = nps.registerNotificationListener(this.updateCommiter);
         this.listenerRegistration = registerNotificationListener;
         
+        statsUpdateHandler = new StatisticsUpdateHandler(StatisticsProvider.this);
+        
+        registerDataStoreUpdateListener(this.getDataBrokerService());
+        
         // Get Group/Meter statistics service instance
         groupStatsService = StatisticsManagerActivator.getProviderContext().
                 getRpcService(OpendaylightGroupStatisticsService.class);
@@ -158,9 +202,60 @@ public class StatisticsProvider implements AutoCloseable {
         
         statisticsRequesterThread.start();
         
+        statisticsAgerThread = new Thread( new Runnable(){
+
+            @Override
+            public void run() {
+                while(true){
+                    try {
+                        for(NodeStatisticsAger nodeStatisticsAger : statisticsCache.values()){
+                            nodeStatisticsAger.cleanStaleStatistics();
+                        }
+                        
+                        Thread.sleep(STATS_THREAD_EXECUTION_TIME);
+                    }catch (Exception e){
+                        spLogger.error("Exception occurred while sending stats request : {}",e);
+                    }
+                }
+            }
+        });
+        
+        spLogger.debug("Statistics ager thread started with timer interval : {}",STATS_THREAD_EXECUTION_TIME);
+
+        statisticsAgerThread.start();
+        
         spLogger.info("Statistics Provider started.");
     }
     
+    private void registerDataStoreUpdateListener(DataBrokerService dbs) {
+        //Register for flow updates
+        InstanceIdentifier<? extends DataObject> pathFlow = InstanceIdentifier.builder(Nodes.class).child(Node.class)
+                                                                    .augmentation(FlowCapableNode.class)
+                                                                    .child(Table.class)
+                                                                    .child(Flow.class).toInstance();
+        dbs.registerDataChangeListener(pathFlow, statsUpdateHandler);
+        
+        //Register for meter updates
+        InstanceIdentifier<? extends DataObject> pathMeter = InstanceIdentifier.builder(Nodes.class).child(Node.class)
+                                                    .augmentation(FlowCapableNode.class)
+                                                    .child(Meter.class).toInstance();
+
+        dbs.registerDataChangeListener(pathMeter, statsUpdateHandler);
+        
+        //Register for group updates 
+        InstanceIdentifier<? extends DataObject> pathGroup = InstanceIdentifier.builder(Nodes.class).child(Node.class)
+                                                    .augmentation(FlowCapableNode.class)
+                                                    .child(Group.class).toInstance();
+        dbs.registerDataChangeListener(pathGroup, statsUpdateHandler);
+
+        //Register for queue updates
+        InstanceIdentifier<? extends DataObject> pathQueue = InstanceIdentifier.builder(Nodes.class).child(Node.class)
+                                                                    .child(NodeConnector.class)
+                                                                    .augmentation(FlowCapableNodeConnector.class)
+                                                                    .child(Queue.class).toInstance();
+        dbs.registerDataChangeListener(pathQueue, statsUpdateHandler);
+    }
+
     protected DataModificationTransaction startChange() {
         
         DataProviderService dps = this.getDataService();
@@ -210,7 +305,7 @@ public class StatisticsProvider implements AutoCloseable {
         }
     }
 
-    private void sendAllFlowTablesStatisticsRequest(NodeRef targetNodeRef) throws InterruptedException, ExecutionException {
+    public void sendAllFlowTablesStatisticsRequest(NodeRef targetNodeRef) throws InterruptedException, ExecutionException {
         final GetFlowTablesStatisticsInputBuilder input = 
                 new GetFlowTablesStatisticsInputBuilder();
         
@@ -224,7 +319,7 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
 
-    private void sendAllFlowsStatsFromAllTablesRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
+    public void sendAllFlowsStatsFromAllTablesRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
         final GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
                 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
         
@@ -238,7 +333,22 @@ public class StatisticsProvider implements AutoCloseable {
         
     }
     
-    private void sendAggregateFlowsStatsFromAllTablesRequest(NodeKey targetNodeKey) throws InterruptedException, ExecutionException{
+    public void sendFlowStatsFromTableRequest(NodeRef targetNode,Flow flow) throws InterruptedException, ExecutionException{
+        final GetFlowStatisticsFromFlowTableInputBuilder input =
+                new GetFlowStatisticsFromFlowTableInputBuilder();
+        
+        input.setNode(targetNode);
+        input.fieldsFrom(flow);
+        
+        Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> response = 
+                flowStatsService.getFlowStatisticsFromFlowTable(input.build());
+        
+        this.multipartMessageManager.addTxIdToRequestTypeEntry(response.get().getResult().getTransactionId()
+                , StatsRequestType.ALL_FLOW);
+        
+    }
+
+    public void sendAggregateFlowsStatsFromAllTablesRequest(NodeKey targetNodeKey) throws InterruptedException, ExecutionException{
         
         List<Short> tablesId = getTablesFromNode(targetNodeKey);
         
@@ -263,7 +373,7 @@ public class StatisticsProvider implements AutoCloseable {
         }
     }
 
-    private void sendAllNodeConnectorsStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
+    public void sendAllNodeConnectorsStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
         
         final GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
         
@@ -276,7 +386,7 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
 
-    private void sendAllGroupStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
+    public void sendAllGroupStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
         
         final GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
         
@@ -290,7 +400,7 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
     
-    private void sendGroupDescriptionRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
+    public void sendGroupDescriptionRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
         final GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
         
         input.setNode(targetNode);
@@ -303,7 +413,7 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
     
-    private void sendAllMeterStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
+    public void sendAllMeterStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
         
         GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
         
@@ -317,7 +427,7 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
     
-    private void sendMeterConfigStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
+    public void sendMeterConfigStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
         
         GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
         
@@ -331,7 +441,7 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
     
-    private void sendAllQueueStatsFromAllNodeConnector(NodeRef targetNode) throws InterruptedException, ExecutionException {
+    public void sendAllQueueStatsFromAllNodeConnector(NodeRef targetNode) throws InterruptedException, ExecutionException {
         GetAllQueuesStatisticsFromAllPortsInputBuilder input = new GetAllQueuesStatisticsFromAllPortsInputBuilder();
         
         input.setNode(targetNode);
@@ -344,7 +454,21 @@ public class StatisticsProvider implements AutoCloseable {
 
     }
 
-    public ConcurrentMap<NodeId, NodeStatistics> getStatisticsCache() {
+    public void sendQueueStatsFromGivenNodeConnector(NodeRef targetNode,NodeConnectorId nodeConnectorId, QueueId queueId) throws InterruptedException, ExecutionException {
+        GetQueueStatisticsFromGivenPortInputBuilder input = new GetQueueStatisticsFromGivenPortInputBuilder();
+        
+        input.setNode(targetNode);
+        input.setNodeConnectorId(nodeConnectorId);
+        input.setQueueId(queueId);
+        Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> response = 
+                queueStatsService.getQueueStatisticsFromGivenPort(input.build());
+        
+        this.multipartMessageManager.addTxIdToRequestTypeEntry(response.get().getResult().getTransactionId()
+                , StatsRequestType.ALL_QUEUE_STATS);;
+
+    }
+
+    public ConcurrentMap<NodeId, NodeStatisticsAger> getStatisticsCache() {
         return statisticsCache;
     }
     
@@ -383,6 +507,8 @@ public class StatisticsProvider implements AutoCloseable {
                 this.listenerRegistration.close();
                 
                 this.statisticsRequesterThread.destroy();
+                
+                this.statisticsAgerThread.destroy();
             
             }
           } catch (Throwable e) {
index f3188e1..ace547a 100644 (file)
@@ -7,10 +7,11 @@
  */
 package org.opendaylight.controller.md.statistics.manager;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.ConcurrentMap;
 
+import org.opendaylight.controller.md.statistics.manager.NodeStatisticsAger.FlowEntry;
+import org.opendaylight.controller.md.statistics.manager.NodeStatisticsAger.QueueEntry;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
@@ -44,7 +45,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
@@ -88,7 +88,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatisticsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericQueueStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.GenericStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
@@ -126,7 +125,7 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
 
     private final StatisticsProvider statisticsManager;
     
-    private final int unaccountedFlowsCounter = 1;
+    private int unaccountedFlowsCounter = 1;
 
     public StatisticsUpdateCommiter(final StatisticsProvider manager){
 
@@ -143,19 +142,19 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         if(this.statisticsManager.getMultipartMessageManager().removeTxId(notification.getTransactionId()) == null)
             return;
         
+        NodeKey key = new NodeKey(notification.getId());
+
         //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        ConcurrentMap<NodeId, NodeStatisticsAger> cache = this.statisticsManager.getStatisticsCache();
         if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
+            cache.put(notification.getId(), new NodeStatisticsAger(statisticsManager,key));
         }
-        cache.get(notification.getId()).setMeterConfigStats(notification.getMeterConfigStats());
+        cache.get(notification.getId()).updateMeterConfigStats(notification.getMeterConfigStats());
         
         //Publish data to configuration data store
-        NodeKey key = new NodeKey(notification.getId());
+        List<MeterConfigStats> meterConfigStatsList = notification.getMeterConfigStats();
         
-        List<MeterConfigStats> eterConfigStatsList = notification.getMeterConfigStats();
-        
-        for(MeterConfigStats meterConfigStats : eterConfigStatsList){
+        for(MeterConfigStats meterConfigStats : meterConfigStatsList){
             DataModificationTransaction it = this.statisticsManager.startChange();
             MeterBuilder meterBuilder = new MeterBuilder();
             MeterKey meterKey = new MeterKey(meterConfigStats.getMeterId());
@@ -185,13 +184,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         if(this.statisticsManager.getMultipartMessageManager().removeTxId(notification.getTransactionId()) == null)
             return;
 
-        //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
-        }
-        cache.get(notification.getId()).setMeterStatistics(notification.getMeterStats());
-        
         NodeKey key = new NodeKey(notification.getId());
         
         List<MeterStats> meterStatsList = notification.getMeterStats();
@@ -227,15 +219,16 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         if(this.statisticsManager.getMultipartMessageManager().removeTxId(notification.getTransactionId()) == null)
             return;
 
+        NodeKey key = new NodeKey(notification.getId());
+
         //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        ConcurrentMap<NodeId, NodeStatisticsAger> cache = this.statisticsManager.getStatisticsCache();
         if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
+            cache.put(notification.getId(), new NodeStatisticsAger(statisticsManager,key));
         }
-        cache.get(notification.getId()).setGroupDescStats(notification.getGroupDescStats());
+        cache.get(notification.getId()).updateGroupDescStats(notification.getGroupDescStats());
         
         //Publish data to configuration data store
-        NodeKey key = new NodeKey(notification.getId());
         List<GroupDescStats> groupDescStatsList = notification.getGroupDescStats();
 
         for(GroupDescStats groupDescStats : groupDescStatsList){
@@ -269,13 +262,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         if(this.statisticsManager.getMultipartMessageManager().removeTxId(notification.getTransactionId()) == null)
             return;
 
-        //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
-        }
-        cache.get(notification.getId()).setGroupStatistics(notification.getGroupStats());
-        
         //Publish data to configuration data store
         NodeKey key = new NodeKey(notification.getId());
         List<GroupStats> groupStatsList = notification.getGroupStats();
@@ -306,11 +292,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
     @Override
     public void onMeterFeaturesUpdated(MeterFeaturesUpdated notification) {
 
-        //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
-        }
         MeterFeaturesBuilder meterFeature = new MeterFeaturesBuilder();
         meterFeature.setMeterBandSupported(notification.getMeterBandSupported());
         meterFeature.setMeterCapabilitiesSupported(notification.getMeterCapabilitiesSupported());
@@ -318,8 +299,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         meterFeature.setMaxColor(notification.getMaxColor());
         meterFeature.setMaxMeter(notification.getMaxMeter());
         
-        cache.get(notification.getId()).setMeterFeatures(meterFeature.build());
-        
         //Publish data to configuration data store
         DataModificationTransaction it = this.statisticsManager.startChange();
         NodeKey key = new NodeKey(notification.getId());
@@ -342,18 +321,11 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
     @Override
     public void onGroupFeaturesUpdated(GroupFeaturesUpdated notification) {
 
-        //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
-        }
-        
         GroupFeaturesBuilder groupFeatures = new GroupFeaturesBuilder();
         groupFeatures.setActions(notification.getActions());
         groupFeatures.setGroupCapabilitiesSupported(notification.getGroupCapabilitiesSupported());
         groupFeatures.setGroupTypesSupported(notification.getGroupTypesSupported());
         groupFeatures.setMaxGroups(notification.getMaxGroups());
-        cache.get(notification.getId()).setGroupFeatures(groupFeatures.build());
         
         //Publish data to configuration data store
         DataModificationTransaction it = this.statisticsManager.startChange();
@@ -427,14 +399,13 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
             GenericStatistics flowStats = stats.build();
                 
             //Add statistics to local cache
-            ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+            ConcurrentMap<NodeId, NodeStatisticsAger> cache = this.statisticsManager.getStatisticsCache();
             if(!cache.containsKey(notification.getId())){
-                cache.put(notification.getId(), new NodeStatistics());
+                cache.put(notification.getId(), new NodeStatisticsAger(statisticsManager,key));
             }
-            if(!cache.get(notification.getId()).getFlowAndStatsMap().containsKey(tableId)){
-                cache.get(notification.getId()).getFlowAndStatsMap().put(tableId, new HashMap<Flow,GenericStatistics>());
-            }
-            cache.get(notification.getId()).getFlowAndStatsMap().get(tableId).put(flowRule,flowStats);
+            NodeStatisticsAger nsa = cache.get(notification.getId());
+            FlowEntry flowStatsEntry = nsa.new FlowEntry(tableId,flowRule);
+            cache.get(notification.getId()).updateFlowStats(flowStatsEntry);
                 
             //Augment the data to the flow node
 
@@ -492,10 +463,35 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
                 }
             }
             
+            table= (Table)it.readOperationalData(tableRef);
+            if(!foundOriginalFlow && table != null){
+
+                for(Flow existingFlow : table.getFlow()){
+                    FlowStatisticsData augmentedflowStatisticsData = existingFlow.getAugmentation(FlowStatisticsData.class);
+                    if(augmentedflowStatisticsData != null){
+                        FlowBuilder existingOperationalFlow = new FlowBuilder();
+                        existingOperationalFlow.fieldsFrom(augmentedflowStatisticsData.getFlowStatistics());
+                        sucLogger.debug("Existing unaccounted flow in operational data store : {}",existingFlow.toString());
+                        if(flowEquals(flowRule,existingOperationalFlow.build())){
+                            InstanceIdentifier<Flow> flowRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
+                                    .augmentation(FlowCapableNode.class)
+                                    .child(Table.class, new TableKey(tableId))
+                                    .child(Flow.class,existingFlow.getKey()).toInstance();
+                            flowBuilder.setKey(existingFlow.getKey());
+                            flowBuilder.addAugmentation(FlowStatisticsData.class, flowStatisticsData.build());
+                            sucLogger.debug("Found matching flow in the operational datastore, augmenting statistics");
+                            foundOriginalFlow = true;
+                            it.putOperationalData(flowRef, flowBuilder.build());
+                            it.commit();
+                            break;
+                        }
+                    }
+                }
+            }
             if(!foundOriginalFlow){
                 sucLogger.debug("Associated original flow is not found in data store. Augmenting flow in operational data store");
-                //TODO: Temporary fix: format [ 1+tableid+1+unaccounted flow counter]
-                long flowKey = Long.parseLong(new String("1"+Short.toString(tableId)+"1"+Integer.toString(this.unaccountedFlowsCounter)));
+                long flowKey = Long.parseLong(new String("1"+Short.toString(tableId)+"0"+Integer.toString(this.unaccountedFlowsCounter)));
+                this.unaccountedFlowsCounter++;
                 FlowKey newFlowKey = new FlowKey(new FlowId(Long.toString(flowKey)));
                 InstanceIdentifier<Flow> flowRef = InstanceIdentifier.builder(Nodes.class).child(Node.class, key)
                         .augmentation(FlowCapableNode.class)
@@ -534,12 +530,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
             aggregateFlowStatisticsBuilder.setPacketCount(notification.getPacketCount());
             aggregateFlowStatisticsDataBuilder.setAggregateFlowStatistics(aggregateFlowStatisticsBuilder.build());
             
-            ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-            if(!cache.containsKey(notification.getId())){
-                cache.put(notification.getId(), new NodeStatistics());
-            }
-            cache.get(notification.getId()).getTableAndAggregateFlowStatsMap().put(tableId,aggregateFlowStatisticsBuilder.build());
-            
             sucLogger.debug("Augment aggregate statistics: {} for table {} on Node {}",aggregateFlowStatisticsBuilder.build().toString(),tableId,key);
 
             TableBuilder tableBuilder = new TableBuilder();
@@ -560,13 +550,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         NodeKey key = new NodeKey(notification.getId());
         sucLogger.debug("Received port stats update : {}",notification.toString());
         
-        //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-        if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
-        }
-
-
         List<NodeConnectorStatisticsAndPortNumberMap> portsStats = notification.getNodeConnectorStatisticsAndPortNumberMap();
         for(NodeConnectorStatisticsAndPortNumberMap portStats : portsStats){
             
@@ -586,9 +569,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
             statisticsBuilder.setTransmitDrops(portStats.getTransmitDrops());
             statisticsBuilder.setTransmitErrors(portStats.getTransmitErrors());
             
-            //Update data in the cache
-            cache.get(notification.getId()).getNodeConnectorStats().put(portStats.getNodeConnectorId(), statisticsBuilder.build());
-            
             //Augment data to the node-connector
             FlowCapableNodeConnectorStatisticsDataBuilder statisticsDataBuilder = 
                     new FlowCapableNodeConnectorStatisticsDataBuilder();
@@ -635,12 +615,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
             
             statisticsDataBuilder.setFlowTableStatistics(statisticsBuilder.build());
             
-            ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
-            if(!cache.containsKey(notification.getId())){
-                cache.put(notification.getId(), new NodeStatistics());
-            }
-            cache.get(notification.getId()).getFlowTableAndStatisticsMap().put(ftStats.getTableId().getValue(),statisticsBuilder.build());
-            
             sucLogger.debug("Augment flow table statistics: {} for table {} on Node {}",statisticsBuilder.build().toString(),ftStats.getTableId(),key);
             
             TableBuilder tableBuilder = new TableBuilder();
@@ -662,17 +636,18 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
         sucLogger.debug("Received queue stats update : {}",notification.toString());
         
         //Add statistics to local cache
-        ConcurrentMap<NodeId, NodeStatistics> cache = this.statisticsManager.getStatisticsCache();
+        ConcurrentMap<NodeId, NodeStatisticsAger> cache = this.statisticsManager.getStatisticsCache();
         if(!cache.containsKey(notification.getId())){
-            cache.put(notification.getId(), new NodeStatistics());
+            cache.put(notification.getId(), new NodeStatisticsAger(statisticsManager,key));
         }
         
+        NodeStatisticsAger nsa = cache.get(notification.getId());
+        
         List<QueueIdAndStatisticsMap> queuesStats = notification.getQueueIdAndStatisticsMap();
         for(QueueIdAndStatisticsMap swQueueStats : queuesStats){
             
-            if(!cache.get(notification.getId()).getNodeConnectorAndQueuesStatsMap().containsKey(swQueueStats.getNodeConnectorId())){
-                cache.get(notification.getId()).getNodeConnectorAndQueuesStatsMap().put(swQueueStats.getNodeConnectorId(), new HashMap<QueueId,GenericQueueStatistics>());
-            }
+            QueueEntry queueEntry = nsa.new QueueEntry(swQueueStats.getNodeConnectorId(),swQueueStats.getQueueId());
+            nsa.updateQueueStats(queueEntry);
             
             FlowCapableNodeConnectorQueueStatisticsDataBuilder queueStatisticsDataBuilder = new FlowCapableNodeConnectorQueueStatisticsDataBuilder();
             
@@ -682,11 +657,6 @@ public class StatisticsUpdateCommiter implements OpendaylightGroupStatisticsList
             
             queueStatisticsDataBuilder.setFlowCapableNodeConnectorQueueStatistics(queueStatisticsBuilder.build());
             
-            cache.get(notification.getId()).getNodeConnectorAndQueuesStatsMap()
-                                            .get(swQueueStats.getNodeConnectorId())
-                                            .put(swQueueStats.getQueueId(), queueStatisticsBuilder.build());
-            
-            
             DataModificationTransaction it = this.statisticsManager.startChange();
 
             InstanceIdentifier<Queue> queueRef 
diff --git a/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateHandler.java b/opendaylight/md-sal/statistics-manager/src/main/java/org/opendaylight/controller/md/statistics/manager/StatisticsUpdateHandler.java
new file mode 100644 (file)
index 0000000..f04c29f
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * Copyright IBM Corporation, 2013.  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
+ */
+package org.opendaylight.controller.md.statistics.manager;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterConfigStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.FlowCapableNodeConnectorQueueStatisticsData;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Following are two main responsibilities of the class
+ * 1) Listen for the create changes in config data store for tree nodes (Flow,Group,Meter,Queue) 
+ * and send statistics request to the switch to fetch the statistics
+ * 
+ * 2)Listen for the remove changes in config data store for tree nodes (Flow,Group,Meter,Queue)
+ * and remove the relative statistics data from operational data store.
+ * 
+ * @author avishnoi@in.ibm.com
+ *
+ */
+public class StatisticsUpdateHandler implements DataChangeListener {
+
+    public final static Logger suhLogger = LoggerFactory.getLogger(StatisticsUpdateHandler.class);
+
+    private final StatisticsProvider statisticsManager;
+    
+    public StatisticsUpdateHandler(final StatisticsProvider manager){
+
+        this.statisticsManager = manager;
+    }
+    
+    public StatisticsProvider getStatisticsManager(){
+        return statisticsManager;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+        
+        Map<InstanceIdentifier<?>, DataObject> additions = change.getCreatedConfigurationData();
+        for (InstanceIdentifier<? extends DataObject> dataObjectInstance : additions.keySet()) {
+            DataObject dataObject = additions.get(dataObjectInstance);
+            InstanceIdentifier<Node> nodeII = dataObjectInstance.firstIdentifierOf(Node.class);
+            NodeRef nodeRef = new NodeRef(nodeII);
+            if(dataObject instanceof Flow){
+                Flow flow = (Flow) dataObject;
+                try {
+                    this.statisticsManager.sendFlowStatsFromTableRequest(nodeRef, flow);
+                } catch (InterruptedException | ExecutionException e) {
+                    suhLogger.warn("Following exception occured while sending flow statistics request newly added flow: {}", e);
+                }
+            }
+            if(dataObject instanceof Meter){
+                try {
+                    this.statisticsManager.sendMeterConfigStatisticsRequest(nodeRef);
+                } catch (InterruptedException | ExecutionException e) {
+                    suhLogger.warn("Following exception occured while sending meter statistics request for newly added meter: {}", e);
+                }
+            }
+            if(dataObject instanceof Group){
+                try {
+                    this.statisticsManager.sendGroupDescriptionRequest(nodeRef);
+                } catch (InterruptedException | ExecutionException e) {
+                    suhLogger.warn("Following exception occured while sending group description request for newly added group: {}", e);
+                }
+            }
+            if(dataObject instanceof Queue){
+                Queue queue = (Queue) dataObject;
+                InstanceIdentifier<NodeConnector> nodeConnectorII = dataObjectInstance.firstIdentifierOf(NodeConnector.class);
+                NodeConnectorKey nodeConnectorKey = InstanceIdentifier.keyOf(nodeConnectorII);
+                try {
+                    this.statisticsManager.sendQueueStatsFromGivenNodeConnector(nodeRef, nodeConnectorKey.getId(), queue.getQueueId());
+                } catch (InterruptedException | ExecutionException e) {
+                    suhLogger.warn("Following exception occured while sending queue statistics request for newly added group: {}", e);
+                }
+            }
+        }
+            
+        Set<InstanceIdentifier<? extends DataObject>> removals = change.getRemovedConfigurationData();
+        for (InstanceIdentifier<? extends DataObject> dataObjectInstance : removals) {
+            DataObject dataObject = change.getOriginalConfigurationData().get(dataObjectInstance);
+            
+            if(dataObject instanceof Flow){
+                InstanceIdentifier<Flow> flowII = (InstanceIdentifier<Flow>)dataObjectInstance;
+                InstanceIdentifier<?> flowAugmentation = 
+                        InstanceIdentifier.builder(flowII).augmentation(FlowStatisticsData.class).toInstance();
+                removeAugmentedOperationalData(flowAugmentation);
+            }
+            if(dataObject instanceof Meter){
+                InstanceIdentifier<Meter> meterII = (InstanceIdentifier<Meter>)dataObjectInstance;
+                
+                InstanceIdentifier<?> nodeMeterConfigStatsAugmentation = 
+                        InstanceIdentifier.builder(meterII).augmentation(NodeMeterConfigStats.class).toInstance();
+                removeAugmentedOperationalData(nodeMeterConfigStatsAugmentation);
+
+                InstanceIdentifier<?> nodeMeterStatisticsAugmentation = 
+                        InstanceIdentifier.builder(meterII).augmentation(NodeMeterStatistics.class).toInstance();
+                removeAugmentedOperationalData(nodeMeterStatisticsAugmentation);
+            }
+            
+            if(dataObject instanceof Group){
+                InstanceIdentifier<Group> groupII = (InstanceIdentifier<Group>)dataObjectInstance;
+                
+                InstanceIdentifier<?> nodeGroupDescStatsAugmentation = 
+                        InstanceIdentifier.builder(groupII).augmentation(NodeGroupDescStats.class).toInstance();
+                removeAugmentedOperationalData(nodeGroupDescStatsAugmentation);
+
+                InstanceIdentifier<?> nodeGroupStatisticsAugmentation = 
+                        InstanceIdentifier.builder(groupII).augmentation(NodeGroupStatistics.class).toInstance();
+                removeAugmentedOperationalData(nodeGroupStatisticsAugmentation);
+            }
+            
+            if(dataObject instanceof Queue){
+                InstanceIdentifier<Queue> queueII = (InstanceIdentifier<Queue>)dataObjectInstance;
+                
+                InstanceIdentifier<?> nodeConnectorQueueStatisticsDataAugmentation = 
+                        InstanceIdentifier.builder(queueII).augmentation(FlowCapableNodeConnectorQueueStatisticsData.class).toInstance();
+                removeAugmentedOperationalData(nodeConnectorQueueStatisticsDataAugmentation);
+            }
+        }
+    }
+    
+    private void removeAugmentedOperationalData(InstanceIdentifier<? extends DataObject> dataObjectInstance ){
+        if(dataObjectInstance != null){
+            DataModificationTransaction it = this.statisticsManager.startChange();
+            it.removeOperationalData(dataObjectInstance);
+            it.commit();
+        }
+    }
+}
index e49fb33..c03833d 100644 (file)
         <dependency>
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
-            <version>1.8</version>
+            <version>1.7</version>
         </dependency>
         <dependency>
             <groupId>equinoxSDK381</groupId>
index ed94c8d..36c4f62 100644 (file)
@@ -71,7 +71,7 @@
           <dependency>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
-                   <version>1.8</version>
+                   <version>1.7</version>
                  </dependency>
     <dependency>
             <groupId>org.opendaylight.controller</groupId>
index 8820d58..592d8e4 100644 (file)
@@ -66,7 +66,7 @@ public class Commit extends AbstractConfigNetconfOperation {
                     "Unable to retrieve config snapshot after commit for persister, details: " + e.getMessage(),
                     ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error, e.getErrorInfo());
         }
-        logger.info("Datastore {} committed successfully: {}", Datastore.candidate, status);
+        logger.trace("Datastore {} committed successfully: {}", Datastore.candidate, status);
 
         return document.createElement(XmlNetconfConstants.OK);
     }
index b8fa5dd..3da02a8 100644 (file)
@@ -71,7 +71,7 @@ public class DiscardChanges extends AbstractConfigNetconfOperation {
             throw new NetconfDocumentedException(e.getMessage(), e, ErrorType.application, ErrorTag.operation_failed,
                     ErrorSeverity.error, errorInfo);
         }
-        logger.info("Changes discarded successfully from datastore {}", Datastore.candidate);
+        logger.trace("Changes discarded successfully from datastore {}", Datastore.candidate);
 
         return document.createElement(XmlNetconfConstants.OK);
     }
index b8cae43..24611c2 100644 (file)
@@ -98,7 +98,7 @@ public class Validate extends AbstractConfigNetconfOperation {
 
         }
 
-        logger.info("Datastore {} validated successfully", Datastore.candidate);
+        logger.trace("Datastore {} validated successfully", Datastore.candidate);
 
         return document.createElement(XmlNetconfConstants.OK);
     }
index 709573c..a61d463 100644 (file)
@@ -73,7 +73,7 @@ public class EditConfig extends AbstractConfigNetconfOperation {
             executeSet(configRegistryClient, editConfigExecution);
         }
 
-        logger.info("Operation {} successful", EditConfigXmlParser.EDIT_CONFIG);
+        logger.trace("Operation {} successful", EditConfigXmlParser.EDIT_CONFIG);
 
         return document.createElement(XmlNetconfConstants.OK);
     }
index 8ed9eb8..92e30f1 100644 (file)
@@ -28,7 +28,7 @@ public class MissingInstanceHandlingStrategy extends AbstractEditConfigStrategy
         ObjectName on = null;
         try {
             on = ta.createModule(module, instance);
-            logger.info("New instance for {} {} created under name {}", module, instance, on);
+            logger.trace("New instance for {} {} created under name {}", module, instance, on);
         } catch (InstanceAlreadyExistsException e1) {
             throw new IllegalStateException("Unable to create instance for " + module + " : " + instance);
         }
index ea60209..dd9a071 100644 (file)
@@ -153,7 +153,7 @@ public class Get extends AbstractConfigNetconfOperation {
         ConfigTransactionClient ta = configRegistryClient.getConfigTransactionClient(txOn);
         final Element element = runtime.toXml(runtimeBeans, configBeans, document, new ServiceRegistryWrapper(ta));
 
-        logger.info("{} operation successful", XmlNetconfConstants.GET);
+        logger.trace("{} operation successful", XmlNetconfConstants.GET);
 
         return element;
     }
index 16dd5ad..297f789 100644 (file)
@@ -90,7 +90,7 @@ public class GetConfig extends AbstractConfigNetconfOperation {
         ServiceRegistryWrapper serviceTracker = new ServiceRegistryWrapper(ta);
         dataElement = configMapping.toXml(instances, this.maybeNamespace, document, dataElement, serviceTracker);
 
-        logger.info("{} operation successful", GET_CONFIG);
+        logger.trace("{} operation successful", GET_CONFIG);
 
         return dataElement;
     }
index f838c6f..e7f9772 100644 (file)
@@ -173,7 +173,7 @@ public class RuntimeRpc extends AbstractConfigNetconfOperation {
         final Object result = executeOperation(configRegistryClient, execution.on, execution.operationName,
                 execution.attributes);
 
-        logger.info("Operation {} called successfully on {} with arguments {} with result {}", execution.operationName,
+        logger.trace("Operation {} called successfully on {} with arguments {} with result {}", execution.operationName,
                 execution.on, execution.attributes, result);
 
         if (execution.isVoid()) {
index b66a1a5..889fa84 100644 (file)
@@ -69,7 +69,7 @@ public class ConfigPersisterNotificationHandler implements NotificationListener,
         // Socket should not be closed at this point
         // Activator unregisters this as JMX listener before close is called
 
-        logger.info("Received notification {}", notification);
+        logger.trace("Received notification {}", notification);
         if (notification instanceof CommitJMXNotification) {
             try {
                 handleAfterCommitNotification((CommitJMXNotification) notification);
@@ -87,7 +87,7 @@ public class ConfigPersisterNotificationHandler implements NotificationListener,
         try {
             persisterAggregator.persistConfig(new CapabilityStrippingConfigSnapshotHolder(notification.getConfigSnapshot(),
                     notification.getCapabilities(), ignoredMissingCapabilityRegex));
-            logger.info("Configuration persisted successfully");
+            logger.trace("Configuration persisted successfully");
         } catch (IOException e) {
             throw new RuntimeException("Unable to persist configuration snapshot", e);
         }
index a47d6dd..6e62a98 100644 (file)
@@ -35,6 +35,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 @Immutable
 public class ConfigPusher {
@@ -45,20 +46,24 @@ public class ConfigPusher {
     private final InetSocketAddress address;
     private final EventLoopGroup nettyThreadgroup;
 
-
-    public static final long DEFAULT_TIMEOUT = 120000L;// 120 seconds until netconf must be stable
-    private final long timeout;
+    // Default timeout for netconf becoming stable
+    public static final long DEFAULT_TIMEOUT = TimeUnit.MINUTES.toNanos(2);
+    private final int delayMillis = 5000;
+    private final long timeoutNanos;
 
     public ConfigPusher(InetSocketAddress address, EventLoopGroup nettyThreadgroup) {
-        this(address, DEFAULT_TIMEOUT, nettyThreadgroup);
+        this(address, nettyThreadgroup, DEFAULT_TIMEOUT);
+    }
 
+    @Deprecated
+    public ConfigPusher(InetSocketAddress address, long timeoutMillis, EventLoopGroup nettyThreadgroup) {
+        this(address, nettyThreadgroup, TimeUnit.MILLISECONDS.toNanos(timeoutMillis));
     }
 
-    public ConfigPusher(InetSocketAddress address, long timeout, EventLoopGroup nettyThreadgroup) {
+    public ConfigPusher(InetSocketAddress address, EventLoopGroup nettyThreadgroup, long timeoutNanos) {
         this.address = address;
-        this.timeout = timeout;
-
         this.nettyThreadgroup = nettyThreadgroup;
+        this.timeoutNanos = timeoutNanos;
     }
 
     public synchronized NetconfClient init(List<ConfigSnapshotHolder> configs) throws InterruptedException {
@@ -121,39 +126,36 @@ public class ConfigPusher {
         // TODO think about moving capability subset check to netconf client
         // could be utilized by integration tests
 
-        long pollingStart = System.currentTimeMillis();
-        int delay = 5000;
-
+        final long pollingStart = System.nanoTime();
+        final long deadline = pollingStart + timeoutNanos;
         int attempt = 0;
 
-        long deadline = pollingStart + timeout;
-
         String additionalHeader = NetconfMessageAdditionalHeader.toString("unknown", address.getAddress().getHostAddress(),
                 Integer.toString(address.getPort()), "tcp", Optional.of("persister"));
 
         Set<String> latestCapabilities = new HashSet<>();
-        while (System.currentTimeMillis() < deadline) {
+        while (System.nanoTime() < deadline) {
             attempt++;
             NetconfClientDispatcher netconfClientDispatcher = new NetconfClientDispatcher(nettyThreadgroup,
                     nettyThreadgroup, additionalHeader);
             NetconfClient netconfClient;
             try {
-                netconfClient = new NetconfClient(this.toString(), address, delay, netconfClientDispatcher);
+                netconfClient = new NetconfClient(this.toString(), address, delayMillis, netconfClientDispatcher);
             } catch (IllegalStateException e) {
                 logger.debug("Netconf {} was not initialized or is not stable, attempt {}", address, attempt, e);
                 netconfClientDispatcher.close();
-                Thread.sleep(delay);
+                Thread.sleep(delayMillis);
                 continue;
             }
             latestCapabilities = netconfClient.getCapabilities();
             if (Util.isSubset(netconfClient, expectedCaps)) {
                 logger.debug("Hello from netconf stable with {} capabilities", latestCapabilities);
-                logger.info("Session id received from netconf server: {}", netconfClient.getClientSession());
+                logger.trace("Session id received from netconf server: {}", netconfClient.getClientSession());
                 return netconfClient;
             }
             logger.debug("Polling hello from netconf, attempt {}, capabilities {}", attempt, latestCapabilities);
             Util.closeClientAndDispatcher(netconfClient);
-            Thread.sleep(delay);
+            Thread.sleep(delayMillis);
         }
         Set<String> allNotFound = new HashSet<>(expectedCaps);
         allNotFound.removeAll(latestCapabilities);
@@ -167,7 +169,7 @@ public class ConfigPusher {
             throws ConflictingVersionException, IOException, SAXException {
 
         Element xmlToBePersisted = XmlUtil.readXmlToElement(configSnapshotHolder.getConfigSnapshot());
-        logger.info("Pushing last configuration to netconf: {}", configSnapshotHolder);
+        logger.trace("Pushing last configuration to netconf: {}", configSnapshotHolder);
         StringBuilder response = new StringBuilder("editConfig response = {");
 
         NetconfMessage message = createEditConfigMessage(xmlToBePersisted, "/netconfOp/editConfig.xml");
@@ -186,7 +188,7 @@ public class ConfigPusher {
         response.append("commit response = {");
         response.append(XmlUtil.toString(responseMessage.getDocument()));
         response.append("}");
-        logger.info("Last configuration loaded successfully");
+        logger.trace("Last configuration loaded successfully");
         logger.trace("Detailed message {}", response);
     }
 
index 3c901c3..8579120 100644 (file)
@@ -25,6 +25,7 @@ import javax.management.MBeanServer;
 import java.lang.management.ManagementFactory;
 import java.net.InetSocketAddress;
 import java.util.regex.Pattern;
+import java.util.concurrent.TimeUnit;
 
 public class ConfigPersisterActivator implements BundleActivator {
 
@@ -33,6 +34,8 @@ public class ConfigPersisterActivator implements BundleActivator {
     private final static MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
     private static final String IGNORED_MISSING_CAPABILITY_REGEX_SUFFIX = "ignoredMissingCapabilityRegex";
 
+    private static final String PUSH_TIMEOUT = "pushTimeout";
+
     public static final String NETCONF_CONFIG_PERSISTER = "netconf.config.persister";
 
     public static final String STORAGE_ADAPTER_CLASS_PROP_SUFFIX = "storageAdapterClass";
@@ -59,6 +62,10 @@ public class ConfigPersisterActivator implements BundleActivator {
         } else {
             regex = DEFAULT_IGNORED_REGEX;
         }
+
+        String timeoutProperty = propertiesProvider.getProperty(PUSH_TIMEOUT);
+        long timeout = timeoutProperty == null ? ConfigPusher.DEFAULT_TIMEOUT : TimeUnit.SECONDS.toNanos(Integer.valueOf(timeoutProperty));
+
         final Pattern ignoredMissingCapabilityRegex = Pattern.compile(regex);
         nettyThreadgroup = new NioEventLoopGroup();
 
index ba9e4d0..f34529d 100644 (file)
@@ -95,7 +95,7 @@ public final class DefaultGetSchema extends AbstractNetconfOperation implements
         XmlUtil.addNamespaceAttr(getSchemaResult,
                 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING);
 
-        logger.info("{} operation successful", GET_SCHEMA);
+        logger.trace("{} operation successful", GET_SCHEMA);
 
         return getSchemaResult;
     }
index 9e84be6..679e280 100644 (file)
@@ -73,7 +73,7 @@ public class DefaultStartExi extends AbstractNetconfOperation implements Default
                     .createElement(XmlNetconfConstants.RPC_ERROR);\r
         }\r
 \r
-        logger.info("{} operation successful", START_EXI);\r
+        logger.trace("{} operation successful", START_EXI);\r
         logger.debug("received start-exi message {} ", XmlUtil.toString(document));\r
         return getSchemaResult;\r
 \r
index 2c6c896..d841a66 100644 (file)
@@ -57,7 +57,7 @@ public class DefaultStopExi extends AbstractNetconfOperation implements DefaultN
         Element getSchemaResult = document.createElement(XmlNetconfConstants.OK);\r
         XmlUtil.addNamespaceAttr(getSchemaResult,\r
                 XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);\r
-        logger.info("{} operation successful", STOP_EXI);\r
+        logger.trace("{} operation successful", STOP_EXI);\r
         logger.debug("received stop-exi message {} ", XmlUtil.toString(document));\r
         return getSchemaResult;\r
     }\r
index 8b3c5d7..9162400 100644 (file)
@@ -43,7 +43,7 @@ public class NetconfSSHActivator implements BundleActivator{
     ServiceTrackerCustomizer<IUserManager, IUserManager> customizer = new ServiceTrackerCustomizer<IUserManager, IUserManager>(){
         @Override
         public IUserManager addingService(ServiceReference<IUserManager> reference) {
-            logger.info("Service {} added, let there be SSH bridge.", reference);
+            logger.trace("Service {} added, let there be SSH bridge.", reference);
             iUserManager =  context.getService(reference);
             try {
                 onUserManagerFound(iUserManager);
@@ -54,12 +54,12 @@ public class NetconfSSHActivator implements BundleActivator{
         }
         @Override
         public void modifiedService(ServiceReference<IUserManager> reference, IUserManager service) {
-            logger.info("Replacing modified service {} in netconf SSH.", reference);
+            logger.trace("Replacing modified service {} in netconf SSH.", reference);
             server.addUserManagerService(service);
         }
         @Override
         public void removedService(ServiceReference<IUserManager> reference, IUserManager service) {
-            logger.info("Removing service {} from netconf SSH. " +
+            logger.trace("Removing service {} from netconf SSH. " +
                     "SSH won't authenticate users until IUserManeger service will be started.", reference);
             removeUserManagerService();
         }
index d159f59..d1b5213 100644 (file)
@@ -194,7 +194,7 @@ public class SocketThread implements Runnable, ServerAuthenticationCallback, Ser
                 return AuthenticationResult.SUCCESS;
             }
         } catch (Exception e){
-            logger.info("Authentication failed due to :" + e.getLocalizedMessage());
+            logger.warn("Authentication failed due to :" + e.getLocalizedMessage());
         }
         return AuthenticationResult.FAILURE;
     }
index a432169..6dc00bb 100644 (file)
@@ -34,13 +34,13 @@ public class SendErrorExceptionUtil {
 
     public static void sendErrorMessage(final NetconfSession session,
             final NetconfDocumentedException sendErrorException) {
-        logger.info("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+        logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
         final Document errorDocument = createDocument(sendErrorException);
         session.sendMessage(new NetconfMessage(errorDocument));
     }
 
     public static void sendErrorMessage(Channel channel, NetconfDocumentedException sendErrorException) {
-        logger.info("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+        logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
         final Document errorDocument = createDocument(sendErrorException);
         channel.writeAndFlush(new NetconfMessage(errorDocument));
     }
@@ -48,7 +48,7 @@ public class SendErrorExceptionUtil {
     public static void sendErrorMessage(NetconfSession session, NetconfDocumentedException sendErrorException,
             NetconfMessage incommingMessage) {
         final Document errorDocument = createDocument(sendErrorException);
-        logger.info("Sending error {}", XmlUtil.toString(errorDocument));
+        logger.trace("Sending error {}", XmlUtil.toString(errorDocument));
         tryToCopyAttributes(incommingMessage.getDocument(), errorDocument, sendErrorException);
         session.sendMessage(new NetconfMessage(errorDocument));
     }
index 0c64082..c590da4 100644 (file)
@@ -313,7 +313,7 @@ import org.slf4j.LoggerFactory;
             }
         }
         if (conflictsMsg.length() > 0) {
-            LOGGER.info("JAXB type conflicts detected : {}", conflictsMsg.toString());
+            LOGGER.warn("JAXB type conflicts detected : {}", conflictsMsg.toString());
         }
     }
 
index bf8844d..58ba776 100644 (file)
@@ -135,7 +135,7 @@ public class NorthboundUtils {
         } else {
             auditMsg = "Mode: " + mode + " User " + user + " "  + action + " " + moduleName + " " + resource;
         }
-        logger.info(auditMsg);
+        logger.trace(auditMsg);
     }
 
     public static void auditlog(String moduleName, String user, String action, String resource) {
index 70c5072..47461f4 100644 (file)
@@ -150,7 +150,7 @@ public class ControllerIO {
             } else {
                 if (!currentlyUp) {
                     // only generate log if the interface changes from down to up
-                    logger.info("Interface {} with address {} is UP!",
+                    logger.trace("Interface {} with address {} is UP!",
                             netInt.getDisplayName(),
                             controllerIP.getHostAddress());
                 }
index 8111352..394be07 100644 (file)
@@ -412,7 +412,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
 
         List<LLDPTLV> optionalTLVList = lldp.getOptionalTLVList();
         if (optionalTLVList == null) {
-            logger.info("The discovery packet with null custom option from {}", dstNodeConnector);
+            logger.warn("The discovery packet with null custom option from {}", dstNodeConnector);
             return false;
         }
 
index 361f977..78a2ea5 100644 (file)
@@ -423,7 +423,7 @@ public class FlowConverter {
                     continue;
                 }
                 if (action.getType() == ActionType.SET_NEXT_HOP) {
-                    logger.info("Unsupported action: {}", action);
+                    logger.warn("Unsupported action: {}", action);
                     continue;
                 }
             }
index 27a7ae6..e5883d6 100644 (file)
@@ -431,7 +431,7 @@ public class OFStatisticsManager implements IOFStatisticsManager, IInventoryShim
     }
 
     private void printInfoMessage(String type, StatsRequest request) {
-        log.info("{} stats request not inserted for switch: {}. Queue size: {}. Collector state: {}.",
+        log.trace("{} stats request not inserted for switch: {}. Queue size: {}. Collector state: {}.",
                 new Object[] {type, HexString.toHexString(request.switchId), pendingStatsRequests.size(),
                 statisticsCollector.getState().toString() });
     }
index ff91e93..77d03aa 100644 (file)
@@ -91,23 +91,23 @@ public class ConfigManager implements IConfigManager{
     }
 
     public VIP getVIPWithPoolName(VIP vip){
-        cmLogger.info("Search a VIP with name:{}",vip);
+        cmLogger.trace("Search a VIP with name:{}",vip);
         for(VIP vipTemp: this.vips.values()){
             if(vipTemp.equals(vip)){
 
-                cmLogger.info("Found VIP with pool detail : {}",vipTemp);
+                cmLogger.trace("Found VIP with pool detail : {}",vipTemp);
                 return vipTemp;
             }
         }
 
-        cmLogger.info("VIP with pool detail not found ");
+        cmLogger.trace("VIP with pool detail not found ");
         return null;
     }
 
     @Override
     public VIP createVIP(String name,String ip,String protocol,short protocolPort,String poolName){
 
-        cmLogger.info("Create VIP with the following details :[ name : "+name
+        cmLogger.trace("Create VIP with the following details :[ name : "+name
                                                                     +" ip : "+ip
                                                                     +" protocol : "+protocol
                                                                     +" protocol_port : "+protocolPort
@@ -124,7 +124,7 @@ public class ConfigManager implements IConfigManager{
         vip.setStatus(LBConst.STATUS_ACTIVE);
         this.vips.put(name, vip);
 
-        cmLogger.info("New VIP created : "+vip.toString());
+        cmLogger.trace("New VIP created : "+vip.toString());
         return vip;
     }
 
@@ -136,7 +136,7 @@ public class ConfigManager implements IConfigManager{
     @Override
     public VIP updateVIP(String name, String poolName){
 
-        cmLogger.info("Updating VIP : "+name+" pool name  to "+poolName);
+        cmLogger.trace("Updating VIP : "+name+" pool name  to "+poolName);
 
         if(vips.containsKey(name)){
             VIP vip = vips.get(name);
@@ -154,7 +154,7 @@ public class ConfigManager implements IConfigManager{
     @Override
     public VIP deleteVIP(String name){
 
-        cmLogger.info("Deleting VIP : "+name);
+        cmLogger.trace("Deleting VIP : "+name);
 
         VIP vip = vips.get(name);
 
@@ -167,7 +167,7 @@ public class ConfigManager implements IConfigManager{
             }
         }
 
-        cmLogger.info("VIP removed : "+vip.toString());
+        cmLogger.trace("VIP removed : "+vip.toString());
 
         vips.remove(vip.getName());
 
@@ -196,7 +196,7 @@ public class ConfigManager implements IConfigManager{
 
         PoolMember pm = new PoolMember(name,memberIP,poolName);
 
-        cmLogger.info("Adding pool member : "+pm.toString());
+        cmLogger.trace("Adding pool member : "+pm.toString());
 
         pools.get(poolName).addMember(pm);
 
@@ -206,7 +206,7 @@ public class ConfigManager implements IConfigManager{
     @Override
     public PoolMember removePoolMember(String name, String poolName){
 
-        cmLogger.info("Removing pool member : {} from pool {}",name, poolName);
+        cmLogger.trace("Removing pool member : {} from pool {}",name, poolName);
 
         Pool pool = pools.get(poolName);
 
@@ -214,7 +214,7 @@ public class ConfigManager implements IConfigManager{
 
         pool.removeMember(name);
 
-        cmLogger.info("Pool member {} removed from {} ",name,poolName);
+        cmLogger.trace("Pool member {} removed from {} ",name,poolName);
 
         return pm;
     }
@@ -240,7 +240,7 @@ public class ConfigManager implements IConfigManager{
 
         Pool newPool = new Pool(name,lbMethod);
 
-        cmLogger.info("New pool created : " + newPool.toString());
+        cmLogger.trace("New pool created : " + newPool.toString());
 
         pools.put(name, newPool);
 
@@ -258,7 +258,7 @@ public class ConfigManager implements IConfigManager{
 
         }
 
-        cmLogger.info("Pool removed : "+pool.toString());
+        cmLogger.trace("Pool removed : "+pool.toString());
 
         pools.remove(poolName);
 
index aa195a3..729a49b 100644 (file)
@@ -35,17 +35,17 @@ public class LBUtil {
      * @return  Details of the source machine in Client object.
      */
     public Client getClientFromPacket(IPv4 inPkt){
-        lbuLogger.info("Find client information from packet : {}",inPkt.toString());
+        lbuLogger.trace("Find client information from packet : {}",inPkt.toString());
 
         String ip = NetUtils.getInetAddress(inPkt.getSourceAddress()).getHostAddress();
 
         String protocol = IPProtocols.getProtocolName(inPkt.getProtocol());
 
-        lbuLogger.info("client ip {} and protocl {}",ip,protocol);
+        lbuLogger.trace("client ip {} and protocl {}",ip,protocol);
 
         Packet tpFrame= inPkt.getPayload();
 
-        lbuLogger.info("Get protocol layer {}",tpFrame.toString());
+        lbuLogger.trace("Get protocol layer {}",tpFrame.toString());
 
         short port = 0;
 
@@ -57,11 +57,11 @@ public class LBUtil {
             port = udpFrame.getSourcePort();
         }
 
-        lbuLogger.info("Found port {}",port);
+        lbuLogger.trace("Found port {}",port);
 
         Client source = new Client(ip, protocol,port);
 
-        lbuLogger.info("Client information : {}",source.toString());
+        lbuLogger.trace("Client information : {}",source.toString());
 
         return source;
     }
@@ -74,7 +74,7 @@ public class LBUtil {
      */
     public VIP getVIPFromPacket(IPv4 inPkt){
 
-        lbuLogger.info("Find VIP information from packet : {}",inPkt.toString());
+        lbuLogger.trace("Find VIP information from packet : {}",inPkt.toString());
 
         String ip = NetUtils.getInetAddress(inPkt.getDestinationAddress()).getHostAddress();
 
@@ -95,7 +95,7 @@ public class LBUtil {
 
         VIP dest = new VIP(null,ip, protocol,port,null);
 
-        lbuLogger.info("VIP information : {}",dest.toString());
+        lbuLogger.trace("VIP information : {}",dest.toString());
 
         return dest;
     }
index b2229cb..e1a997b 100644 (file)
@@ -268,14 +268,14 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager {
                                 forwardPort = hnConnector.getnodeConnector();
 
                                 lbsLogger
-                                        .info("Both source (client) and destination pool machine is connected to same switch nodes. Respective ports are - {},{}",
+                                        .trace("Both source (client) and destination pool machine is connected to same switch nodes. Respective ports are - {},{}",
                                                 forwardPort, inPkt.getIncomingNodeConnector());
 
                             } else {
 
                                 Path route = this.routing.getRoute(clientNode, destNode);
 
-                                lbsLogger.info("Path between source (client) and destination switch nodes : {}",
+                                lbsLogger.trace("Path between source (client) and destination switch nodes : {}",
                                         route.toString());
 
                                 forwardPort = route.getEdges().get(0).getTailNodeConnector();
@@ -285,7 +285,7 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager {
                             if (installLoadBalancerFlow(client, vip, clientNode, poolMemberIp,
                                     hnConnector.getDataLayerAddressBytes(), forwardPort,
                                     LBConst.FORWARD_DIRECTION_LB_FLOW)) {
-                                lbsLogger.info("Traffic from client : {} will be routed " + "to pool machine : {}",
+                                lbsLogger.trace("Traffic from client : {} will be routed " + "to pool machine : {}",
                                         client, poolMemberIp);
                             } else {
                                 lbsLogger.error("Not able to route traffic from client : {}", client);
@@ -293,7 +293,7 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager {
 
                             if (installLoadBalancerFlow(client, vip, clientNode, poolMemberIp, vipMacAddr,
                                     inPkt.getIncomingNodeConnector(), LBConst.REVERSE_DIRECTION_LB_FLOW)) {
-                                lbsLogger.info("Flow rule installed to change the source ip/mac from "
+                                lbsLogger.trace("Flow rule installed to change the source ip/mac from "
                                         + "pool machine ip {} to VIP {} for traffic coming pool machine", poolMemberIp,
                                         vip);
                             } else {
@@ -389,7 +389,7 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager {
 
         FlowEntry fEntry = new FlowEntry(policyName, flowName, flow, sourceSwitch);
 
-        lbsLogger.info("Install flow entry {} on node {}", fEntry.toString(), sourceSwitch.toString());
+        lbsLogger.trace("Install flow entry {} on node {}", fEntry.toString(), sourceSwitch.toString());
 
         if (!this.ruleManager.checkFlowEntryConflict(fEntry)) {
             if (this.ruleManager.installFlowEntry(fEntry).isSuccess()) {
@@ -413,13 +413,13 @@ public class LoadBalancerService implements IListenDataPacket, IConfigManager {
         if (props != null) {
             this.containerName = (String) props.get("containerName");
 
-            lbsLogger.info("Running container name:" + this.containerName);
+            lbsLogger.trace("Running container name:" + this.containerName);
         } else {
 
             // In the Global instance case the containerName is empty
             this.containerName = "";
         }
-        lbsLogger.info(configManager.toString());
+        lbsLogger.trace(configManager.toString());
 
     }
 
index ba5d5ba..c169d79 100644 (file)
@@ -57,7 +57,7 @@ public class RandomLBPolicy implements ILoadBalancingPolicy {
     @Override
     public String getPoolMemberForClient(Client source, VIP dest){
 
-        rLogger.info("Received traffic from client : {} for VIP : {} ",source, dest);
+        rLogger.trace("Received traffic from client : {} for VIP : {} ",source, dest);
 
         syncWithLoadBalancerData();
 
@@ -65,14 +65,14 @@ public class RandomLBPolicy implements ILoadBalancingPolicy {
 
         if(this.clientMemberMap.containsKey(source)){
             pm= this.clientMemberMap.get(source);
-            rLogger.info("Client {} had sent traffic before,new traffic will be routed to the same pool member {}",source,pm);
+            rLogger.trace("Client {} had sent traffic before,new traffic will be routed to the same pool member {}",source,pm);
         }else{
             Pool pool = null;
             pool = this.cmgr.getPool(dest.getPoolName());
             int memberNum = this.randomGenerator.nextInt(pool.getAllMembers().size()-1);
             pm = pool.getAllMembers().get(memberNum);
             this.clientMemberMap.put(source, pm );
-            rLogger.info("Network traffic from client {} will be directed to pool member {}",pm);
+            rLogger.trace("Network traffic from client {} will be directed to pool member {}",pm);
         }
         return pm.getIp();
     }
index 1a473a7..492c7a9 100644 (file)
@@ -60,7 +60,7 @@ public class RoundRobinLBPolicy implements ILoadBalancingPolicy{
     @Override
     public String getPoolMemberForClient(Client source, VIP dest){
 
-        rrLogger.info("Received traffic from client : {} for VIP : {} ",source, dest);
+        rrLogger.trace("Received traffic from client : {} for VIP : {} ",source, dest);
 
         syncWithLoadBalancerData();
 
@@ -69,7 +69,7 @@ public class RoundRobinLBPolicy implements ILoadBalancingPolicy{
         if(this.clientMemberMap.containsKey(source)){
 
             pm= this.clientMemberMap.get(source);
-            rrLogger.info("Client {} had sent traffic before,new traffic will be routed to the same pool member {}",source,pm);
+            rrLogger.trace("Client {} had sent traffic before,new traffic will be routed to the same pool member {}",source,pm);
         }else{
 
             Pool pool = null;
@@ -80,7 +80,7 @@ public class RoundRobinLBPolicy implements ILoadBalancingPolicy{
                 pool = this.cmgr.getPool(dest.getPoolName());
                 pm = pool.getAllMembers().get(memberNum);
                 this.clientMemberMap.put(source, pm );
-                rrLogger.info("New client's packet will be directed to pool member {}",pm);
+                rrLogger.trace("New client's packet will be directed to pool member {}",pm);
                 memberNum++;
 
                 if(memberNum > pool.getAllMembers().size()-1){
@@ -95,7 +95,7 @@ public class RoundRobinLBPolicy implements ILoadBalancingPolicy{
                 pm = pool.getAllMembers().get(0);
                 this.clientMemberMap.put(source, pm);
 
-                rrLogger.info("Network traffic from client {} will be directed to pool member {}",pm);
+                rrLogger.trace("Network traffic from client {} will be directed to pool member {}",pm);
                 this.nextItemFromPool.put(dest, 1);
                 rrLogger.debug("Next pool member for new client of VIP is set to {}",pool.getAllMembers().get(1));
             }
index 7a3625a..4b3363b 100644 (file)
@@ -168,7 +168,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
 
     private void allocateCaches() {
         if (this.clusterContainerService == null) {
-            log.info("un-initialized clusterContainerService, can't create cache");
+            log.trace("un-initialized clusterContainerService, can't create cache");
             return;
         }
 
@@ -185,7 +185,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
     @SuppressWarnings({ "unchecked" })
     private void retrieveCaches() {
         if (this.clusterContainerService == null) {
-            log.info("un-initialized clusterContainerService, can't retrieve cache");
+            log.trace("un-initialized clusterContainerService, can't retrieve cache");
             return;
         }
 
@@ -198,7 +198,7 @@ public class SimpleForwardingImpl implements IfNewHostNotify,
 
     private void destroyCaches() {
         if (this.clusterContainerService == null) {
-            log.info("un-initialized clusterContainerService, can't destroy cache");
+            log.trace("un-initialized clusterContainerService, can't destroy cache");
             return;
         }
 
index 56df8e2..2794109 100644 (file)
@@ -25,6 +25,7 @@ public class Subnet implements Cloneable, Serializable {
     private static final long serialVersionUID = 1L;
     // Key fields
     private InetAddress networkAddress;
+    private transient InetAddress subnetPrefix;
     private short subnetMaskLength;
     // Property fields
     private short vlan;
@@ -114,6 +115,7 @@ public class Subnet implements Cloneable, Serializable {
      */
     public Subnet setNetworkAddress(InetAddress networkAddress) {
         this.networkAddress = networkAddress;
+        this.subnetPrefix = null;
         return this;
     }
 
@@ -159,10 +161,12 @@ public class Subnet implements Cloneable, Serializable {
         if (ip == null) {
             return false;
         }
-        InetAddress thisPrefix = getPrefixForAddress(this.networkAddress);
+        if(subnetPrefix == null) {
+            subnetPrefix = getPrefixForAddress(this.networkAddress);
+        }
         InetAddress otherPrefix = getPrefixForAddress(ip);
         boolean isSubnetOf = true;
-        if (((thisPrefix == null) || (otherPrefix == null)) || (!thisPrefix.equals(otherPrefix)) ) {
+        if (((subnetPrefix == null) || (otherPrefix == null)) || (!subnetPrefix.equals(otherPrefix)) ) {
             isSubnetOf = false;
         }
         return isSubnetOf;
index 4b186fc..8808bee 100644 (file)
@@ -237,7 +237,7 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa
     @SuppressWarnings({ "unchecked" })
     private void retrieveCaches() {
         if (this.clusterContainerService == null) {
-            log.info("un-initialized clusterContainerService, can't create cache");
+            log.warn("un-initialized clusterContainerService, can't create cache");
             return;
         }
 
@@ -789,7 +789,7 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa
             return;
         }
 
-        log.info("Set Node {}'s Mode to {}", nodeId, cfgObject.getMode());
+        log.trace("Set Node {}'s Mode to {}", nodeId, cfgObject.getMode());
 
         if (modeChange) {
             notifyModeChange(node, cfgObject.isProactive());
index 5d0cbb6..5d673fb 100644 (file)
@@ -276,18 +276,18 @@ public class UserManager implements IUserManager, IObjectReader,
                 rcResponse = aaaClient.authService(userName, password,
                         aaaServer.getAddress(), aaaServer.getSecret());
                 if (rcResponse.getStatus() == AuthResultEnum.AUTH_ACCEPT) {
-                    logger.info(
+                    logger.trace(
                             "Remote Authentication Succeeded for User: \"{}\", by Server: {}",
                             userName, aaaServer.getAddress());
                     remotelyAuthenticated = true;
                     break;
                 } else if (rcResponse.getStatus() == AuthResultEnum.AUTH_REJECT) {
-                    logger.info(
+                    logger.trace(
                             "Remote Authentication Rejected User: \"{}\", from Server: {}, Reason:{}",
                             new Object[] { userName, aaaServer.getAddress(),
                                     rcResponse.getStatus().toString() });
                 } else {
-                    logger.info(
+                    logger.trace(
                             "Remote Authentication Failed for User: \"{}\", from Server: {}, Reason:{}",
                             new Object[] { userName, aaaServer.getAddress(),
                                     rcResponse.getStatus().toString() });
@@ -684,7 +684,7 @@ public class UserManager implements IUserManager, IObjectReader,
         // Trigger cluster update
         localUserConfigList.put(user, targetConfigEntry);
 
-        logger.info("Password changed for User \"{}\"", user);
+        logger.trace("Password changed for User \"{}\"", user);
 
         return status;
     }
@@ -694,7 +694,7 @@ public class UserManager implements IUserManager, IObjectReader,
         // TODO: if user was authenticated through AAA server, send
         // Acct-Status-Type=stop message to server with logout as reason
         removeUserFromActiveList(userName);
-        logger.info("User \"{}\" logged out", userName);
+        logger.trace("User \"{}\" logged out", userName);
     }
 
     /*
@@ -705,7 +705,7 @@ public class UserManager implements IUserManager, IObjectReader,
         // TODO: if user was authenticated through AAA server, send
         // Acct-Status-Type=stop message to server with timeout as reason
         removeUserFromActiveList(userName);
-        logger.info("User \"{}\" timed out", userName);
+        logger.trace("User \"{}\" timed out", userName);
     }
 
     @Override
index 6f09577..fb252bf 100644 (file)
@@ -73,7 +73,7 @@ public class DaylightWebUtil {
         } else {
             auditMsg = "Mode: " + mode + " User " + user + " "  + action + " " + moduleName + " " + resource;
         }
-        logger.info(auditMsg);
+        logger.trace(auditMsg);
     }
 
     public static void auditlog(String moduleName, String user, String action, String resource) {