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 | |
pierventre | 1eb9871 | 2021-07-13 18:03:22 +0200 | [diff] [blame^] | 19 | import org.onosproject.store.service.TestEventuallyConsistentMap; |
| 20 | import org.onosproject.store.service.WallClockTimestamp; |
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(); |
pierventre | 1eb9871 | 2021-07-13 18:03:22 +0200 | [diff] [blame^] | 33 | TestEventuallyConsistentMap.Builder<Integer, UpfRuleIdentifier> reverseFarIdMapBuilder = |
| 34 | TestEventuallyConsistentMap.builder(); |
| 35 | reverseFarIdMapBuilder.withName(FAR_ID_MAP_NAME) |
| 36 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
| 37 | .withSerializer(SERIALIZER.build()); |
| 38 | store.reverseFarIdMap = reverseFarIdMapBuilder.build(); |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 39 | |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 40 | store.activate(); |
| 41 | |
| 42 | // Init with some translation state. |
pierventre | 1eb9871 | 2021-07-13 18:03:22 +0200 | [diff] [blame^] | 43 | store.reverseFarIdMap.put(TestUpfConstants.UPLINK_PHYSICAL_FAR_ID, |
| 44 | new UpfRuleIdentifier(TestUpfConstants.SESSION_ID, TestUpfConstants.UPLINK_FAR_ID)); |
| 45 | store.reverseFarIdMap.put(TestUpfConstants.DOWNLINK_PHYSICAL_FAR_ID, |
| 46 | new UpfRuleIdentifier(TestUpfConstants.SESSION_ID, TestUpfConstants.DOWNLINK_FAR_ID)); |
Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame] | 47 | |
| 48 | return store; |
| 49 | } |
| 50 | } |