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