blob: 1dbf8bd6a9fe22779c693873696b1c58263919d9 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
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 */
Madan Jampani117aaae2014-10-23 10:04:05 -070016package org.onlab.onos.net.flow;
17
18import org.onlab.onos.event.AbstractEvent;
19
20/**
21 * Describes flow rule batch event.
22 */
23public final class FlowRuleBatchEvent extends AbstractEvent<FlowRuleBatchEvent.Type, FlowRuleBatchRequest> {
24
25 /**
26 * Type of flow rule events.
27 */
28 public enum Type {
29
Yuta HIGUCHI2fcb40c2014-11-03 14:39:10 -080030 // Request has been forwarded to MASTER Node
Madan Jampani117aaae2014-10-23 10:04:05 -070031 /**
32 * Signifies that a batch operation has been initiated.
33 */
34 BATCH_OPERATION_REQUESTED,
35
Yuta HIGUCHI2fcb40c2014-11-03 14:39:10 -080036 // MASTER Node has pushed the batch down to the Device
37 // (e.g., Received barrier reply)
Madan Jampani117aaae2014-10-23 10:04:05 -070038 /**
39 * Signifies that a batch operation has completed.
40 */
41 BATCH_OPERATION_COMPLETED,
42 }
43
44 private final CompletedBatchOperation result;
45
46 /**
47 * Constructs a new FlowRuleBatchEvent.
48 * @param request batch operation request.
49 * @return event.
50 */
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070051 public static FlowRuleBatchEvent requested(FlowRuleBatchRequest request) {
Madan Jampani117aaae2014-10-23 10:04:05 -070052 FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_REQUESTED, request, null);
53 return event;
54 }
55
56 /**
57 * Constructs a new FlowRuleBatchEvent.
58 * @param request batch operation request.
59 * @param result completed batch operation result.
60 * @return event.
61 */
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070062 public static FlowRuleBatchEvent completed(FlowRuleBatchRequest request, CompletedBatchOperation result) {
Madan Jampani117aaae2014-10-23 10:04:05 -070063 FlowRuleBatchEvent event = new FlowRuleBatchEvent(Type.BATCH_OPERATION_COMPLETED, request, result);
64 return event;
65 }
66
67 /**
68 * Returns the result of this batch operation.
69 * @return batch operation result.
70 */
71 public CompletedBatchOperation result() {
72 return result;
73 }
74
75 /**
76 * Creates an event of a given type and for the specified flow rule batch.
77 *
78 * @param type flow rule batch event type
79 * @param batch event flow rule batch subject
80 */
81 private FlowRuleBatchEvent(Type type, FlowRuleBatchRequest request, CompletedBatchOperation result) {
82 super(type, request);
83 this.result = result;
84 }
85}