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
9 package org.opendaylight.netconf.sal.connect.netconf.util;
11 import com.google.common.util.concurrent.FutureCallback;
12 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
13 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Simple Netconf rpc logging callback
20 public class NetconfRpcFutureCallback implements FutureCallback<DOMRpcResult> {
21 private static final Logger LOG = LoggerFactory.getLogger(NetconfRpcFutureCallback.class);
23 private final String type;
24 private final RemoteDeviceId id;
26 public NetconfRpcFutureCallback(final String prefix, final RemoteDeviceId id) {
32 public void onSuccess(final DOMRpcResult result) {
33 if(result.getErrors().isEmpty()) {
34 LOG.trace("{}: {} invoked successfully", id, type);
40 protected void onUnsuccess(final DOMRpcResult result) {
41 LOG.warn("{}: {} invoked unsuccessfully: {}", id, type, result.getErrors());
45 public void onFailure(final Throwable t) {
46 LOG.warn("{}: {} failed.", id, type, t);