summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core')
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdEvent.java34
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdStoreDelegate.java24
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java150
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java79
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java66
-rw-r--r--framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/package-info.java20
6 files changed, 0 insertions, 373 deletions
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdEvent.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdEvent.java
deleted file mode 100644
index 9f021b13..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdEvent.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.core.impl;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.event.AbstractEvent;
-
-/**
- * Application ID event.
- */
-public class AppIdEvent extends AbstractEvent<AppIdEvent.Type, ApplicationId> {
-
- public enum Type {
- APP_REGISTERED
- }
-
- protected AppIdEvent(Type type, ApplicationId subject) {
- super(type, subject);
- }
-
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdStoreDelegate.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdStoreDelegate.java
deleted file mode 100644
index 6240a311..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/AppIdStoreDelegate.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.core.impl;
-
-import org.onosproject.store.StoreDelegate;
-
-/**
- * Application ID store delegate.
- */
-public interface AppIdStoreDelegate extends StoreDelegate<AppIdEvent> {
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java
deleted file mode 100644
index 7c3769a3..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentApplicationIdStore.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.core.impl;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.Map;
-import java.util.Set;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.util.KryoNamespace;
-import org.onlab.util.Tools;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.ApplicationIdStore;
-import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.AtomicCounter;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageException;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Versioned;
-import org.slf4j.Logger;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-
-/**
- * ApplicationIdStore implementation on top of {@code AtomicCounter}
- * and {@code ConsistentMap} primitives.
- */
-@Component(immediate = true, enabled = true)
-@Service
-public class ConsistentApplicationIdStore implements ApplicationIdStore {
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- private AtomicCounter appIdCounter;
- private ConsistentMap<String, ApplicationId> registeredIds;
- private Map<String, ApplicationId> nameToAppIdCache = Maps.newConcurrentMap();
- private Map<Short, ApplicationId> idToAppIdCache = Maps.newConcurrentMap();
-
- private static final Serializer SERIALIZER = Serializer.using(new KryoNamespace.Builder()
- .register(KryoNamespaces.API)
- .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
- .build());
-
- @Activate
- public void activate() {
- appIdCounter = storageService.atomicCounterBuilder()
- .withName("onos-app-id-counter")
- .withPartitionsDisabled()
- .build();
-
- registeredIds = storageService.<String, ApplicationId>consistentMapBuilder()
- .withName("onos-app-ids")
- .withPartitionsDisabled()
- .withSerializer(SERIALIZER)
- .build();
-
- primeAppIds();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Set<ApplicationId> getAppIds() {
- // TODO: Rework this when we have notification support in ConsistentMap.
- primeAppIds();
- return ImmutableSet.copyOf(nameToAppIdCache.values());
- }
-
- @Override
- public ApplicationId getAppId(Short id) {
- if (!idToAppIdCache.containsKey(id)) {
- primeAppIds();
- }
- return idToAppIdCache.get(id);
- }
-
- @Override
- public ApplicationId getAppId(String name) {
- ApplicationId appId = nameToAppIdCache.computeIfAbsent(name, key -> {
- Versioned<ApplicationId> existingAppId = registeredIds.get(key);
- return existingAppId != null ? existingAppId.value() : null;
- });
- if (appId != null) {
- idToAppIdCache.putIfAbsent(appId.id(), appId);
- }
- return appId;
- }
-
- @Override
- public ApplicationId registerApplication(String name) {
- ApplicationId appId = nameToAppIdCache.computeIfAbsent(name, key -> {
- Versioned<ApplicationId> existingAppId = registeredIds.get(name);
- if (existingAppId == null) {
- int id = Tools.retryable(appIdCounter::incrementAndGet, StorageException.class, 1, 2000)
- .get()
- .intValue();
- DefaultApplicationId newAppId = new DefaultApplicationId(id, name);
- existingAppId = registeredIds.putIfAbsent(name, newAppId);
- if (existingAppId != null) {
- return existingAppId.value();
- } else {
- return newAppId;
- }
- } else {
- return existingAppId.value();
- }
- });
- idToAppIdCache.putIfAbsent(appId.id(), appId);
- return appId;
- }
-
- private void primeAppIds() {
- registeredIds.values()
- .stream()
- .map(Versioned::value)
- .forEach(appId -> {
- nameToAppIdCache.putIfAbsent(appId.name(), appId);
- idToAppIdCache.putIfAbsent(appId.id(), appId);
- });
- }
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java
deleted file mode 100644
index c6f48a44..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/ConsistentIdBlockStore.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.core.impl;
-
-import com.google.common.collect.Maps;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.util.Tools;
-import org.onosproject.core.IdBlock;
-import org.onosproject.core.IdBlockStore;
-import org.onosproject.store.service.AtomicCounter;
-import org.onosproject.store.service.StorageException;
-import org.onosproject.store.service.StorageService;
-import org.slf4j.Logger;
-
-import java.util.Map;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of {@code IdBlockStore} using {@code AtomicCounter}.
- */
-@Component(immediate = true, enabled = true)
-@Service
-public class ConsistentIdBlockStore implements IdBlockStore {
-
- private static final int MAX_TRIES = 5;
- private static final int RETRY_DELAY_MS = 2_000;
-
- private final Logger log = getLogger(getClass());
- private final Map<String, AtomicCounter> topicCounters = Maps.newConcurrentMap();
-
- private static final long DEFAULT_BLOCK_SIZE = 0x100000L;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public IdBlock getIdBlock(String topic) {
- AtomicCounter counter = topicCounters
- .computeIfAbsent(topic,
- name -> storageService.atomicCounterBuilder()
- .withName(name)
- .build());
- Long blockBase = Tools.retryable(counter::getAndAdd,
- StorageException.class,
- MAX_TRIES,
- RETRY_DELAY_MS).apply(DEFAULT_BLOCK_SIZE);
- return new IdBlock(blockBase, DEFAULT_BLOCK_SIZE);
- }
-}
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java
deleted file mode 100644
index 6a667e32..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/LogicalClockManager.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.core.impl;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onosproject.store.Timestamp;
-import org.onosproject.store.impl.LogicalTimestamp;
-import org.onosproject.store.service.AtomicCounter;
-import org.onosproject.store.service.LogicalClockService;
-import org.onosproject.store.service.StorageService;
-import org.slf4j.Logger;
-
-/**
- * LogicalClockService implementation based on a AtomicCounter.
- */
-@Component(immediate = true, enabled = true)
-@Service
-public class LogicalClockManager implements LogicalClockService {
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- private static final String SYSTEM_LOGICAL_CLOCK_COUNTER_NAME = "sys-clock-counter";
- private AtomicCounter atomicCounter;
-
- @Activate
- public void activate() {
- atomicCounter = storageService.atomicCounterBuilder()
- .withName(SYSTEM_LOGICAL_CLOCK_COUNTER_NAME)
- .withPartitionsDisabled()
- .build();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Timestamp getTimestamp() {
- return new LogicalTimestamp(atomicCounter.incrementAndGet());
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/package-info.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/package-info.java
deleted file mode 100644
index bb758b10..00000000
--- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/core/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of a distributed application ID registry store using Hazelcast.
- */
-package org.onosproject.store.core.impl;