2 * Copyright (c) 2017 Red Hat, 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.controller.md.sal.trace.cli;
10 import java.util.List;
11 import org.apache.karaf.shell.api.action.Action;
12 import org.apache.karaf.shell.api.action.Command;
13 import org.apache.karaf.shell.api.action.lifecycle.Reference;
14 import org.apache.karaf.shell.api.action.lifecycle.Service;
15 import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker;
18 * Karaf CLI command to dump all open transactions.
20 * @author Michael Vorburger.ch
23 @Command(scope = "trace", name = "transactions",
24 description = "Show all (still) open transactions; including stack trace of creator, "
25 + "if transaction-debug-context-enabled is true in mdsaltrace_config.xml")
26 public class PrintOpenTransactionsCommand implements Action {
29 private List<TracingDOMDataBroker> tracingDOMDataBrokers;
31 // NB: Do NOT have a non-default constructor for injection of @Reference
32 // Karaf needs a default constructor to create the command - and it works as is.
35 @SuppressWarnings("checkstyle:RegexpSingleLineJava")
36 public Object execute() {
37 for (TracingDOMDataBroker tracingDOMDataBroker : tracingDOMDataBrokers) {
38 tracingDOMDataBroker.printOpenTransactions(System.out);