2 * Copyright (c) 2014 Cisco Systems, 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
9 package org.opendaylight.openflowplugin.openflow.md.core.cmd;
11 import org.eclipse.osgi.framework.console.CommandInterpreter;
12 import org.eclipse.osgi.framework.console.CommandProvider;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
14 import org.opendaylight.openflowplugin.openflow.md.queue.MessageCountDumper;
15 import org.osgi.framework.BundleContext;
20 public class MessageCountCommandProvider implements CommandProvider {
22 private boolean sessionInitiated;
23 private BundleContext ctx;
24 private MessageCountDumper provider;
30 public MessageCountCommandProvider(BundleContext ctx, MessageCountDumper provider) {
32 this.provider = provider;
36 public String getHelp() {
37 String helpString = "----------------- dumpMsgCount--------------\n"
38 + " dumps message counters \n";
45 public void onSessionInitiated(ProviderContext session) {
46 ctx.registerService(CommandProvider.class.getName(), this, null);
47 this.sessionInitiated = true;
53 public void _dumpMsgCount(CommandInterpreter ci) {
54 if(sessionInitiated) {
55 ci.println("dumping msg counts");
56 for (String countItem : provider.dumpMessageCounts()) {
57 ci.println(countItem);
60 ci.println("Session not initiated, try again in a few seconds");