blob: 5570a40521d4991cab2c054cc706c2b6b8679682 [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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
Madan Jampani117aaae2014-10-23 10:04:05 -070017
Brian O'Connor72cb19a2015-01-16 16:14:41 -080018import com.google.common.collect.Lists;
19import org.onosproject.net.DeviceId;
20
Madan Jampani117aaae2014-10-23 10:04:05 -070021import java.util.Collections;
22import java.util.List;
Brian O'Connor72cb19a2015-01-16 16:14:41 -080023import java.util.Set;
Madan Jampani117aaae2014-10-23 10:04:05 -070024
25public class FlowRuleBatchRequest {
26
Brian O'Connor72cb19a2015-01-16 16:14:41 -080027 /**
28 * This id is used to cary to id of the original
29 * FlowOperations and track where this batch operation
30 * came from. The id is unique cluster wide.
31 */
32 private final long batchId;
Madan Jampani117aaae2014-10-23 10:04:05 -070033
Brian O'Connor72cb19a2015-01-16 16:14:41 -080034 private final Set<FlowRuleBatchEntry> ops;
35
36
37 public FlowRuleBatchRequest(long batchId, Set<FlowRuleBatchEntry> ops) {
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070038 this.batchId = batchId;
Brian O'Connor72cb19a2015-01-16 16:14:41 -080039 this.ops = Collections.unmodifiableSet(ops);
40
41
Madan Jampani117aaae2014-10-23 10:04:05 -070042 }
43
Brian O'Connor72cb19a2015-01-16 16:14:41 -080044 public Set<FlowRuleBatchEntry> ops() {
45 return ops;
Madan Jampani117aaae2014-10-23 10:04:05 -070046 }
47
Brian O'Connor72cb19a2015-01-16 16:14:41 -080048 public FlowRuleBatchOperation asBatchOperation(DeviceId deviceId) {
Madan Jampani117aaae2014-10-23 10:04:05 -070049 List<FlowRuleBatchEntry> entries = Lists.newArrayList();
Brian O'Connor72cb19a2015-01-16 16:14:41 -080050 entries.addAll(ops);
51 return new FlowRuleBatchOperation(entries, deviceId, batchId);
Madan Jampani117aaae2014-10-23 10:04:05 -070052 }
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070053
Brian O'Connor72cb19a2015-01-16 16:14:41 -080054 public long batchId() {
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070055 return batchId;
56 }
Madan Jampani117aaae2014-10-23 10:04:05 -070057}