X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fschema%2Fprovider%2Fimpl%2FRemoteYangTextSourceProviderImpl.java;h=eeab236ed9e91b85e951c295f06b68488b2c41b6;hp=fc492872bd6eb3ca6237d9351373d5b431d3f37f;hb=b5cb353e3553a39f576c284119af75ffa5ea66a9;hpb=0f4c2236a45097dcac1d66415cb76aabcc4a873f diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java index fc492872bd..eeab236ed9 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImpl.java @@ -9,9 +9,11 @@ package org.opendaylight.controller.cluster.schema.provider.impl; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.base.Preconditions; 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 javax.annotation.Nonnull; @@ -34,8 +36,9 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro private final SchemaRepository repository; private final Set providedSources; - public RemoteYangTextSourceProviderImpl(SchemaRepository repository, Set providedSources) { - this.repository = repository; + public RemoteYangTextSourceProviderImpl(final SchemaRepository repository, + final Set providedSources) { + this.repository = Preconditions.checkNotNull(repository); this.providedSources = providedSources; } @@ -45,16 +48,16 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro } @Override - public Future getYangTextSchemaSource(SourceIdentifier identifier) { + public Future getYangTextSchemaSource(final SourceIdentifier identifier) { LOG.trace("Sending yang schema source for {}", identifier); final Promise promise = akka.dispatch.Futures.promise(); - CheckedFuture future = + ListenableFuture future = repository.getSchemaSource(identifier, YangTextSchemaSource.class); Futures.addCallback(future, new FutureCallback() { @Override - public void onSuccess(@Nonnull YangTextSchemaSource result) { + public void onSuccess(@Nonnull final YangTextSchemaSource result) { try { promise.success(new YangTextSchemaSourceSerializationProxy(result)); } catch (IOException e) { @@ -64,11 +67,11 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro } @Override - public void onFailure(Throwable failure) { + public void onFailure(final Throwable failure) { LOG.warn("Unable to retrieve schema source from provider", failure); promise.failure(failure); } - }); + }, MoreExecutors.directExecutor()); return promise.future(); }