blob: fa9f9993c52650176f5481ebfaf21d4c995454eb [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2 * Copyright 2012, Big Switch Networks, Inc.
Ray Milkey269ffb92014-04-03 14:43:30 -07003 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08004 * 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
17package net.floodlightcontroller.core.internal;
18
19import java.util.concurrent.TimeUnit;
20
Brian O'Connorc67f9fa2014-08-07 18:17:46 -070021import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
22import org.projectfloodlight.openflow.protocol.OFMessage;
23import org.projectfloodlight.openflow.protocol.OFType;
24
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080025import net.floodlightcontroller.core.IOFSwitch;
26import net.floodlightcontroller.threadpool.IThreadPoolService;
27
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080028/**
29 * A concrete implementation that handles asynchronously receiving
30 * OFFeaturesReply
Ray Milkey269ffb92014-04-03 14:43:30 -070031 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080032 * @author Shudong Zhou
33 */
34public class OFFeaturesReplyFuture extends
35 OFMessageFuture<OFFeaturesReply> {
36
37 protected volatile boolean finished;
38
39 public OFFeaturesReplyFuture(IThreadPoolService tp,
Ray Milkey269ffb92014-04-03 14:43:30 -070040 IOFSwitch sw, int transactionId) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080041 super(tp, sw, OFType.FEATURES_REPLY, transactionId);
42 init();
43 }
44
45 public OFFeaturesReplyFuture(IThreadPoolService tp,
Ray Milkey269ffb92014-04-03 14:43:30 -070046 IOFSwitch sw, int transactionId, long timeout, TimeUnit unit) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080047 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}