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.Argument;
13 import org.apache.karaf.shell.api.action.Command;
14 import org.apache.karaf.shell.api.action.lifecycle.Reference;
15 import org.apache.karaf.shell.api.action.lifecycle.Service;
16 import org.opendaylight.controller.md.sal.trace.api.TracingDOMDataBroker;
19 * Karaf CLI command to dump all open transactions.
21 * @author Michael Vorburger.ch
24 @Command(scope = "trace", name = "transactions",
25 description = "Show all (still) open transactions; including stack trace of creator, "
26 + "if transaction-debug-context-enabled is true in mdsaltrace_config.xml")
27 public class PrintOpenTransactionsCommand implements Action {
29 @Argument(index = 0, name = "minOpenTransactions", required = false, multiValued = false,
30 description = "Minimum open number of transactions (leaks with fewer are suppressed)")
31 Integer minOpenTransactions = 1;
34 private List<TracingDOMDataBroker> tracingDOMDataBrokers;
36 // NB: Do NOT have a non-default constructor for injection of @Reference
37 // Karaf needs a default constructor to create the command - and it works as is.
40 @SuppressWarnings("checkstyle:RegexpSingleLineJava")
41 public Object execute() {
42 boolean hasFound = false;
43 for (TracingDOMDataBroker tracingDOMDataBroker : tracingDOMDataBrokers) {
44 hasFound |= tracingDOMDataBroker.printOpenTransactions(System.out, minOpenTransactions);
48 "Actually did find real leaks with more than " + minOpenTransactions + " open transactions");
51 "Did not find any real leaks with more than " + minOpenTransactions + " open transactions");