2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.sal.connect.netconf.util;
10 import com.google.common.util.concurrent.FutureCallback;
11 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
12 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
17 * Simple Netconf RPC logging callback.
19 public class NetconfRpcFutureCallback implements FutureCallback<DOMRpcResult> {
20 private static final Logger LOG = LoggerFactory.getLogger(NetconfRpcFutureCallback.class);
22 private final String type;
23 private final RemoteDeviceId id;
25 public NetconfRpcFutureCallback(final String prefix, final RemoteDeviceId id) {
31 public void onSuccess(final DOMRpcResult result) {
32 if (result.errors().isEmpty()) {
33 LOG.trace("{}: {} invoked successfully", id, type);
39 protected void onUnsuccess(final DOMRpcResult result) {
40 LOG.warn("{}: {} invoked unsuccessfully: {}", id, type, result.errors());
44 public void onFailure(final Throwable throwable) {
45 LOG.warn("{}: {} failed.", id, type, throwable);