All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.controller.remote.rpc.RemoteDOMRpcFuture Maven / Gradle / Ivy

There is a newer version: 10.0.4
Show newest version
/*
 * Copyright (c) 2015 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
 */
package org.opendaylight.controller.remote.rpc;

import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.remote.rpc.messages.RpcResponse;
import org.opendaylight.mdsal.dom.api.DOMRpcException;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.yangtools.yang.common.QName;
import scala.concurrent.Future;

final class RemoteDOMRpcFuture extends AbstractRemoteFuture {
    RemoteDOMRpcFuture(final @NonNull QName type, final @NonNull Future requestFuture) {
        super(type, requestFuture);
    }

    @Override
    DOMRpcResult processReply(final Object reply) {
        return reply instanceof RpcResponse response ? new DefaultDOMRpcResult(response.getOutput()) : null;
    }

    @Override
    Class exceptionClass() {
        return DOMRpcException.class;
    }

    @Override
    DOMRpcException wrapCause(final Throwable cause) {
        return new RemoteDOMRpcException("Exception during invoking RPC", cause);
    }
}