import akka.actor.ActorSystem;
import akka.pattern.Patterns;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
+import com.google.common.base.Verify;
import java.util.Collections;
import java.util.Map;
import javax.annotation.Nonnull;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadWriteTransactionRequest;
import org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionReply;
import org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionRequest;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import scala.concurrent.Await;
import scala.concurrent.Future;
@Override
public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
final Future<Object> txActorFuture = Patterns.ask(masterNode, new NewReadTransactionRequest(), askTimeout);
+ final Object msg;
try {
- final Object msg = Await.result(txActorFuture, askTimeout.duration());
- if (msg instanceof Throwable) {
- throw (Throwable) msg;
- }
- Preconditions.checkState(msg instanceof NewReadTransactionReply);
- final NewReadTransactionReply reply = (NewReadTransactionReply) msg;
- return new ProxyReadTransaction(reply.getTxActor(), id, actorSystem, askTimeout);
- } catch (final Throwable t) {
- throw new IllegalStateException("Can't create ProxyReadTransaction", t);
+ msg = Await.result(txActorFuture, askTimeout.duration());
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't create ProxyReadTransaction", e);
}
+
+ if (msg instanceof Exception) {
+ throw new IllegalStateException("Can't create ProxyReadTransaction", (Exception) msg);
+ }
+
+ Verify.verify(msg instanceof NewReadTransactionReply);
+ final NewReadTransactionReply reply = (NewReadTransactionReply) msg;
+ return new ProxyReadTransaction(reply.getTxActor(), id, actorSystem, askTimeout);
}
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
final Future<Object> txActorFuture = Patterns.ask(masterNode, new NewReadWriteTransactionRequest(), askTimeout);
+ final Object msg;
try {
- final Object msg = Await.result(txActorFuture, askTimeout.duration());
- if (msg instanceof Throwable) {
- throw (Throwable) msg;
- }
- Preconditions.checkState(msg instanceof NewReadWriteTransactionReply);
- final NewReadWriteTransactionReply reply = (NewReadWriteTransactionReply) msg;
- return new ProxyReadWriteTransaction(reply.getTxActor(), id, actorSystem, askTimeout);
- } catch (final Throwable t) {
- throw new IllegalStateException("Can't create ProxyReadTransaction", t);
+ msg = Await.result(txActorFuture, askTimeout.duration());
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't create ProxyReadWriteTransaction", e);
+ }
+
+ if (msg instanceof Exception) {
+ throw new IllegalStateException("Can't create ProxyReadWriteTransaction", (Exception) msg);
}
+
+ Verify.verify(msg instanceof NewReadWriteTransactionReply);
+ final NewReadWriteTransactionReply reply = (NewReadWriteTransactionReply) msg;
+ return new ProxyReadWriteTransaction(reply.getTxActor(), id, actorSystem, askTimeout);
}
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public DOMDataWriteTransaction newWriteOnlyTransaction() {
final Future<Object> txActorFuture = Patterns.ask(masterNode, new NewWriteTransactionRequest(), askTimeout);
+ final Object msg;
try {
- final Object msg = Await.result(txActorFuture, askTimeout.duration());
- if (msg instanceof Throwable) {
- throw (Throwable) msg;
- }
- Preconditions.checkState(msg instanceof NewWriteTransactionReply);
- final NewWriteTransactionReply reply = (NewWriteTransactionReply) msg;
- return new ProxyWriteTransaction(reply.getTxActor(), id, actorSystem, askTimeout);
- } catch (final Throwable t) {
- throw new IllegalStateException("Can't create ProxyWriteTransaction", t);
+ msg = Await.result(txActorFuture, askTimeout.duration());
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't create ProxyWriteTransaction", e);
}
- }
- @Override
- public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(
- final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener,
- final DataChangeScope triggeringScope) {
- throw new UnsupportedOperationException(id + ": Data change listeners not supported for netconf mount point");
+ if (msg instanceof Exception) {
+ throw new IllegalStateException("Can't create ProxyWriteTransaction", (Exception) msg);
+ }
+
+ Verify.verify(msg instanceof NewWriteTransactionReply);
+ final NewWriteTransactionReply reply = (NewWriteTransactionReply) msg;
+ return new ProxyWriteTransaction(reply.getTxActor(), id, actorSystem, askTimeout);
}
@Override