<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.yangtools</groupId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<packaging>bundle</packaging>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<packaging>bundle</packaging>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<packaging>bundle</packaging>
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayList;
import java.util.List;
// Shouldn't happen
fail("Unexpected failure " + t);
}
- });
+ }, MoreExecutors.directExecutor());
}
@Test
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
caughtEx.set(t);
futureCompletedLatch.countDown();
}
- });
+ }, MoreExecutors.directExecutor());
initialInvoker.invokeExecutor(executor, task);
<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
<!--
- Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ Copyright © 2016 Red Hat, 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.opendaylight.odlparent</groupId>
- <artifactId>features-parent</artifactId>
- <version>1.9.0</version>
+ <artifactId>feature-repo-parent</artifactId>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>features-yangtools</artifactId>
<version>1.2.0-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>${project.version}</version>
- <scope>import</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <packaging>feature</packaging>
<dependencies>
<dependency>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>features-odlparent</artifactId>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>odl-yangtools-common</artifactId>
+ <version>${project.version}</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-codec-gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-codec-xml</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-impl</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>object-cache-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>object-cache-guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>object-cache-noop</artifactId>
+ <artifactId>odl-yangtools-yang-data</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
- <artifactId>triemap</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <artifactId>odl-yangtools-yang-parser</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
</dependency>
</dependencies>
<url>${nexus.site.url}/${project.artifactId}/</url>
</site>
</distributionManagement>
+
</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: -->
-<!--
- Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<features name="odl-yangtools-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0">
- <repository>mvn:org.opendaylight.odlparent/features-odlparent/{{VERSION}}/xml/features</repository>
- <feature name='odl-yangtools-yang-data' version='${project.version}' description='OpenDaylight :: Yangtools :: Data Binding'>
- <feature version='${project.version}' dependency="true">odl-yangtools-yang-parser</feature>
- <bundle>mvn:org.opendaylight.yangtools/yang-data-impl/{{VERSION}}</bundle>
-
- <!-- GSON-based JSON codec. Can be split out -->
- <bundle dependency="true">mvn:com.google.code.gson/gson/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-data-codec-gson/{{VERSION}}</bundle>
-
- <bundle>mvn:org.opendaylight.yangtools/yang-data-codec-xml/{{VERSION}}</bundle>
- </feature>
-
- <feature name='odl-yangtools-common' version='${project.version}' description='OpenDaylight :: Yangtools :: Common'>
- <feature version="[1.7.0, 2.0.0)" dependency="true">odl-guava-18</feature>
- <feature version="[1.7.0, 2.0.0)" dependency="true">odl-triemap-0.2</feature>
- <bundle>mvn:org.opendaylight.yangtools/concepts/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-common/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/util/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/object-cache-api/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/object-cache-guava/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/object-cache-noop/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/triemap/{{VERSION}}</bundle>
- </feature>
-
- <feature name='odl-yangtools-yang-parser' version='${project.version}' description='OpenDaylight :: Yangtools :: YANG Parser'>
- <feature version='${project.version}' dependency="true">odl-yangtools-common</feature>
- <bundle dependency="true">mvn:org.antlr/antlr4-runtime/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-model-api/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-model-util/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-data-api/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-data-util/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-parser-api/{{VERSION}}</bundle>
- <bundle>mvn:org.opendaylight.yangtools/yang-parser-impl/{{VERSION}}</bundle>
- </feature>
-
-</features>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2016 Red Hat, 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
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>feature-repo-parent</artifactId>
- <version>1.9.0</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>features4-yangtools</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>odl-yangtools-common</artifactId>
- <version>${project.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>odl-yangtools-yang-data</artifactId>
- <version>${project.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>odl-yangtools-yang-parser</artifactId>
- <version>${project.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- </dependency>
- </dependencies>
-
- <!--
- Maven Site Configuration
-
- The following configuration is necessary for maven-site-plugin to
- correctly identify the correct deployment path for OpenDaylight Maven
- sites.
- -->
- <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
-
- <distributionManagement>
- <site>
- <id>opendaylight-site</id>
- <url>${nexus.site.url}/${project.artifactId}/</url>
- </site>
- </distributionManagement>
-
-</project>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-artifacts</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependencies>
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odl4-guava-18</artifactId>
+ <artifactId>odl-guava-22</artifactId>
+ <version>2.0.0</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odl4-triemap-0.2</artifactId>
+ <artifactId>odl-triemap-0.2</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<packaging>pom</packaging>
<modules>
- <!-- Karaf 3 features -->
- <module>features-yangtools</module>
-
<!-- Karaf 4 features -->
<module>odl-yangtools-common</module>
<module>odl-yangtools-yang-data</module>
<module>odl-yangtools-yang-parser</module>
- <module>features4-yangtools</module>
+ <module>features-yangtools</module>
</modules>
<!--
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
package org.opendaylight.yangtools.yang.common;
import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
try {
return Revision.forString(str);
} catch (ParseException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
import static org.w3c.dom.Node.TEXT_NODE;
import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.net.URI;
throws IOException {
try {
((JSONCodec<Object>) codec).writeValue(writer, value);
- } catch (IOException e) {
+ } catch (IOException | RuntimeException e) {
throw e;
} catch (Exception e) {
- Throwables.propagateIfPossible(e);
throw new RuntimeException(e);
}
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
try {
return complexCodecs.get(schema, () -> codec);
} catch (ExecutionException e) {
- throw Throwables.propagate(e.getCause());
+ final Throwable cause = e.getCause();
+ Throwables.throwIfUnchecked(cause);
+ throw new RuntimeException(e);
}
}
try {
return simpleCodecs.get(type, () -> codec);
} catch (ExecutionException e) {
- throw Throwables.propagate(e.getCause());
+ final Throwable cause = e.getCause();
+ Throwables.throwIfUnchecked(cause);
+ throw new RuntimeException(e);
}
}
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
import com.google.common.collect.Multimap;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.FutureFallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@GuardedBy("this")
private final Collection<SchemaListenerRegistration> listeners = new ArrayList<>();
- private static <T extends SchemaSourceRepresentation> CheckedFuture<T, SchemaSourceException> fetchSource(
+ @SuppressWarnings("unchecked")
+ private static <T extends SchemaSourceRepresentation> ListenableFuture<T> fetchSource(
final SourceIdentifier id, final Iterator<AbstractSchemaSourceRegistration<?>> it) {
final AbstractSchemaSourceRegistration<?> reg = it.next();
- @SuppressWarnings("unchecked")
- final CheckedFuture<? extends T, SchemaSourceException> f =
- ((SchemaSourceProvider<T>)reg.getProvider()).getSource(id);
-
- return Futures.makeChecked(Futures.withFallback(f, new FutureFallback<T>() {
- @Override
- public ListenableFuture<T> create(@Nonnull final Throwable cause) throws SchemaSourceException {
- LOG.debug("Failed to acquire source from {}", reg, cause);
+ return Futures.catchingAsync(((SchemaSourceProvider<T>)reg.getProvider()).getSource(id), Throwable.class,
+ input -> {
+ LOG.debug("Failed to acquire source from {}", reg, input);
if (it.hasNext()) {
return fetchSource(id, it);
}
- throw new MissingSchemaSourceException("All available providers exhausted", id, cause);
- }
- }), FETCH_MAPPER);
+ throw new MissingSchemaSourceException("All available providers exhausted", id, input);
+ }, MoreExecutors.directExecutor());
}
@Override
"No providers for source " + id + " representation " + representation + " available", id));
}
- CheckedFuture<T, SchemaSourceException> fetchSourceFuture = fetchSource(id, regs);
+ final ListenableFuture<T> fetchSourceFuture = fetchSource(id, regs);
// Add callback to notify cache listeners about encountered schema
Futures.addCallback(fetchSourceFuture, new FutureCallback<T>() {
@Override
public void onFailure(@Nonnull final Throwable t) {
LOG.trace("Skipping notification for encountered source {}, fetching source failed", id, t);
}
- });
+ }, MoreExecutors.directExecutor());
- return fetchSourceFuture;
+ return Futures.makeChecked(fetchSourceFuture, FETCH_MAPPER);
}
private synchronized <T extends SchemaSourceRepresentation> void addSource(final PotentialSchemaSource<T> source,
import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
@Override
public CheckedFuture<D, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
final CheckedFuture<S, SchemaSourceException> f = provider.getSchemaSource(sourceIdentifier, srcClass);
- return Futures.makeChecked(Futures.transform(f, function), MAPPER);
+ return Futures.makeChecked(Futures.transformAsync(f, function, MoreExecutors.directExecutor()), MAPPER);
}
@Override
import com.google.common.collect.Collections2;
import com.google.common.io.Files;
import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
assertThat(fileNames, both(hasItem("test2")).and(hasItem("test@2012-12-12")));
- assertThat(Files.toString(storedFiles.get(0), StandardCharsets.UTF_8),
+ assertThat(Files.asCharSource(storedFiles.get(0), StandardCharsets.UTF_8).read(),
either(containsString(content)).or(containsString(content2)));
- assertThat(Files.toString(storedFiles.get(1), StandardCharsets.UTF_8),
+ assertThat(Files.asCharSource(storedFiles.get(1), StandardCharsets.UTF_8).read(),
either(containsString(content)).or(containsString(content2)));
verify(this.registry, times(2)).registerSchemaSource(any(SchemaSourceProvider.class),
final YangTextSchemaSource source = new TestingYangSource("test", "2013-12-12", content);
cache.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test1", "2012-12-12");
- final CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> checked = cache
- .getSource(sourceIdentifier);
+ final ListenableFuture<? extends YangTextSchemaSource> checked = cache.getSource(sourceIdentifier);
Assert.assertNotNull(checked);
checked.get();
}
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.YangSchemaSourceRepresentation;
final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
inMemorySchemaSourceCache.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", "2012-12-12");
- final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource =
- inMemorySchemaSourceCache.getSource(sourceIdentifier);
+ final ListenableFuture<? extends YangSchemaSourceRepresentation> checkedSource = inMemorySchemaSourceCache
+ .getSource(sourceIdentifier);
Assert.assertNotNull(checkedSource);
final YangSchemaSourceRepresentation yangSchemaSourceRepresentation = checkedSource.get();
Assert.assertNotNull(yangSchemaSourceRepresentation);
final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", "2012-12-12");
- final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource =
+ final ListenableFuture<? extends YangSchemaSourceRepresentation> checkedSource =
inMemorySchemaSourceCache.getSource(sourceIdentifier);
Assert.assertNotNull(checkedSource);
checkedSource.get();
inMemorySchemaSourceCache2.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", "2012-12-12");
- final CheckedFuture<? extends YangSchemaSourceRepresentation, SchemaSourceException> checkedSource =
+ final ListenableFuture<? extends YangSchemaSourceRepresentation> checkedSource =
inMemorySchemaSourceCache.getSource(sourceIdentifier);
- final CheckedFuture<? extends SchemaSourceRepresentation, SchemaSourceException> checkedSource2 =
+ final ListenableFuture<? extends SchemaSourceRepresentation> checkedSource2 =
inMemorySchemaSourceCache2.getSource(sourceIdentifier);
Assert.assertNotNull(checkedSource);
Assert.assertNotNull(checkedSource2);
import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.Arrays;
import java.util.concurrent.Future;
import javax.annotation.Nonnull;
final PotentialSchemaSource<?>[] potList = { foo.getPotentialSchemSource() };
final Iterable<PotentialSchemaSource<?>> sources = Arrays.asList(potList);
listener.schemaSourceRegistered(sources);
- final CheckedFuture<YinXmlSchemaSource, SchemaSourceException> source = this.schema.getSource(sourceIdentifier);
+ final ListenableFuture<YinXmlSchemaSource> source = this.schema.getSource(sourceIdentifier);
Assert.assertNotNull(source);
listener.schemaSourceUnregistered(foo.getPotentialSchemSource());
- final CheckedFuture<YinXmlSchemaSource, SchemaSourceException> source2 = this.schema
- .getSource(sourceIdentifier);
+ final ListenableFuture<YinXmlSchemaSource> source2 = this.schema.getSource(sourceIdentifier);
Assert.assertNotNull(source2);
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
// Detect mismatch between requested Source IDs and IDs that are extracted from parsed source
// Also remove duplicates if present
// We are relying on preserved order of uniqueSourceIdentifiers as well as sf
- sf = Futures.transform(sf, new SourceIdMismatchDetector(uniqueSourceIdentifiers));
+ sf = Futures.transform(sf, new SourceIdMismatchDetector(uniqueSourceIdentifiers),
+ MoreExecutors.directExecutor());
// Assemble sources into a schema context
- final ListenableFuture<SchemaContext> cf = Futures.transform(sf, assembleSources);
+ final ListenableFuture<SchemaContext> cf = Futures.transformAsync(sf, assembleSources,
+ MoreExecutors.directExecutor());
// Populate cache when successful
Futures.addCallback(cf, new FutureCallback<SchemaContext>() {
public void onFailure(@Nonnull final Throwable t) {
LOG.debug("Failed to assemble sources", t);
}
- });
+ }, MoreExecutors.directExecutor());
return Futures.makeChecked(cf, MAPPER);
}
return buildAction;
}
- private static <T> T warnOnNull(final T obj) {
- if (obj == null) {
- LOG.info("Set of supported features has not been provided, so all features are supported by default.");
- }
- return obj;
- }
-
public static class Builder implements org.opendaylight.yangtools.concepts.Builder<CrossSourceStatementReactor> {
private final Map<ValidationBundleType, Collection<?>> validationBundles =
new EnumMap<>(ValidationBundleType.class);
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
sharedSchemaRepository.registerSchemaSourceListener(listener);
final File test = new File(storageDir, "test.yang");
- Files.write("content-test", test, StandardCharsets.UTF_8);
+ Files.asCharSink(test, StandardCharsets.UTF_8).write("content-test");
final File test2 = new File(storageDir, "test@2012-12-12.yang");
- Files.write("content-test-2012", test2, StandardCharsets.UTF_8);
+ Files.asCharSink(test2, StandardCharsets.UTF_8).write("content-test-2012");
final File test3 = new File(storageDir, "test@2013-12-12.yang");
- Files.write("content-test-2013", test3, StandardCharsets.UTF_8);
+ Files.asCharSink(test3, StandardCharsets.UTF_8).write("content-test-2013");
final File test4 = new File(storageDir, "module@2010-12-12.yang");
- Files.write("content-module-2010", test4, StandardCharsets.UTF_8);
-
+ Files.asCharSink(test4, StandardCharsets.UTF_8).write("content-module-2010");
final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(
sharedSchemaRepository, YangTextSchemaSource.class, storageDir);
sharedSchemaRepository.registerSchemaSourceListener(transformer);
// Request schema to make repository notify the cache
- final CheckedFuture<SchemaContext, SchemaResolutionException> schemaFuture = sharedSchemaRepository
+ final ListenableFuture<SchemaContext> schemaFuture = sharedSchemaRepository
.createSchemaContextFactory(ALWAYS_ACCEPT).createSchemaContext(ImmutableList.of(runningId));
Futures.addCallback(schemaFuture, new FutureCallback<SchemaContext>() {
@Override
assertEquals(1, cachedSchemas.size());
assertEquals(Files.getNameWithoutExtension(cachedSchemas.get(0).getName()), "running@2012-12-12");
}
- });
+ }, MoreExecutors.directExecutor());
try {
schemaFuture.get();
import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.PrintStream;
import java.util.Date;
import org.junit.Test;
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath />
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>1.9.0</version>
+ <version>2.0.0</version>
<relativePath/>
</parent>