Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021-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.pipelines.fabric.impl.behaviour.upf; |
| 18 | |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 19 | import org.onosproject.store.service.Serializer; |
| 20 | import org.onosproject.store.service.TestConsistentMap; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 21 | |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 22 | import static org.onosproject.pipelines.fabric.impl.behaviour.upf.DistributedFabricUpfStore.FAR_ID_MAP_NAME; |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 23 | import static org.onosproject.pipelines.fabric.impl.behaviour.upf.DistributedFabricUpfStore.SERIALIZER; |
| 24 | |
| 25 | |
| 26 | public final class TestDistributedFabricUpfStore { |
| 27 | |
| 28 | private TestDistributedFabricUpfStore() { |
| 29 | } |
| 30 | |
| 31 | public static DistributedFabricUpfStore build() { |
| 32 | var store = new DistributedFabricUpfStore(); |
| 33 | TestConsistentMap.Builder<UpfRuleIdentifier, Integer> farIdMapBuilder = |
| 34 | TestConsistentMap.builder(); |
| 35 | farIdMapBuilder.withName(FAR_ID_MAP_NAME) |
| 36 | .withRelaxedReadConsistency() |
| 37 | .withSerializer(Serializer.using(SERIALIZER.build())); |
| 38 | store.farIdMap = farIdMapBuilder.build(); |
| 39 | |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 40 | store.activate(); |
| 41 | |
| 42 | // Init with some translation state. |
| 43 | store.farIdMap.put( |
| 44 | new UpfRuleIdentifier(TestUpfConstants.SESSION_ID, TestUpfConstants.UPLINK_FAR_ID), |
| 45 | TestUpfConstants.UPLINK_PHYSICAL_FAR_ID); |
| 46 | store.farIdMap.put( |
| 47 | new UpfRuleIdentifier(TestUpfConstants.SESSION_ID, TestUpfConstants.DOWNLINK_FAR_ID), |
| 48 | TestUpfConstants.DOWNLINK_PHYSICAL_FAR_ID); |
| 49 | |
| 50 | return store; |
| 51 | } |
| 52 | } |