2 * Copyright (c) 2013 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
8 package org.opendaylight.openflowplugin.testcommon;
10 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
16 * Provides activation and deactivation of drop responder service - responds on packetIn.
18 public class DropTestRpcProvider implements AutoCloseable {
19 private static final Logger LOG = LoggerFactory.getLogger(DropTestRpcProvider.class);
21 private SalFlowService flowService;
22 private NotificationService notificationService;
23 private final DropTestRpcSender commiter = new DropTestRpcSender();
24 private boolean active = false;
26 public void setFlowService(final SalFlowService flowService) {
27 this.flowService = flowService;
30 public void setNotificationService(final NotificationService notificationService) {
31 this.notificationService = notificationService;
35 * Activates drop responder.
38 commiter.setFlowService(flowService);
39 commiter.setNotificationService(notificationService);
42 LOG.debug("DropTestProvider Started.");
46 * Returns the message counts.
48 public DropTestStats getStats() {
49 if (this.commiter != null) {
50 return commiter.getStats();
52 return new DropTestStats("Not initialized yet.");
57 * Reset message counts.
59 public void clearStats() {
60 if (commiter != null) {
61 commiter.clearStats();
67 LOG.debug("DropTestProvider stopped.");
68 if (commiter != null) {
75 * Returns the active state.
77 public boolean isActive() {