blob: 3bf3b26b3f7829a1df8106d32a52244e029b8d00 [file] [log] [blame]
Daniele Moro8d630f12021-06-15 20:53:22 +02001/*
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
17package org.onosproject.pipelines.fabric.impl.behaviour.upf;
18
pierventre1eb98712021-07-13 18:03:22 +020019import org.onosproject.store.service.TestEventuallyConsistentMap;
20import org.onosproject.store.service.WallClockTimestamp;
Daniele Moro8d630f12021-06-15 20:53:22 +020021
Daniele Moro8d630f12021-06-15 20:53:22 +020022import static org.onosproject.pipelines.fabric.impl.behaviour.upf.DistributedFabricUpfStore.FAR_ID_MAP_NAME;
Daniele Moro8d630f12021-06-15 20:53:22 +020023import static org.onosproject.pipelines.fabric.impl.behaviour.upf.DistributedFabricUpfStore.SERIALIZER;
24
25
26public final class TestDistributedFabricUpfStore {
27
28 private TestDistributedFabricUpfStore() {
29 }
30
31 public static DistributedFabricUpfStore build() {
32 var store = new DistributedFabricUpfStore();
pierventre1eb98712021-07-13 18:03:22 +020033 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 Moro8d630f12021-06-15 20:53:22 +020039
Daniele Moro8d630f12021-06-15 20:53:22 +020040 store.activate();
41
42 // Init with some translation state.
pierventre1eb98712021-07-13 18:03:22 +020043 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 Moro8d630f12021-06-15 20:53:22 +020047
48 return store;
49 }
50}