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 org.apache.karaf.shell.api.action.Action;
11 import org.apache.karaf.shell.api.action.Command;
12 import org.apache.karaf.shell.api.action.lifecycle.Reference;
13 import org.apache.karaf.shell.api.action.lifecycle.Service;
14 import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker;
17 * Karaf CLI command to dump all open transactions.
19 * @author Michael Vorburger.ch
22 @Command(scope = "trace", name = "transactions",
23 description = "Show all (still) open transactions; including stack trace of creator, "
24 + "if transaction-debug-context-enabled is true in mdsaltrace_config.xml")
25 public class PrintOpenTransactionsCommand implements Action {
28 private TracingDOMDataBroker tracingDOMDataBroker;
30 // NB: Do NOT have a non-default constructor for injection of @Reference
31 // Karaf needs a default constructor to create the command - and it works as is.
34 @SuppressWarnings("checkstyle:RegexpSingleLineJava")
35 public Object execute() throws Exception {
36 if (!tracingDOMDataBroker.printOpenTransactions(System.out)) {
37 System.out.println("No open transactions, great!");