blob: 142e4bbe90f3db5905eafaa211bd642a239acb8a [file] [log] [blame]
Phaneendra Manda8db7d092016-06-04 00:17:24 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Phaneendra Manda8db7d092016-06-04 00:17:24 +05303 *
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 */
16package org.onosproject.sfc.util;
17
18import java.util.concurrent.ConcurrentHashMap;
19import java.util.concurrent.ConcurrentMap;
20
21import org.onosproject.vtnrsc.TenantNetwork;
22import org.onosproject.vtnrsc.TenantNetworkId;
23import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
24
25import com.google.common.collect.ImmutableList;
26
27/**
28 * Provides implementation of the VtnRsc service.
29 */
30public class TenantNetworkAdapter implements TenantNetworkService {
31
32 private final ConcurrentMap<TenantNetworkId, TenantNetwork> tenantNetworkStore = new ConcurrentHashMap<>();
33
34 @Override
35 public boolean exists(TenantNetworkId networkId) {
36 return tenantNetworkStore.containsKey(networkId);
37 }
38
39 @Override
40 public int getNetworkCount() {
41 return tenantNetworkStore.size();
42 }
43
44 @Override
45 public Iterable<TenantNetwork> getNetworks() {
46 return ImmutableList.copyOf(tenantNetworkStore.values());
47 }
48
49 @Override
50 public TenantNetwork getNetwork(TenantNetworkId networkId) {
51 return tenantNetworkStore.get(networkId);
52 }
53
54 @Override
55 public boolean createNetworks(Iterable<TenantNetwork> networks) {
56 for (TenantNetwork network : networks) {
57 tenantNetworkStore.put(network.id(), network);
58 if (!tenantNetworkStore.containsKey(network.id())) {
59 return false;
60 }
61 }
62 return true;
63 }
64
65 @Override
66 public boolean updateNetworks(Iterable<TenantNetwork> networks) {
67 return false;
68 }
69
70 @Override
71 public boolean removeNetworks(Iterable<TenantNetworkId> networksIds) {
72 return false;
73 }
74
75}