Fix license header violations in openflowplugin-api
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / md / queue / WaterMarkListenerImpl.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.api.openflow.md.queue;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 public class WaterMarkListenerImpl implements WaterMarkListener {
17
18     private static final Logger LOG = LoggerFactory
19             .getLogger(WaterMarkListenerImpl.class);
20
21     private ConnectionAdapter connectionAdapter;
22
23     public WaterMarkListenerImpl(ConnectionAdapter connectionAdapter) {
24         this.connectionAdapter = Preconditions.checkNotNull(connectionAdapter);
25     }
26
27     /*
28      * (non-Javadoc)
29      *
30      * @see org.opendaylight.openflowplugin.api.openflow.md.queue.QueueListener#
31      * onHighWaterMark
32      * (org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)
33      */
34     @Override
35     public void onHighWaterMark() {
36         connectionAdapter.setAutoRead(false);
37         LOG.debug("AutoRead is set on false: {}", connectionAdapter.getRemoteAddress());
38     }
39
40     /*
41      * (non-Javadoc)
42      *
43      * @see org.opendaylight.openflowplugin.api.openflow.md.queue.QueueListener#
44      * onLowWaterMark
45      * (org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)
46      */
47     @Override
48     public void onLowWaterMark() {
49         connectionAdapter.setAutoRead(true);
50         LOG.debug("AutoRead is set on true: {}", connectionAdapter.getRemoteAddress());
51     }
52 }