blob: bd5d374cb3c880a1329c9357e42cf4c72fa8e030 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 /**
Hongtao Yin142b7582015-01-21 14:41:30 -080028 * This id is used to carry to id of the original
Brian O'Connor72cb19a2015-01-16 16:14:41 -080029 * 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);
Madan Jampani117aaae2014-10-23 10:04:05 -070040 }
41
Brian O'Connor72cb19a2015-01-16 16:14:41 -080042 public Set<FlowRuleBatchEntry> ops() {
43 return ops;
Madan Jampani117aaae2014-10-23 10:04:05 -070044 }
45
Brian O'Connor72cb19a2015-01-16 16:14:41 -080046 public FlowRuleBatchOperation asBatchOperation(DeviceId deviceId) {
Madan Jampani117aaae2014-10-23 10:04:05 -070047 List<FlowRuleBatchEntry> entries = Lists.newArrayList();
Brian O'Connor72cb19a2015-01-16 16:14:41 -080048 entries.addAll(ops);
49 return new FlowRuleBatchOperation(entries, deviceId, batchId);
Madan Jampani117aaae2014-10-23 10:04:05 -070050 }
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070051
Brian O'Connor72cb19a2015-01-16 16:14:41 -080052 public long batchId() {
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070053 return batchId;
54 }
Madan Jampani117aaae2014-10-23 10:04:05 -070055}