Yoonseon Han | 096cea0 | 2017-05-15 15:10:41 -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 | |
| 17 | package org.onosproject.incubator.net.virtual.impl.intent.phase; |
| 18 | |
| 19 | import org.onosproject.incubator.net.virtual.NetworkId; |
| 20 | import org.onosproject.incubator.net.virtual.impl.intent.VirtualIntentProcessor; |
| 21 | import org.onosproject.net.intent.IntentData; |
| 22 | |
| 23 | import java.util.Optional; |
| 24 | |
| 25 | import static com.google.common.base.Preconditions.checkNotNull; |
| 26 | import static org.onosproject.incubator.net.virtual.impl.intent.phase.VirtualIntentProcessPhase.transferErrorCount; |
| 27 | |
| 28 | /** |
| 29 | * Represents a phase where intent installation has been requested |
| 30 | * for a virtual network. |
| 31 | */ |
| 32 | final class VirtualIntentInstallRequest implements VirtualIntentProcessPhase { |
| 33 | |
| 34 | private final NetworkId networkId; |
| 35 | private final VirtualIntentProcessor processor; |
| 36 | private final IntentData data; |
| 37 | private final Optional<IntentData> stored; |
| 38 | |
| 39 | /** |
| 40 | * Creates an install request phase. |
| 41 | * |
| 42 | * @param networkId virtual network identifier |
| 43 | * @param processor intent processor to be passed to intent process phases |
| 44 | * generated after this phase |
| 45 | * @param intentData intent data to be processed |
| 46 | * @param stored intent data stored in the store |
| 47 | */ |
| 48 | VirtualIntentInstallRequest(NetworkId networkId, VirtualIntentProcessor processor, |
| 49 | IntentData intentData, Optional<IntentData> stored) { |
| 50 | this.networkId = checkNotNull(networkId); |
| 51 | this.processor = checkNotNull(processor); |
| 52 | this.data = checkNotNull(intentData); |
| 53 | this.stored = checkNotNull(stored); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public Optional<VirtualIntentProcessPhase> execute() { |
| 58 | transferErrorCount(data, stored); |
| 59 | |
| 60 | return Optional.of(new VirtualIntentCompiling(networkId, processor, data, stored)); |
| 61 | } |
| 62 | } |