blob: d82ff94341a6e3156766a624b10d1b1301a16658 [file] [log] [blame]
Jian Li92919592017-02-27 17:10:47 +09001/*
2 * Copyright 2017-present Open Networking Laboratory
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 */
16package org.onosproject.mapping.impl;
17
18import com.google.common.collect.Maps;
19
20import org.apache.felix.scr.annotations.Activate;
21import org.apache.felix.scr.annotations.Component;
22import org.apache.felix.scr.annotations.Deactivate;
23import org.apache.felix.scr.annotations.Service;
24import org.apache.felix.scr.annotations.Modified;
25import org.onosproject.mapping.MappingEvent;
26import org.onosproject.mapping.Mapping;
27import org.onosproject.mapping.MappingId;
28import org.onosproject.mapping.MappingStore;
29import org.onosproject.mapping.MappingEntry;
30import org.onosproject.mapping.MappingStoreDelegate;
31import org.onosproject.net.DeviceId;
32import org.onosproject.store.AbstractStore;
33import org.osgi.service.component.ComponentContext;
34import org.slf4j.Logger;
35
36import java.util.List;
37import java.util.concurrent.ConcurrentMap;
38import java.util.concurrent.atomic.AtomicInteger;
39
40import static org.slf4j.LoggerFactory.getLogger;
41
42/**
43 * Manages inventory of mappings using trivial in-memory implementation.
44 */
45@Component(immediate = true)
46@Service
47public class SimpleMappingStore
48 extends AbstractStore<MappingEvent, MappingStoreDelegate>
49 implements MappingStore {
50
51 private final Logger log = getLogger(getClass());
52
53 private final ConcurrentMap<DeviceId, ConcurrentMap<MappingId, List<MappingEntry>>>
54 mapDbStore = Maps.newConcurrentMap();
55
56 private final ConcurrentMap<DeviceId, ConcurrentMap<MappingId, List<MappingEntry>>>
57 mapCacheStore = Maps.newConcurrentMap();
58
59 private final AtomicInteger localBatchIdGen = new AtomicInteger();
60
61 @Activate
62 public void activate() {
63 log.info("Started");
64 }
65
66 @Deactivate
67 public void deactivate() {
68 mapDbStore.clear();
69 mapCacheStore.clear();
70 log.info("Stopped");
71 }
72
73 @Modified
74 public void modified(ComponentContext context) {
75
76 }
77
78 @Override
79 public int getMappingCount(Type type) {
80 return 0;
81 }
82
83 @Override
84 public MappingEntry getMappingEntry(Type type, Mapping mapping) {
85 return null;
86 }
87
88 @Override
89 public Iterable<MappingEntry> getMappingEntries(Type type, DeviceId deviceId) {
90 return null;
91 }
92
93 @Override
94 public void deleteMapping(Type type, Mapping mapping) {
95
96 }
97
98 @Override
99 public MappingEvent addOrUpdateMappingEntry(Type type, MappingEntry entry) {
100 return null;
101 }
102
103 @Override
104 public MappingEvent removeMappingEntry(Type type, MappingEntry entry) {
105 return null;
106 }
107
108 @Override
109 public MappingEvent pendingMappingEntry(Type type, MappingEntry entry) {
110 return null;
111 }
112
113 @Override
114 public void purgeMappingEntries(Type type) {
115
116 }
117}
118
119