Jian Li | 9291959 | 2017-02-27 17:10:47 +0900 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.mapping.impl; |
| 17 | |
| 18 | import com.google.common.collect.Maps; |
| 19 | |
| 20 | import org.apache.felix.scr.annotations.Activate; |
| 21 | import org.apache.felix.scr.annotations.Component; |
| 22 | import org.apache.felix.scr.annotations.Deactivate; |
| 23 | import org.apache.felix.scr.annotations.Service; |
| 24 | import org.apache.felix.scr.annotations.Modified; |
| 25 | import org.onosproject.mapping.MappingEvent; |
| 26 | import org.onosproject.mapping.Mapping; |
| 27 | import org.onosproject.mapping.MappingId; |
| 28 | import org.onosproject.mapping.MappingStore; |
| 29 | import org.onosproject.mapping.MappingEntry; |
| 30 | import org.onosproject.mapping.MappingStoreDelegate; |
| 31 | import org.onosproject.net.DeviceId; |
| 32 | import org.onosproject.store.AbstractStore; |
| 33 | import org.osgi.service.component.ComponentContext; |
| 34 | import org.slf4j.Logger; |
| 35 | |
| 36 | import java.util.List; |
| 37 | import java.util.concurrent.ConcurrentMap; |
| 38 | import java.util.concurrent.atomic.AtomicInteger; |
| 39 | |
| 40 | import static org.slf4j.LoggerFactory.getLogger; |
| 41 | |
| 42 | /** |
| 43 | * Manages inventory of mappings using trivial in-memory implementation. |
| 44 | */ |
| 45 | @Component(immediate = true) |
| 46 | @Service |
| 47 | public 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 | |