X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-cluster-admin-karaf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fadmin%2Fcommand%2FAbstractRpcAction.java;fp=opendaylight%2Fmd-sal%2Fsal-cluster-admin-karaf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fadmin%2Fcommand%2FAbstractRpcAction.java;h=0a85b562eb2cef8720c4177da7f974034dec0794;hb=40fd067185aafea2a7da7e4fd0b1111dc2bbb9bd;hp=0000000000000000000000000000000000000000;hpb=3404a29b4ee3b146a5ff98889bcf1afdebb65c3f;p=controller.git diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AbstractRpcAction.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AbstractRpcAction.java new file mode 100644 index 0000000000..0a85b562eb --- /dev/null +++ b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AbstractRpcAction.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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.cluster.datastore.admin.command; + + +import com.google.common.util.concurrent.ListenableFuture; +import java.util.concurrent.ExecutionException; +import org.apache.karaf.shell.api.action.Action; +import org.opendaylight.yangtools.yang.common.RpcResult; + + +/** + * Common base class for all commands which end up invoking an RPC. + */ +public abstract class AbstractRpcAction implements Action { + @Override + @SuppressWarnings("checkstyle:RegexpSinglelineJava") + public final Object execute() throws InterruptedException, ExecutionException { + final RpcResult result = invokeRpc().get(); + if (!result.isSuccessful()) { + // FIXME: is there a better way to report errors? + System.out.println("Invocation failed: " + result.getErrors()); + } + return null; + } + + protected abstract ListenableFuture> invokeRpc(); +}