2 * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. 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.openflowplugin.applications.southboundcli.cli;
10 import java.util.ArrayList;
11 import org.apache.karaf.shell.commands.Command;
12 import org.apache.karaf.shell.console.OsgiCommandSupport;
13 import org.opendaylight.openflowplugin.applications.frm.ReconciliationJMXServiceMBean;
15 @Command(scope = "openflow", name = "getreconciliationstate",
16 description = "Print reconciliation state for all devices")
17 public class GetReconciliationStateProvider extends OsgiCommandSupport {
18 private final ReconciliationJMXServiceMBean reconciliationJMXServiceMBean;
20 public GetReconciliationStateProvider(final ReconciliationJMXServiceMBean reconciliationJMXServiceMBean) {
21 this.reconciliationJMXServiceMBean = reconciliationJMXServiceMBean;
25 protected Object doExecute() {
26 final var reconciliationStates = reconciliationJMXServiceMBean.acquireReconciliationStates();
27 if (!reconciliationStates.isEmpty()) {
28 final var result = new ArrayList<String>();
29 reconciliationStates.forEach((datapathId, reconciliationState) -> {
30 String status = String.format("%-17s %-50s", datapathId, reconciliationState);
33 session.getConsole().println(getHeaderOutput());
34 session.getConsole().println(getLineSeparator());
35 result.stream().forEach(p -> session.getConsole().println(p));
37 session.getConsole().println("Reconciliation data not available");
42 private static String getHeaderOutput() {
43 return String.format("%-17s %-25s %-25s", "DatapathId", "Reconciliation Status", "Reconciliation Time");
46 private static String getLineSeparator() {
47 return "-------------------------------------------------------------------";