Bump upstreams
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / schema / provider / impl / RemoteYangTextSourceProviderImpl.java
index 0b07eeb19bb049305d2fff05f481daba4ee25bc8..eea0aa86071d115e04f4bfbd23b83f8fa29a066d 100644 (file)
@@ -5,19 +5,21 @@
  * 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.cluster.schema.provider.impl;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-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.IOException;
 import java.util.Set;
 import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
+import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
@@ -33,8 +35,9 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro
     private final SchemaRepository repository;
     private final Set<SourceIdentifier> providedSources;
 
-    public RemoteYangTextSourceProviderImpl(SchemaRepository repository, Set<SourceIdentifier> providedSources) {
-        this.repository = repository;
+    public RemoteYangTextSourceProviderImpl(final SchemaRepository repository,
+            final Set<SourceIdentifier> providedSources) {
+        this.repository = requireNonNull(repository);
         this.providedSources = providedSources;
     }
 
@@ -44,29 +47,30 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro
     }
 
     @Override
-    public Future<YangTextSchemaSourceSerializationProxy> getYangTextSchemaSource(SourceIdentifier identifier) {
+    public Future<YangTextSchemaSourceSerializationProxy> getYangTextSchemaSource(final SourceIdentifier identifier) {
         LOG.trace("Sending yang schema source for {}", identifier);
 
         final Promise<YangTextSchemaSourceSerializationProxy> promise = akka.dispatch.Futures.promise();
-        CheckedFuture<YangTextSchemaSource, ?> future = repository.getSchemaSource(identifier, YangTextSchemaSource.class);
+        ListenableFuture<YangTextSource> future =
+                repository.getSchemaSource(identifier, YangTextSource.class);
 
-        Futures.addCallback(future, new FutureCallback<YangTextSchemaSource>() {
+        Futures.addCallback(future, new FutureCallback<YangTextSource>() {
             @Override
-            public void onSuccess(YangTextSchemaSource result) {
+            public void onSuccess(final YangTextSource result) {
                 try {
                     promise.success(new YangTextSchemaSourceSerializationProxy(result));
                 } catch (IOException e) {
-                    LOG.warn("Unable to read schema source for {}", result.getIdentifier(), e);
+                    LOG.warn("Unable to read schema source for {}", result.sourceId(), e);
                     promise.failure(e);
                 }
             }
 
             @Override
-            public void onFailure(Throwable t) {
-                LOG.warn("Unable to retrieve schema source from provider", t);
-                promise.failure(t);
+            public void onFailure(final Throwable failure) {
+                LOG.warn("Unable to retrieve schema source from provider", failure);
+                promise.failure(failure);
             }
-        });
+        }, MoreExecutors.directExecutor());
 
         return promise.future();
     }