Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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 | */ |
| 16 | |
Carmelo Cascone | 356ab8b | 2019-09-25 01:02:53 -0700 | [diff] [blame] | 17 | package org.onosproject.pipelines.fabric.impl.behaviour.pipeliner; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 18 | |
| 19 | import com.google.common.collect.ImmutableList; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 20 | import org.onlab.util.KryoNamespace; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 21 | import org.onlab.util.SharedExecutors; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.PortNumber; |
| 24 | import org.onosproject.net.behaviour.NextGroup; |
| 25 | import org.onosproject.net.behaviour.Pipeliner; |
| 26 | import org.onosproject.net.behaviour.PipelinerContext; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 27 | import org.onosproject.net.flow.FlowRule; |
| 28 | import org.onosproject.net.flow.FlowRuleOperations; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 29 | import org.onosproject.net.flow.FlowRuleService; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 30 | import org.onosproject.net.flowobjective.FilteringObjective; |
| 31 | import org.onosproject.net.flowobjective.FlowObjectiveStore; |
| 32 | import org.onosproject.net.flowobjective.ForwardingObjective; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 33 | import org.onosproject.net.flowobjective.IdNextTreatment; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 34 | import org.onosproject.net.flowobjective.NextObjective; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 35 | import org.onosproject.net.flowobjective.NextTreatment; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 36 | import org.onosproject.net.flowobjective.Objective; |
| 37 | import org.onosproject.net.flowobjective.ObjectiveError; |
| 38 | import org.onosproject.net.group.GroupDescription; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 39 | import org.onosproject.net.group.GroupService; |
Carmelo Cascone | 356ab8b | 2019-09-25 01:02:53 -0700 | [diff] [blame] | 40 | import org.onosproject.pipelines.fabric.impl.behaviour.AbstractFabricHandlerBehavior; |
| 41 | import org.onosproject.pipelines.fabric.impl.behaviour.FabricCapabilities; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 42 | import org.onosproject.store.serializers.KryoNamespaces; |
| 43 | import org.slf4j.Logger; |
| 44 | |
| 45 | import java.util.Collection; |
| 46 | import java.util.List; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 47 | import java.util.Objects; |
Yi Tseng | fe13f3e | 2018-08-19 03:09:54 +0800 | [diff] [blame] | 48 | import java.util.concurrent.CompletableFuture; |
Yi Tseng | fe13f3e | 2018-08-19 03:09:54 +0800 | [diff] [blame] | 49 | import java.util.concurrent.ExecutorService; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 50 | import java.util.stream.Collectors; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 51 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 52 | import static java.lang.String.format; |
pierventre | 4e02fb5 | 2020-08-13 16:35:15 +0200 | [diff] [blame^] | 53 | import static org.onosproject.net.flowobjective.NextObjective.Type.SIMPLE; |
Carmelo Cascone | 356ab8b | 2019-09-25 01:02:53 -0700 | [diff] [blame] | 54 | import static org.onosproject.pipelines.fabric.impl.behaviour.FabricUtils.outputPort; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 55 | import static org.slf4j.LoggerFactory.getLogger; |
| 56 | |
| 57 | /** |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 58 | * Pipeliner implementation for fabric pipeline which uses ObjectiveTranslator |
| 59 | * implementations to translate flow objectives for the different blocks, |
| 60 | * filtering, forwarding and next. |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 61 | */ |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 62 | public class FabricPipeliner extends AbstractFabricHandlerBehavior |
| 63 | implements Pipeliner { |
| 64 | |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 65 | private static final Logger log = getLogger(FabricPipeliner.class); |
| 66 | |
| 67 | protected static final KryoNamespace KRYO = new KryoNamespace.Builder() |
| 68 | .register(KryoNamespaces.API) |
| 69 | .register(FabricNextGroup.class) |
| 70 | .build("FabricPipeliner"); |
| 71 | |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 72 | protected DeviceId deviceId; |
| 73 | protected FlowRuleService flowRuleService; |
| 74 | protected GroupService groupService; |
| 75 | protected FlowObjectiveStore flowObjectiveStore; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 76 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 77 | private FilteringObjectiveTranslator filteringTranslator; |
| 78 | private ForwardingObjectiveTranslator forwardingTranslator; |
| 79 | private NextObjectiveTranslator nextTranslator; |
Charles Chan | 91ea972 | 2018-08-30 15:56:32 -0700 | [diff] [blame] | 80 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 81 | private final ExecutorService callbackExecutor = SharedExecutors.getPoolThreadExecutor(); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 82 | |
Daniele Moro | f51d0c1 | 2019-07-30 10:43:10 -0700 | [diff] [blame] | 83 | /** |
| 84 | * Creates a new instance of this behavior with the given capabilities. |
| 85 | * |
| 86 | * @param capabilities capabilities |
| 87 | */ |
| 88 | public FabricPipeliner(FabricCapabilities capabilities) { |
| 89 | super(capabilities); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Create a new instance of this behaviour. Used by the abstract projectable |
| 94 | * model (i.e., {@link org.onosproject.net.Device#as(Class)}. |
| 95 | */ |
| 96 | public FabricPipeliner() { |
| 97 | super(); |
| 98 | } |
| 99 | |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 100 | @Override |
| 101 | public void init(DeviceId deviceId, PipelinerContext context) { |
| 102 | this.deviceId = deviceId; |
| 103 | this.flowRuleService = context.directory().get(FlowRuleService.class); |
| 104 | this.groupService = context.directory().get(GroupService.class); |
| 105 | this.flowObjectiveStore = context.directory().get(FlowObjectiveStore.class); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 106 | this.filteringTranslator = new FilteringObjectiveTranslator(deviceId, capabilities); |
| 107 | this.forwardingTranslator = new ForwardingObjectiveTranslator(deviceId, capabilities); |
| 108 | this.nextTranslator = new NextObjectiveTranslator(deviceId, capabilities); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | @Override |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 112 | public void filter(FilteringObjective obj) { |
| 113 | final ObjectiveTranslation result = filteringTranslator.translate(obj); |
| 114 | handleResult(obj, result); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | @Override |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 118 | public void forward(ForwardingObjective obj) { |
| 119 | final ObjectiveTranslation result = forwardingTranslator.translate(obj); |
| 120 | handleResult(obj, result); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | @Override |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 124 | public void next(NextObjective obj) { |
| 125 | if (obj.op() == Objective.Operation.VERIFY) { |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 126 | // TODO: support VERIFY operation |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 127 | log.debug("VERIFY operation not yet supported for NextObjective, will return success"); |
| 128 | success(obj); |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 129 | return; |
| 130 | } |
| 131 | |
pierventre | 4e02fb5 | 2020-08-13 16:35:15 +0200 | [diff] [blame^] | 132 | if (obj.op() == Objective.Operation.MODIFY && obj.type() != SIMPLE) { |
| 133 | log.warn("MODIFY operation not yet supported for NextObjective {}, will return failure :(", |
| 134 | obj.type()); |
| 135 | if (log.isTraceEnabled()) { |
| 136 | log.trace("Objective {}", obj); |
| 137 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 138 | fail(obj, ObjectiveError.UNSUPPORTED); |
Charles Chan | 91ea972 | 2018-08-30 15:56:32 -0700 | [diff] [blame] | 139 | return; |
| 140 | } |
| 141 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 142 | final ObjectiveTranslation result = nextTranslator.translate(obj); |
| 143 | handleResult(obj, result); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | @Override |
| 147 | public List<String> getNextMappings(NextGroup nextGroup) { |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 148 | final FabricNextGroup fabricNextGroup = KRYO.deserialize(nextGroup.data()); |
| 149 | return fabricNextGroup.nextMappings().stream() |
| 150 | .map(m -> format("%s -> %s", fabricNextGroup.type(), m)) |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 151 | .collect(Collectors.toList()); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 154 | private void handleResult(Objective obj, ObjectiveTranslation result) { |
| 155 | if (result.error().isPresent()) { |
| 156 | fail(obj, result.error().get()); |
| 157 | return; |
| 158 | } |
| 159 | processGroups(obj, result.groups()); |
| 160 | processFlows(obj, result.flowRules()); |
| 161 | if (obj instanceof NextObjective) { |
| 162 | handleNextGroup((NextObjective) obj); |
| 163 | } |
| 164 | success(obj); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 167 | private void handleNextGroup(NextObjective obj) { |
| 168 | switch (obj.op()) { |
| 169 | case REMOVE: |
| 170 | removeNextGroup(obj); |
| 171 | break; |
| 172 | case ADD: |
| 173 | case ADD_TO_EXISTING: |
| 174 | case REMOVE_FROM_EXISTING: |
| 175 | case MODIFY: |
| 176 | putNextGroup(obj); |
| 177 | break; |
| 178 | case VERIFY: |
| 179 | break; |
| 180 | default: |
| 181 | log.error("Unknown NextObjective operation '{}'", obj.op()); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | private void processFlows(Objective objective, Collection<FlowRule> flowRules) { |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 186 | if (flowRules.isEmpty()) { |
Yi Tseng | f78e174 | 2018-04-08 19:57:17 +0800 | [diff] [blame] | 187 | return; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 188 | } |
pierventre | 4e02fb5 | 2020-08-13 16:35:15 +0200 | [diff] [blame^] | 189 | |
| 190 | if (log.isTraceEnabled()) { |
| 191 | log.trace("Objective {} -> Flows {}", objective, flowRules); |
| 192 | } |
| 193 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 194 | final FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); |
| 195 | switch (objective.op()) { |
| 196 | case ADD: |
| 197 | case ADD_TO_EXISTING: |
pierventre | 4e02fb5 | 2020-08-13 16:35:15 +0200 | [diff] [blame^] | 198 | case MODIFY: |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 199 | flowRules.forEach(ops::add); |
| 200 | break; |
| 201 | case REMOVE: |
| 202 | case REMOVE_FROM_EXISTING: |
| 203 | flowRules.forEach(ops::remove); |
| 204 | break; |
| 205 | default: |
pierventre | 4e02fb5 | 2020-08-13 16:35:15 +0200 | [diff] [blame^] | 206 | log.warn("Unsupported Objective operation {}", objective.op()); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 207 | return; |
wu | 914ed23 | 2018-10-23 11:19:53 +0800 | [diff] [blame] | 208 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 209 | flowRuleService.apply(ops.build()); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 212 | private void processGroups(Objective objective, Collection<GroupDescription> groups) { |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 213 | if (groups.isEmpty()) { |
Yi Tseng | f78e174 | 2018-04-08 19:57:17 +0800 | [diff] [blame] | 214 | return; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 215 | } |
pierventre | 4e02fb5 | 2020-08-13 16:35:15 +0200 | [diff] [blame^] | 216 | |
| 217 | if (log.isTraceEnabled()) { |
| 218 | log.trace("Objective {} -> Groups {}", objective, groups); |
| 219 | } |
| 220 | |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 221 | switch (objective.op()) { |
| 222 | case ADD: |
| 223 | groups.forEach(groupService::addGroup); |
| 224 | break; |
| 225 | case REMOVE: |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 226 | groups.forEach(group -> groupService.removeGroup( |
| 227 | deviceId, group.appCookie(), objective.appId())); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 228 | break; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 229 | case ADD_TO_EXISTING: |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 230 | groups.forEach(group -> groupService.addBucketsToGroup( |
| 231 | deviceId, group.appCookie(), group.buckets(), |
| 232 | group.appCookie(), group.appId()) |
Charles Chan | 91ea972 | 2018-08-30 15:56:32 -0700 | [diff] [blame] | 233 | ); |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 234 | break; |
| 235 | case REMOVE_FROM_EXISTING: |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 236 | groups.forEach(group -> groupService.removeBucketsFromGroup( |
| 237 | deviceId, group.appCookie(), group.buckets(), |
| 238 | group.appCookie(), group.appId()) |
Charles Chan | 91ea972 | 2018-08-30 15:56:32 -0700 | [diff] [blame] | 239 | ); |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 240 | break; |
pierventre | 4e02fb5 | 2020-08-13 16:35:15 +0200 | [diff] [blame^] | 241 | case MODIFY: |
| 242 | // Modify is only supported for simple next objective |
| 243 | // Replace group bucket directly |
| 244 | groups.forEach(group -> groupService.setBucketsForGroup( |
| 245 | deviceId, group.appCookie(), group.buckets(), |
| 246 | group.appCookie(), group.appId()) |
| 247 | ); |
| 248 | break; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 249 | default: |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 250 | log.warn("Unsupported Objective operation {}", objective.op()); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 251 | } |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 252 | } |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 253 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 254 | private void fail(Objective objective, ObjectiveError error) { |
| 255 | CompletableFuture.runAsync( |
| 256 | () -> objective.context().ifPresent( |
| 257 | ctx -> ctx.onError(objective, error)), callbackExecutor); |
Yi Tseng | fe13f3e | 2018-08-19 03:09:54 +0800 | [diff] [blame] | 258 | |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Charles Chan | 91ea972 | 2018-08-30 15:56:32 -0700 | [diff] [blame] | 261 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 262 | private void success(Objective objective) { |
| 263 | CompletableFuture.runAsync( |
| 264 | () -> objective.context().ifPresent( |
| 265 | ctx -> ctx.onSuccess(objective)), callbackExecutor); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 266 | } |
| 267 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 268 | private void removeNextGroup(NextObjective obj) { |
| 269 | final NextGroup removed = flowObjectiveStore.removeNextGroup(obj.id()); |
| 270 | if (removed == null) { |
| 271 | log.debug("NextGroup {} was not found in FlowObjectiveStore"); |
| 272 | } |
Charles Chan | 91ea972 | 2018-08-30 15:56:32 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 275 | private void putNextGroup(NextObjective obj) { |
| 276 | final List<String> nextMappings = obj.nextTreatments().stream() |
| 277 | .map(this::nextTreatmentToMappingString) |
| 278 | .filter(Objects::nonNull) |
| 279 | .collect(Collectors.toList()); |
| 280 | final FabricNextGroup nextGroup = new FabricNextGroup(obj.type(), nextMappings); |
| 281 | flowObjectiveStore.putNextGroup(obj.id(), nextGroup); |
| 282 | } |
| 283 | |
| 284 | private String nextTreatmentToMappingString(NextTreatment n) { |
| 285 | switch (n.type()) { |
| 286 | case TREATMENT: |
| 287 | final PortNumber p = outputPort(n); |
| 288 | return p == null ? "UNKNOWN" |
| 289 | : format("OUTPUT:%s", p.toString()); |
| 290 | case ID: |
| 291 | final IdNextTreatment id = (IdNextTreatment) n; |
| 292 | return format("NEXT_ID:%d", id.nextId()); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 293 | default: |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 294 | log.warn("Unknown NextTreatment type '{}'", n.type()); |
| 295 | return "???"; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 296 | } |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 299 | /** |
| 300 | * NextGroup implementation. |
| 301 | */ |
| 302 | private static class FabricNextGroup implements NextGroup { |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 303 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 304 | private final NextObjective.Type type; |
| 305 | private final List<String> nextMappings; |
| 306 | |
| 307 | FabricNextGroup(NextObjective.Type type, List<String> nextMappings) { |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 308 | this.type = type; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 309 | this.nextMappings = ImmutableList.copyOf(nextMappings); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Charles Chan | 91ea972 | 2018-08-30 15:56:32 -0700 | [diff] [blame] | 312 | NextObjective.Type type() { |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 313 | return type; |
| 314 | } |
| 315 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 316 | Collection<String> nextMappings() { |
| 317 | return nextMappings; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | @Override |
| 321 | public byte[] data() { |
| 322 | return KRYO.serialize(this); |
| 323 | } |
| 324 | } |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 325 | } |