Fix default schema cache failures 75/72775/1
authorTom Pantelis <tompantelis@gmail.com>
Fri, 8 Jun 2018 02:45:55 +0000 (22:45 -0400)
committerTom Pantelis <tompantelis@gmail.com>
Fri, 8 Jun 2018 02:45:55 +0000 (22:45 -0400)
commit29900137ce29276cecae2a95f758205887f67da9
tree08aa10b2017f7a30f24a0d21b23a52ef867904a2
parentb823dc5b5d2b245db10368e7de52f50a7bdb651c
Fix default schema cache failures

We've these seen intermittent failures on jenkins:

 Caused by: java.lang.IllegalArgumentException: Unable to create cache directory at cache/schema
     at com.google.common.base.Preconditions.checkArgument(Preconditions.java:210)
     at org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache.<init>(FilesystemSchemaSourceCache.java:74)
     at org.opendaylight.netconf.topology.AbstractNetconfTopology.<clinit>(AbstractNetconfTopology.java:149)

In FilesystemSchemaSourceCache"

  if (!storageDirectory.exists()) {
      checkArgument(storageDirectory.mkdirs(), "Unable to create cache directory at %s",
              storageDirectory);
  }

mkdirs returns false if the dir/file already exists - this seems the likely reason
in this case even though it checks exists() just prior. This scenario could happen
if there's a race where some other component interleaves and creates the dir in
between the exists and mkdirs calls.

To protect against this sceniario, AbstractNetconfTopology and NetconfTopologyUtils
were changed to retry if FilesystemSchemaSourceCache throws an IAE. Also they no
longer fail class initialization on failure.

Change-Id: I9f7ec134e7fd817aa753f0db175bf5620cc52ff4
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologyUtils.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java