Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2012, Big Switch Networks, Inc. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 3 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | * not use this file except in compliance with the License. You may obtain |
| 6 | * a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | * License for the specific language governing permissions and limitations |
| 14 | * under the License. |
| 15 | **/ |
| 16 | |
| 17 | package net.floodlightcontroller.core.internal; |
| 18 | |
| 19 | import java.util.concurrent.TimeUnit; |
| 20 | |
| 21 | import net.floodlightcontroller.core.IOFSwitch; |
| 22 | import net.floodlightcontroller.threadpool.IThreadPoolService; |
| 23 | |
| 24 | import org.openflow.protocol.OFFeaturesReply; |
| 25 | import org.openflow.protocol.OFMessage; |
| 26 | import org.openflow.protocol.OFType; |
| 27 | |
| 28 | /** |
| 29 | * A concrete implementation that handles asynchronously receiving |
| 30 | * OFFeaturesReply |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 31 | * |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 32 | * @author Shudong Zhou |
| 33 | */ |
| 34 | public class OFFeaturesReplyFuture extends |
| 35 | OFMessageFuture<OFFeaturesReply> { |
| 36 | |
| 37 | protected volatile boolean finished; |
| 38 | |
| 39 | public OFFeaturesReplyFuture(IThreadPoolService tp, |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 40 | IOFSwitch sw, int transactionId) { |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 41 | super(tp, sw, OFType.FEATURES_REPLY, transactionId); |
| 42 | init(); |
| 43 | } |
| 44 | |
| 45 | public OFFeaturesReplyFuture(IThreadPoolService tp, |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 46 | IOFSwitch sw, int transactionId, long timeout, TimeUnit unit) { |
Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 47 | super(tp, sw, OFType.FEATURES_REPLY, transactionId, timeout, unit); |
| 48 | init(); |
| 49 | } |
| 50 | |
| 51 | private void init() { |
| 52 | this.finished = false; |
| 53 | this.result = null; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | protected void handleReply(IOFSwitch sw, OFMessage msg) { |
| 58 | this.result = (OFFeaturesReply) msg; |
| 59 | this.finished = true; |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | protected boolean isFinished() { |
| 64 | return finished; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | protected void unRegister() { |
| 69 | super.unRegister(); |
| 70 | sw.cancelFeaturesReply(transactionId); |
| 71 | } |
| 72 | } |