blob: cf09c02ae2efa0231adb5802930d643a065fe111 [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
Daniele Moro8d630f12021-06-15 20:53:22 +020019import org.onosproject.store.service.Serializer;
20import org.onosproject.store.service.TestConsistentMap;
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();
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 Moro8d630f12021-06-15 20:53:22 +020040 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}