Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain 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, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import org.onosproject.event.AbstractEvent; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 20 | |
Ray Milkey | c4dd726 | 2015-08-21 09:33:42 -0700 | [diff] [blame] | 21 | @Deprecated |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 22 | /** |
| 23 | * Describes flow rule batch event. |
Ray Milkey | c4dd726 | 2015-08-21 09:33:42 -0700 | [diff] [blame] | 24 | * |
| 25 | * @deprecated in Drake release - no longer a public API |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 26 | */ |
| 27 | public final class FlowRuleBatchEvent extends AbstractEvent<FlowRuleBatchEvent.Type, FlowRuleBatchRequest> { |
| 28 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 29 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 30 | /** |
| 31 | * Type of flow rule events. |
| 32 | */ |
| 33 | public enum Type { |
| 34 | |
Yuta HIGUCHI | 2fcb40c | 2014-11-03 14:39:10 -0800 | [diff] [blame] | 35 | // Request has been forwarded to MASTER Node |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 36 | /** |
| 37 | * Signifies that a batch operation has been initiated. |
| 38 | */ |
| 39 | BATCH_OPERATION_REQUESTED, |
| 40 | |
Yuta HIGUCHI | 2fcb40c | 2014-11-03 14:39:10 -0800 | [diff] [blame] | 41 | // MASTER Node has pushed the batch down to the Device |
| 42 | // (e.g., Received barrier reply) |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 43 | /** |
| 44 | * Signifies that a batch operation has completed. |
| 45 | */ |
| 46 | BATCH_OPERATION_COMPLETED, |
| 47 | } |
| 48 | |
| 49 | private final CompletedBatchOperation result; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 50 | private final DeviceId deviceId; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Constructs a new FlowRuleBatchEvent. |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 54 | * |
| 55 | * @param request batch operation request |
| 56 | * @param deviceId the device this batch will be processed on |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 57 | * @return event. |
| 58 | */ |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 59 | public static FlowRuleBatchEvent requested(FlowRuleBatchRequest request, DeviceId deviceId) { |
| 60 | FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_REQUESTED, request, deviceId); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 61 | return event; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Constructs a new FlowRuleBatchEvent. |
| 66 | * @param request batch operation request. |
| 67 | * @param result completed batch operation result. |
| 68 | * @return event. |
| 69 | */ |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 70 | public static FlowRuleBatchEvent completed(FlowRuleBatchRequest request, CompletedBatchOperation result) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 71 | FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_COMPLETED, request, result); |
| 72 | return event; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Returns the result of this batch operation. |
| 77 | * @return batch operation result. |
| 78 | */ |
| 79 | public CompletedBatchOperation result() { |
| 80 | return result; |
| 81 | } |
| 82 | |
| 83 | /** |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 84 | * Returns the deviceId for this batch. |
| 85 | * @return device id |
| 86 | */ |
| 87 | public DeviceId deviceId() { |
| 88 | return deviceId; |
| 89 | } |
| 90 | |
| 91 | /** |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 92 | * Creates an event of a given type and for the specified flow rule batch. |
| 93 | * |
| 94 | * @param type flow rule batch event type |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 95 | * @param request event flow rule batch subject |
| 96 | * @param result the result of the batch operation |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 97 | */ |
| 98 | private FlowRuleBatchEvent(Type type, FlowRuleBatchRequest request, CompletedBatchOperation result) { |
| 99 | super(type, request); |
| 100 | this.result = result; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 101 | this.deviceId = result.deviceId(); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Creates an event of a given type and for the specified flow rule batch. |
| 106 | * |
| 107 | * @param type flow rule batch event type |
| 108 | * @param request event flow rule batch subject |
| 109 | * @param deviceId the device id for this batch |
| 110 | */ |
| 111 | private FlowRuleBatchEvent(Type type, FlowRuleBatchRequest request, DeviceId deviceId) { |
| 112 | super(type, request); |
| 113 | this.result = null; |
| 114 | this.deviceId = deviceId; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 115 | } |
| 116 | } |