2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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.controller.cluster.datastore.admin.command;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import java.util.concurrent.ExecutionException;
13 import org.apache.karaf.shell.api.action.Action;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
18 * Common base class for all commands which end up invoking an RPC.
20 public abstract class AbstractRpcAction implements Action {
22 @SuppressWarnings("checkstyle:RegexpSinglelineJava")
23 public final Object execute() throws InterruptedException, ExecutionException {
24 final RpcResult<?> result = invokeRpc().get();
25 if (!result.isSuccessful()) {
26 // FIXME: is there a better way to report errors?
27 System.out.println("Invocation failed: " + result.getErrors());
32 protected abstract ListenableFuture<? extends RpcResult<?>> invokeRpc();